error handling in pqRowProcessor broken
От | Peter Eisentraut |
---|---|
Тема | error handling in pqRowProcessor broken |
Дата | |
Msg-id | b52277b9-fa66-b027-4a37-fb8989c73ff8@enterprisedb.com обсуждение исходный текст |
Ответы |
Re: error handling in pqRowProcessor broken
Re: error handling in pqRowProcessor broken |
Список | pgsql-hackers |
The error handling for pqRowProcessor is described as * Add the received row to the current async result (conn->result). * Returns 1 if OK, 0 if error occurred. * * On error, *errmsgp can be set to an error string to be returned. * If it is left NULL, the error is presumed to be "out of memory". I find that this doesn't work anymore. If you set *errmsgp = "some message" and return 0, then psql will just print a result set with zero rows. Bisecting points to commit 618c16707a6d6e8f5c83ede2092975e4670201ad Author: Tom Lane <tgl@sss.pgh.pa.us> Date: Fri Feb 18 15:35:15 2022 -0500 Rearrange libpq's error reporting to avoid duplicated error text. It is very uncommon to get an error from pqRowProcessor(). To reproduce, I inserted this code: diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index c7c48d07dc..9c1b33c6e2 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -1124,6 +1124,12 @@ pqRowProcessor(PGconn *conn, const char **errmsgp) return 0; } + if (nfields == 7) + { + *errmsgp = "gotcha"; + goto fail; + } + /* * Basically we just allocate space in the PGresult for each field and * copy the data over. This will produce assorted failures in the regression tests that illustrate the effect. (Even before the above commit, the handling of the returned message was a bit weird: The error output was just the message string, without any prefix like "ERROR:".)
В списке pgsql-hackers по дате отправления: