summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-protocol3.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/libpq/fe-protocol3.c')
-rw-r--r--src/interfaces/libpq/fe-protocol3.c51
1 files changed, 16 insertions, 35 deletions
diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c
index f5664e0f83..88dd360c90 100644
--- a/src/interfaces/libpq/fe-protocol3.c
+++ b/src/interfaces/libpq/fe-protocol3.c
@@ -201,8 +201,7 @@ pqParseInput3(PGconn *conn)
PGRES_COMMAND_OK);
if (!conn->result)
{
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("out of memory\n"));
+ libpq_append_conn_error(conn, "out of memory");
pqSaveErrorResult(conn);
}
}
@@ -226,8 +225,7 @@ pqParseInput3(PGconn *conn)
PGRES_PIPELINE_SYNC);
if (!conn->result)
{
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("out of memory\n"));
+ libpq_append_conn_error(conn, "out of memory");
pqSaveErrorResult(conn);
}
else
@@ -255,8 +253,7 @@ pqParseInput3(PGconn *conn)
PGRES_EMPTY_QUERY);
if (!conn->result)
{
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("out of memory\n"));
+ libpq_append_conn_error(conn, "out of memory");
pqSaveErrorResult(conn);
}
}
@@ -273,8 +270,7 @@ pqParseInput3(PGconn *conn)
PGRES_COMMAND_OK);
if (!conn->result)
{
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("out of memory\n"));
+ libpq_append_conn_error(conn, "out of memory");
pqSaveErrorResult(conn);
}
}
@@ -354,8 +350,7 @@ pqParseInput3(PGconn *conn)
PGRES_COMMAND_OK);
if (!conn->result)
{
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("out of memory\n"));
+ libpq_append_conn_error(conn, "out of memory");
pqSaveErrorResult(conn);
}
}
@@ -387,8 +382,7 @@ pqParseInput3(PGconn *conn)
else
{
/* Set up to report error at end of query */
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("server sent data (\"D\" message) without prior row description (\"T\" message)\n"));
+ libpq_append_conn_error(conn, "server sent data (\"D\" message) without prior row description (\"T\" message)");
pqSaveErrorResult(conn);
/* Discard the unexpected message */
conn->inCursor += msgLength;
@@ -430,9 +424,7 @@ pqParseInput3(PGconn *conn)
*/
break;
default:
- appendPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unexpected response from server; first received character was \"%c\"\n"),
- id);
+ libpq_append_conn_error(conn, "unexpected response from server; first received character was \"%c\"", id);
/* build an error result holding the error message */
pqSaveErrorResult(conn);
/* not sure if we will see more, so go to ready state */
@@ -455,9 +447,7 @@ pqParseInput3(PGconn *conn)
else
{
/* Trouble --- report it */
- appendPQExpBuffer(&conn->errorMessage,
- libpq_gettext("message contents do not agree with length in message type \"%c\"\n"),
- id);
+ libpq_append_conn_error(conn, "message contents do not agree with length in message type \"%c\"", id);
/* build an error result holding the error message */
pqSaveErrorResult(conn);
conn->asyncStatus = PGASYNC_READY;
@@ -475,8 +465,7 @@ pqParseInput3(PGconn *conn)
static void
handleSyncLoss(PGconn *conn, char id, int msgLength)
{
- appendPQExpBuffer(&conn->errorMessage,
- libpq_gettext("lost synchronization with server: got message type \"%c\", length %d\n"),
+ libpq_append_conn_error(conn, "lost synchronization with server: got message type \"%c\", length %d",
id, msgLength);
/* build an error result holding the error message */
pqSaveErrorResult(conn);
@@ -967,8 +956,7 @@ pqGetErrorNotice3(PGconn *conn, bool isError)
}
if (PQExpBufferDataBroken(workBuf))
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("out of memory\n"));
+ libpq_append_conn_error(conn, "out of memory");
else
appendPQExpBufferStr(&conn->errorMessage, workBuf.data);
}
@@ -1723,8 +1711,7 @@ pqGetCopyData3(PGconn *conn, char **buffer, int async)
*buffer = (char *) malloc(msgLength + 1);
if (*buffer == NULL)
{
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("out of memory\n"));
+ libpq_append_conn_error(conn, "out of memory");
return -2;
}
memcpy(*buffer, &conn->inBuffer[conn->inCursor], msgLength);
@@ -1756,8 +1743,7 @@ pqGetline3(PGconn *conn, char *s, int maxlen)
conn->asyncStatus != PGASYNC_COPY_BOTH) ||
conn->copy_is_binary)
{
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("PQgetline: not doing text COPY OUT\n"));
+ libpq_append_conn_error(conn, "PQgetline: not doing text COPY OUT");
*s = '\0';
return EOF;
}
@@ -1862,8 +1848,7 @@ pqEndcopy3(PGconn *conn)
conn->asyncStatus != PGASYNC_COPY_OUT &&
conn->asyncStatus != PGASYNC_COPY_BOTH)
{
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("no COPY in progress\n"));
+ libpq_append_conn_error(conn, "no COPY in progress");
return 1;
}
@@ -2126,15 +2111,13 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
conn->result = PQmakeEmptyPGresult(conn, status);
if (!conn->result)
{
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("out of memory\n"));
+ libpq_append_conn_error(conn, "out of memory");
pqSaveErrorResult(conn);
}
}
else
{
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("protocol error: no function result\n"));
+ libpq_append_conn_error(conn, "protocol error: no function result");
pqSaveErrorResult(conn);
}
}
@@ -2145,9 +2128,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
break;
default:
/* The backend violates the protocol. */
- appendPQExpBuffer(&conn->errorMessage,
- libpq_gettext("protocol error: id=0x%x\n"),
- id);
+ libpq_append_conn_error(conn, "protocol error: id=0x%x", id);
pqSaveErrorResult(conn);
/* trust the specified message length as what to skip */
conn->inStart += 5 + msgLength;