1
1
.\" This is -*-nroff-*-
2
2
.\" XXX standard disclaimer belongs here....
3
- .\" $Header: /usr/local/devel/postgres/src/ref/RCS/large_objects.3pqsrc,v 1.12 1
4
- 993/08/23 09:03:16 aoki Exp $
3
+ .\" $Header: /cvsroot/pgsql/src/man/Attic/large_objects.3,v 1.2 1996/11/15 17:55:29 momjian Exp $
5
4
.TH "LARGE OBJECTS" INTRO 03/18/94 Postgres95 Postgres95
6
5
.SH DESCRIPTION
7
6
.PP
@@ -16,7 +15,6 @@ This section describes the implementation and the
16
15
programmatic and query language interfaces to Postgres large object data.
17
16
.PP
18
17
.SH "Historical Note"
19
- .SH "Historical Note"
20
18
.PP
21
19
Originally, postgres 4.2 supports three standard implementations of large
22
20
objects: as files external to Postgres, as Unix files managed by Postgres, and as
@@ -27,15 +25,13 @@ it provides stricter data integrity and time travel. For historical reasons,
27
25
they are called Inversion large objects. (We will use Inversion and large
28
26
objects interchangeably to mean the same thing in this section.)
29
27
.SH "Inversion Large Objects"
30
- .SH "Inversion Large Objects"
31
28
.PP
32
29
The Inversion large
33
30
object implementation breaks large objects up into \*( lq chunks\*( rq and
34
31
stores the chunks in tuples in the database. A B-tree index
35
32
guarantees fast searches for the correct chunk number when doing
36
33
random access reads and writes.
37
34
.SH "Large Object Interfaces"
38
- .SH "Large Object Interfaces"
39
35
.PP
40
36
The facilities Postgres provides to access large objects, both in
41
37
the backend as part of user-defined functions or the front end
@@ -77,7 +73,6 @@ Postgres provides a set of routines that
77
73
support opening, reading, writing, closing, and seeking on large
78
74
objects.
79
75
.SH "Creating a Large Object"
80
- .SH "Creating a Large Object"
81
76
.PP
82
77
The routine
83
78
.nf
@@ -114,7 +109,6 @@ The commands below create an (Inversion) large object:
114
109
inv_oid = lo_creat(INV_READ|INV_WRITE|INV_ARCHIVE);
115
110
.fi
116
111
.SH "Importing a Large Object"
117
- .SH "Importing a Large Object"
118
112
To import a UNIX file as a large object, call
119
113
.nf
120
114
Oid
125
119
argument specifies the UNIX pathname of the file to be imported as
126
120
a large object.
127
121
.SH "Exporting a Large Object"
128
- .SH "Exporting a Large Object"
129
122
To export a large object into UNIX file, call
130
123
.nf
131
124
int
138
131
.I filename
139
132
argument specifies the UNIX pathname of the file.
140
133
.SH "Opening an Existing Large Object"
141
- .SH "Opening an Existing Large Object"
142
134
.PP
143
135
To open an existing large object, call
144
136
.nf
165
157
.B lo_close .
166
158
.\" -----------
167
159
.SH "Writing Data to a Large Object"
168
- .SH "Writing Data to a Large Object"
169
160
.PP
170
161
The routine
171
162
.nf
@@ -187,7 +178,6 @@ The number of bytes actually written is returned.
187
178
In the event of an error,
188
179
the return value is negative.
189
180
.SH "Seeking on a Large Object"
190
- .SH "Seeking on a Large Object"
191
181
.PP
192
182
To change the current read or write location on a large object,
193
183
call
207
197
.SM SEEK_END.
208
198
.\" -----------
209
199
.SH "Closing a Large Object Descriptor"
210
- .SH "Closing a Large Object Descriptor"
211
200
.PP
212
201
A large object may be closed by calling
213
202
.nf
@@ -223,7 +212,6 @@ On success,
223
212
returns zero. On error, the return value is negative.
224
213
.PP
225
214
.SH "Built in registered functions"
226
- .SH "Built in registered functions"
227
215
.PP
228
216
There are two built-in registered functions,
229
217
.I lo_import
@@ -241,12 +229,11 @@ CREATE TABLE image (
241
229
INSERT INTO image (name, raster)
242
230
VALUES ('beautiful image', lo_import('/etc/motd'));
243
231
244
- SELECT lo_export(image.raster, " /tmp/motd" ) from image
232
+ SELECT lo_export(image.raster, ' /tmp/motd' ) from image
245
233
WHERE name = 'beautiful image';
246
234
.fi
247
235
.PP
248
236
.SH "Accessing Large Objects from LIBPQ"
249
- .SH "Accessing Large Objects from LIBPQ"
250
237
Below is a sample program which shows how the large object interface in
251
238
\*( LP can be used. Parts of the program are commented out but are left
252
239
in the source for the readers benefit. This program can be found in
@@ -262,7 +249,6 @@ and link with the
262
249
library.
263
250
.bp
264
251
.SH "Sample Program"
265
- .SH "Sample Program"
266
252
.nf
267
253
/*-------------------------------------------------------------------------
268
254
*
@@ -273,7 +259,7 @@ library.
273
259
*
274
260
*
275
261
* IDENTIFICATION
276
- * $Header: /cvsroot/pgsql/src/man/Attic/large_objects.3,v 1.1 1996/11/14 10: 17:24 scrappy Exp $
262
+ * $Header: /cvsroot/pgsql/src/man/Attic/large_objects.3,v 1.2 1996/11/15 17:55:29 momjian Exp $
277
263
*
278
264
*-------------------------------------------------------------------------
279
265
*/
@@ -301,7 +287,7 @@ Oid importFile(PGconn *conn, char *filename)
301
287
*/
302
288
fd = open(filename, O_RDONLY, 0666);
303
289
if (fd < 0) { /* error */
304
- fprintf(stderr, "can't open unix file\" %s\" \n", filename);
290
+ fprintf(stderr, "can't open unix file\\ " %s\\"\ \n", filename);
305
291
}
306
292
307
293
/*
@@ -319,7 +305,7 @@ Oid importFile(PGconn *conn, char *filename)
319
305
while ((nbytes = read(fd, buf, BUFSIZE)) > 0) {
320
306
tmp = lo_write(conn, lobj_fd, buf, nbytes);
321
307
if (tmp < nbytes) {
322
- fprintf(stderr, "error while reading \" %s\"", filename);
308
+ fprintf(stderr, "error while reading \\ " %s\ \"", filename);
323
309
}
324
310
}
325
311
@@ -348,11 +334,11 @@ void pickout(PGconn *conn, Oid lobjId, int start, int len)
348
334
nread = 0;
349
335
while (len - nread > 0) {
350
336
nbytes = lo_read(conn, lobj_fd, buf, len - nread);
351
- buf[nbytes] = '\0 ';
337
+ buf[nbytes] = '\\ 0 ';
352
338
fprintf(stderr,">>> %s", buf);
353
339
nread += nbytes;
354
340
}
355
- fprintf(stderr,"\n " );
341
+ fprintf(stderr,"\\ n" );
356
342
lo_close(conn, lobj_fd);
357
343
}
358
344
@@ -375,14 +361,14 @@ void overwrite(PGconn *conn, Oid lobjId, int start, int len)
375
361
376
362
for (i=0;i<len;i++)
377
363
buf[i] = 'X';
378
- buf[i] = '\0 ';
364
+ buf[i] = '\\ 0 ';
379
365
380
366
nwritten = 0;
381
367
while (len - nwritten > 0) {
382
368
nbytes = lo_write(conn, lobj_fd, buf + nwritten, len - nwritten);
383
369
nwritten += nbytes;
384
370
}
385
- fprintf(stderr,"\n " );
371
+ fprintf(stderr,"\\ n" );
386
372
lo_close(conn, lobj_fd);
387
373
}
388
374
@@ -413,7 +399,7 @@ void exportFile(PGconn *conn, Oid lobjId, char *filename)
413
399
*/
414
400
fd = open(filename, O_CREAT|O_WRONLY, 0666);
415
401
if (fd < 0) { /* error */
416
- fprintf(stderr, "can't open unix file\" %s\"",
402
+ fprintf(stderr, "can't open unix file\\ " %s\ \"",
417
403
filename);
418
404
}
419
405
@@ -423,7 +409,7 @@ void exportFile(PGconn *conn, Oid lobjId, char *filename)
423
409
while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0) {
424
410
tmp = write(fd, buf, nbytes);
425
411
if (tmp < nbytes) {
426
- fprintf(stderr,"error while writing \" %s\"",
412
+ fprintf(stderr,"error while writing \\ " %s\ \"",
427
413
filename);
428
414
}
429
415
}
@@ -451,7 +437,7 @@ main(int argc, char **argv)
451
437
PGresult *res;
452
438
453
439
if (argc != 4) {
454
- fprintf(stderr, "Usage: %s database_name in_filename out_filename\n " ,
440
+ fprintf(stderr, "Usage: %s database_name in_filename out_filename\\ n" ,
455
441
argv[0]);
456
442
exit(1);
457
443
}
@@ -467,27 +453,27 @@ main(int argc, char **argv)
467
453
468
454
/* check to see that the backend connection was successfully made */
469
455
if (PQstatus(conn) == CONNECTION_BAD) {
470
- fprintf(stderr,"Connection to database '%s' failed.\n " , database);
456
+ fprintf(stderr,"Connection to database '%s' failed.\\ n" , database);
471
457
fprintf(stderr,"%s",PQerrorMessage(conn));
472
458
exit_nicely(conn);
473
459
}
474
460
475
461
res = PQexec(conn, "begin");
476
462
PQclear(res);
477
- printf("importing file \" %s\" ...\n", in_filename);
463
+ printf("importing file \\ " %s\\ " ...\ \n", in_filename);
478
464
/* lobjOid = importFile(conn, in_filename); */
479
465
lobjOid = lo_import(conn, in_filename);
480
466
/*
481
- printf("\t as large object %d.\n " , lobjOid);
467
+ printf("\\ t as large object %d.\ \n " , lobjOid);
482
468
483
- printf("picking out bytes 1000-2000 of the large object\n " );
469
+ printf("picking out bytes 1000-2000 of the large object\\ n" );
484
470
pickout(conn, lobjOid, 1000, 1000);
485
471
486
- printf("overwriting bytes 1000-2000 of the large object with X's\n " );
472
+ printf("overwriting bytes 1000-2000 of the large object with X's\\ n" );
487
473
overwrite(conn, lobjOid, 1000, 1000);
488
474
*/
489
475
490
- printf("exporting large object to file \" %s\" ...\n", out_filename);
476
+ printf("exporting large object to file \\ " %s\\ " ...\ \n", out_filename);
491
477
/* exportFile(conn, lobjOid, out_filename); */
492
478
lo_export(conn, lobjOid,out_filename);
493
479
0 commit comments