diff options
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/pg_dump/pg_backup_archiver.c | 2 | ||||
-rw-r--r-- | src/bin/psql/common.c | 15 | ||||
-rw-r--r-- | src/bin/psql/describe.c | 4 | ||||
-rw-r--r-- | src/bin/psql/t/001_basic.pl | 22 |
4 files changed, 38 insertions, 5 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 175fe9c4273..197c1295d93 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -2655,7 +2655,7 @@ WriteToc(ArchiveHandle *AH) pg_fatal("unexpected TOC entry in WriteToc(): %d %s %s", te->dumpId, te->desc, te->tag); - if (fseeko(AH->FH, te->defnLen, SEEK_CUR != 0)) + if (fseeko(AH->FH, te->defnLen, SEEK_CUR) != 0) pg_fatal("error during file seek: %m"); } else if (te->defnDumper) diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 3e4e444f3fd..47352b7faed 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -1867,6 +1867,21 @@ ExecQueryAndProcessResults(const char *query, { FILE *copy_stream = NULL; + if (pset.piped_syncs > 1) + { + /* + * When reading COPY data, the backend ignores sync messages + * and will not send a matching ReadyForQuery response. Even + * if we adjust piped_syncs and requested_results, it is not + * possible to salvage this as the sync message would still be + * in libpq's command queue and we would be stuck in a busy + * pipeline state. Thus, we abort the connection to avoid + * this state. + */ + pg_log_info("\\syncpipeline after COPY is not supported, aborting connection"); + exit(EXIT_BADCONN); + } + /* * For COPY OUT, direct the output to the default place (probably * a pager pipe) for \watch, or to pset.copyStream for \copy, diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 1d08268393e..24e0100c9f0 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -6188,8 +6188,8 @@ listExtensions(const char *pattern) "FROM pg_catalog.pg_extension e " "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace " "LEFT JOIN pg_catalog.pg_description d ON d.objoid = e.oid " - "LEFT JOIN pg_catalog.pg_available_extensions() ae(name, default_version, comment) ON ae.name = e.extname " - "AND d.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass\n", + "AND d.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass " + "LEFT JOIN pg_catalog.pg_available_extensions() ae(name, default_version, comment) ON ae.name = e.extname\n", gettext_noop("Name"), gettext_noop("Version"), gettext_noop("Default version"), diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl index 4050f9a5e3e..ae5c1d66405 100644 --- a/src/bin/psql/t/001_basic.pl +++ b/src/bin/psql/t/001_basic.pl @@ -513,15 +513,33 @@ SELECT 'val1' \\bind \\sendpipeline qr/server closed the connection unexpectedly/, 'protocol sync loss in pipeline: bind COPY, SELECT, sync and getresult'); -# This time, test without the \getresults. +# This time, test without the \getresults and \syncpipeline. psql_fails_like( $node, qq{\\startpipeline COPY psql_pipeline FROM STDIN; SELECT 'val1'; -\\syncpipeline \\endpipeline}, qr/server closed the connection unexpectedly/, 'protocol sync loss in pipeline: COPY, SELECT and sync'); +# Tests sending a sync after a COPY TO/FROM. These abort the connection +# from the frontend. +psql_fails_like( + $node, + qq{\\startpipeline +COPY psql_pipeline FROM STDIN; +\\syncpipeline +\\endpipeline}, + qr/\\syncpipeline after COPY is not supported, aborting connection/, + 'sending sync after COPY FROM'); +psql_fails_like( + $node, + qq{\\startpipeline +COPY psql_pipeline TO STDOUT; +\\syncpipeline +\\endpipeline}, + qr/\\syncpipeline after COPY is not supported, aborting connection/, + 'sending sync after COPY TO'); + done_testing(); |