mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +03:00
Changed " to '. Removed bug section from psql. added reminder for log call
in built-in. fixed backslases in source for libpq.
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
.\" This is -*-nroff-*-
|
.\" This is -*-nroff-*-
|
||||||
.\" XXX standard disclaimer belongs here....
|
.\" XXX standard disclaimer belongs here....
|
||||||
.\" $Header: /cvsroot/pgsql/src/man/Attic/built-in.3,v 1.1 1996/11/14 10:15:15 scrappy Exp $
|
.\" $Header: /cvsroot/pgsql/src/man/Attic/built-in.3,v 1.2 1996/11/15 17:55:26 momjian Exp $
|
||||||
.TH BUILT-INS INTRO 11/05/95 Postgres95 Postgres95
|
.TH BUILT-INS INTRO 11/05/95 Postgres95 Postgres95
|
||||||
.SH "DESCRIPTION"
|
.SH "DESCRIPTION"
|
||||||
This section describes the data types, functions and operators
|
This section describes the data types, functions and operators
|
||||||
@ -208,7 +208,7 @@ float8
|
|||||||
|/ square root
|
|/ square root
|
||||||
||/ cube root
|
||/ cube root
|
||||||
: exponential function
|
: exponential function
|
||||||
; natural logarithm
|
; natural logarithm (in psql, protect with parentheses)
|
||||||
|
|
||||||
point
|
point
|
||||||
!< A is left of B
|
!< A is left of B
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
.\" This is -*-nroff-*-
|
.\" This is -*-nroff-*-
|
||||||
.\" XXX standard disclaimer belongs here....
|
.\" XXX standard disclaimer belongs here....
|
||||||
.\" $Header: /usr/local/devel/postgres/src/ref/RCS/large_objects.3pqsrc,v 1.12 1
|
.\" $Header: /cvsroot/pgsql/src/man/Attic/large_objects.3,v 1.2 1996/11/15 17:55:29 momjian Exp $
|
||||||
993/08/23 09:03:16 aoki Exp $
|
|
||||||
.TH "LARGE OBJECTS" INTRO 03/18/94 Postgres95 Postgres95
|
.TH "LARGE OBJECTS" INTRO 03/18/94 Postgres95 Postgres95
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.PP
|
.PP
|
||||||
@ -16,7 +15,6 @@ This section describes the implementation and the
|
|||||||
programmatic and query language interfaces to Postgres large object data.
|
programmatic and query language interfaces to Postgres large object data.
|
||||||
.PP
|
.PP
|
||||||
.SH "Historical Note"
|
.SH "Historical Note"
|
||||||
.SH "Historical Note"
|
|
||||||
.PP
|
.PP
|
||||||
Originally, postgres 4.2 supports three standard implementations of large
|
Originally, postgres 4.2 supports three standard implementations of large
|
||||||
objects: as files external to Postgres, as Unix files managed by Postgres, and as
|
objects: as files external to Postgres, as Unix files managed by Postgres, and as
|
||||||
@ -27,7 +25,6 @@ it provides stricter data integrity and time travel. For historical reasons,
|
|||||||
they are called Inversion large objects. (We will use Inversion and large
|
they are called Inversion large objects. (We will use Inversion and large
|
||||||
objects interchangeably to mean the same thing in this section.)
|
objects interchangeably to mean the same thing in this section.)
|
||||||
.SH "Inversion Large Objects"
|
.SH "Inversion Large Objects"
|
||||||
.SH "Inversion Large Objects"
|
|
||||||
.PP
|
.PP
|
||||||
The Inversion large
|
The Inversion large
|
||||||
object implementation breaks large objects up into \*(lqchunks\*(rq and
|
object implementation breaks large objects up into \*(lqchunks\*(rq and
|
||||||
@ -35,7 +32,6 @@ stores the chunks in tuples in the database. A B-tree index
|
|||||||
guarantees fast searches for the correct chunk number when doing
|
guarantees fast searches for the correct chunk number when doing
|
||||||
random access reads and writes.
|
random access reads and writes.
|
||||||
.SH "Large Object Interfaces"
|
.SH "Large Object Interfaces"
|
||||||
.SH "Large Object Interfaces"
|
|
||||||
.PP
|
.PP
|
||||||
The facilities Postgres provides to access large objects, both in
|
The facilities Postgres provides to access large objects, both in
|
||||||
the backend as part of user-defined functions or the front end
|
the backend as part of user-defined functions or the front end
|
||||||
@ -77,7 +73,6 @@ Postgres provides a set of routines that
|
|||||||
support opening, reading, writing, closing, and seeking on large
|
support opening, reading, writing, closing, and seeking on large
|
||||||
objects.
|
objects.
|
||||||
.SH "Creating a Large Object"
|
.SH "Creating a Large Object"
|
||||||
.SH "Creating a Large Object"
|
|
||||||
.PP
|
.PP
|
||||||
The routine
|
The routine
|
||||||
.nf
|
.nf
|
||||||
@ -114,7 +109,6 @@ The commands below create an (Inversion) large object:
|
|||||||
inv_oid = lo_creat(INV_READ|INV_WRITE|INV_ARCHIVE);
|
inv_oid = lo_creat(INV_READ|INV_WRITE|INV_ARCHIVE);
|
||||||
.fi
|
.fi
|
||||||
.SH "Importing a Large Object"
|
.SH "Importing a Large Object"
|
||||||
.SH "Importing a Large Object"
|
|
||||||
To import a UNIX file as a large object, call
|
To import a UNIX file as a large object, call
|
||||||
.nf
|
.nf
|
||||||
Oid
|
Oid
|
||||||
@ -125,7 +119,6 @@ The
|
|||||||
argument specifies the UNIX pathname of the file to be imported as
|
argument specifies the UNIX pathname of the file to be imported as
|
||||||
a large object.
|
a large object.
|
||||||
.SH "Exporting a Large Object"
|
.SH "Exporting a Large Object"
|
||||||
.SH "Exporting a Large Object"
|
|
||||||
To export a large object into UNIX file, call
|
To export a large object into UNIX file, call
|
||||||
.nf
|
.nf
|
||||||
int
|
int
|
||||||
@ -138,7 +131,6 @@ the
|
|||||||
.I filename
|
.I filename
|
||||||
argument specifies the UNIX pathname of the file.
|
argument specifies the UNIX pathname of the file.
|
||||||
.SH "Opening an Existing Large Object"
|
.SH "Opening an Existing Large Object"
|
||||||
.SH "Opening an Existing Large Object"
|
|
||||||
.PP
|
.PP
|
||||||
To open an existing large object, call
|
To open an existing large object, call
|
||||||
.nf
|
.nf
|
||||||
@ -165,7 +157,6 @@ and
|
|||||||
.B lo_close .
|
.B lo_close .
|
||||||
.\"-----------
|
.\"-----------
|
||||||
.SH "Writing Data to a Large Object"
|
.SH "Writing Data to a Large Object"
|
||||||
.SH "Writing Data to a Large Object"
|
|
||||||
.PP
|
.PP
|
||||||
The routine
|
The routine
|
||||||
.nf
|
.nf
|
||||||
@ -187,7 +178,6 @@ The number of bytes actually written is returned.
|
|||||||
In the event of an error,
|
In the event of an error,
|
||||||
the return value is negative.
|
the return value is negative.
|
||||||
.SH "Seeking on a Large Object"
|
.SH "Seeking on a Large Object"
|
||||||
.SH "Seeking on a Large Object"
|
|
||||||
.PP
|
.PP
|
||||||
To change the current read or write location on a large object,
|
To change the current read or write location on a large object,
|
||||||
call
|
call
|
||||||
@ -207,7 +197,6 @@ and
|
|||||||
.SM SEEK_END.
|
.SM SEEK_END.
|
||||||
.\"-----------
|
.\"-----------
|
||||||
.SH "Closing a Large Object Descriptor"
|
.SH "Closing a Large Object Descriptor"
|
||||||
.SH "Closing a Large Object Descriptor"
|
|
||||||
.PP
|
.PP
|
||||||
A large object may be closed by calling
|
A large object may be closed by calling
|
||||||
.nf
|
.nf
|
||||||
@ -223,7 +212,6 @@ On success,
|
|||||||
returns zero. On error, the return value is negative.
|
returns zero. On error, the return value is negative.
|
||||||
.PP
|
.PP
|
||||||
.SH "Built in registered functions"
|
.SH "Built in registered functions"
|
||||||
.SH "Built in registered functions"
|
|
||||||
.PP
|
.PP
|
||||||
There are two built-in registered functions,
|
There are two built-in registered functions,
|
||||||
.I lo_import
|
.I lo_import
|
||||||
@ -241,12 +229,11 @@ CREATE TABLE image (
|
|||||||
INSERT INTO image (name, raster)
|
INSERT INTO image (name, raster)
|
||||||
VALUES ('beautiful image', lo_import('/etc/motd'));
|
VALUES ('beautiful image', lo_import('/etc/motd'));
|
||||||
|
|
||||||
SELECT lo_export(image.raster, "/tmp/motd") from image
|
SELECT lo_export(image.raster, '/tmp/motd') from image
|
||||||
WHERE name = 'beautiful image';
|
WHERE name = 'beautiful image';
|
||||||
.fi
|
.fi
|
||||||
.PP
|
.PP
|
||||||
.SH "Accessing Large Objects from LIBPQ"
|
.SH "Accessing Large Objects from LIBPQ"
|
||||||
.SH "Accessing Large Objects from LIBPQ"
|
|
||||||
Below is a sample program which shows how the large object interface in
|
Below is a sample program which shows how the large object interface in
|
||||||
\*(LP can be used. Parts of the program are commented out but are left
|
\*(LP can be used. Parts of the program are commented out but are left
|
||||||
in the source for the readers benefit. This program can be found in
|
in the source for the readers benefit. This program can be found in
|
||||||
@ -262,7 +249,6 @@ and link with the
|
|||||||
library.
|
library.
|
||||||
.bp
|
.bp
|
||||||
.SH "Sample Program"
|
.SH "Sample Program"
|
||||||
.SH "Sample Program"
|
|
||||||
.nf
|
.nf
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
@ -273,7 +259,7 @@ library.
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/man/Attic/large_objects.3,v 1.1 1996/11/14 10:17:24 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/man/Attic/large_objects.3,v 1.2 1996/11/15 17:55:29 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -301,7 +287,7 @@ Oid importFile(PGconn *conn, char *filename)
|
|||||||
*/
|
*/
|
||||||
fd = open(filename, O_RDONLY, 0666);
|
fd = open(filename, O_RDONLY, 0666);
|
||||||
if (fd < 0) { /* error */
|
if (fd < 0) { /* error */
|
||||||
fprintf(stderr, "can't open unix file\"%s\"\n", filename);
|
fprintf(stderr, "can't open unix file\\"%s\\"\\n", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -319,7 +305,7 @@ Oid importFile(PGconn *conn, char *filename)
|
|||||||
while ((nbytes = read(fd, buf, BUFSIZE)) > 0) {
|
while ((nbytes = read(fd, buf, BUFSIZE)) > 0) {
|
||||||
tmp = lo_write(conn, lobj_fd, buf, nbytes);
|
tmp = lo_write(conn, lobj_fd, buf, nbytes);
|
||||||
if (tmp < nbytes) {
|
if (tmp < nbytes) {
|
||||||
fprintf(stderr, "error while reading \"%s\"", filename);
|
fprintf(stderr, "error while reading \\"%s\\"", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,11 +334,11 @@ void pickout(PGconn *conn, Oid lobjId, int start, int len)
|
|||||||
nread = 0;
|
nread = 0;
|
||||||
while (len - nread > 0) {
|
while (len - nread > 0) {
|
||||||
nbytes = lo_read(conn, lobj_fd, buf, len - nread);
|
nbytes = lo_read(conn, lobj_fd, buf, len - nread);
|
||||||
buf[nbytes] = '\0';
|
buf[nbytes] = '\\0';
|
||||||
fprintf(stderr,">>> %s", buf);
|
fprintf(stderr,">>> %s", buf);
|
||||||
nread += nbytes;
|
nread += nbytes;
|
||||||
}
|
}
|
||||||
fprintf(stderr,"\n");
|
fprintf(stderr,"\\n");
|
||||||
lo_close(conn, lobj_fd);
|
lo_close(conn, lobj_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,14 +361,14 @@ void overwrite(PGconn *conn, Oid lobjId, int start, int len)
|
|||||||
|
|
||||||
for (i=0;i<len;i++)
|
for (i=0;i<len;i++)
|
||||||
buf[i] = 'X';
|
buf[i] = 'X';
|
||||||
buf[i] = '\0';
|
buf[i] = '\\0';
|
||||||
|
|
||||||
nwritten = 0;
|
nwritten = 0;
|
||||||
while (len - nwritten > 0) {
|
while (len - nwritten > 0) {
|
||||||
nbytes = lo_write(conn, lobj_fd, buf + nwritten, len - nwritten);
|
nbytes = lo_write(conn, lobj_fd, buf + nwritten, len - nwritten);
|
||||||
nwritten += nbytes;
|
nwritten += nbytes;
|
||||||
}
|
}
|
||||||
fprintf(stderr,"\n");
|
fprintf(stderr,"\\n");
|
||||||
lo_close(conn, lobj_fd);
|
lo_close(conn, lobj_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +399,7 @@ void exportFile(PGconn *conn, Oid lobjId, char *filename)
|
|||||||
*/
|
*/
|
||||||
fd = open(filename, O_CREAT|O_WRONLY, 0666);
|
fd = open(filename, O_CREAT|O_WRONLY, 0666);
|
||||||
if (fd < 0) { /* error */
|
if (fd < 0) { /* error */
|
||||||
fprintf(stderr, "can't open unix file\"%s\"",
|
fprintf(stderr, "can't open unix file\\"%s\\"",
|
||||||
filename);
|
filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +409,7 @@ void exportFile(PGconn *conn, Oid lobjId, char *filename)
|
|||||||
while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0) {
|
while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0) {
|
||||||
tmp = write(fd, buf, nbytes);
|
tmp = write(fd, buf, nbytes);
|
||||||
if (tmp < nbytes) {
|
if (tmp < nbytes) {
|
||||||
fprintf(stderr,"error while writing \"%s\"",
|
fprintf(stderr,"error while writing \\"%s\\"",
|
||||||
filename);
|
filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -451,7 +437,7 @@ main(int argc, char **argv)
|
|||||||
PGresult *res;
|
PGresult *res;
|
||||||
|
|
||||||
if (argc != 4) {
|
if (argc != 4) {
|
||||||
fprintf(stderr, "Usage: %s database_name in_filename out_filename\n",
|
fprintf(stderr, "Usage: %s database_name in_filename out_filename\\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -467,27 +453,27 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* check to see that the backend connection was successfully made */
|
/* check to see that the backend connection was successfully made */
|
||||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||||
fprintf(stderr,"Connection to database '%s' failed.\n", database);
|
fprintf(stderr,"Connection to database '%s' failed.\\n", database);
|
||||||
fprintf(stderr,"%s",PQerrorMessage(conn));
|
fprintf(stderr,"%s",PQerrorMessage(conn));
|
||||||
exit_nicely(conn);
|
exit_nicely(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = PQexec(conn, "begin");
|
res = PQexec(conn, "begin");
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
printf("importing file \"%s\" ...\n", in_filename);
|
printf("importing file \\"%s\\" ...\\n", in_filename);
|
||||||
/* lobjOid = importFile(conn, in_filename); */
|
/* lobjOid = importFile(conn, in_filename); */
|
||||||
lobjOid = lo_import(conn, in_filename);
|
lobjOid = lo_import(conn, in_filename);
|
||||||
/*
|
/*
|
||||||
printf("\tas large object %d.\n", lobjOid);
|
printf("\\tas large object %d.\\n", lobjOid);
|
||||||
|
|
||||||
printf("picking out bytes 1000-2000 of the large object\n");
|
printf("picking out bytes 1000-2000 of the large object\\n");
|
||||||
pickout(conn, lobjOid, 1000, 1000);
|
pickout(conn, lobjOid, 1000, 1000);
|
||||||
|
|
||||||
printf("overwriting bytes 1000-2000 of the large object with X's\n");
|
printf("overwriting bytes 1000-2000 of the large object with X's\\n");
|
||||||
overwrite(conn, lobjOid, 1000, 1000);
|
overwrite(conn, lobjOid, 1000, 1000);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
printf("exporting large object to file \"%s\" ...\n", out_filename);
|
printf("exporting large object to file \\"%s\\" ...\\n", out_filename);
|
||||||
/* exportFile(conn, lobjOid, out_filename); */
|
/* exportFile(conn, lobjOid, out_filename); */
|
||||||
lo_export(conn, lobjOid,out_filename);
|
lo_export(conn, lobjOid,out_filename);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
.\" This is -*-nroff-*-
|
.\" This is -*-nroff-*-
|
||||||
.\" XXX standard disclaimer belongs here....
|
.\" XXX standard disclaimer belongs here....
|
||||||
.\" $Header: /cvsroot/pgsql/src/man/Attic/libpq.3,v 1.1 1996/11/14 10:17:26 scrappy Exp $
|
.\" $Header: /cvsroot/pgsql/src/man/Attic/libpq.3,v 1.2 1996/11/15 17:55:30 momjian Exp $
|
||||||
.TH LIBPQ INTRO 03/12/94 Postgres95 Postgres95
|
.TH LIBPQ INTRO 03/12/94 Postgres95 Postgres95
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Libpq is the programmer's interface to Postgres. Libpq is a set of
|
Libpq is the programmer's interface to Postgres. Libpq is a set of
|
||||||
@ -469,7 +469,7 @@ returns EOF at EOF, 0 if the entire line has been read, and 1 if the
|
|||||||
buffer is full but the terminating newline has not yet been read.
|
buffer is full but the terminating newline has not yet been read.
|
||||||
.IP
|
.IP
|
||||||
Notice that the application must check to see if a new line consists
|
Notice that the application must check to see if a new line consists
|
||||||
of the single character \*(lq.\*(rq, which indicates that the backend
|
of the characters \*(lq\\.\*(rq, which indicates that the backend
|
||||||
server has finished sending the results of the
|
server has finished sending the results of the
|
||||||
.I copy
|
.I copy
|
||||||
command. Therefore, if the application ever expects to receive lines
|
command. Therefore, if the application ever expects to receive lines
|
||||||
@ -645,7 +645,7 @@ main()
|
|||||||
|
|
||||||
/* check to see that the backend connection was successfully made */
|
/* check to see that the backend connection was successfully made */
|
||||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||||
fprintf(stderr,"Connection to database '%s' failed.\n", dbName);
|
fprintf(stderr,"Connection to database '%s' failed.\\n", dbName);
|
||||||
fprintf(stderr,"%s",PQerrorMessage(conn));
|
fprintf(stderr,"%s",PQerrorMessage(conn));
|
||||||
exit_nicely(conn);
|
exit_nicely(conn);
|
||||||
}
|
}
|
||||||
@ -656,7 +656,7 @@ main()
|
|||||||
/* start a transaction block */
|
/* start a transaction block */
|
||||||
res = PQexec(conn,"BEGIN");
|
res = PQexec(conn,"BEGIN");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||||
fprintf(stderr,"BEGIN command failed\n");
|
fprintf(stderr,"BEGIN command failed\\n");
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
exit_nicely(conn);
|
exit_nicely(conn);
|
||||||
}
|
}
|
||||||
@ -667,7 +667,7 @@ main()
|
|||||||
/* fetch instances from the pg_database, the system catalog of databases*/
|
/* fetch instances from the pg_database, the system catalog of databases*/
|
||||||
res = PQexec(conn,"DECLARE mycursor CURSOR FOR select * from pg_database");
|
res = PQexec(conn,"DECLARE mycursor CURSOR FOR select * from pg_database");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||||
fprintf(stderr,"DECLARE CURSOR command failed\n");
|
fprintf(stderr,"DECLARE CURSOR command failed\\n");
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
exit_nicely(conn);
|
exit_nicely(conn);
|
||||||
}
|
}
|
||||||
@ -675,7 +675,7 @@ main()
|
|||||||
|
|
||||||
res = PQexec(conn,"FETCH ALL in mycursor");
|
res = PQexec(conn,"FETCH ALL in mycursor");
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
|
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
|
||||||
fprintf(stderr,"FETCH ALL command didn't return tuples properly\n");
|
fprintf(stderr,"FETCH ALL command didn't return tuples properly\\n");
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
exit_nicely(conn);
|
exit_nicely(conn);
|
||||||
}
|
}
|
||||||
@ -685,14 +685,14 @@ main()
|
|||||||
for (i=0; i < nFields; i++) {
|
for (i=0; i < nFields; i++) {
|
||||||
printf("%-15s",PQfname(res,i));
|
printf("%-15s",PQfname(res,i));
|
||||||
}
|
}
|
||||||
printf("\n\n");
|
printf("\\n\\n");
|
||||||
|
|
||||||
/* next, print out the instances */
|
/* next, print out the instances */
|
||||||
for (i=0; i < PQntuples(res); i++) {
|
for (i=0; i < PQntuples(res); i++) {
|
||||||
for (j=0 ; j < nFields; j++) {
|
for (j=0 ; j < nFields; j++) {
|
||||||
printf("%-15s", PQgetvalue(res,i,j));
|
printf("%-15s", PQgetvalue(res,i,j));
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
@ -770,14 +770,14 @@ main()
|
|||||||
|
|
||||||
/* check to see that the backend connection was successfully made */
|
/* check to see that the backend connection was successfully made */
|
||||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||||
fprintf(stderr,"Connection to database '%s' failed.\n", dbName);
|
fprintf(stderr,"Connection to database '%s' failed.\\n", dbName);
|
||||||
fprintf(stderr,"%s",PQerrorMessage(conn));
|
fprintf(stderr,"%s",PQerrorMessage(conn));
|
||||||
exit_nicely(conn);
|
exit_nicely(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = PQexec(conn, "LISTEN TBL2");
|
res = PQexec(conn, "LISTEN TBL2");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||||
fprintf(stderr,"LISTEN command failed\n");
|
fprintf(stderr,"LISTEN command failed\\n");
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
exit_nicely(conn);
|
exit_nicely(conn);
|
||||||
}
|
}
|
||||||
@ -789,12 +789,12 @@ main()
|
|||||||
/* async notification only come back as a result of a query*/
|
/* async notification only come back as a result of a query*/
|
||||||
/* we can send empty queries */
|
/* we can send empty queries */
|
||||||
res = PQexec(conn, " ");
|
res = PQexec(conn, " ");
|
||||||
/* printf("res->status = %s\n", pgresStatus[PQresultStatus(res)]); */
|
/* printf("res->status = %s\\n", pgresStatus[PQresultStatus(res)]); */
|
||||||
/* check for asynchronous returns */
|
/* check for asynchronous returns */
|
||||||
notify = PQnotifies(conn);
|
notify = PQnotifies(conn);
|
||||||
if (notify) {
|
if (notify) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"ASYNC NOTIFY of '%s' from backend pid '%d' received\n",
|
"ASYNC NOTIFY of '%s' from backend pid '%d' received\\n",
|
||||||
notify->relname, notify->be_pid);
|
notify->relname, notify->be_pid);
|
||||||
free(notify);
|
free(notify);
|
||||||
break;
|
break;
|
||||||
@ -876,7 +876,7 @@ main()
|
|||||||
|
|
||||||
/* check to see that the backend connection was successfully made */
|
/* check to see that the backend connection was successfully made */
|
||||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||||
fprintf(stderr,"Connection to database '%s' failed.\n", dbName);
|
fprintf(stderr,"Connection to database '%s' failed.\\n", dbName);
|
||||||
fprintf(stderr,"%s",PQerrorMessage(conn));
|
fprintf(stderr,"%s",PQerrorMessage(conn));
|
||||||
exit_nicely(conn);
|
exit_nicely(conn);
|
||||||
}
|
}
|
||||||
@ -884,7 +884,7 @@ main()
|
|||||||
/* start a transaction block */
|
/* start a transaction block */
|
||||||
res = PQexec(conn,"BEGIN");
|
res = PQexec(conn,"BEGIN");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||||
fprintf(stderr,"BEGIN command failed\n");
|
fprintf(stderr,"BEGIN command failed\\n");
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
exit_nicely(conn);
|
exit_nicely(conn);
|
||||||
}
|
}
|
||||||
@ -895,7 +895,7 @@ main()
|
|||||||
/* fetch instances from the pg_database, the system catalog of databases*/
|
/* fetch instances from the pg_database, the system catalog of databases*/
|
||||||
res = PQexec(conn,"DECLARE mycursor BINARY CURSOR FOR select * from test1");
|
res = PQexec(conn,"DECLARE mycursor BINARY CURSOR FOR select * from test1");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||||
fprintf(stderr,"DECLARE CURSOR command failed\n");
|
fprintf(stderr,"DECLARE CURSOR command failed\\n");
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
exit_nicely(conn);
|
exit_nicely(conn);
|
||||||
}
|
}
|
||||||
@ -903,7 +903,7 @@ main()
|
|||||||
|
|
||||||
res = PQexec(conn,"FETCH ALL in mycursor");
|
res = PQexec(conn,"FETCH ALL in mycursor");
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
|
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
|
||||||
fprintf(stderr,"FETCH ALL command didn't return tuples properly\n");
|
fprintf(stderr,"FETCH ALL command didn't return tuples properly\\n");
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
exit_nicely(conn);
|
exit_nicely(conn);
|
||||||
}
|
}
|
||||||
@ -913,7 +913,7 @@ main()
|
|||||||
p_fnum = PQfnumber(res,"p");
|
p_fnum = PQfnumber(res,"p");
|
||||||
|
|
||||||
for (i=0;i<3;i++) {
|
for (i=0;i<3;i++) {
|
||||||
printf("type[%d] = %d, size[%d] = %d\n",
|
printf("type[%d] = %d, size[%d] = %d\\n",
|
||||||
i, PQftype(res,i),
|
i, PQftype(res,i),
|
||||||
i, PQfsize(res,i));
|
i, PQfsize(res,i));
|
||||||
}
|
}
|
||||||
@ -931,12 +931,12 @@ main()
|
|||||||
pval = (POLYGON*) malloc(plen + VARHDRSZ);
|
pval = (POLYGON*) malloc(plen + VARHDRSZ);
|
||||||
pval->size = plen;
|
pval->size = plen;
|
||||||
memmove((char*)&pval->npts, PQgetvalue(res,i,p_fnum), plen);
|
memmove((char*)&pval->npts, PQgetvalue(res,i,p_fnum), plen);
|
||||||
printf("tuple %d: got\n", i);
|
printf("tuple %d: got\\n", i);
|
||||||
printf(" i = (%d bytes) %d,\n",
|
printf(" i = (%d bytes) %d,\\n",
|
||||||
PQgetlength(res,i,i_fnum), *ival);
|
PQgetlength(res,i,i_fnum), *ival);
|
||||||
printf(" d = (%d bytes) %f,\n",
|
printf(" d = (%d bytes) %f,\\n",
|
||||||
PQgetlength(res,i,d_fnum), *dval);
|
PQgetlength(res,i,d_fnum), *dval);
|
||||||
printf(" p = (%d bytes) %d points \tboundbox = (hi=%f/%f, lo = %f,%f)\n",
|
printf(" p = (%d bytes) %d points \\tboundbox = (hi=%f/%f, lo = %f,%f)\\n",
|
||||||
PQgetlength(res,i,d_fnum),
|
PQgetlength(res,i,d_fnum),
|
||||||
pval->npts,
|
pval->npts,
|
||||||
pval->boundbox.xh,
|
pval->boundbox.xh,
|
||||||
@ -960,3 +960,4 @@ main()
|
|||||||
|
|
||||||
}
|
}
|
||||||
.fi
|
.fi
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
.\" This is -*-nroff-*-
|
.\" This is -*-nroff-*-
|
||||||
.\" XXX standard disclaimer belongs here....
|
.\" XXX standard disclaimer belongs here....
|
||||||
.\" $Header: /cvsroot/pgsql/src/man/Attic/psql.1,v 1.1 1996/11/14 10:17:50 scrappy Exp $
|
.\" $Header: /cvsroot/pgsql/src/man/Attic/psql.1,v 1.2 1996/11/15 17:55:31 momjian Exp $
|
||||||
.TH PSQL UNIX 1/20/96 Postgres95 Postgres95
|
.TH PSQL UNIX 1/20/96 Postgres95 Postgres95
|
||||||
.SH NAME
|
.SH NAME
|
||||||
psql \(em run the interactive query front-end
|
psql \(em run the interactive query front-end
|
||||||
@ -343,7 +343,8 @@ When executed with the
|
|||||||
.BR "-c"
|
.BR "-c"
|
||||||
option,
|
option,
|
||||||
.IR psql
|
.IR psql
|
||||||
returns 0 to the shell on successful query completion, 1 otherwise.
|
returns 0 to the shell on successful query completion, 1 for errors,
|
||||||
|
2 for abrupt disconnection from the backend.
|
||||||
.IR psql
|
.IR psql
|
||||||
will also return 1 if the connection to a database could not be made for
|
will also return 1 if the connection to a database could not be made for
|
||||||
any reason.
|
any reason.
|
||||||
@ -352,8 +353,3 @@ introduction(libpq),
|
|||||||
monitor(1)
|
monitor(1)
|
||||||
postgres(1),
|
postgres(1),
|
||||||
postmaster(1).
|
postmaster(1).
|
||||||
.SH BUGS
|
|
||||||
If multiple queries are sent to the backend at once without semicolon
|
|
||||||
termination after each query, psql gets confused about the query
|
|
||||||
results. The queries will still be processed correctly by the backend.
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user