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:16 +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 b19083ebce51794a67ab85531a8c9c23d5ad8419..7586bd7cc2dd10d0b1c35f98179ad04b5eefef40 100644 (file)
@@ -7977,7 +7977,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);
@@ -8147,7 +8147,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 64868267c4e599656d02af1a3828d4538b58c032..818e59e32a31a49c33d37f1504d66a6375438040 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 8a65f897cd7f96d34304f4f1d3c5e8aafbcb6cdb..cba115a3abf29e22e87f71c848e39eab7faaa59f 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 5512107dfad5035cff94c4a6eba0763f9f543342..94a1d79a15d97066b6758a5412f1e6408ff8e1c0 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);