mirror of https://github.com/jackc/pgx.git
Handle empty query response
parent
413ef99979
commit
23cbe89dfd
|
@ -440,6 +440,10 @@ func (pgConn *PgConn) NextResult(ctx context.Context) bool {
|
|||
cleanupContext()
|
||||
pgConn.resultReader = PgResultReader{pgConn: pgConn, ctx: ctx, commandTag: CommandTag(msg.CommandTag), complete: true}
|
||||
return true
|
||||
case *pgproto3.EmptyQueryResponse:
|
||||
cleanupContext()
|
||||
pgConn.resultReader = PgResultReader{pgConn: pgConn, ctx: ctx, complete: true}
|
||||
return true
|
||||
case *pgproto3.ErrorResponse:
|
||||
cleanupContext()
|
||||
pgConn.resultReader = PgResultReader{pgConn: pgConn, ctx: ctx, err: errorResponseToPgError(msg), complete: true}
|
||||
|
|
|
@ -245,6 +245,19 @@ func TestConnExec(t *testing.T) {
|
|||
assert.Equal(t, pgConn.Config.Database, string(result.Rows[0][0]))
|
||||
}
|
||||
|
||||
func TestConnExecEmpty(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pgConn, err := pgconn.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
|
||||
require.Nil(t, err)
|
||||
defer closeConn(t, pgConn)
|
||||
|
||||
result, err := pgConn.Exec(context.Background(), ";")
|
||||
require.Nil(t, err)
|
||||
assert.Nil(t, result.CommandTag)
|
||||
assert.Equal(t, 0, len(result.Rows))
|
||||
}
|
||||
|
||||
func TestConnExecMultipleQueries(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
Loading…
Reference in New Issue