Skip to content

Commit c3a1750

Browse files
committed
pgx batch uses SendQueryStatement
1 parent a4213bc commit c3a1750

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

batch_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,15 +1043,12 @@ func TestSendBatchStatementTimeout(t *testing.T) {
10431043
assert.NoError(t, err)
10441044

10451045
// get pg_sleep results
1046-
rows, err := br.Query()
1047-
assert.NoError(t, err)
1046+
rows, _ := br.Query()
10481047

10491048
// Consume rows and check error
1050-
for rows.Next() {
1051-
}
1049+
rows.Close()
10521050
err = rows.Err()
10531051
assert.ErrorContains(t, err, "(SQLSTATE 57014)")
1054-
rows.Close()
10551052

10561053
// The last error should be repeated when closing the batch
10571054
err = br.Close()
@@ -1161,8 +1158,8 @@ func TestBatchNetworkUsage(t *testing.T) {
11611158
err := conn.SendBatch(context.Background(), batch).Close()
11621159
require.NoError(t, err)
11631160

1164-
assert.Equal(t, 4116, counterConn.bytesRead)
1165-
assert.Equal(t, 1478, counterConn.bytesWritten)
1161+
assert.Equal(t, 1736, counterConn.bytesRead)
1162+
assert.Equal(t, 1408, counterConn.bytesWritten)
11661163

11671164
ensureConnValid(t, conn)
11681165
}

conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ func (c *Conn) sendBatchExtendedWithDescription(ctx context.Context, b *Batch, d
12361236
if bi.sd.Name == "" {
12371237
pipeline.SendQueryParams(bi.sd.SQL, c.eqb.ParamValues, bi.sd.ParamOIDs, c.eqb.ParamFormats, c.eqb.ResultFormats)
12381238
} else {
1239-
pipeline.SendQueryPrepared(bi.sd.Name, c.eqb.ParamValues, c.eqb.ParamFormats, c.eqb.ResultFormats)
1239+
pipeline.SendQueryStatement(bi.sd, c.eqb.ParamValues, c.eqb.ParamFormats, c.eqb.ResultFormats)
12401240
}
12411241
}
12421242

0 commit comments

Comments
 (0)