2
0

Remove actualTarget argument

This commit is contained in:
Jack Christensen
2022-02-21 09:30:01 -06:00
parent f3defbc150
commit 9c538cd4a9
39 changed files with 49 additions and 50 deletions
+3 -3
View File
@@ -210,7 +210,7 @@ func (p *encodePlanArrayCodecBinary) Encode(value interface{}, buf []byte) (newB
return buf, nil
}
func (c *ArrayCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (c *ArrayCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
arrayScanner, ok := target.(ArraySetter)
if !ok {
return nil
@@ -248,7 +248,7 @@ func (c *ArrayCodec) decodeBinary(m *Map, arrayOID uint32, src []byte, array Arr
return nil
}
elementScanPlan := c.ElementType.Codec.PlanScan(m, c.ElementType.OID, BinaryFormatCode, array.ScanIndex(0), false)
elementScanPlan := c.ElementType.Codec.PlanScan(m, c.ElementType.OID, BinaryFormatCode, array.ScanIndex(0))
if elementScanPlan == nil {
elementScanPlan = m.PlanScan(c.ElementType.OID, BinaryFormatCode, array.ScanIndex(0))
}
@@ -286,7 +286,7 @@ func (c *ArrayCodec) decodeText(m *Map, arrayOID uint32, src []byte, array Array
return nil
}
elementScanPlan := c.ElementType.Codec.PlanScan(m, c.ElementType.OID, TextFormatCode, array.ScanIndex(0), false)
elementScanPlan := c.ElementType.Codec.PlanScan(m, c.ElementType.OID, TextFormatCode, array.ScanIndex(0))
if elementScanPlan == nil {
elementScanPlan = m.PlanScan(c.ElementType.OID, TextFormatCode, array.ScanIndex(0))
}
+1 -1
View File
@@ -126,7 +126,7 @@ func (encodePlanBitsCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return buf, nil
}
func (BitsCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (BitsCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -197,7 +197,7 @@ func (encodePlanBoolCodecTextBool) Encode(value interface{}, buf []byte) (newBuf
return buf, nil
}
func (BoolCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (BoolCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -126,7 +126,7 @@ func (encodePlanBoxCodecText) Encode(value interface{}, buf []byte) (newBuf []by
return buf, nil
}
func (BoxCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (BoxCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -147,7 +147,7 @@ func (encodePlanBytesCodecTextBytesValuer) Encode(value interface{}, buf []byte)
return buf, nil
}
func (ByteaCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (ByteaCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -125,7 +125,7 @@ func (encodePlanCircleCodecText) Encode(value interface{}, buf []byte) (newBuf [
return buf, nil
}
func (CircleCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (CircleCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
switch target.(type) {
+1 -1
View File
@@ -109,7 +109,7 @@ func (plan *encodePlanCompositeCodecCompositeIndexGetterToText) Encode(value int
return b.Finish()
}
func (c *CompositeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (c *CompositeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
switch target.(type) {
+1 -1
View File
@@ -196,7 +196,7 @@ func (encodePlanDateCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return append(buf, s...), nil
}
func (DateCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (DateCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -38,7 +38,7 @@ func (EnumCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
return nil
}
func (c *EnumCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (c *EnumCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case TextFormatCode, BinaryFormatCode:
switch target.(type) {
+1 -1
View File
@@ -145,7 +145,7 @@ func (encodePlanFloat4CodecBinaryInt64Valuer) Encode(value interface{}, buf []by
return pgio.AppendUint32(buf, math.Float32bits(f)), nil
}
func (Float4Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (Float4Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -183,7 +183,7 @@ func (encodePlanTextInt64Valuer) Encode(value interface{}, buf []byte) (newBuf [
return append(buf, strconv.FormatInt(n.Int, 10)...), nil
}
func (Float8Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (Float8Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -150,7 +150,7 @@ func (encodePlanHstoreCodecText) Encode(value interface{}, buf []byte) (newBuf [
return buf, nil
}
func (HstoreCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (HstoreCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -140,7 +140,7 @@ func (encodePlanInetCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return append(buf, inet.IPNet.String()...), nil
}
func (InetCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (InetCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+3 -3
View File
@@ -206,7 +206,7 @@ func (encodePlanInt2CodecTextInt64Valuer) Encode(value interface{}, buf []byte)
return append(buf, strconv.FormatInt(n.Int, 10)...), nil
}
func (Int2Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (Int2Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
@@ -743,7 +743,7 @@ func (encodePlanInt4CodecTextInt64Valuer) Encode(value interface{}, buf []byte)
return append(buf, strconv.FormatInt(n.Int, 10)...), nil
}
func (Int4Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (Int4Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
@@ -1291,7 +1291,7 @@ func (encodePlanInt8CodecTextInt64Valuer) Encode(value interface{}, buf []byte)
return append(buf, strconv.FormatInt(n.Int, 10)...), nil
}
func (Int8Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (Int8Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -207,7 +207,7 @@ func (encodePlanInt<%= pg_byte_size %>CodecTextInt64Valuer) Encode(value interfa
return append(buf, strconv.FormatInt(n.Int, 10)...), nil
}
func (Int<%= pg_byte_size %>Codec) PlanScan(m *TypeMap, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (Int<%= pg_byte_size %>Codec) PlanScan(m *TypeMap, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -151,7 +151,7 @@ func (encodePlanIntervalCodecText) Encode(value interface{}, buf []byte) (newBuf
return buf, nil
}
func (IntervalCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (IntervalCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -49,7 +49,7 @@ func (encodePlanJSONCodecEitherFormatMarshal) Encode(value interface{}, buf []by
return buf, nil
}
func (JSONCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (JSONCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch target.(type) {
case *string:
return scanPlanAnyToString{}
+3 -3
View File
@@ -39,15 +39,15 @@ func (plan *encodePlanJSONBCodecBinaryWrapper) Encode(value interface{}, buf []b
return plan.textPlan.Encode(value, buf)
}
func (JSONBCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (JSONBCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
plan := JSONCodec{}.PlanScan(m, oid, TextFormatCode, target, actualTarget)
plan := JSONCodec{}.PlanScan(m, oid, TextFormatCode, target)
if plan != nil {
return &scanPlanJSONBCodecBinaryUnwrapper{textPlan: plan}
}
case TextFormatCode:
return JSONCodec{}.PlanScan(m, oid, format, target, actualTarget)
return JSONCodec{}.PlanScan(m, oid, format, target)
}
return nil
+1 -1
View File
@@ -128,7 +128,7 @@ func (encodePlanLineCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return buf, nil
}
func (LineCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (LineCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -126,7 +126,7 @@ func (encodePlanLsegCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return buf, nil
}
func (LsegCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (LsegCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -78,7 +78,7 @@ func (encodePlanMacaddrCodecTextHardwareAddr) Encode(value interface{}, buf []by
return append(buf, addr.String()...), nil
}
func (MacaddrCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (MacaddrCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
switch target.(type) {
+1 -1
View File
@@ -501,7 +501,7 @@ func encodeNumericText(n Numeric, buf []byte) (newBuf []byte, err error) {
return buf, nil
}
func (NumericCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (NumericCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -63,7 +63,7 @@ func isExpectedEqNumeric(a interface{}) func(interface{}) bool {
func mustParseNumeric(t *testing.T, src string) pgtype.Numeric {
var n pgtype.Numeric
plan := pgtype.NumericCodec{}.PlanScan(nil, pgtype.NumericOID, pgtype.TextFormatCode, &n, false)
plan := pgtype.NumericCodec{}.PlanScan(nil, pgtype.NumericOID, pgtype.TextFormatCode, &n)
require.NotNil(t, plan)
err := plan.Scan([]byte(src), &n)
require.NoError(t, err)
+1 -1
View File
@@ -153,7 +153,7 @@ func (encodePlanPathCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return buf, nil
}
func (PathCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (PathCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+4 -5
View File
@@ -144,9 +144,8 @@ type Codec interface {
PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
// PlanScan returns a ScanPlan for scanning a PostgreSQL value into a destination with the same type as target. If
// actualTarget is true then the returned ScanPlan may be optimized to directly scan into target. If no plan can be
// found then nil is returned.
PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan
// no plan can be found then nil is returned.
PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
// DecodeDatabaseSQLValue returns src decoded into a value compatible with the sql.Scanner interface.
DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
@@ -1030,7 +1029,7 @@ func (m *Map) PlanScan(oid uint32, formatCode int16, target interface{}) ScanPla
}
if dt != nil {
if plan := dt.Codec.PlanScan(m, oid, formatCode, target, false); plan != nil {
if plan := dt.Codec.PlanScan(m, oid, formatCode, target); plan != nil {
return plan
}
}
@@ -1094,7 +1093,7 @@ func scanUnknownType(oid uint32, formatCode int16, buf []byte, dest interface{})
var ErrScanTargetTypeChanged = errors.New("scan target type changed")
func codecScan(codec Codec, m *Map, oid uint32, format int16, src []byte, dst interface{}) error {
scanPlan := codec.PlanScan(m, oid, format, dst, true)
scanPlan := codec.PlanScan(m, oid, format, dst)
if scanPlan == nil {
return fmt.Errorf("PlanScan did not find a plan")
}
+1 -1
View File
@@ -177,7 +177,7 @@ func (encodePlanPointCodecText) Encode(value interface{}, buf []byte) (newBuf []
)...), nil
}
func (PointCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (PointCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -138,7 +138,7 @@ func (encodePlanPolygonCodecText) Encode(value interface{}, buf []byte) (newBuf
return buf, nil
}
func (PolygonCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (PolygonCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -56,7 +56,7 @@ func (encodePlanQcharCodecRune) Encode(value interface{}, buf []byte) (newBuf []
return buf, nil
}
func (QCharCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (QCharCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case TextFormatCode, BinaryFormatCode:
switch target.(type) {
+2 -2
View File
@@ -270,7 +270,7 @@ func (plan *encodePlanRangeCodecRangeValuerToText) Encode(value interface{}, buf
return buf, nil
}
func (c *RangeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (c *RangeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
switch target.(type) {
@@ -410,6 +410,6 @@ func (c *RangeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (
}
var r GenericRange
err := c.PlanScan(m, oid, format, &r, true).Scan(src, &r)
err := c.PlanScan(m, oid, format, &r).Scan(src, &r)
return r, err
}
+1 -1
View File
@@ -25,7 +25,7 @@ func (RecordCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{
return nil
}
func (RecordCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (RecordCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
if format == BinaryFormatCode {
switch target.(type) {
case CompositeIndexScanner:
+1 -1
View File
@@ -156,7 +156,7 @@ func (encodePlanTextCodecTextValuer) Encode(value interface{}, buf []byte) (newB
return buf, nil
}
func (TextCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (TextCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case TextFormatCode, BinaryFormatCode:
+1 -1
View File
@@ -130,7 +130,7 @@ func (encodePlanTIDCodecText) Encode(value interface{}, buf []byte) (newBuf []by
return buf, nil
}
func (TIDCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (TIDCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -129,7 +129,7 @@ func (encodePlanTimeCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return append(buf, s...), nil
}
func (TimeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (TimeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -152,7 +152,7 @@ func discardTimeZone(t time.Time) time.Time {
return t
}
func (TimestampCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (TimestampCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -51,7 +51,7 @@ func TestTimestampTranscodeBigTimeBinary(t *testing.T) {
func TestTimestampCodecDecodeTextInvalid(t *testing.T) {
c := &pgtype.TimestampCodec{}
var ts pgtype.Timestamp
plan := c.PlanScan(nil, pgtype.TimestampOID, pgtype.TextFormatCode, &ts, false)
plan := c.PlanScan(nil, pgtype.TimestampOID, pgtype.TextFormatCode, &ts)
err := plan.Scan([]byte(`eeeee`), &ts)
require.Error(t, err)
}
+1 -1
View File
@@ -200,7 +200,7 @@ func (encodePlanTimestamptzCodecText) Encode(value interface{}, buf []byte) (new
return buf, nil
}
func (TimestamptzCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (TimestamptzCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -51,7 +51,7 @@ func TestTimestamptzTranscodeBigTimeBinary(t *testing.T) {
func TestTimestamptzDecodeTextInvalid(t *testing.T) {
c := &pgtype.TimestamptzCodec{}
var tstz pgtype.Timestamptz
plan := c.PlanScan(nil, pgtype.TimestamptzOID, pgtype.TextFormatCode, &tstz, false)
plan := c.PlanScan(nil, pgtype.TimestamptzOID, pgtype.TextFormatCode, &tstz)
err := plan.Scan([]byte(`eeeee`), &tstz)
require.Error(t, err)
}
+1 -1
View File
@@ -196,7 +196,7 @@ func (encodePlanUint32CodecTextInt64Valuer) Encode(value interface{}, buf []byte
return append(buf, strconv.FormatInt(v.Int, 10)...), nil
}
func (Uint32Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (Uint32Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
+1 -1
View File
@@ -167,7 +167,7 @@ func (encodePlanUUIDCodecTextUUIDValuer) Encode(value interface{}, buf []byte) (
return append(buf, encodeUUID(uuid.Bytes)...), nil
}
func (UUIDCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}, actualTarget bool) ScanPlan {
func (UUIDCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan {
switch format {
case BinaryFormatCode:
switch target.(type) {