mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Add res checking to libpq examples, from Dan Merillat.
This commit is contained in:
@ -1600,7 +1600,7 @@ main()
|
||||
|
||||
/* start a transaction block */
|
||||
res = PQexec(conn, "BEGIN");
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
{
|
||||
fprintf(stderr, "BEGIN command failed\n");
|
||||
PQclear(res);
|
||||
@ -1618,7 +1618,7 @@ main()
|
||||
* databases
|
||||
*/
|
||||
res = PQexec(conn, "DECLARE mycursor CURSOR FOR select * from pg_database");
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
{
|
||||
fprintf(stderr, "DECLARE CURSOR command failed\n");
|
||||
PQclear(res);
|
||||
@ -1626,7 +1626,7 @@ main()
|
||||
}
|
||||
PQclear(res);
|
||||
res = PQexec(conn, "FETCH ALL in mycursor");
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
fprintf(stderr, "FETCH ALL command didn't return tuples properly\n");
|
||||
PQclear(res);
|
||||
@ -1742,7 +1742,7 @@ main()
|
||||
}
|
||||
|
||||
res = PQexec(conn, "LISTEN TBL2");
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
{
|
||||
fprintf(stderr, "LISTEN command failed\n");
|
||||
PQclear(res);
|
||||
@ -1871,7 +1871,7 @@ main()
|
||||
|
||||
/* start a transaction block */
|
||||
res = PQexec(conn, "BEGIN");
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
{
|
||||
fprintf(stderr, "BEGIN command failed\n");
|
||||
PQclear(res);
|
||||
@ -1889,7 +1889,7 @@ main()
|
||||
* databases
|
||||
*/
|
||||
res = PQexec(conn, "DECLARE mycursor BINARY CURSOR FOR select * from test1");
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
{
|
||||
fprintf(stderr, "DECLARE CURSOR command failed\n");
|
||||
PQclear(res);
|
||||
@ -1898,7 +1898,7 @@ main()
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn, "FETCH ALL in mycursor");
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
fprintf(stderr, "FETCH ALL command didn't return tuples properly\n");
|
||||
PQclear(res);
|
||||
|
Reference in New Issue
Block a user