mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +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:
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "access/printsimple.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "libpq/protocol.h"
|
||||
#include "libpq/pqformat.h"
|
||||
#include "utils/builtins.h"
|
||||
|
||||
@@ -32,7 +33,7 @@ printsimple_startup(DestReceiver *self, int operation, TupleDesc tupdesc)
|
||||
StringInfoData buf;
|
||||
int i;
|
||||
|
||||
pq_beginmessage(&buf, 'T'); /* RowDescription */
|
||||
pq_beginmessage(&buf, PqMsg_RowDescription);
|
||||
pq_sendint16(&buf, tupdesc->natts);
|
||||
|
||||
for (i = 0; i < tupdesc->natts; ++i)
|
||||
@@ -65,7 +66,7 @@ printsimple(TupleTableSlot *slot, DestReceiver *self)
|
||||
slot_getallattrs(slot);
|
||||
|
||||
/* Prepare and send message */
|
||||
pq_beginmessage(&buf, 'D');
|
||||
pq_beginmessage(&buf, PqMsg_DataRow);
|
||||
pq_sendint16(&buf, tupdesc->natts);
|
||||
|
||||
for (i = 0; i < tupdesc->natts; ++i)
|
||||
|
@@ -1127,7 +1127,7 @@ HandleParallelMessage(ParallelContext *pcxt, int i, StringInfo msg)
|
||||
|
||||
switch (msgtype)
|
||||
{
|
||||
case 'K': /* BackendKeyData */
|
||||
case PqMsg_BackendKeyData:
|
||||
{
|
||||
int32 pid = pq_getmsgint(msg, 4);
|
||||
|
||||
@@ -1137,8 +1137,8 @@ HandleParallelMessage(ParallelContext *pcxt, int i, StringInfo msg)
|
||||
break;
|
||||
}
|
||||
|
||||
case 'E': /* ErrorResponse */
|
||||
case 'N': /* NoticeResponse */
|
||||
case PqMsg_ErrorResponse:
|
||||
case PqMsg_NoticeResponse:
|
||||
{
|
||||
ErrorData edata;
|
||||
ErrorContextCallback *save_error_context_stack;
|
||||
@@ -1183,7 +1183,7 @@ HandleParallelMessage(ParallelContext *pcxt, int i, StringInfo msg)
|
||||
break;
|
||||
}
|
||||
|
||||
case 'A': /* NotifyResponse */
|
||||
case PqMsg_NotificationResponse:
|
||||
{
|
||||
/* Propagate NotifyResponse. */
|
||||
int32 pid;
|
||||
@@ -1217,7 +1217,7 @@ HandleParallelMessage(ParallelContext *pcxt, int i, StringInfo msg)
|
||||
break;
|
||||
}
|
||||
|
||||
case 'X': /* Terminate, indicating clean exit */
|
||||
case PqMsg_Terminate:
|
||||
{
|
||||
shm_mq_detach(pcxt->worker[i].error_mqh);
|
||||
pcxt->worker[i].error_mqh = NULL;
|
||||
@@ -1372,7 +1372,7 @@ ParallelWorkerMain(Datum main_arg)
|
||||
* protocol message is defined, but it won't actually be used for anything
|
||||
* in this case.
|
||||
*/
|
||||
pq_beginmessage(&msgbuf, 'K');
|
||||
pq_beginmessage(&msgbuf, PqMsg_BackendKeyData);
|
||||
pq_sendint32(&msgbuf, (int32) MyProcPid);
|
||||
pq_sendint32(&msgbuf, (int32) MyCancelKey);
|
||||
pq_endmessage(&msgbuf);
|
||||
@@ -1550,7 +1550,7 @@ ParallelWorkerMain(Datum main_arg)
|
||||
DetachSession();
|
||||
|
||||
/* Report success. */
|
||||
pq_putmessage('X', NULL, 0);
|
||||
pq_putmessage(PqMsg_Terminate, NULL, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user