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

Commit1de0a4e

Browse files
committed
libpq: Make target_session_attrs=read-write consume empty result.
Otherwise, the leftover empty result can cause problems in somesituations.Michael Paquier and Ashutosh Bapat, per a report from Higuchi Daisuke
1 parentfbe7a3f commit1de0a4e

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

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

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,7 @@ PQconnectPoll(PGconn *conn)
18961896
caseCONNECTION_SSL_STARTUP:
18971897
caseCONNECTION_NEEDED:
18981898
caseCONNECTION_CHECK_WRITABLE:
1899+
caseCONNECTION_CONSUME:
18991900
break;
19001901

19011902
default:
@@ -2935,6 +2936,34 @@ PQconnectPoll(PGconn *conn)
29352936
conn->status=CONNECTION_OK;
29362937
returnPGRES_POLLING_OK;
29372938

2939+
caseCONNECTION_CONSUME:
2940+
{
2941+
conn->status=CONNECTION_OK;
2942+
if (!PQconsumeInput(conn))
2943+
gotoerror_return;
2944+
2945+
if (PQisBusy(conn))
2946+
{
2947+
conn->status=CONNECTION_CONSUME;
2948+
restoreErrorMessage(conn,&savedMessage);
2949+
returnPGRES_POLLING_READING;
2950+
}
2951+
2952+
/*
2953+
* Call PQgetResult() again to consume NULL result.
2954+
*/
2955+
res=PQgetResult(conn);
2956+
if (res!=NULL)
2957+
{
2958+
PQclear(res);
2959+
conn->status=CONNECTION_CONSUME;
2960+
gotokeep_going;
2961+
}
2962+
2963+
/* We are open for business! */
2964+
conn->status=CONNECTION_OK;
2965+
returnPGRES_POLLING_OK;
2966+
}
29382967
caseCONNECTION_CHECK_WRITABLE:
29392968
{
29402969
if (!saveErrorMessage(conn,&savedMessage))
@@ -2994,9 +3023,12 @@ PQconnectPoll(PGconn *conn)
29943023
/* We can release the address lists now. */
29953024
release_all_addrinfo(conn);
29963025

2997-
/* We are open for business! */
2998-
conn->status=CONNECTION_OK;
2999-
returnPGRES_POLLING_OK;
3026+
/*
3027+
* Finish reading any remaining messages before
3028+
* being considered as ready.
3029+
*/
3030+
conn->status=CONNECTION_CONSUME;
3031+
gotokeep_going;
30003032
}
30013033

30023034
/*

‎src/interfaces/libpq/libpq-fe.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ typedef enum
6363
CONNECTION_SETENV,/* Negotiating environment. */
6464
CONNECTION_SSL_STARTUP,/* Negotiating SSL. */
6565
CONNECTION_NEEDED,/* Internal state: connect() needed */
66-
CONNECTION_CHECK_WRITABLE/* Check if we could make a writable
66+
CONNECTION_CHECK_WRITABLE,/* Check if we could make a writable
6767
* connection. */
68+
CONNECTION_CONSUME/* Wait for any pending message and
69+
* consume them. */
6870
}ConnStatusType;
6971

7072
typedefenum

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp