Fix libpq example programs
authorPeter Eisentraut <peter_e@gmx.net>
Sun, 1 Jul 2018 12:06:40 +0000 (14:06 +0200)
committerPeter Eisentraut <peter_e@gmx.net>
Sun, 1 Jul 2018 12:09:27 +0000 (14:09 +0200)
When these programs call pg_catalog.set_config, they need to check for
PGRES_TUPLES_OK instead of PGRES_COMMAND_OK.  Fix for
5770172cb0c9df9e6ce27c507b449557e5b45124.

Reported-by: Ideriha, Takeshi <ideriha.takeshi@jp.fujitsu.com>
doc/src/sgml/libpq.sgml
doc/src/sgml/lobj.sgml
src/test/examples/testlibpq.c
src/test/examples/testlibpq2.c
src/test/examples/testlibpq4.c
src/test/examples/testlo.c
src/test/examples/testlo64.c

index 0dab74f2a56d8290206d566dc7d2f6694ef230bf..b910e03c63df0e3d0bfa1262df1e4354a3521759 100644 (file)
@@ -7848,7 +7848,7 @@ main(int argc, char **argv)
     /* Set always-secure search path, so malicous users can't take control. */
     res = PQexec(conn,
                  "SELECT pg_catalog.set_config('search_path', '', false)");
-    if (PQresultStatus(res) != PGRES_COMMAND_OK)
+    if (PQresultStatus(res) != PGRES_TUPLES_OK)
     {
         fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
         PQclear(res);
@@ -8014,7 +8014,7 @@ main(int argc, char **argv)
     /* Set always-secure search path, so malicous users can't take control. */
     res = PQexec(conn,
                  "SELECT pg_catalog.set_config('search_path', '', false)");
-    if (PQresultStatus(res) != PGRES_COMMAND_OK)
+    if (PQresultStatus(res) != PGRES_TUPLES_OK)
     {
         fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
         PQclear(res);
index f87b61bf8c0b1d17de3fb2131356d2c122e78002..809061892d1a86a431550b4c31ad95660ebcda11 100644 (file)
@@ -823,7 +823,7 @@ main(int argc, char **argv)
     /* Set always-secure search path, so malicous users can't take control. */
     res = PQexec(conn,
                  "SELECT pg_catalog.set_config('search_path', '', false)");
-    if (PQresultStatus(res) != PGRES_COMMAND_OK)
+    if (PQresultStatus(res) != PGRES_TUPLES_OK)
     {
         fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
         PQclear(res);
index 92a05e53093ee88c819610f727e50542aa91d8c7..d9c6c4587d4584125be690a0b3021902c9dad0e2 100644 (file)
@@ -51,7 +51,7 @@ main(int argc, char **argv)
    /* Set always-secure search path, so malicous users can't take control. */
    res = PQexec(conn,
                 "SELECT pg_catalog.set_config('search_path', '', false)");
-   if (PQresultStatus(res) != PGRES_COMMAND_OK)
+   if (PQresultStatus(res) != PGRES_TUPLES_OK)
    {
        fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
        PQclear(res);
index 76787fe010b8ed942f5321c2583a04326aae43f9..62ecd68b55e39799d27789a4d980799fbcb604cb 100644 (file)
@@ -80,7 +80,7 @@ main(int argc, char **argv)
    /* Set always-secure search path, so malicous users can't take control. */
    res = PQexec(conn,
                 "SELECT pg_catalog.set_config('search_path', '', false)");
-   if (PQresultStatus(res) != PGRES_COMMAND_OK)
+   if (PQresultStatus(res) != PGRES_TUPLES_OK)
    {
        fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
        PQclear(res);
index a20f6249b4eeb3dda9ebd17b35a98d88c6051e57..6fcbdda2fa7d62e115eac1dfd0d0c0fc130c1a95 100644 (file)
@@ -37,7 +37,7 @@ check_prepare_conn(PGconn *conn, const char *dbName)
    /* Set always-secure search path, so malicous users can't take control. */
    res = PQexec(conn,
                 "SELECT pg_catalog.set_config('search_path', '', false)");
-   if (PQresultStatus(res) != PGRES_COMMAND_OK)
+   if (PQresultStatus(res) != PGRES_TUPLES_OK)
    {
        fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
        PQclear(res);
index 8030ce997daa70a1cba0e95a9ebd1de0abf9ae71..fe2f17441f6742ec0d447a1efc1fa428859c6fef 100644 (file)
@@ -235,7 +235,7 @@ main(int argc, char **argv)
    /* Set always-secure search path, so malicous users can't take control. */
    res = PQexec(conn,
                 "SELECT pg_catalog.set_config('search_path', '', false)");
-   if (PQresultStatus(res) != PGRES_COMMAND_OK)
+   if (PQresultStatus(res) != PGRES_TUPLES_OK)
    {
        fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
        PQclear(res);
index 901357f264443803f9484b551021baf83c8865f4..e309ad37e0a5efea2eb7120cfc5fc340179375ec 100644 (file)
@@ -259,7 +259,7 @@ main(int argc, char **argv)
    /* Set always-secure search path, so malicous users can't take control. */
    res = PQexec(conn,
                 "SELECT pg_catalog.set_config('search_path', '', false)");
-   if (PQresultStatus(res) != PGRES_COMMAND_OK)
+   if (PQresultStatus(res) != PGRES_TUPLES_OK)
    {
        fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
        PQclear(res);