#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include "libpq-fe.h"
#include <netinet/in.h>
#include <arpa/inet.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 115 of file testlibpq3.c.
117 const char *conninfo;
120 const char *paramValues[1];
123 uint32_t binaryIntVal;
133 conninfo =
"dbname = postgres";
167 paramValues[0] =
"joe's place";
170 "SELECT * FROM test1 WHERE t = $1",
200 binaryIntVal = htonl((uint32_t) 2);
203 paramValues[0] = (
char *) &binaryIntVal;
204 paramLengths[0] =
sizeof(binaryIntVal);
208 "SELECT * FROM test1 WHERE i = $1::int4",
static void PGresult * res
char * PQerrorMessage(const PGconn *conn)
ConnStatusType PQstatus(const PGconn *conn)
PGconn * PQconnectdb(const char *conninfo)
PGresult * PQexecParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
ExecStatusType PQresultStatus(const PGresult *res)
PGresult * PQexec(PGconn *conn, const char *query)
static void exit_nicely(PGconn *conn)
static void show_binary_results(PGresult *res)
References conn, CONNECTION_OK, exit_nicely(), fprintf, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PQclear(), PQconnectdb(), PQerrorMessage(), PQexec(), PQexecParams(), PQfinish(), PQresultStatus(), PQstatus(), res, and show_binary_results().
◆ show_binary_results()
static void show_binary_results |
( |
PGresult * |
res | ) |
|
|
static |
Definition at line 60 of file testlibpq3.c.
90 ival = ntohl(*((uint32_t *) iptr));
103 printf(
" i = (%d bytes) %d\n",
105 printf(
" t = (%d bytes) '%s'\n",
107 printf(
" b = (%d bytes) ", blen);
108 for (
j = 0;
j < blen;
j++)
int PQgetlength(const PGresult *res, int tup_num, int field_num)
int PQntuples(const PGresult *res)
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
int PQfnumber(const PGresult *res, const char *field_name)
References i, j, PQfnumber(), PQgetlength(), PQgetvalue(), PQntuples(), printf, and res.
Referenced by main().