From 461ef73f0977c95c9452680495bc161618db9227 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Sun, 7 Oct 2012 08:36:48 +0900 Subject: Add API for 64-bit large object access. Now users can access up to 4TB large objects (standard 8KB BLCKSZ case). For this purpose new libpq API lo_lseek64, lo_tell64 and lo_truncate64 are added. Also corresponding new backend functions lo_lseek64, lo_tell64 and lo_truncate64 are added. inv_api.c is changed to handle 64-bit offsets. Patch contributed by Nozomi Anzai (backend side) and Yugo Nagata (frontend side, docs, regression tests and example program). Reviewed by Kohei Kaigai. Committed by Tatsuo Ishii with minor editings. --- doc/src/sgml/lobj.sgml | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/lobj.sgml b/doc/src/sgml/lobj.sgml index 291409fde0b..66467e00f37 100644 --- a/doc/src/sgml/lobj.sgml +++ b/doc/src/sgml/lobj.sgml @@ -41,7 +41,7 @@ larger than a single database page into a secondary storage area per table. This makes the large object facility partially obsolete. One remaining advantage of the large object facility is that it allows values - up to 2 GB in size, whereas TOASTed fields can be at + up to 4 TB in size, whereas TOASTed fields can be at most 1 GB. Also, large objects can be randomly modified using a read/write API that is more efficient than performing such operations using TOAST. @@ -237,7 +237,9 @@ int lo_open(PGconn *conn, Oid lobjId, int mode); lo_open returns a (non-negative) large object descriptor for later use in lo_read, lo_write, lo_lseek, - lo_tell, and lo_close. + lo_lseek64, lo_tell, + lo_tell64, lo_truncate, + lo_truncate64, and lo_close. The descriptor is only valid for the duration of the current transaction. On failure, -1 is returned. @@ -312,6 +314,7 @@ int lo_read(PGconn *conn, int fd, char *buf, size_t len); large object descriptor, call int lo_lseek(PGconn *conn, int fd, int offset, int whence); +pg_int64 lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence); lo_lseek This function moves the current location pointer for the large object descriptor identified by @@ -321,7 +324,16 @@ int lo_lseek(PGconn *conn, int fd, int offset, int whence); SEEK_CUR (seek from current position), and SEEK_END (seek from object end). The return value is the new location pointer, or -1 on error. + lo_lseek64 lo_lseek64 + is a function for large objects larger than 2GB. pg_int64 + is defined as 8-byte integer type. + + lo_lseek64 is new as of PostgreSQL + 9.3; if this function is run against an older server version, it will + fail and return a negative value. + + @@ -332,9 +344,17 @@ int lo_lseek(PGconn *conn, int fd, int offset, int whence); call int lo_tell(PGconn *conn, int fd); +pg_int64 lo_tell64(PGconn *conn, int fd); lo_tell If there is an error, the return value is negative. + lo_tell64 lo_tell64 is + a function for large objects larger than 2GB. + + + lo_tell64 is new as of PostgreSQL + 9.3; if this function is run against an older server version, it will + fail and return a negative value. @@ -345,6 +365,7 @@ int lo_tell(PGconn *conn, int fd); To truncate a large object to a given length, call int lo_truncate(PGcon *conn, int fd, size_t len); +int lo_truncate64(PGcon *conn, int fd, pg_int64 len); lo_truncate truncates the large object descriptor fd to length len. The @@ -352,6 +373,8 @@ int lo_truncate(PGcon *conn, int fd, size_t len); previous lo_open. If len is greater than the current large object length, the large object is extended with null bytes ('\0'). + lo_truncate64 lo_truncate64 + is a function for large objects larger than 2GB. @@ -359,7 +382,7 @@ int lo_truncate(PGcon *conn, int fd, size_t len); - On success lo_truncate returns + On success lo_truncate and lo_truncate64 returns zero. On error, the return value is negative. @@ -368,6 +391,11 @@ int lo_truncate(PGcon *conn, int fd, size_t len); 8.3; if this function is run against an older server version, it will fail and return a negative value. + + lo_truncate64 is new as of PostgreSQL + 9.3; if this function is run against an older server version, it will + fail and return a negative value. + -- cgit v1.2.3