mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
Fix psql's \copy command to ensure that it cycles libpq back to the idle state
(in particular, causing the ReadyForQuery message to be eaten) before returning from do_copy. The only known consequence of failing to do so is that get_prompt might show a wrong result for the %x transaction status escape, as reported by Bernd Helmle; but it's possible there are other issues. Back-patch as far as 7.4, the oldest version supporting %x.
This commit is contained in:
parent
35f9bf3725
commit
2f523a6f53
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.58 2005/10/15 02:49:40 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.58.2.1 2006/11/24 23:06:56 tgl Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
#include "copy.h"
|
#include "copy.h"
|
||||||
@ -573,6 +573,18 @@ do_copy(const char *args)
|
|||||||
|
|
||||||
PQclear(result);
|
PQclear(result);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure we have pumped libpq dry of results; else it may still be
|
||||||
|
* in ASYNC_BUSY state, leading to false readings in, eg, get_prompt().
|
||||||
|
*/
|
||||||
|
while ((result = PQgetResult(pset.db)) != NULL)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
psql_error("\\copy: unexpected response (%d)\n",
|
||||||
|
PQresultStatus(result));
|
||||||
|
PQclear(result);
|
||||||
|
}
|
||||||
|
|
||||||
if (options->file != NULL)
|
if (options->file != NULL)
|
||||||
{
|
{
|
||||||
if (fclose(copystream) != 0)
|
if (fclose(copystream) != 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user