Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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:22 +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 be1ef116fbf21d779f20ce7fd2f80234f989437d..54328798a6dbb264616c26f5192e2cf7ade6c2e0 100644 (file)
@@ -7842,7 +7842,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);
@@ -8012,7 +8012,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 a663daffd1e831ee7775e22913e7b3337068505a..dd76d3074b4d0d62774c75a2d5f7b6b4da12d724 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 bd6a397f86c537465ce99958ab8830d6cd882f8e..dae68dcadedfcbaf6f1f6a61e1547970eeacf201 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 0ee13b280b824cd717ec2b299eb833b7faacb726..19d9cba4734cfc33dea2a30548ef2718878c5fdd 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);