Fix libpq example programs
authorPeter Eisentraut
Sun, 1 Jul 2018 12:06:40 +0000 (14:06 +0200)
committerPeter Eisentraut
Sun, 1 Jul 2018 12:09:11 +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
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 758798f2732472a229ae34575be995024aeb46dd..1cba6a0d3751deaad047df55dd2164bd51ccbd94 100644 (file)
@@ -8084,7 +8084,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);
@@ -8254,7 +8254,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 5bb1a1611197260bd11eece595632c5ca0e68363..152eb6d44ab25721ac940f74c94713116aa8c32a 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 6a9846cb5a69336639be3b309387bac20fab4be9..c853d74e82809ea16a72488931e74086e54efa15 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 4df9bb5351ac3bfdf49c030fe20e41ab69f1d476..e83a78371e8773c77bbf6f4b7dfa3dd1544ff870 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);