#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
#include "libpq-fe.h"
Go to the source code of this file.
◆ exit_nicely()
static void exit_nicely |
( |
PGconn * |
conn | ) |
|
|
static |
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 51 of file testlibpq2.c.
References pgNotify::be_pid, conn, CONNECTION_OK, exit_nicely(), fprintf, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PQclear(), PQconnectdb(), PQconsumeInput(), PQerrorMessage(), PQexec(), PQfinish(), PQfreemem(), PQnotifies(), PQresultStatus(), PQsocket(), PQstatus(), pgNotify::relname, select, and strerror.
67 conninfo =
"dbname = postgres";
75 fprintf(stderr,
"Connection to database failed: %s",
82 "SELECT pg_catalog.set_config('search_path', '', false)");
99 res =
PQexec(conn,
"LISTEN TBL2");
110 while (nnotifies < 4)
125 FD_ZERO(&input_mask);
126 FD_SET(sock, &input_mask);
128 if (
select(sock + 1, &input_mask, NULL, NULL, NULL) < 0)
139 "ASYNC NOTIFY of '%s' received from backend PID %d\n",
char * PQerrorMessage(const PGconn *conn)
PGnotify * PQnotifies(PGconn *conn)
void PQfinish(PGconn *conn)
ExecStatusType PQresultStatus(const PGresult *res)
#define select(n, r, w, e, timeout)
int PQconsumeInput(PGconn *conn)
void PQclear(PGresult *res)
static void exit_nicely(PGconn *conn)
PGresult * PQexec(PGconn *conn, const char *query)
ConnStatusType PQstatus(const PGconn *conn)
void PQfreemem(void *ptr)
int PQsocket(const PGconn *conn)
PGconn * PQconnectdb(const char *conninfo)