@@ -45,10 +45,11 @@ func TestCopyInError(t *testing.T) {
4545
4646func TestCopyInErrorWrongType (t * testing.T ) {
4747 t .Parallel ()
48- tx := pqtest .Begin (t , pqtest .MustDB (t ))
48+ db := pqtest .MustDB (t )
49+ tx := pqtest .Begin (t , db )
4950 pqtest .Exec (t , tx , `create temp table tbl (num integer)` )
5051
51- stmt := pqtest .Prepare (t , tx , `copy tbl (num) from stdin` )
52+ stmt := pqtest .Prepare (t , tx , `copy tbl (num) from stdin` , db )
5253 stmt .MustExec (t , "Héllö\n ☃!\r \t \\ " )
5354 _ , err := stmt .Exec ()
5455 mustAs (t , err , pqerror .InvalidTextRepresentation )
@@ -66,10 +67,11 @@ func TestCopyInErrorOutsideTransaction(t *testing.T) {
6667
6768func TestCopyInQueryWhileCopy (t * testing.T ) {
6869 t .Parallel ()
69- tx := pqtest .Begin (t , pqtest .MustDB (t ))
70+ db := pqtest .MustDB (t )
71+ tx := pqtest .Begin (t , db )
7072 pqtest .Exec (t , tx , `create temp table tbl (i int primary key)` )
7173
72- pqtest .Prepare (t , tx , "copy tbl (i) from stdin" )
74+ pqtest .Prepare (t , tx , "copy tbl (i) from stdin" , db )
7375 _ , err := tx .Query (`select 1` )
7476 if ! errors .Is (err , errQueryInProgress ) {
7577 t .Errorf ("wrong error:\n have: %s\n want: %s" , err , errQueryInProgress )
@@ -97,10 +99,11 @@ func TestCopyInNull(t *testing.T) {
9799 tt := tt
98100 t .Run ("" , func (t * testing.T ) {
99101 t .Parallel ()
100- tx := pqtest .Begin (t , pqtest .MustDB (t ))
102+ db := pqtest .MustDB (t )
103+ tx := pqtest .Begin (t , db )
101104
102105 pqtest .Exec (t , tx , `create temp table tbl (i int, t text)` )
103- stmt := pqtest .Prepare (t , tx , tt .copy )
106+ stmt := pqtest .Prepare (t , tx , tt .copy , db )
104107 stmt .MustExec (t , 42 , "forty-two" )
105108 stmt .MustExec (t , tt .null , tt .null )
106109 stmt .MustExec (t )
@@ -130,10 +133,11 @@ func TestCopyInMultipleValues(t *testing.T) {
130133 tt := tt
131134 t .Run ("" , func (t * testing.T ) {
132135 t .Parallel ()
133- tx := pqtest .Begin (t , pqtest .MustDB (t ))
136+ db := pqtest .MustDB (t )
137+ tx := pqtest .Begin (t , db )
134138 pqtest .Exec (t , tx , `create temp table tbl (a int, b varchar)` )
135139
136- stmt := pqtest .Prepare (t , tx , tt .query )
140+ stmt := pqtest .Prepare (t , tx , tt .query , db )
137141 for i := 0 ; i < 500 ; i ++ {
138142 stmt .MustExec (t , int64 (i ), strings .Repeat ("#" , 500 ))
139143 }
@@ -161,7 +165,8 @@ func TestCopyInMultipleValues(t *testing.T) {
161165
162166func TestCopyInRaiseStmtTrigger (t * testing.T ) {
163167 t .Parallel ()
164- tx := pqtest .Begin (t , pqtest .MustDB (t ))
168+ db := pqtest .MustDB (t )
169+ tx := pqtest .Begin (t , db )
165170 pqtest .Exec (t , tx , `create temp table tbl (a int, b varchar)` )
166171 pqtest .Exec (t , tx , `
167172 create or replace function pg_temp.temptest()
@@ -178,7 +183,7 @@ func TestCopyInRaiseStmtTrigger(t *testing.T) {
178183 for each row execute procedure pg_temp.temptest()
179184 ` )
180185
181- stmt := pqtest .Prepare (t , tx , `copy tbl (a, b) from stdin` )
186+ stmt := pqtest .Prepare (t , tx , `copy tbl (a, b) from stdin` , db )
182187 stmt .MustExec (t , int64 (1 ), strings .Repeat ("#" , 500 ))
183188 stmt .MustExec (t )
184189 stmt .MustClose (t )
@@ -195,10 +200,11 @@ func TestCopyInRaiseStmtTrigger(t *testing.T) {
195200
196201func TestCopyInTypes (t * testing.T ) {
197202 t .Parallel ()
198- tx := pqtest .Begin (t , pqtest .MustDB (t ))
203+ db := pqtest .MustDB (t )
204+ tx := pqtest .Begin (t , db )
199205 pqtest .Exec (t , tx , `create temp table tbl (num integer, text varchar, blob bytea, nothing varchar)` )
200206
201- stmt := pqtest .Prepare (t , tx , `copy tbl (num, text, blob, nothing) from stdin` )
207+ stmt := pqtest .Prepare (t , tx , `copy tbl (num, text, blob, nothing) from stdin` , db )
202208 stmt .MustExec (t , int64 (1234567890 ), "Héllö\n ☃!\r \t \\ " , []byte {0 , 255 , 9 , 10 , 13 }, nil )
203209 stmt .MustExec (t )
204210 stmt .MustClose (t )
@@ -241,7 +247,7 @@ func TestCopyInRespLoopConnectionError(t *testing.T) {
241247
242248 pid := pqtest .Query [int64 ](t , tx , `select pg_backend_pid() as pid` )
243249 pqtest .Exec (t , tx , "create temp table tbl (a int)" )
244- stmt := pqtest .Prepare (t , tx , `copy tbl (a) from stdin` )
250+ stmt := pqtest .Prepare (t , tx , `copy tbl (a) from stdin` , db )
245251 pqtest .Exec (t , db , `select pg_terminate_backend($1)` , pid [0 ]["pid" ])
246252
247253 var err error
@@ -271,10 +277,11 @@ func TestCopyInRespLoopConnectionError(t *testing.T) {
271277}
272278
273279func BenchmarkCopyIn (b * testing.B ) {
274- tx := pqtest .Begin (b , pqtest .MustDB (b ))
280+ db := pqtest .MustDB (b )
281+ tx := pqtest .Begin (b , db )
275282
276283 pqtest .Exec (b , tx , `create temp table tbl (a int, b varchar)` )
277- stmt := pqtest .Prepare (b , tx , `copy tbl (a, b) from stdin` )
284+ stmt := pqtest .Prepare (b , tx , `copy tbl (a, b) from stdin` , db )
278285
279286 b .ResetTimer ()
280287 for i := 0 ; i < b .N ; i ++ {
0 commit comments