diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-01-09 18:50:03 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-01-09 18:50:03 +0000 |
commit | d25ada4d7810304ee04b1f4fd9a14ad9ff0c894f (patch) | |
tree | 3a9b52d19285c3df870c23b5ca44337f4d9d80ed /src | |
parent | d04db370720ece56ffcad54e46cf03483c742ebb (diff) | |
download | postgresql-d25ada4d7810304ee04b1f4fd9a14ad9ff0c894f.tar.gz postgresql-d25ada4d7810304ee04b1f4fd9a14ad9ff0c894f.zip |
Fix libpq so that it reports PGRES_EMPTY_QUERY not PGRES_COMMAND_OK when an
empty query string is passed to PQexecParams and related functions. Its
handling of the NoData response to Describe messages was subtly incorrect.
Per my report of yesterday.
Although I consider this a bug, it's a behavioral change that might affect
applications, so not back-patched.
In passing fix a second issue in the same code: it didn't react well to an
out-of-memory failure while trying to make the PGresult object.
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/libpq/fe-protocol3.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c index 9cd9c6b203c..7dba7c2f815 100644 --- a/src/interfaces/libpq/fe-protocol3.c +++ b/src/interfaces/libpq/fe-protocol3.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.37 2009/01/01 17:24:03 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.38 2009/01/09 18:50:03 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -297,19 +297,24 @@ pqParseInput3(PGconn *conn) /* * NoData indicates that we will not be seeing a * RowDescription message because the statement or portal - * inquired about doesn't return rows. Set up a COMMAND_OK - * result, instead of TUPLES_OK. - */ - if (conn->result == NULL) - conn->result = PQmakeEmptyPGresult(conn, - PGRES_COMMAND_OK); - - /* - * If we're doing a Describe, we're ready to pass the - * result back to the client. + * inquired about doesn't return rows. + * + * If we're doing a Describe, we have to pass something + * back to the client, so set up a COMMAND_OK result, + * instead of TUPLES_OK. Otherwise we can just ignore + * this message. */ if (conn->queryclass == PGQUERY_DESCRIBE) + { + if (conn->result == NULL) + { + conn->result = PQmakeEmptyPGresult(conn, + PGRES_COMMAND_OK); + if (!conn->result) + return; + } conn->asyncStatus = PGASYNC_READY; + } break; case 't': /* Parameter Description */ if (getParamDescriptions(conn)) |