Skip to content

Commit 2a4dca9

Browse files
committed
Fix libpq example programs
When these programs call pg_catalog.set_config, they need to check for PGRES_TUPLES_OK instead of PGRES_COMMAND_OK. Fix for 5770172. Reported-by: Ideriha, Takeshi <ideriha.takeshi@jp.fujitsu.com>
1 parent f61a257 commit 2a4dca9

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

doc/src/sgml/libpq.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7842,7 +7842,7 @@ main(int argc, char **argv)
78427842
/* Set always-secure search path, so malicous users can't take control. */
78437843
res = PQexec(conn,
78447844
"SELECT pg_catalog.set_config('search_path', '', false)");
7845-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
7845+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
78467846
{
78477847
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
78487848
PQclear(res);
@@ -8012,7 +8012,7 @@ main(int argc, char **argv)
80128012
/* Set always-secure search path, so malicous users can't take control. */
80138013
res = PQexec(conn,
80148014
"SELECT pg_catalog.set_config('search_path', '', false)");
8015-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
8015+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
80168016
{
80178017
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
80188018
PQclear(res);

doc/src/sgml/lobj.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ main(int argc, char **argv)
902902
/* Set always-secure search path, so malicous users can't take control. */
903903
res = PQexec(conn,
904904
"SELECT pg_catalog.set_config('search_path', '', false)");
905-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
905+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
906906
{
907907
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
908908
PQclear(res);

src/test/examples/testlibpq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ main(int argc, char **argv)
5151
/* Set always-secure search path, so malicous users can't take control. */
5252
res = PQexec(conn,
5353
"SELECT pg_catalog.set_config('search_path', '', false)");
54-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
54+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
5555
{
5656
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
5757
PQclear(res);

src/test/examples/testlibpq2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ main(int argc, char **argv)
8080
/* Set always-secure search path, so malicous users can't take control. */
8181
res = PQexec(conn,
8282
"SELECT pg_catalog.set_config('search_path', '', false)");
83-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
83+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
8484
{
8585
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
8686
PQclear(res);

src/test/examples/testlibpq4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ check_prepare_conn(PGconn *conn, const char *dbName)
3737
/* Set always-secure search path, so malicous users can't take control. */
3838
res = PQexec(conn,
3939
"SELECT pg_catalog.set_config('search_path', '', false)");
40-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
40+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
4141
{
4242
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
4343
PQclear(res);

src/test/examples/testlo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ main(int argc, char **argv)
235235
/* Set always-secure search path, so malicous users can't take control. */
236236
res = PQexec(conn,
237237
"SELECT pg_catalog.set_config('search_path', '', false)");
238-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
238+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
239239
{
240240
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
241241
PQclear(res);

src/test/examples/testlo64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ main(int argc, char **argv)
259259
/* Set always-secure search path, so malicous users can't take control. */
260260
res = PQexec(conn,
261261
"SELECT pg_catalog.set_config('search_path', '', false)");
262-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
262+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
263263
{
264264
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
265265
PQclear(res);

0 commit comments

Comments
 (0)