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,9 +1808,18 @@ static void
SendCopyBegin(CopyOutState cstate)
{
#if PG_VERSION_NUM < PG_VERSION_14
if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3)
{
/* new way */
if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3) {
/* old way */
if (cstate->binary)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("COPY BINARY is not supported to stdout or from stdin")));
pq_putemptymessage('H');
/* grottiness needed for old COPY OUT protocol */
pq_startcopyout();
cstate->copy_dest = COPY_OLD_FE;
return;
}
#endif
StringInfoData buf;
int natts = list_length(cstate->attnumlist);
@ -1823,22 +1832,7 @@ SendCopyBegin(CopyOutState cstate)
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 */
if (cstate->binary)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("COPY BINARY is not supported to stdout or from stdin")));
pq_putemptymessage('H');
/* grottiness needed for old COPY OUT protocol */
pq_startcopyout();
cstate->copy_dest = COPY_OLD_FE;
}
#endif
cstate->copy_dest = COPY_FRONTEND;
}
@ -1847,23 +1841,19 @@ static void
SendCopyEnd(CopyOutState cstate)
{
#if PG_VERSION_NUM < PG_VERSION_14
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
if (cstate->copy_dest != COPY_NEW_FE)
{
CopySendData(cstate, "\\.", 2);
/* Need to flush out the trailer (this also appends a newline) */
CopySendEndOfRow(cstate, true);
pq_endcopyout(false);
return;
}
#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;
#endif
case COPY_FRONTEND_COMPAT:
case COPY_FRONTEND:
/* The FE/BE protocol uses \n as newline for all platforms */
if (!cstate->binary && includeEndOfLine)
CopySendChar(cstate, '\n');

View File

@ -46,7 +46,6 @@
standard_ProcessUtility(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)
#define COPY_FRONTEND_COMPAT COPY_FRONTEND
#define SetTuplestoreDestReceiverParams_compat(a, b, c, d, e, f) \
SetTuplestoreDestReceiverParams(a, b, c, d, e, f)
#define pgproc_statusflags_compat(pgproc) ((pgproc)->statusFlags)
@ -81,7 +80,7 @@
#define standard_ProcessUtility_compat(a, b, c, 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 COPY_FRONTEND_COMPAT COPY_NEW_FE
#define COPY_FRONTEND COPY_NEW_FE
#define SetTuplestoreDestReceiverParams_compat(a, b, c, d, e, f) \
SetTuplestoreDestReceiverParams(a, b, c, d)
#define pgproc_statusflags_compat(pgproc) \