1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-28 18:48:04 +03:00

Introduce macros for protocol characters.

This commit introduces descriptively-named macros for the
identifiers used in wire protocol messages.  These new macros are
placed in a new header file so that they can be easily used by
third-party code.

Author: Dave Cramer
Reviewed-by: Alvaro Herrera, Tatsuo Ishii, Peter Smith, Robert Haas, Tom Lane, Peter Eisentraut, Michael Paquier
Discussion: https://postgr.es/m/CADK3HHKbBmK-PKf1bPNFoMC%2BoBt%2BpD9PH8h5nvmBQskEHm-Ehw%40mail.gmail.com
This commit is contained in:
Nathan Bossart
2023-08-22 19:16:12 -07:00
parent 7114791158
commit f4b54e1ed9
25 changed files with 305 additions and 204 deletions

View File

@@ -586,7 +586,7 @@ pg_SASL_init(PGconn *conn, int payloadlen)
/*
* Build a SASLInitialResponse message, and send it.
*/
if (pqPutMsgStart('p', conn))
if (pqPutMsgStart(PqMsg_SASLInitialResponse, conn))
goto error;
if (pqPuts(selected_mechanism, conn))
goto error;

View File

@@ -3591,7 +3591,9 @@ keep_going: /* We will come back to here until there is
* Anything else probably means it's not Postgres on the other
* end at all.
*/
if (!(beresp == 'R' || beresp == 'v' || beresp == 'E'))
if (beresp != PqMsg_AuthenticationRequest &&
beresp != PqMsg_ErrorResponse &&
beresp != PqMsg_NegotiateProtocolVersion)
{
libpq_append_conn_error(conn, "expected authentication request from server, but received %c",
beresp);
@@ -3618,19 +3620,22 @@ keep_going: /* We will come back to here until there is
* version 14, the server also used the old protocol for
* errors that happened before processing the startup packet.)
*/
if (beresp == 'R' && (msgLength < 8 || msgLength > 2000))
if (beresp == PqMsg_AuthenticationRequest &&
(msgLength < 8 || msgLength > 2000))
{
libpq_append_conn_error(conn, "received invalid authentication request");
goto error_return;
}
if (beresp == 'v' && (msgLength < 8 || msgLength > 2000))
if (beresp == PqMsg_NegotiateProtocolVersion &&
(msgLength < 8 || msgLength > 2000))
{
libpq_append_conn_error(conn, "received invalid protocol negotiation message");
goto error_return;
}
#define MAX_ERRLEN 30000
if (beresp == 'E' && (msgLength < 8 || msgLength > MAX_ERRLEN))
if (beresp == PqMsg_ErrorResponse &&
(msgLength < 8 || msgLength > MAX_ERRLEN))
{
/* Handle error from a pre-3.0 server */
conn->inCursor = conn->inStart + 1; /* reread data */
@@ -3693,7 +3698,7 @@ keep_going: /* We will come back to here until there is
}
/* Handle errors. */
if (beresp == 'E')
if (beresp == PqMsg_ErrorResponse)
{
if (pqGetErrorNotice3(conn, true))
{
@@ -3770,7 +3775,7 @@ keep_going: /* We will come back to here until there is
goto error_return;
}
else if (beresp == 'v')
else if (beresp == PqMsg_NegotiateProtocolVersion)
{
if (pqGetNegotiateProtocolVersion3(conn))
{
@@ -4540,7 +4545,7 @@ sendTerminateConn(PGconn *conn)
* Try to send "close connection" message to backend. Ignore any
* error.
*/
pqPutMsgStart('X', conn);
pqPutMsgStart(PqMsg_Terminate, conn);
pqPutMsgEnd(conn);
(void) pqFlush(conn);
}

View File

@@ -1458,7 +1458,7 @@ PQsendQueryInternal(PGconn *conn, const char *query, bool newQuery)
/* Send the query message(s) */
/* construct the outgoing Query message */
if (pqPutMsgStart('Q', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Query, conn) < 0 ||
pqPuts(query, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
{
@@ -1571,7 +1571,7 @@ PQsendPrepare(PGconn *conn,
return 0; /* error msg already set */
/* construct the Parse message */
if (pqPutMsgStart('P', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Parse, conn) < 0 ||
pqPuts(stmtName, conn) < 0 ||
pqPuts(query, conn) < 0)
goto sendFailed;
@@ -1599,7 +1599,7 @@ PQsendPrepare(PGconn *conn,
/* Add a Sync, unless in pipeline mode. */
if (conn->pipelineStatus == PQ_PIPELINE_OFF)
{
if (pqPutMsgStart('S', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Sync, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
goto sendFailed;
}
@@ -1784,7 +1784,7 @@ PQsendQueryGuts(PGconn *conn,
if (command)
{
/* construct the Parse message */
if (pqPutMsgStart('P', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Parse, conn) < 0 ||
pqPuts(stmtName, conn) < 0 ||
pqPuts(command, conn) < 0)
goto sendFailed;
@@ -1808,7 +1808,7 @@ PQsendQueryGuts(PGconn *conn,
}
/* Construct the Bind message */
if (pqPutMsgStart('B', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Bind, conn) < 0 ||
pqPuts("", conn) < 0 ||
pqPuts(stmtName, conn) < 0)
goto sendFailed;
@@ -1874,14 +1874,14 @@ PQsendQueryGuts(PGconn *conn,
goto sendFailed;
/* construct the Describe Portal message */
if (pqPutMsgStart('D', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Describe, conn) < 0 ||
pqPutc('P', conn) < 0 ||
pqPuts("", conn) < 0 ||
pqPutMsgEnd(conn) < 0)
goto sendFailed;
/* construct the Execute message */
if (pqPutMsgStart('E', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Execute, conn) < 0 ||
pqPuts("", conn) < 0 ||
pqPutInt(0, 4, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
@@ -1890,7 +1890,7 @@ PQsendQueryGuts(PGconn *conn,
/* construct the Sync message if not in pipeline mode */
if (conn->pipelineStatus == PQ_PIPELINE_OFF)
{
if (pqPutMsgStart('S', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Sync, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
goto sendFailed;
}
@@ -2422,7 +2422,7 @@ PQdescribePrepared(PGconn *conn, const char *stmt)
{
if (!PQexecStart(conn))
return NULL;
if (!PQsendTypedCommand(conn, 'D', 'S', stmt))
if (!PQsendTypedCommand(conn, PqMsg_Describe, 'S', stmt))
return NULL;
return PQexecFinish(conn);
}
@@ -2441,7 +2441,7 @@ PQdescribePortal(PGconn *conn, const char *portal)
{
if (!PQexecStart(conn))
return NULL;
if (!PQsendTypedCommand(conn, 'D', 'P', portal))
if (!PQsendTypedCommand(conn, PqMsg_Describe, 'P', portal))
return NULL;
return PQexecFinish(conn);
}
@@ -2456,7 +2456,7 @@ PQdescribePortal(PGconn *conn, const char *portal)
int
PQsendDescribePrepared(PGconn *conn, const char *stmt)
{
return PQsendTypedCommand(conn, 'D', 'S', stmt);
return PQsendTypedCommand(conn, PqMsg_Describe, 'S', stmt);
}
/*
@@ -2469,7 +2469,7 @@ PQsendDescribePrepared(PGconn *conn, const char *stmt)
int
PQsendDescribePortal(PGconn *conn, const char *portal)
{
return PQsendTypedCommand(conn, 'D', 'P', portal);
return PQsendTypedCommand(conn, PqMsg_Describe, 'P', portal);
}
/*
@@ -2488,7 +2488,7 @@ PQclosePrepared(PGconn *conn, const char *stmt)
{
if (!PQexecStart(conn))
return NULL;
if (!PQsendTypedCommand(conn, 'C', 'S', stmt))
if (!PQsendTypedCommand(conn, PqMsg_Close, 'S', stmt))
return NULL;
return PQexecFinish(conn);
}
@@ -2506,7 +2506,7 @@ PQclosePortal(PGconn *conn, const char *portal)
{
if (!PQexecStart(conn))
return NULL;
if (!PQsendTypedCommand(conn, 'C', 'P', portal))
if (!PQsendTypedCommand(conn, PqMsg_Close, 'P', portal))
return NULL;
return PQexecFinish(conn);
}
@@ -2521,7 +2521,7 @@ PQclosePortal(PGconn *conn, const char *portal)
int
PQsendClosePrepared(PGconn *conn, const char *stmt)
{
return PQsendTypedCommand(conn, 'C', 'S', stmt);
return PQsendTypedCommand(conn, PqMsg_Close, 'S', stmt);
}
/*
@@ -2534,7 +2534,7 @@ PQsendClosePrepared(PGconn *conn, const char *stmt)
int
PQsendClosePortal(PGconn *conn, const char *portal)
{
return PQsendTypedCommand(conn, 'C', 'P', portal);
return PQsendTypedCommand(conn, PqMsg_Close, 'P', portal);
}
/*
@@ -2542,8 +2542,8 @@ PQsendClosePortal(PGconn *conn, const char *portal)
* Common code to send a Describe or Close command
*
* Available options for "command" are
* 'C' for Close; or
* 'D' for Describe.
* PqMsg_Close for Close; or
* PqMsg_Describe for Describe.
*
* Available options for "type" are
* 'S' to run a command on a prepared statement; or
@@ -2577,17 +2577,17 @@ PQsendTypedCommand(PGconn *conn, char command, char type, const char *target)
/* construct the Sync message */
if (conn->pipelineStatus == PQ_PIPELINE_OFF)
{
if (pqPutMsgStart('S', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Sync, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
goto sendFailed;
}
/* remember if we are doing a Close or a Describe */
if (command == 'C')
if (command == PqMsg_Close)
{
entry->queryclass = PGQUERY_CLOSE;
}
else if (command == 'D')
else if (command == PqMsg_Describe)
{
entry->queryclass = PGQUERY_DESCRIBE;
}
@@ -2696,7 +2696,7 @@ PQputCopyData(PGconn *conn, const char *buffer, int nbytes)
return pqIsnonblocking(conn) ? 0 : -1;
}
/* Send the data (too simple to delegate to fe-protocol files) */
if (pqPutMsgStart('d', conn) < 0 ||
if (pqPutMsgStart(PqMsg_CopyData, conn) < 0 ||
pqPutnchar(buffer, nbytes, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
return -1;
@@ -2731,7 +2731,7 @@ PQputCopyEnd(PGconn *conn, const char *errormsg)
if (errormsg)
{
/* Send COPY FAIL */
if (pqPutMsgStart('f', conn) < 0 ||
if (pqPutMsgStart(PqMsg_CopyFail, conn) < 0 ||
pqPuts(errormsg, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
return -1;
@@ -2739,7 +2739,7 @@ PQputCopyEnd(PGconn *conn, const char *errormsg)
else
{
/* Send COPY DONE */
if (pqPutMsgStart('c', conn) < 0 ||
if (pqPutMsgStart(PqMsg_CopyDone, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
return -1;
}
@@ -2751,7 +2751,7 @@ PQputCopyEnd(PGconn *conn, const char *errormsg)
if (conn->cmd_queue_head &&
conn->cmd_queue_head->queryclass != PGQUERY_SIMPLE)
{
if (pqPutMsgStart('S', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Sync, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
return -1;
}
@@ -3263,7 +3263,7 @@ PQpipelineSync(PGconn *conn)
entry->query = NULL;
/* construct the Sync message */
if (pqPutMsgStart('S', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Sync, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
goto sendFailed;
@@ -3311,7 +3311,7 @@ PQsendFlushRequest(PGconn *conn)
return 0;
}
if (pqPutMsgStart('H', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Flush, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
{
return 0;

View File

@@ -34,8 +34,13 @@
* than a couple of kilobytes).
*/
#define VALID_LONG_MESSAGE_TYPE(id) \
((id) == 'T' || (id) == 'D' || (id) == 'd' || (id) == 'V' || \
(id) == 'E' || (id) == 'N' || (id) == 'A')
((id) == PqMsg_CopyData || \
(id) == PqMsg_DataRow || \
(id) == PqMsg_ErrorResponse || \
(id) == PqMsg_FunctionCallResponse || \
(id) == PqMsg_NoticeResponse || \
(id) == PqMsg_NotificationResponse || \
(id) == PqMsg_RowDescription)
static void handleSyncLoss(PGconn *conn, char id, int msgLength);
@@ -140,12 +145,12 @@ pqParseInput3(PGconn *conn)
* from config file due to SIGHUP), but otherwise we hold off until
* BUSY state.
*/
if (id == 'A')
if (id == PqMsg_NotificationResponse)
{
if (getNotify(conn))
return;
}
else if (id == 'N')
else if (id == PqMsg_NoticeResponse)
{
if (pqGetErrorNotice3(conn, false))
return;
@@ -165,12 +170,12 @@ pqParseInput3(PGconn *conn)
* it is about to close the connection, so we don't want to just
* discard it...)
*/
if (id == 'E')
if (id == PqMsg_ErrorResponse)
{
if (pqGetErrorNotice3(conn, false /* treat as notice */ ))
return;
}
else if (id == 'S')
else if (id == PqMsg_ParameterStatus)
{
if (getParameterStatus(conn))
return;
@@ -192,7 +197,7 @@ pqParseInput3(PGconn *conn)
*/
switch (id)
{
case 'C': /* command complete */
case PqMsg_CommandComplete:
if (pqGets(&conn->workBuffer, conn))
return;
if (!pgHavePendingResult(conn))
@@ -210,13 +215,12 @@ pqParseInput3(PGconn *conn)
CMDSTATUS_LEN);
conn->asyncStatus = PGASYNC_READY;
break;
case 'E': /* error return */
case PqMsg_ErrorResponse:
if (pqGetErrorNotice3(conn, true))
return;
conn->asyncStatus = PGASYNC_READY;
break;
case 'Z': /* sync response, backend is ready for new
* query */
case PqMsg_ReadyForQuery:
if (getReadyForQuery(conn))
return;
if (conn->pipelineStatus != PQ_PIPELINE_OFF)
@@ -246,7 +250,7 @@ pqParseInput3(PGconn *conn)
conn->asyncStatus = PGASYNC_IDLE;
}
break;
case 'I': /* empty query */
case PqMsg_EmptyQueryResponse:
if (!pgHavePendingResult(conn))
{
conn->result = PQmakeEmptyPGresult(conn,
@@ -259,7 +263,7 @@ pqParseInput3(PGconn *conn)
}
conn->asyncStatus = PGASYNC_READY;
break;
case '1': /* Parse Complete */
case PqMsg_ParseComplete:
/* If we're doing PQprepare, we're done; else ignore */
if (conn->cmd_queue_head &&
conn->cmd_queue_head->queryclass == PGQUERY_PREPARE)
@@ -277,10 +281,10 @@ pqParseInput3(PGconn *conn)
conn->asyncStatus = PGASYNC_READY;
}
break;
case '2': /* Bind Complete */
case PqMsg_BindComplete:
/* Nothing to do for this message type */
break;
case '3': /* Close Complete */
case PqMsg_CloseComplete:
/* If we're doing PQsendClose, we're done; else ignore */
if (conn->cmd_queue_head &&
conn->cmd_queue_head->queryclass == PGQUERY_CLOSE)
@@ -298,11 +302,11 @@ pqParseInput3(PGconn *conn)
conn->asyncStatus = PGASYNC_READY;
}
break;
case 'S': /* parameter status */
case PqMsg_ParameterStatus:
if (getParameterStatus(conn))
return;
break;
case 'K': /* secret key data from the backend */
case PqMsg_BackendKeyData:
/*
* This is expected only during backend startup, but it's
@@ -314,7 +318,7 @@ pqParseInput3(PGconn *conn)
if (pqGetInt(&(conn->be_key), 4, conn))
return;
break;
case 'T': /* Row Description */
case PqMsg_RowDescription:
if (conn->error_result ||
(conn->result != NULL &&
conn->result->resultStatus == PGRES_FATAL_ERROR))
@@ -346,7 +350,7 @@ pqParseInput3(PGconn *conn)
return;
}
break;
case 'n': /* No Data */
case PqMsg_NoData:
/*
* NoData indicates that we will not be seeing a
@@ -374,11 +378,11 @@ pqParseInput3(PGconn *conn)
conn->asyncStatus = PGASYNC_READY;
}
break;
case 't': /* Parameter Description */
case PqMsg_ParameterDescription:
if (getParamDescriptions(conn, msgLength))
return;
break;
case 'D': /* Data Row */
case PqMsg_DataRow:
if (conn->result != NULL &&
conn->result->resultStatus == PGRES_TUPLES_OK)
{
@@ -405,24 +409,24 @@ pqParseInput3(PGconn *conn)
conn->inCursor += msgLength;
}
break;
case 'G': /* Start Copy In */
case PqMsg_CopyInResponse:
if (getCopyStart(conn, PGRES_COPY_IN))
return;
conn->asyncStatus = PGASYNC_COPY_IN;
break;
case 'H': /* Start Copy Out */
case PqMsg_CopyOutResponse:
if (getCopyStart(conn, PGRES_COPY_OUT))
return;
conn->asyncStatus = PGASYNC_COPY_OUT;
conn->copy_already_done = 0;
break;
case 'W': /* Start Copy Both */
case PqMsg_CopyBothResponse:
if (getCopyStart(conn, PGRES_COPY_BOTH))
return;
conn->asyncStatus = PGASYNC_COPY_BOTH;
conn->copy_already_done = 0;
break;
case 'd': /* Copy Data */
case PqMsg_CopyData:
/*
* If we see Copy Data, just silently drop it. This would
@@ -431,7 +435,7 @@ pqParseInput3(PGconn *conn)
*/
conn->inCursor += msgLength;
break;
case 'c': /* Copy Done */
case PqMsg_CopyDone:
/*
* If we see Copy Done, just silently drop it. This is
@@ -1692,21 +1696,21 @@ getCopyDataMessage(PGconn *conn)
*/
switch (id)
{
case 'A': /* NOTIFY */
case PqMsg_NotificationResponse:
if (getNotify(conn))
return 0;
break;
case 'N': /* NOTICE */
case PqMsg_NoticeResponse:
if (pqGetErrorNotice3(conn, false))
return 0;
break;
case 'S': /* ParameterStatus */
case PqMsg_ParameterStatus:
if (getParameterStatus(conn))
return 0;
break;
case 'd': /* Copy Data, pass it back to caller */
case PqMsg_CopyData:
return msgLength;
case 'c':
case PqMsg_CopyDone:
/*
* If this is a CopyDone message, exit COPY_OUT mode and let
@@ -1929,7 +1933,7 @@ pqEndcopy3(PGconn *conn)
if (conn->asyncStatus == PGASYNC_COPY_IN ||
conn->asyncStatus == PGASYNC_COPY_BOTH)
{
if (pqPutMsgStart('c', conn) < 0 ||
if (pqPutMsgStart(PqMsg_CopyDone, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
return 1;
@@ -1940,7 +1944,7 @@ pqEndcopy3(PGconn *conn)
if (conn->cmd_queue_head &&
conn->cmd_queue_head->queryclass != PGQUERY_SIMPLE)
{
if (pqPutMsgStart('S', conn) < 0 ||
if (pqPutMsgStart(PqMsg_Sync, conn) < 0 ||
pqPutMsgEnd(conn) < 0)
return 1;
}
@@ -2023,7 +2027,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
/* PQfn already validated connection state */
if (pqPutMsgStart('F', conn) < 0 || /* function call msg */
if (pqPutMsgStart(PqMsg_FunctionCall, conn) < 0 ||
pqPutInt(fnid, 4, conn) < 0 || /* function id */
pqPutInt(1, 2, conn) < 0 || /* # of format codes */
pqPutInt(1, 2, conn) < 0 || /* format code: BINARY */

View File

@@ -562,110 +562,120 @@ pqTraceOutputMessage(PGconn *conn, const char *message, bool toServer)
switch (id)
{
case '1':
case PqMsg_ParseComplete:
fprintf(conn->Pfdebug, "ParseComplete");
/* No message content */
break;
case '2':
case PqMsg_BindComplete:
fprintf(conn->Pfdebug, "BindComplete");
/* No message content */
break;
case '3':
case PqMsg_CloseComplete:
fprintf(conn->Pfdebug, "CloseComplete");
/* No message content */
break;
case 'A': /* Notification Response */
case PqMsg_NotificationResponse:
pqTraceOutputA(conn->Pfdebug, message, &logCursor, regress);
break;
case 'B': /* Bind */
case PqMsg_Bind:
pqTraceOutputB(conn->Pfdebug, message, &logCursor);
break;
case 'c':
case PqMsg_CopyDone:
fprintf(conn->Pfdebug, "CopyDone");
/* No message content */
break;
case 'C': /* Close(F) or Command Complete(B) */
case PqMsg_CommandComplete:
/* Close(F) and CommandComplete(B) use the same identifier. */
Assert(PqMsg_Close == PqMsg_CommandComplete);
pqTraceOutputC(conn->Pfdebug, toServer, message, &logCursor);
break;
case 'd': /* Copy Data */
case PqMsg_CopyData:
/* Drop COPY data to reduce the overhead of logging. */
break;
case 'D': /* Describe(F) or Data Row(B) */
case PqMsg_Describe:
/* Describe(F) and DataRow(B) use the same identifier. */
Assert(PqMsg_Describe == PqMsg_DataRow);
pqTraceOutputD(conn->Pfdebug, toServer, message, &logCursor);
break;
case 'E': /* Execute(F) or Error Response(B) */
case PqMsg_Execute:
/* Execute(F) and ErrorResponse(B) use the same identifier. */
Assert(PqMsg_Execute == PqMsg_ErrorResponse);
pqTraceOutputE(conn->Pfdebug, toServer, message, &logCursor,
regress);
break;
case 'f': /* Copy Fail */
case PqMsg_CopyFail:
pqTraceOutputf(conn->Pfdebug, message, &logCursor);
break;
case 'F': /* Function Call */
case PqMsg_FunctionCall:
pqTraceOutputF(conn->Pfdebug, message, &logCursor, regress);
break;
case 'G': /* Start Copy In */
case PqMsg_CopyInResponse:
pqTraceOutputG(conn->Pfdebug, message, &logCursor);
break;
case 'H': /* Flush(F) or Start Copy Out(B) */
case PqMsg_Flush:
/* Flush(F) and CopyOutResponse(B) use the same identifier */
Assert(PqMsg_CopyOutResponse == PqMsg_Flush);
if (!toServer)
pqTraceOutputH(conn->Pfdebug, message, &logCursor);
else
fprintf(conn->Pfdebug, "Flush"); /* no message content */
break;
case 'I':
case PqMsg_EmptyQueryResponse:
fprintf(conn->Pfdebug, "EmptyQueryResponse");
/* No message content */
break;
case 'K': /* secret key data from the backend */
case PqMsg_BackendKeyData:
pqTraceOutputK(conn->Pfdebug, message, &logCursor, regress);
break;
case 'n':
case PqMsg_NoData:
fprintf(conn->Pfdebug, "NoData");
/* No message content */
break;
case 'N':
case PqMsg_NoticeResponse:
pqTraceOutputNR(conn->Pfdebug, "NoticeResponse", message,
&logCursor, regress);
break;
case 'P': /* Parse */
case PqMsg_Parse:
pqTraceOutputP(conn->Pfdebug, message, &logCursor, regress);
break;
case 'Q': /* Query */
case PqMsg_Query:
pqTraceOutputQ(conn->Pfdebug, message, &logCursor);
break;
case 'R': /* Authentication */
case PqMsg_AuthenticationRequest:
pqTraceOutputR(conn->Pfdebug, message, &logCursor);
break;
case 's':
case PqMsg_PortalSuspended:
fprintf(conn->Pfdebug, "PortalSuspended");
/* No message content */
break;
case 'S': /* Parameter Status(B) or Sync(F) */
case PqMsg_Sync:
/* Parameter Status(B) and Sync(F) use the same identifier */
Assert(PqMsg_ParameterStatus == PqMsg_Sync);
if (!toServer)
pqTraceOutputS(conn->Pfdebug, message, &logCursor);
else
fprintf(conn->Pfdebug, "Sync"); /* no message content */
break;
case 't': /* Parameter Description */
case PqMsg_ParameterDescription:
pqTraceOutputt(conn->Pfdebug, message, &logCursor, regress);
break;
case 'T': /* Row Description */
case PqMsg_RowDescription:
pqTraceOutputT(conn->Pfdebug, message, &logCursor, regress);
break;
case 'v': /* Negotiate Protocol Version */
case PqMsg_NegotiateProtocolVersion:
pqTraceOutputv(conn->Pfdebug, message, &logCursor);
break;
case 'V': /* Function Call response */
case PqMsg_FunctionCallResponse:
pqTraceOutputV(conn->Pfdebug, message, &logCursor);
break;
case 'W': /* Start Copy Both */
case PqMsg_CopyBothResponse:
pqTraceOutputW(conn->Pfdebug, message, &logCursor, length);
break;
case 'X':
case PqMsg_Terminate:
fprintf(conn->Pfdebug, "Terminate");
/* No message content */
break;
case 'Z': /* Ready For Query */
case PqMsg_ReadyForQuery:
pqTraceOutputZ(conn->Pfdebug, message, &logCursor);
break;
default: