Skip to content

Commit 56aa84a

Browse files
committed
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.
1 parent 9356877 commit 56aa84a

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

doc/src/sgml/lobj.sgml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/lobj.sgml,v 1.37 2005/06/13 02:26:46 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/lobj.sgml,v 1.38 2006/03/02 21:49:09 tgl Exp $
33
-->
44

55
<chapter id="largeObjects">
@@ -527,7 +527,7 @@ overwrite(PGconn *conn, Oid lobjId, int start, int len)
527527
int nwritten;
528528
int i;
529529

530-
lobj_fd = lo_open(conn, lobjId, INV_READ);
530+
lobj_fd = lo_open(conn, lobjId, INV_WRITE);
531531
if (lobj_fd &lt; 0)
532532
{
533533
fprintf(stderr, &quot;can't open large object %d\n&quot;,
@@ -553,7 +553,8 @@ overwrite(PGconn *conn, Oid lobjId, int start, int len)
553553
}
554554

555555
/*
556-
* exportFile * export large object &quot;lobjOid&quot; to file &quot;out_filename&quot;
556+
* exportFile
557+
* export large object &quot;lobjOid&quot; to file &quot;out_filename&quot;
557558
*
558559
*/
559560
void
@@ -566,7 +567,7 @@ exportFile(PGconn *conn, Oid lobjId, char *filename)
566567
int fd;
567568

568569
/*
569-
* create an inversion &quot;object&quot;
570+
* open the large object
570571
*/
571572
lobj_fd = lo_open(conn, lobjId, INV_READ);
572573
if (lobj_fd &lt; 0)
@@ -586,7 +587,7 @@ exportFile(PGconn *conn, Oid lobjId, char *filename)
586587
}
587588

588589
/*
589-
* read in from the Unix file and write to the inversion file
590+
* read in from the inversion file and write to the Unix file
590591
*/
591592
while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) &gt; 0)
592593
{

src/test/examples/testlo.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/test/examples/testlo.c,v 1.25 2004/12/31 22:03:58 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/test/examples/testlo.c,v 1.26 2006/03/02 21:49:09 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -113,7 +113,7 @@ overwrite(PGconn *conn, Oid lobjId, int start, int len)
113113
int nwritten;
114114
int i;
115115

116-
lobj_fd = lo_open(conn, lobjId, INV_READ);
116+
lobj_fd = lo_open(conn, lobjId, INV_WRITE);
117117
if (lobj_fd < 0)
118118
fprintf(stderr, "can't open large object %u", lobjId);
119119

@@ -156,7 +156,7 @@ exportFile(PGconn *conn, Oid lobjId, char *filename)
156156
int fd;
157157

158158
/*
159-
* create an inversion "object"
159+
* open the large object
160160
*/
161161
lobj_fd = lo_open(conn, lobjId, INV_READ);
162162
if (lobj_fd < 0)
@@ -173,7 +173,7 @@ exportFile(PGconn *conn, Oid lobjId, char *filename)
173173
}
174174

175175
/*
176-
* read in from the Unix file and write to the inversion file
176+
* read in from the inversion file and write to the Unix file
177177
*/
178178
while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0)
179179
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy