diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-08-13 18:56:21 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-08-13 18:56:21 +0000 |
commit | c01641f8aed00642163b7eb8748a297668a990de (patch) | |
tree | 8cc98b812370e21206b926fded6446b11c06e16d /src/backend/commands/copy.c | |
parent | 0be731ad4441bcb8d2aea809c08c37a4a5d831ce (diff) | |
download | postgresql-c01641f8aed00642163b7eb8748a297668a990de.tar.gz postgresql-c01641f8aed00642163b7eb8748a297668a990de.zip |
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.
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r-- | src/backend/commands/copy.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index eb8a796f229..bf798288f1b 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -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), |