From f6355165a91cd2c3476675a4dd15504a3af85611 Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 6 Jun 2020 09:10:11 -0500 Subject: [PATCH] Remove superfluous argument from ScanPlan --- go.mod | 2 +- go.sum | 3 +++ pgtype.go | 28 ++++++++++++++-------------- pgtype_test.go | 6 +++--- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index c7738ac9..ebf3a3c5 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( github.com/gofrs/uuid v3.2.0+incompatible - github.com/jackc/pgconn v1.5.0 + github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853 github.com/jackc/pgio v1.0.0 github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9 github.com/lib/pq v1.3.0 diff --git a/go.sum b/go.sum index a4816869..049ed43b 100644 --- a/go.sum +++ b/go.sum @@ -27,6 +27,8 @@ github.com/jackc/pgconn v1.4.0 h1:E82UBzFyD752mvI+4RIl1WSxfO2ug64T+sLjvDBWTpA= github.com/jackc/pgconn v1.4.0/go.mod h1:Y2O3ZDF0q4mMacyWV3AstPJpeHXWGEetiFttmq5lahk= github.com/jackc/pgconn v1.5.0 h1:oFSOilzIZkyg787M1fEmyMfOUUvwj0daqYMfaWwNL4o= github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= +github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853 h1:LRlrfJW9S99uiOCY8F/qLvX1yEY1TVAaCBHFb79yHBQ= +github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2 h1:JVX6jT/XfzNqIjye4717ITLaNwV9mWbJx0dLCpcRzdA= @@ -51,6 +53,7 @@ github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrU github.com/jackc/pgtype v1.2.0/go.mod h1:5m2OfMh1wTK7x+Fk952IDmI4nw3nPrvtQdM0ZT4WpC0= github.com/jackc/pgtype v1.3.1-0.20200510045248-7e66ab1e146c/go.mod h1:vaogEUkALtxZMCH411K+tKzNpwzCKU+AnPzBKZ+I+Po= github.com/jackc/pgtype v1.3.1-0.20200510190516-8cd94a14c75a/go.mod h1:vaogEUkALtxZMCH411K+tKzNpwzCKU+AnPzBKZ+I+Po= +github.com/jackc/pgtype v1.3.1-0.20200513130519-238967ec4e4c/go.mod h1:f3c+S645fwV5ZqwPvLWZmmnAfPkmaTeLnXs0byan+aA= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96 h1:ylEAOd688Duev/fxTmGdupsbyZfxNMdngIG14DoBKTM= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912 h1:YuOWGsSK5L4Fz81Olx5TNlZftmDuNrfv4ip0Yos77Tw= diff --git a/pgtype.go b/pgtype.go index 5fe78704..0997df6e 100644 --- a/pgtype.go +++ b/pgtype.go @@ -502,7 +502,7 @@ func (scanPlanDstBinaryDecoder) Scan(ci *ConnInfo, oid uint32, formatCode int16, return d.DecodeBinary(ci, src) } - newPlan := ci.PlanScan(oid, formatCode, src, dst) + newPlan := ci.PlanScan(oid, formatCode, dst) return newPlan.Scan(ci, oid, formatCode, src, dst) } @@ -513,7 +513,7 @@ func (plan scanPlanDstTextDecoder) Scan(ci *ConnInfo, oid uint32, formatCode int return d.DecodeText(ci, src) } - newPlan := ci.PlanScan(oid, formatCode, src, dst) + newPlan := ci.PlanScan(oid, formatCode, dst) return newPlan.Scan(ci, oid, formatCode, src, dst) } @@ -522,7 +522,7 @@ type scanPlanDataTypeSQLScanner DataType func (plan *scanPlanDataTypeSQLScanner) Scan(ci *ConnInfo, oid uint32, formatCode int16, src []byte, dst interface{}) error { scanner, ok := dst.(sql.Scanner) if !ok { - newPlan := ci.PlanScan(oid, formatCode, src, dst) + newPlan := ci.PlanScan(oid, formatCode, dst) return newPlan.Scan(ci, oid, formatCode, src, dst) } @@ -566,7 +566,7 @@ func (plan *scanPlanDataTypeAssignTo) Scan(ci *ConnInfo, oid uint32, formatCode } // assignToErr might have failed because the type of destination has changed - newPlan := ci.PlanScan(oid, formatCode, src, dst) + newPlan := ci.PlanScan(oid, formatCode, dst) if newPlan, sameType := newPlan.(*scanPlanDataTypeAssignTo); !sameType { return newPlan.Scan(ci, oid, formatCode, src, dst) } @@ -604,7 +604,7 @@ func (scanPlanReflection) Scan(ci *ConnInfo, oid uint32, formatCode int16, src [ elemPtr := reflect.New(refVal.Type().Elem().Elem()) refVal.Elem().Set(elemPtr) - plan := ci.PlanScan(oid, formatCode, src, elemPtr.Interface()) + plan := ci.PlanScan(oid, formatCode, elemPtr.Interface()) return plan.Scan(ci, oid, formatCode, src, elemPtr.Interface()) } @@ -627,7 +627,7 @@ func (scanPlanBinaryInt16) Scan(ci *ConnInfo, oid uint32, formatCode int16, src return nil } - newPlan := ci.PlanScan(oid, formatCode, src, dst) + newPlan := ci.PlanScan(oid, formatCode, dst) return newPlan.Scan(ci, oid, formatCode, src, dst) } @@ -647,7 +647,7 @@ func (scanPlanBinaryInt32) Scan(ci *ConnInfo, oid uint32, formatCode int16, src return nil } - newPlan := ci.PlanScan(oid, formatCode, src, dst) + newPlan := ci.PlanScan(oid, formatCode, dst) return newPlan.Scan(ci, oid, formatCode, src, dst) } @@ -667,7 +667,7 @@ func (scanPlanBinaryInt64) Scan(ci *ConnInfo, oid uint32, formatCode int16, src return nil } - newPlan := ci.PlanScan(oid, formatCode, src, dst) + newPlan := ci.PlanScan(oid, formatCode, dst) return newPlan.Scan(ci, oid, formatCode, src, dst) } @@ -688,7 +688,7 @@ func (scanPlanBinaryFloat32) Scan(ci *ConnInfo, oid uint32, formatCode int16, sr return nil } - newPlan := ci.PlanScan(oid, formatCode, src, dst) + newPlan := ci.PlanScan(oid, formatCode, dst) return newPlan.Scan(ci, oid, formatCode, src, dst) } @@ -709,7 +709,7 @@ func (scanPlanBinaryFloat64) Scan(ci *ConnInfo, oid uint32, formatCode int16, sr return nil } - newPlan := ci.PlanScan(oid, formatCode, src, dst) + newPlan := ci.PlanScan(oid, formatCode, dst) return newPlan.Scan(ci, oid, formatCode, src, dst) } @@ -721,7 +721,7 @@ func (scanPlanBinaryBytes) Scan(ci *ConnInfo, oid uint32, formatCode int16, src return nil } - newPlan := ci.PlanScan(oid, formatCode, src, dst) + newPlan := ci.PlanScan(oid, formatCode, dst) return newPlan.Scan(ci, oid, formatCode, src, dst) } @@ -737,12 +737,12 @@ func (scanPlanString) Scan(ci *ConnInfo, oid uint32, formatCode int16, src []byt return nil } - newPlan := ci.PlanScan(oid, formatCode, src, dst) + newPlan := ci.PlanScan(oid, formatCode, dst) return newPlan.Scan(ci, oid, formatCode, src, dst) } // PlanScan prepares a plan to scan a value into dst. -func (ci *ConnInfo) PlanScan(oid uint32, formatCode int16, buf []byte, dst interface{}) ScanPlan { +func (ci *ConnInfo) PlanScan(oid uint32, formatCode int16, dst interface{}) ScanPlan { switch formatCode { case BinaryFormatCode: switch dst.(type) { @@ -819,7 +819,7 @@ func (ci *ConnInfo) Scan(oid uint32, formatCode int16, src []byte, dst interface return nil } - plan := ci.PlanScan(oid, formatCode, src, dst) + plan := ci.PlanScan(oid, formatCode, dst) return plan.Scan(ci, oid, formatCode, src, dst) } diff --git a/pgtype_test.go b/pgtype_test.go index 6bdbe7c8..b3a23676 100644 --- a/pgtype_test.go +++ b/pgtype_test.go @@ -186,7 +186,7 @@ func TestScanPlanBinaryInt32ScanChangedType(t *testing.T) { src := []byte{0, 0, 0, 42} var v int32 - plan := ci.PlanScan(pgtype.Int4OID, pgtype.BinaryFormatCode, src, &v) + plan := ci.PlanScan(pgtype.Int4OID, pgtype.BinaryFormatCode, &v) err := plan.Scan(ci, pgtype.Int4OID, pgtype.BinaryFormatCode, src, &v) require.NoError(t, err) require.EqualValues(t, 42, v) @@ -220,7 +220,7 @@ func BenchmarkScanPlanScanInt4IntoBinaryDecoder(b *testing.B) { src := []byte{0, 0, 0, 42} var v pgtype.Int4 - plan := ci.PlanScan(pgtype.Int4OID, pgtype.BinaryFormatCode, src, &v) + plan := ci.PlanScan(pgtype.Int4OID, pgtype.BinaryFormatCode, &v) for i := 0; i < b.N; i++ { v = pgtype.Int4{} @@ -239,7 +239,7 @@ func BenchmarkScanPlanScanInt4IntoGoInt32(b *testing.B) { src := []byte{0, 0, 0, 42} var v int32 - plan := ci.PlanScan(pgtype.Int4OID, pgtype.BinaryFormatCode, src, &v) + plan := ci.PlanScan(pgtype.Int4OID, pgtype.BinaryFormatCode, &v) for i := 0; i < b.N; i++ { v = 0