Unhandled errors thrown during execution of a prepared statement #1466
Replies: 4 comments
-
I don't understand what's going on here. The call to Lines 1516 to 1525 in fcec008 That will terminate the loop in AFAICT pgx is doing the right thing. Can you compare the message traffic with psql-wire to PostgreSQL? (pgproto3.Frontend.Trace might be handy here) |
Beta Was this translation helpful? Give feedback.
-
Thanks for looking into this! I have been diving a bit deeper into the message flow. The UNIT test I have written returned a I have compared the message flow of psql-wire to PostgreSQL but was unable to reproduce the throwing of an error during the execution of a prepared statement. Please let me know if you have suggestions on how I could replicate this error message flow inside PostgreSQL. |
Beta Was this translation helpful? Give feedback.
-
I just looked a little closer at your test. The problem is the query results are not being read. This test works: t.Run("jackc/pgx", func(t *testing.T) {
ctx := context.Background()
connstr := fmt.Sprintf("postgres://%s:%d", address.IP, address.Port)
conn, err := pgx.Connect(ctx, connstr)
assert.NoError(t, err)
rows, _ := conn.Query(ctx, "SELECT *;")
rows.Close()
assert.Error(t, rows.Err())
err = conn.Close(ctx)
assert.NoError(t, err)
}) |
Beta Was this translation helpful? Give feedback.
-
Perfect! Thanks for looking into my tests. I have updated the test and everything seems to be working perfectly! We could convert this discussion to an issue and close it if you like. |
Beta Was this translation helpful? Give feedback.
-
👋🏻 , I am currently working on a PSQL server wire protocol implementation allowing you to create a PSQL server in a few lines of code. I noticed while testing the extended query protocol that errors thrown while executing a prepared statement are not handled. I have opened a PR inside the
psql-wire
protocol repository which is able to reproduce the issue.It seems that the error is not handled due to the error not being handled when reading until a row descriptor while executing a prepared query.
pgx/pgconn/pgconn.go
Lines 1480 to 1484 in 74f9b9f
I would like to propose to handle the error returned when reading the next message and to return it to the client.
Beta Was this translation helpful? Give feedback.
All reactions