1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-26 12:21:12 +03:00

Add support for multiple error messages from libpq, by simply appending them

after each other (since we already add a newline on each, this makes them
multiline).

Previously a new error would just overwrite the old one, so for example any
error caused when trying to connect with SSL enabled would be overwritten
by the error message form the non-SSL connection when using sslmode=prefer.
This commit is contained in:
Magnus Hagander
2008-10-27 09:42:31 +00:00
parent 0fec77ae88
commit f3a0688ace
5 changed files with 54 additions and 36 deletions

View File

@ -23,7 +23,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.135 2008/08/20 11:53:45 mha Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.136 2008/10/27 09:42:31 mha Exp $
*
*-------------------------------------------------------------------------
*/
@ -106,14 +106,14 @@ pqPutc(char c, PGconn *conn)
/*
* pqGets:
* pqGets[_append]:
* get a null-terminated string from the connection,
* and store it in an expansible PQExpBuffer.
* If we run out of memory, all of the string is still read,
* but the excess characters are silently discarded.
*/
int
pqGets(PQExpBuffer buf, PGconn *conn)
static int
pqGets_internal(PQExpBuffer buf, PGconn *conn, bool resetbuffer)
{
/* Copy conn data to locals for faster search loop */
char *inBuffer = conn->inBuffer;
@ -129,7 +129,9 @@ pqGets(PQExpBuffer buf, PGconn *conn)
slen = inCursor - conn->inCursor;
resetPQExpBuffer(buf);
if (resetbuffer)
resetPQExpBuffer(buf);
appendBinaryPQExpBuffer(buf, inBuffer + conn->inCursor, slen);
conn->inCursor = ++inCursor;
@ -141,6 +143,18 @@ pqGets(PQExpBuffer buf, PGconn *conn)
return 0;
}
int
pqGets(PQExpBuffer buf, PGconn *conn)
{
return pqGets_internal(buf, conn, true);
}
int
pqGets_append(PQExpBuffer buf, PGconn *conn)
{
return pqGets_internal(buf, conn, false);
}
/*
* pqPuts: write a null-terminated string to the current message