mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Fix ancient error in large objects usage example: overwrite() subroutine
was opening with INV_READ flag and then writing. Prior to 8.1 the backend did not reject this, but now it does.
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$PostgreSQL: pgsql/doc/src/sgml/lobj.sgml,v 1.37 2005/06/13 02:26:46 tgl Exp $
|
$PostgreSQL: pgsql/doc/src/sgml/lobj.sgml,v 1.37.2.1 2006/03/02 21:49:19 tgl Exp $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<chapter id="largeObjects">
|
<chapter id="largeObjects">
|
||||||
@ -527,7 +527,7 @@ overwrite(PGconn *conn, Oid lobjId, int start, int len)
|
|||||||
int nwritten;
|
int nwritten;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
lobj_fd = lo_open(conn, lobjId, INV_READ);
|
lobj_fd = lo_open(conn, lobjId, INV_WRITE);
|
||||||
if (lobj_fd < 0)
|
if (lobj_fd < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "can't open large object %d\n",
|
fprintf(stderr, "can't open large object %d\n",
|
||||||
@ -553,7 +553,8 @@ overwrite(PGconn *conn, Oid lobjId, int start, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* exportFile * export large object "lobjOid" to file "out_filename"
|
* exportFile
|
||||||
|
* export large object "lobjOid" to file "out_filename"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@ -566,7 +567,7 @@ exportFile(PGconn *conn, Oid lobjId, char *filename)
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create an inversion "object"
|
* open the large object
|
||||||
*/
|
*/
|
||||||
lobj_fd = lo_open(conn, lobjId, INV_READ);
|
lobj_fd = lo_open(conn, lobjId, INV_READ);
|
||||||
if (lobj_fd < 0)
|
if (lobj_fd < 0)
|
||||||
@ -586,7 +587,7 @@ exportFile(PGconn *conn, Oid lobjId, char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* read in from the Unix file and write to the inversion file
|
* read in from the inversion file and write to the Unix file
|
||||||
*/
|
*/
|
||||||
while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0)
|
while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0)
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/test/examples/testlo.c,v 1.25 2004/12/31 22:03:58 pgsql Exp $
|
* $PostgreSQL: pgsql/src/test/examples/testlo.c,v 1.25.6.1 2006/03/02 21:49:19 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -113,7 +113,7 @@ overwrite(PGconn *conn, Oid lobjId, int start, int len)
|
|||||||
int nwritten;
|
int nwritten;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
lobj_fd = lo_open(conn, lobjId, INV_READ);
|
lobj_fd = lo_open(conn, lobjId, INV_WRITE);
|
||||||
if (lobj_fd < 0)
|
if (lobj_fd < 0)
|
||||||
fprintf(stderr, "can't open large object %u", lobjId);
|
fprintf(stderr, "can't open large object %u", lobjId);
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ exportFile(PGconn *conn, Oid lobjId, char *filename)
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create an inversion "object"
|
* open the large object
|
||||||
*/
|
*/
|
||||||
lobj_fd = lo_open(conn, lobjId, INV_READ);
|
lobj_fd = lo_open(conn, lobjId, INV_READ);
|
||||||
if (lobj_fd < 0)
|
if (lobj_fd < 0)
|
||||||
@ -173,7 +173,7 @@ exportFile(PGconn *conn, Oid lobjId, char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* read in from the Unix file and write to the inversion file
|
* read in from the inversion file and write to the Unix file
|
||||||
*/
|
*/
|
||||||
while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0)
|
while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user