Commit 7bdea626 authored by Peter Eisentraut's avatar Peter Eisentraut

Fix libpq example programs

When these programs call pg_catalog.set_config, they need to check for
PGRES_TUPLES_OK instead of PGRES_COMMAND_OK.  Fix for
5770172c.
Reported-by: default avatarIderiha, Takeshi <ideriha.takeshi@jp.fujitsu.com>
parent 56b4da8c
...@@ -8440,7 +8440,7 @@ main(int argc, char **argv) ...@@ -8440,7 +8440,7 @@ main(int argc, char **argv)
/* Set always-secure search path, so malicous users can't take control. */ /* Set always-secure search path, so malicous users can't take control. */
res = PQexec(conn, res = PQexec(conn,
"SELECT pg_catalog.set_config('search_path', '', false)"); "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)); fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
PQclear(res); PQclear(res);
...@@ -8610,7 +8610,7 @@ main(int argc, char **argv) ...@@ -8610,7 +8610,7 @@ main(int argc, char **argv)
/* Set always-secure search path, so malicous users can't take control. */ /* Set always-secure search path, so malicous users can't take control. */
res = PQexec(conn, res = PQexec(conn,
"SELECT pg_catalog.set_config('search_path', '', false)"); "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)); fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
PQclear(res); PQclear(res);
......
...@@ -936,7 +936,7 @@ main(int argc, char **argv) ...@@ -936,7 +936,7 @@ main(int argc, char **argv)
/* Set always-secure search path, so malicous users can't take control. */ /* Set always-secure search path, so malicous users can't take control. */
res = PQexec(conn, res = PQexec(conn,
"SELECT pg_catalog.set_config('search_path', '', false)"); "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)); fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
PQclear(res); PQclear(res);
......
...@@ -51,7 +51,7 @@ main(int argc, char **argv) ...@@ -51,7 +51,7 @@ main(int argc, char **argv)
/* Set always-secure search path, so malicous users can't take control. */ /* Set always-secure search path, so malicous users can't take control. */
res = PQexec(conn, res = PQexec(conn,
"SELECT pg_catalog.set_config('search_path', '', false)"); "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)); fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
PQclear(res); PQclear(res);
......
...@@ -80,7 +80,7 @@ main(int argc, char **argv) ...@@ -80,7 +80,7 @@ main(int argc, char **argv)
/* Set always-secure search path, so malicous users can't take control. */ /* Set always-secure search path, so malicous users can't take control. */
res = PQexec(conn, res = PQexec(conn,
"SELECT pg_catalog.set_config('search_path', '', false)"); "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)); fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
PQclear(res); PQclear(res);
......
...@@ -37,7 +37,7 @@ check_prepare_conn(PGconn *conn, const char *dbName) ...@@ -37,7 +37,7 @@ check_prepare_conn(PGconn *conn, const char *dbName)
/* Set always-secure search path, so malicous users can't take control. */ /* Set always-secure search path, so malicous users can't take control. */
res = PQexec(conn, res = PQexec(conn,
"SELECT pg_catalog.set_config('search_path', '', false)"); "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)); fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
PQclear(res); PQclear(res);
......
...@@ -235,7 +235,7 @@ main(int argc, char **argv) ...@@ -235,7 +235,7 @@ main(int argc, char **argv)
/* Set always-secure search path, so malicous users can't take control. */ /* Set always-secure search path, so malicous users can't take control. */
res = PQexec(conn, res = PQexec(conn,
"SELECT pg_catalog.set_config('search_path', '', false)"); "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)); fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
PQclear(res); PQclear(res);
......
...@@ -259,7 +259,7 @@ main(int argc, char **argv) ...@@ -259,7 +259,7 @@ main(int argc, char **argv)
/* Set always-secure search path, so malicous users can't take control. */ /* Set always-secure search path, so malicous users can't take control. */
res = PQexec(conn, res = PQexec(conn,
"SELECT pg_catalog.set_config('search_path', '', false)"); "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)); fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
PQclear(res); PQclear(res);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment