]> granicus.if.org Git - postgresql/commitdiff
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:03 +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 4ef752daec71e0768be6058bb848c65309594f1b..0be82a7476d0ef92db9e448c151e96d8242fcf0a 100644 (file)
@@ -8299,7 +8299,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);
@@ -8469,7 +8469,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 553c893b5ef6e47efba37e1699ce8f66d49027ad..f79c474ab2aea26ed25f0387e74770d4298b34ca 100644 (file)
@@ -902,7 +902,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 cacdb8b61bcac01f7f90a3b874572549d513ec62..510758c542f571a7f899ebe7a73f1c982c22a763 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 e4f9aca5e83f332bb09eaecf504bb6b57e7e3d09..9805ced37ccb80c28aeee3590c8476beb38ff3ce 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);