summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorTatsuo Ishii2022-01-12 05:02:27 +0000
committerTatsuo Ishii2022-01-12 05:02:27 +0000
commita14fe59ad89d905b1a339526e59f851857812310 (patch)
tree9824b955497f0d54b209dd5d1fbe1044b0d48274 /src/tools
parentd1914fcf1df347f871354c304a2691189c1a26ca (diff)
Enhance pgproto.
Add new command 'z'. This is similar to 'y' except 'z' reads only 1 message and do not wait for "ready for query" arrives (or timeout if no message arrives within 1 second).
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/pgproto/main.c10
-rw-r--r--src/tools/pgproto/read.c8
2 files changed, 14 insertions, 4 deletions
diff --git a/src/tools/pgproto/main.c b/src/tools/pgproto/main.c
index 68730ce0e..8b58ead2c 100644
--- a/src/tools/pgproto/main.c
+++ b/src/tools/pgproto/main.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2017-2018 Tatsuo Ishii
- * Copyright (c) 2018-2021 PgPool Global Development Group
+ * Copyright (c) 2018-2022 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
@@ -372,11 +372,15 @@ process_message_type(int kind, char *buf, PGconn *conn)
switch (kind)
{
case 'Y':
- read_until_ready_for_query(conn, 0);
+ read_until_ready_for_query(conn, 0, 1);
break;
case 'y':
- read_until_ready_for_query(conn, 1);
+ read_until_ready_for_query(conn, 1, 1);
+ break;
+
+ case 'z':
+ read_until_ready_for_query(conn, 1, 0);
break;
case 'X':
diff --git a/src/tools/pgproto/read.c b/src/tools/pgproto/read.c
index ca7dd71c1..5153356a4 100644
--- a/src/tools/pgproto/read.c
+++ b/src/tools/pgproto/read.c
@@ -41,7 +41,7 @@ static char *read_string(PGconn *conn);
* data is available from the connection.
*/
void
-read_until_ready_for_query(PGconn *conn, int timeout)
+read_until_ready_for_query(PGconn *conn, int timeout, int wait_for_ready_for_query)
{
int kind;
int len;
@@ -253,6 +253,12 @@ read_until_ready_for_query(PGconn *conn, int timeout)
break;
}
+ /*
+ * wait_for_ready_for_query is false, immediately return.
+ */
+ if (wait_for_ready_for_query == 0)
+ cont = 0;
+
/* If nap-between-line is requested, nap for some time */
if (read_nap > 0)
{