From 5690b1a18fc1f91a4604dcaacda95f958e1153cb Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 21 May 1999 00:36:46 +0000 Subject: Minor updates to libpq documentation. --- doc/src/sgml/libpq.sgml | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 3442185fd40..e9d7343cb95 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -430,6 +430,24 @@ PGRES_FATAL_ERROR + + +PQresStatus + Converts the enumerated type returned by PQresultStatus into + a string constant describing the status code. + +const char *PQresStatus(ExecStatusType status); + +Older code may perform this same operation by direct access to a constant +string array inside libpq, + +extern const char * const pgresStatus[]; + +However, using the function is recommended instead, since it is more portable +and will not fail on out-of-range values. + + + PQresultErrorMessage @@ -910,8 +928,7 @@ terms is readable data on the file descriptor identified by PQsocket. When the main loop detects input ready, it should call PQconsumeInput to read the input. It can then call PQisBusy, followed by PQgetResult if PQisBusy returns FALSE. It can also call PQnotifies to detect NOTIFY -messages (see "Asynchronous Notification", below). An example is given -in the sample programs section. +messages (see "Asynchronous Notification", below). @@ -1230,10 +1247,10 @@ int PQendcopy(PGconn *conn); As an example: -PQexec(conn, "create table foo (a int4, b char16, d float8)"); +PQexec(conn, "create table foo (a int4, b char(16), d float8)"); PQexec(conn, "copy foo from stdin"); -PQputline(conn, "3<TAB>hello world<TAB>4.5\n"); -PQputline(conn,"4<TAB>goodbye world<TAB>7.11\n"); +PQputline(conn, "3\thello world\t4.5\n"); +PQputline(conn,"4\tgoodbye world\t7.11\n"); ... PQputline(conn,"\\.\n"); PQendcopy(conn); @@ -1671,22 +1688,25 @@ main() /* - * testlibpq2.c Test of the asynchronous notification interface - * - * populate a database with the following: + * testlibpq2.c + * Test of the asynchronous notification interface * - * CREATE TABLE TBL1 (i int4); + * Start this program, then from psql in another window do + * NOTIFY TBL2; * - * CREATE TABLE TBL2 (i int4); + * Or, if you want to get fancy, try this: + * Populate a database with the following: * - * CREATE RULE r1 AS ON INSERT TO TBL1 DO [INSERT INTO TBL2 values - * (new.i); NOTIFY TBL2]; + * CREATE TABLE TBL1 (i int4); * - * Then start up this program After the program has begun, do + * CREATE TABLE TBL2 (i int4); * - * INSERT INTO TBL1 values (10); + * CREATE RULE r1 AS ON INSERT TO TBL1 DO + * (INSERT INTO TBL2 values (new.i); NOTIFY TBL2); * + * and do * + * INSERT INTO TBL1 values (10); * */ #include <stdio.h> -- cgit v1.2.3