#include <stdio.h>
#include <stdlib.h>
#include "libpq-fe.h"
Go to the source code of this file.
◆ check_prepare_conn()
static void check_prepare_conn |
( |
PGconn * |
conn, |
|
|
const char * |
dbName |
|
) |
| |
|
static |
Definition at line 25 of file testlibpq4.c.
38 "SELECT pg_catalog.set_config('search_path', '', false)");
static void PGresult * res
char * PQerrorMessage(const PGconn *conn)
ConnStatusType PQstatus(const PGconn *conn)
ExecStatusType PQresultStatus(const PGresult *res)
PGresult * PQexec(PGconn *conn, const char *query)
References conn, CONNECTION_OK, exit(), fprintf, PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQexec(), PQresultStatus(), PQstatus(), and res.
Referenced by main().
◆ exit_nicely()
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 49 of file testlibpq4.c.
71 fprintf(stderr,
"usage: %s tableName dbName1 dbName2\n", argv[0]);
72 fprintf(stderr,
" compares two tables in two databases\n");
99 res1 =
PQexec(conn1,
"BEGIN");
102 fprintf(stderr,
"BEGIN command failed\n");
116 res1 =
PQexec(conn1,
"DECLARE myportal CURSOR FOR select * from pg_database");
119 fprintf(stderr,
"DECLARE CURSOR command failed\n");
125 res1 =
PQexec(conn1,
"FETCH ALL in myportal");
128 fprintf(stderr,
"FETCH ALL command didn't return tuples properly\n");
135 for (
i = 0;
i < nFields;
i++)
142 for (
j = 0;
j < nFields;
j++)
150 res1 =
PQexec(conn1,
"CLOSE myportal");
154 res1 =
PQexec(conn1,
"END");
int PQntuples(const PGresult *res)
char * PQfname(const PGresult *res, int field_num)
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
int PQnfields(const PGresult *res)
#define PQsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME)
static void exit_nicely(PGconn *conn1, PGconn *conn2)
static void check_prepare_conn(PGconn *conn, const char *dbName)
References check_prepare_conn(), exit(), exit_nicely(), fprintf, i, j, pghost, pgport, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PQclear(), PQexec(), PQfinish(), PQfname(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), PQsetdb, and printf.