Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf3a6fe

Browse files
committed
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) beforereturning from do_copy. The only known consequence of failing to do so isthat get_prompt might show a wrong result for the %x transaction statusescape, 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.
1 parent9b15b14 commitdf3a6fe

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

‎src/bin/psql/copy.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.70 2006/10/06 17:14:00 petere Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.71 2006/11/24 23:06:50 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"copy.h"
@@ -598,6 +598,18 @@ do_copy(const char *args)
598598

599599
PQclear(result);
600600

601+
/*
602+
* Make sure we have pumped libpq dry of results; else it may still be
603+
* in ASYNC_BUSY state, leading to false readings in, eg, get_prompt().
604+
*/
605+
while ((result=PQgetResult(pset.db))!=NULL)
606+
{
607+
success= false;
608+
psql_error("\\copy: unexpected response (%d)\n",
609+
PQresultStatus(result));
610+
PQclear(result);
611+
}
612+
601613
if (options->file!=NULL)
602614
{
603615
if (fclose(copystream)!=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp