fixup! Removes support for old protocols in Copy functions from PG14

talha_testpg14
Sait Talha Nisanci 2021-08-27 08:51:58 +03:00
parent b760ec769c
commit c01e989c6d
2 changed files with 22 additions and 33 deletions

View File

@ -1808,26 +1808,7 @@ static void
SendCopyBegin(CopyOutState cstate) SendCopyBegin(CopyOutState cstate)
{ {
#if PG_VERSION_NUM < PG_VERSION_14 #if PG_VERSION_NUM < PG_VERSION_14
if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3) if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3) {
{
/* new way */
#endif
StringInfoData buf;
int natts = list_length(cstate->attnumlist);
int16 format = (cstate->binary ? 1 : 0);
int i;
pq_beginmessage(&buf, 'H');
pq_sendbyte(&buf, format); /* overall format */
pq_sendint16(&buf, natts);
for (i = 0; i < natts; i++)
pq_sendint16(&buf, format); /* per-column formats */
pq_endmessage(&buf);
cstate->copy_dest = COPY_FRONTEND_COMPAT;
#if PG_VERSION_NUM < PG_VERSION_14
}
else
{
/* old way */ /* old way */
if (cstate->binary) if (cstate->binary)
ereport(ERROR, ereport(ERROR,
@ -1837,8 +1818,21 @@ SendCopyBegin(CopyOutState cstate)
/* grottiness needed for old COPY OUT protocol */ /* grottiness needed for old COPY OUT protocol */
pq_startcopyout(); pq_startcopyout();
cstate->copy_dest = COPY_OLD_FE; cstate->copy_dest = COPY_OLD_FE;
return;
} }
#endif #endif
StringInfoData buf;
int natts = list_length(cstate->attnumlist);
int16 format = (cstate->binary ? 1 : 0);
int i;
pq_beginmessage(&buf, 'H');
pq_sendbyte(&buf, format); /* overall format */
pq_sendint16(&buf, natts);
for (i = 0; i < natts; i++)
pq_sendint16(&buf, format); /* per-column formats */
pq_endmessage(&buf);
cstate->copy_dest = COPY_FRONTEND;
} }
@ -1847,23 +1841,19 @@ static void
SendCopyEnd(CopyOutState cstate) SendCopyEnd(CopyOutState cstate)
{ {
#if PG_VERSION_NUM < PG_VERSION_14 #if PG_VERSION_NUM < PG_VERSION_14
if (cstate->copy_dest == COPY_NEW_FE) if (cstate->copy_dest != COPY_NEW_FE)
{
#endif
/* Shouldn't have any unsent data */
Assert(cstate->fe_msgbuf->len == 0);
/* Send Copy Done message */
pq_putemptymessage('c');
#if PG_VERSION_NUM < PG_VERSION_14
}
else
{ {
CopySendData(cstate, "\\.", 2); CopySendData(cstate, "\\.", 2);
/* Need to flush out the trailer (this also appends a newline) */ /* Need to flush out the trailer (this also appends a newline) */
CopySendEndOfRow(cstate, true); CopySendEndOfRow(cstate, true);
pq_endcopyout(false); pq_endcopyout(false);
return;
} }
#endif #endif
/* Shouldn't have any unsent data */
Assert(cstate->fe_msgbuf->len == 0);
/* Send Copy Done message */
pq_putemptymessage('c');
} }
@ -1932,7 +1922,7 @@ CopySendEndOfRow(CopyOutState cstate, bool includeEndOfLine)
} }
break; break;
#endif #endif
case COPY_FRONTEND_COMPAT: case COPY_FRONTEND:
/* The FE/BE protocol uses \n as newline for all platforms */ /* The FE/BE protocol uses \n as newline for all platforms */
if (!cstate->binary && includeEndOfLine) if (!cstate->binary && includeEndOfLine)
CopySendChar(cstate, '\n'); CopySendChar(cstate, '\n');

View File

@ -46,7 +46,6 @@
standard_ProcessUtility(a, b, c, d, e, f, g, h) standard_ProcessUtility(a, b, c, d, e, f, g, h)
#define ProcessUtility_compat(a, b, c, d, e, f, g, h) \ #define ProcessUtility_compat(a, b, c, d, e, f, g, h) \
ProcessUtility(a, b, c, d, e, f, g, h) ProcessUtility(a, b, c, d, e, f, g, h)
#define COPY_FRONTEND_COMPAT COPY_FRONTEND
#define SetTuplestoreDestReceiverParams_compat(a, b, c, d, e, f) \ #define SetTuplestoreDestReceiverParams_compat(a, b, c, d, e, f) \
SetTuplestoreDestReceiverParams(a, b, c, d, e, f) SetTuplestoreDestReceiverParams(a, b, c, d, e, f)
#define pgproc_statusflags_compat(pgproc) ((pgproc)->statusFlags) #define pgproc_statusflags_compat(pgproc) ((pgproc)->statusFlags)
@ -81,7 +80,7 @@
#define standard_ProcessUtility_compat(a, b, c, d, e, f, g, h) \ #define standard_ProcessUtility_compat(a, b, c, d, e, f, g, h) \
standard_ProcessUtility(a, b, d, e, f, g, h) standard_ProcessUtility(a, b, d, e, f, g, h)
#define ProcessUtility_compat(a, b, c, d, e, f, g, h) ProcessUtility(a, b, d, e, f, g, h) #define ProcessUtility_compat(a, b, c, d, e, f, g, h) ProcessUtility(a, b, d, e, f, g, h)
#define COPY_FRONTEND_COMPAT COPY_NEW_FE #define COPY_FRONTEND COPY_NEW_FE
#define SetTuplestoreDestReceiverParams_compat(a, b, c, d, e, f) \ #define SetTuplestoreDestReceiverParams_compat(a, b, c, d, e, f) \
SetTuplestoreDestReceiverParams(a, b, c, d) SetTuplestoreDestReceiverParams(a, b, c, d)
#define pgproc_statusflags_compat(pgproc) \ #define pgproc_statusflags_compat(pgproc) \