Fix pipeline batch results not closing pipeline
when error occurs while reading directly from results instead of using a callback. https://github.com/jackc/pgx/issues/1578
This commit is contained in:
@@ -720,6 +720,28 @@ func TestTxSendBatchRollback(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// https://github.com/jackc/pgx/issues/1578
|
||||
func TestSendBatchErrorWhileReadingResultsWithoutCallback(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
|
||||
batch := &pgx.Batch{}
|
||||
batch.Queue("select 4 / $1::int", 0)
|
||||
|
||||
batchResult := conn.SendBatch(ctx, batch)
|
||||
|
||||
_, execErr := batchResult.Exec()
|
||||
require.Error(t, execErr)
|
||||
|
||||
closeErr := batchResult.Close()
|
||||
require.Equal(t, execErr, closeErr)
|
||||
|
||||
// Try to use the connection.
|
||||
_, err := conn.Exec(ctx, "select 1")
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestConnBeginBatchDeferredError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user