diff options
author | Nathan Bossart <nathan@postgresql.org> | 2023-08-22 19:16:12 -0700 |
---|---|---|
committer | Nathan Bossart <nathan@postgresql.org> | 2023-08-22 19:16:12 -0700 |
commit | f4b54e1ed9853ab9aff524494866823f951b1e7f (patch) | |
tree | d828a0aceba5a1e74372170b58c97bae56eeefa3 /src/backend/commands/copyfromparse.c | |
parent | 711479115836b2180f50c00bbf0773220848a7f5 (diff) | |
download | postgresql-f4b54e1ed9853ab9aff524494866823f951b1e7f.tar.gz postgresql-f4b54e1ed9853ab9aff524494866823f951b1e7f.zip |
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
Diffstat (limited to 'src/backend/commands/copyfromparse.c')
-rw-r--r-- | src/backend/commands/copyfromparse.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/backend/commands/copyfromparse.c b/src/backend/commands/copyfromparse.c index 232768a6e13..f553734582f 100644 --- a/src/backend/commands/copyfromparse.c +++ b/src/backend/commands/copyfromparse.c @@ -174,7 +174,7 @@ ReceiveCopyBegin(CopyFromState cstate) int16 format = (cstate->opts.binary ? 1 : 0); int i; - pq_beginmessage(&buf, 'G'); + pq_beginmessage(&buf, PqMsg_CopyInResponse); pq_sendbyte(&buf, format); /* overall format */ pq_sendint16(&buf, natts); for (i = 0; i < natts; i++) @@ -279,13 +279,13 @@ CopyGetData(CopyFromState cstate, void *databuf, int minread, int maxread) /* Validate message type and set packet size limit */ switch (mtype) { - case 'd': /* CopyData */ + case PqMsg_CopyData: maxmsglen = PQ_LARGE_MESSAGE_LIMIT; break; - case 'c': /* CopyDone */ - case 'f': /* CopyFail */ - case 'H': /* Flush */ - case 'S': /* Sync */ + case PqMsg_CopyDone: + case PqMsg_CopyFail: + case PqMsg_Flush: + case PqMsg_Sync: maxmsglen = PQ_SMALL_MESSAGE_LIMIT; break; default: @@ -305,20 +305,20 @@ CopyGetData(CopyFromState cstate, void *databuf, int minread, int maxread) /* ... and process it */ switch (mtype) { - case 'd': /* CopyData */ + case PqMsg_CopyData: break; - case 'c': /* CopyDone */ + case PqMsg_CopyDone: /* COPY IN correctly terminated by frontend */ cstate->raw_reached_eof = true; return bytesread; - case 'f': /* CopyFail */ + case PqMsg_CopyFail: ereport(ERROR, (errcode(ERRCODE_QUERY_CANCELED), errmsg("COPY from stdin failed: %s", pq_getmsgstring(cstate->fe_msgbuf)))); break; - case 'H': /* Flush */ - case 'S': /* Sync */ + case PqMsg_Flush: + case PqMsg_Sync: /* * Ignore Flush/Sync for the convenience of client |