Database Reference
In-Depth Information
The lo_open function returns a large object descriptor to be used in lo_read , lo_
write , lo_lseek , lo_lseek64 , lo_tell , lo_tell64 , lo_truncate , lo_truncate64 ,
and lo_close .
The following example shows how lo_open is used:
lo_fd = lo_open(conn, lo_oid, INV_READ);
lo_write
The syntax for the lo_write function is as follows:
int lo_write(PGconn *conn, int fd, const char *buf, size_t len);
This function writes len bytes from buf (which must be at least of the size len ) to
the large object descriptor fd . The number of bytes actually written is returned and
always equal to len unless there is an error where the return value is i1-1 .
The following example shows how lo_write is used:
r = lo_write(conn, lo_fd, buf, n);
lo_read
The syntax for the lo_read function is as follows:
int lo_read(PGconn *conn, int fd, char *buf, size_t len);
Explanation is almost the same as lo_write with the difference of operation; here, it
reads up to len bytes from the large object descriptor fd into buf of the size len . The
fd argument should be returned by the previously mentioned lo_open function. The
number of bytes actually read is returned, and it will be less than len if the end of
the large object is reached irst. In the case of an error, the return value is -1 .
The following example shows how lo_read is used:
n = lo_read(conn, lo_fd, buf, 512);
Though similar in behavior to lo_lseek , lo_read can accept an offset larger than 2
GB and can deliver a result larger than 2 GB.
lo_close
You can close a large object descriptor by calling lo_close .
The syntax for the lo_close function is as follows:
int lo_close(PGconn *conn, int fd);
 
Search WWH ::




Custom Search