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

Commitea20397

Browse files
committed
When using new protocol, PQexec can get out of a COPY IN or COPY OUT
state by itself, so do so.
1 parentbf75f1a commitea20397

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

‎src/interfaces/libpq/fe-exec.c

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.140 2003/06/23 19:20:24 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.141 2003/06/28 00:06:01 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1083,13 +1083,48 @@ PQexecStart(PGconn *conn)
10831083
*/
10841084
while ((result=PQgetResult(conn))!=NULL)
10851085
{
1086-
if (result->resultStatus==PGRES_COPY_IN||
1087-
result->resultStatus==PGRES_COPY_OUT)
1086+
if (result->resultStatus==PGRES_COPY_IN)
10881087
{
1089-
PQclear(result);
1090-
printfPQExpBuffer(&conn->errorMessage,
1091-
libpq_gettext("COPY state must be terminated first\n"));
1092-
return false;
1088+
if (PG_PROTOCOL_MAJOR(conn->pversion) >=3)
1089+
{
1090+
/* In protocol 3, we can get out of a COPY IN state */
1091+
if (PQputCopyEnd(conn,
1092+
libpq_gettext("COPY terminated by new PQexec"))<0)
1093+
{
1094+
PQclear(result);
1095+
return false;
1096+
}
1097+
/* keep waiting to swallow the copy's failure message */
1098+
}
1099+
else
1100+
{
1101+
/* In older protocols we have to punt */
1102+
PQclear(result);
1103+
printfPQExpBuffer(&conn->errorMessage,
1104+
libpq_gettext("COPY IN state must be terminated first\n"));
1105+
return false;
1106+
}
1107+
}
1108+
elseif (result->resultStatus==PGRES_COPY_OUT)
1109+
{
1110+
if (PG_PROTOCOL_MAJOR(conn->pversion) >=3)
1111+
{
1112+
/*
1113+
* In protocol 3, we can get out of a COPY OUT state: we
1114+
* just switch back to BUSY and allow the remaining COPY
1115+
* data to be dropped on the floor.
1116+
*/
1117+
conn->asyncStatus=PGASYNC_BUSY;
1118+
/* keep waiting to swallow the copy's completion message */
1119+
}
1120+
else
1121+
{
1122+
/* In older protocols we have to punt */
1123+
PQclear(result);
1124+
printfPQExpBuffer(&conn->errorMessage,
1125+
libpq_gettext("COPY OUT state must be terminated first\n"));
1126+
return false;
1127+
}
10931128
}
10941129
PQclear(result);
10951130
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp