mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
libpq failed to cope with COPY FROM STDIN if the command was issued
via extended query protocol, because it sends Sync right after Execute without realizing that the command to be executed is COPY. There seems to be no reasonable way for it to realize that, either, so the best fix seems to be to make the backend ignore Sync during copy-in mode. Bit of a wart on the protocol, but little alternative. Also, libpq must send another Sync after terminating the COPY, if the command was issued via Execute.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.208 2003/08/08 21:41:30 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.209 2003/08/13 18:56:21 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -386,6 +386,7 @@ CopyGetData(void *databuf, int datasize)
|
||||
/* Try to receive another message */
|
||||
int mtype;
|
||||
|
||||
readmessage:
|
||||
mtype = pq_getbyte();
|
||||
if (mtype == EOF)
|
||||
ereport(ERROR,
|
||||
@ -409,6 +410,15 @@ CopyGetData(void *databuf, int datasize)
|
||||
errmsg("COPY from stdin failed: %s",
|
||||
pq_getmsgstring(copy_msgbuf))));
|
||||
break;
|
||||
case 'H': /* Flush */
|
||||
case 'S': /* Sync */
|
||||
/*
|
||||
* Ignore Flush/Sync for the convenience of
|
||||
* client libraries (such as libpq) that may
|
||||
* send those without noticing that the command
|
||||
* they just sent was COPY.
|
||||
*/
|
||||
goto readmessage;
|
||||
default:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROTOCOL_VIOLATION),
|
||||
|
Reference in New Issue
Block a user