in built-in. fixed backslases in source for libpq.
.\" This is -*-nroff-*-
.\" 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
.SH "DESCRIPTION"
This section describes the data types, functions and operators
|/ square root
||/ cube root
: exponential function
- ; natural logarithm
+ ; natural logarithm (in psql, protect with parentheses)
point
!< A is left of B
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
-.\" $Header: /usr/local/devel/postgres/src/ref/RCS/large_objects.3pqsrc,v 1.12 1
-993/08/23 09:03:16 aoki Exp $
+.\" $Header: /cvsroot/pgsql/src/man/Attic/large_objects.3,v 1.2 1996/11/15 17:55:29 momjian Exp $
.TH "LARGE OBJECTS" INTRO 03/18/94 Postgres95 Postgres95
.SH DESCRIPTION
.PP
programmatic and query language interfaces to Postgres large object data.
.PP
.SH "Historical Note"
-.SH "Historical Note"
.PP
Originally, postgres 4.2 supports three standard implementations of large
objects: as files external to Postgres, as Unix files managed by Postgres, and as
they are called Inversion large objects. (We will use Inversion and large
objects interchangeably to mean the same thing in this section.)
.SH "Inversion Large Objects"
-.SH "Inversion Large Objects"
.PP
The Inversion large
object implementation breaks large objects up into \*(lqchunks\*(rq and
guarantees fast searches for the correct chunk number when doing
random access reads and writes.
.SH "Large Object Interfaces"
-.SH "Large Object Interfaces"
.PP
The facilities Postgres provides to access large objects, both in
the backend as part of user-defined functions or the front end
support opening, reading, writing, closing, and seeking on large
objects.
.SH "Creating a Large Object"
-.SH "Creating a Large Object"
.PP
The routine
.nf
inv_oid = lo_creat(INV_READ|INV_WRITE|INV_ARCHIVE);
.fi
.SH "Importing a Large Object"
-.SH "Importing a Large Object"
To import a UNIX file as a large object, call
.nf
Oid
argument specifies the UNIX pathname of the file to be imported as
a large object.
.SH "Exporting a Large Object"
-.SH "Exporting a Large Object"
To export a large object into UNIX file, call
.nf
int
.I filename
argument specifies the UNIX pathname of the file.
.SH "Opening an Existing Large Object"
-.SH "Opening an Existing Large Object"
.PP
To open an existing large object, call
.nf
.B lo_close .
.\"-----------
.SH "Writing Data to a Large Object"
-.SH "Writing Data to a Large Object"
.PP
The routine
.nf
In the event of an error,
the return value is negative.
.SH "Seeking on a Large Object"
-.SH "Seeking on a Large Object"
.PP
To change the current read or write location on a large object,
call
.SM SEEK_END.
.\"-----------
.SH "Closing a Large Object Descriptor"
-.SH "Closing a Large Object Descriptor"
.PP
A large object may be closed by calling
.nf
returns zero. On error, the return value is negative.
.PP
.SH "Built in registered functions"
-.SH "Built in registered functions"
.PP
There are two built-in registered functions,
.I lo_import
INSERT INTO image (name, raster)
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';
.fi
.PP
.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
\*(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
library.
.bp
.SH "Sample Program"
-.SH "Sample Program"
.nf
/*-------------------------------------------------------------------------
*
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
*/
fd = open(filename, O_RDONLY, 0666);
if (fd < 0) { /* error */
- fprintf(stderr, "can't open unix file\"%s\"\n", filename);
+ fprintf(stderr, "can't open unix file\\"%s\\"\\n", filename);
}
/*
while ((nbytes = read(fd, buf, BUFSIZE)) > 0) {
tmp = lo_write(conn, lobj_fd, buf, nbytes);
if (tmp < nbytes) {
- fprintf(stderr, "error while reading \"%s\"", filename);
+ fprintf(stderr, "error while reading \\"%s\\"", filename);
}
}
nread = 0;
while (len - nread > 0) {
nbytes = lo_read(conn, lobj_fd, buf, len - nread);
- buf[nbytes] = '\0';
+ buf[nbytes] = '\\0';
fprintf(stderr,">>> %s", buf);
nread += nbytes;
}
- fprintf(stderr,"\n");
+ fprintf(stderr,"\\n");
lo_close(conn, lobj_fd);
}
for (i=0;i<len;i++)
buf[i] = 'X';
- buf[i] = '\0';
+ buf[i] = '\\0';
nwritten = 0;
while (len - nwritten > 0) {
nbytes = lo_write(conn, lobj_fd, buf + nwritten, len - nwritten);
nwritten += nbytes;
}
- fprintf(stderr,"\n");
+ fprintf(stderr,"\\n");
lo_close(conn, lobj_fd);
}
*/
fd = open(filename, O_CREAT|O_WRONLY, 0666);
if (fd < 0) { /* error */
- fprintf(stderr, "can't open unix file\"%s\"",
+ fprintf(stderr, "can't open unix file\\"%s\\"",
filename);
}
while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0) {
tmp = write(fd, buf, nbytes);
if (tmp < nbytes) {
- fprintf(stderr,"error while writing \"%s\"",
+ fprintf(stderr,"error while writing \\"%s\\"",
filename);
}
}
PGresult *res;
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]);
exit(1);
}
/* check to see that the backend connection was successfully made */
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));
exit_nicely(conn);
}
res = PQexec(conn, "begin");
PQclear(res);
- printf("importing file \"%s\" ...\n", in_filename);
+ printf("importing file \\"%s\\" ...\\n", in_filename);
/* lobjOid = importFile(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);
- 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);
*/
- 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); */
lo_export(conn, lobjOid,out_filename);
.\" This is -*-nroff-*-
.\" 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
.SH DESCRIPTION
Libpq is the programmer's interface to Postgres. Libpq is a set of
buffer is full but the terminating newline has not yet been read.
.IP
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
.I copy
command. Therefore, if the application ever expects to receive lines
/* check to see that the backend connection was successfully made */
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));
exit_nicely(conn);
}
/* start a transaction block */
res = PQexec(conn,"BEGIN");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr,"BEGIN command failed\n");
+ fprintf(stderr,"BEGIN command failed\\n");
PQclear(res);
exit_nicely(conn);
}
/* fetch instances from the pg_database, the system catalog of databases*/
res = PQexec(conn,"DECLARE mycursor CURSOR FOR select * from pg_database");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr,"DECLARE CURSOR command failed\n");
+ fprintf(stderr,"DECLARE CURSOR command failed\\n");
PQclear(res);
exit_nicely(conn);
}
res = PQexec(conn,"FETCH ALL in mycursor");
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);
exit_nicely(conn);
}
for (i=0; i < nFields; i++) {
printf("%-15s",PQfname(res,i));
}
- printf("\n\n");
+ printf("\\n\\n");
/* next, print out the instances */
for (i=0; i < PQntuples(res); i++) {
for (j=0 ; j < nFields; j++) {
printf("%-15s", PQgetvalue(res,i,j));
}
- printf("\n");
+ printf("\\n");
}
PQclear(res);
/* check to see that the backend connection was successfully made */
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));
exit_nicely(conn);
}
res = PQexec(conn, "LISTEN TBL2");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr,"LISTEN command failed\n");
+ fprintf(stderr,"LISTEN command failed\\n");
PQclear(res);
exit_nicely(conn);
}
/* async notification only come back as a result of a query*/
/* we can send empty queries */
res = PQexec(conn, " ");
-/* printf("res->status = %s\n", pgresStatus[PQresultStatus(res)]); */
+/* printf("res->status = %s\\n", pgresStatus[PQresultStatus(res)]); */
/* check for asynchronous returns */
notify = PQnotifies(conn);
if (notify) {
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);
free(notify);
break;
/* check to see that the backend connection was successfully made */
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));
exit_nicely(conn);
}
/* start a transaction block */
res = PQexec(conn,"BEGIN");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr,"BEGIN command failed\n");
+ fprintf(stderr,"BEGIN command failed\\n");
PQclear(res);
exit_nicely(conn);
}
/* fetch instances from the pg_database, the system catalog of databases*/
res = PQexec(conn,"DECLARE mycursor BINARY CURSOR FOR select * from test1");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr,"DECLARE CURSOR command failed\n");
+ fprintf(stderr,"DECLARE CURSOR command failed\\n");
PQclear(res);
exit_nicely(conn);
}
res = PQexec(conn,"FETCH ALL in mycursor");
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);
exit_nicely(conn);
}
p_fnum = PQfnumber(res,"p");
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, PQfsize(res,i));
}
pval = (POLYGON*) malloc(plen + VARHDRSZ);
pval->size = plen;
memmove((char*)&pval->npts, PQgetvalue(res,i,p_fnum), plen);
- printf("tuple %d: got\n", i);
- printf(" i = (%d bytes) %d,\n",
+ printf("tuple %d: got\\n", i);
+ printf(" i = (%d bytes) %d,\\n",
PQgetlength(res,i,i_fnum), *ival);
- printf(" d = (%d bytes) %f,\n",
+ printf(" d = (%d bytes) %f,\\n",
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),
pval->npts,
pval->boundbox.xh,
}
.fi
+
.\" This is -*-nroff-*-
.\" 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
.SH NAME
psql \(em run the interactive query front-end
.BR "-c"
option,
.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
will also return 1 if the connection to a database could not be made for
any reason.
monitor(1)
postgres(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.
-