Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
5690b1a1
Commit
5690b1a1
authored
May 21, 1999
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor updates to libpq documentation.
parent
3de11d65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
36 deletions
+92
-36
doc/src/sgml/libpq.sgml
doc/src/sgml/libpq.sgml
+34
-14
src/man/libpq.3
src/man/libpq.3
+58
-22
No files found.
doc/src/sgml/libpq.sgml
View file @
5690b1a1
...
...
@@ -430,6 +430,24 @@ PGRES_FATAL_ERROR
</Para>
</ListItem>
<ListItem>
<Para>
<Function>PQresStatus</Function>
Converts the enumerated type returned by PQresultStatus into
a string constant describing the status code.
<synopsis>
const char *PQresStatus(ExecStatusType status);
</synopsis>
Older code may perform this same operation by direct access to a constant
string array inside libpq,
<synopsis>
extern const char * const pgresStatus[];
</synopsis>
However, using the function is recommended instead, since it is more portable
and will not fail on out-of-range values.
</Para>
</ListItem>
<ListItem>
<Para>
<Function>PQresultErrorMessage</Function>
...
...
@@ -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).
</Para>
<Para>
...
...
@@ -1230,10 +1247,10 @@ int PQendcopy(PGconn *conn);
As an example:
<ProgramListing>
PQexec(conn, "create table foo (a int4, b char
16
, 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\t
4.5\n");
PQputline(conn,"4
\tgoodbye world\t
7.11\n");
...
PQputline(conn,"\\.\n");
PQendcopy(conn);
...
...
@@ -1671,22 +1688,25 @@ main()
<Para>
<ProgramListing>
/*
* 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>
...
...
src/man/libpq.3
View file @
5690b1a1
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/libpq.3,v 1.2
6 1999/04/17 17:18:41 momjian
Exp $
.\" $Header: /cvsroot/pgsql/src/man/Attic/libpq.3,v 1.2
7 1999/05/21 00:36:01 tgl
Exp $
.TH LIBPQ INTRO 08/08/98 PostgreSQL PostgreSQL
.SH DESCRIPTION
Current documentation for this topic is available in the new Programmer's Guide
...
...
@@ -266,9 +266,44 @@ PGRES_NONFATAL_ERROR,
PGRES_FATAL_ERROR
.fi
.IP
If the result status is PGRES_TUPLES_OK, then the following routines can
be used to retrieve the tuples returned by the query.
If the result status is PGRES_TUPLES_OK, then the
routines described below can be used to retrieve the
tuples returned by the query. Note that a SELECT that
happens to retrieve zero tuples still shows PGRES_TUPLES_OK.
PGRES_COMMAND_OK is for commands that can never return tuples.
.PP
.B PQresStatus
.IP
Converts the enumerated type returned by PQresultStatus into
a string constant describing the status code.
.nf
const char *PQresStatus(ExecStatusType status);
.fi
.IP
Older code may perform this same operation by direct access to a constant
string array inside libpq,
.nf
extern const char * const pgresStatus[];
.fi
.IP
However, using the function is recommended instead, since it is more portable
and will not fail on out-of-range values.
.PP
.B PQresultErrorMessage
.IP
returns the error message associated with the query, or an empty string
if there was no error.
.nf
const char *PQresultErrorMessage(PGresult *res);
.fi
.IP
Immediately following a PQexec or PQgetResult call, PQerrorMessage
(on the connection) will return the same string as PQresultErrorMessage
(on the result). However, a PGresult will retain its error message
until destroyed, whereas the connection's error message will change when
subsequent operations are done. Use PQresultErrorMessage when you want to
know the status associated with a particular PGresult; use PQerrorMessage
when you want to know the status from the latest operation on the connection.
.B PQntuples
returns the number of tuples (instances) in the query result.
...
...
@@ -558,8 +593,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).
.PP
A frontend that uses PQsendQuery/PQgetResult can also attempt to cancel
...
...
@@ -789,12 +823,12 @@ int PQendcopy(PGconn *conn);
.fi
As an example:
.nf
PQexec(conn, "create table foo (a int4, b
name
, 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\en");
PQputline(conn,"4
<TAB>goodbye world<TAB>
7.11\en");
PQputline(conn, "3
\ethello world\et
4.5\en");
PQputline(conn,"4
\etgoodbye world\et
7.11\en");
\&...
PQputline(conn,"\
\
.\en");
PQputline(conn,"\
e\e
.\en");
PQendcopy(conn);
.fi
.PP
...
...
@@ -1048,20 +1082,22 @@ main()
* testlibpq2.c
* Test of the asynchronous notification interface
*
populate a database with the following:
CREATE TABLE TBL1 (i int4);
CREATE TABLE TBL2 (i int4);
CREATE RULE r1 AS ON INSERT TO TBL1 DO [INSERT INTO TBL2 values (new.i); NOTIFY TBL2];
* Then start up this program
* After the program has begun, do
INSERT INTO TBL1 values (10);
* Start this program, then from psql in another window do
* NOTIFY TBL2;
*
* Or, if you want to get fancy, try this:
* Populate a database with the following:
*
* CREATE TABLE TBL1 (i int4);
*
* CREATE TABLE TBL2 (i int4);
*
* 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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment