From c50b7c09d852b6dc292bf24c72a0ffcac6cb2cab Mon Sep 17 00:00:00 2001 From: Noah Misch Date: Sun, 27 Oct 2013 22:42:46 -0400 Subject: Add large object functions catering to SQL callers. With these, one need no longer manipulate large object descriptors and extract numeric constants from header files in order to read and write large object contents from SQL. Pavel Stehule, reviewed by Rushabh Lathia. --- doc/src/sgml/func.sgml | 3 +- doc/src/sgml/lobj.sgml | 78 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 75 insertions(+), 6 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 2b91e6e86a0..a1d3aee8f57 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -3420,7 +3420,8 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three'); See also the aggregate function string_agg in - . + and the large object functions + in . diff --git a/doc/src/sgml/lobj.sgml b/doc/src/sgml/lobj.sgml index bb3e08f263c..05a93109911 100644 --- a/doc/src/sgml/lobj.sgml +++ b/doc/src/sgml/lobj.sgml @@ -526,11 +526,79 @@ int lo_unlink(PGconn *conn, Oid lobjId); Server-side Functions - There are server-side functions callable from SQL that correspond to - each of the client-side functions described above; indeed, for the - most part the client-side functions are simply interfaces to the - equivalent server-side functions. The ones that are actually useful - to call via SQL commands are + Server-side functions tailored for manipulating large objects from SQL are + listed in . + + + + SQL-oriented Large Object Functions + + + + Function + Return Type + Description + Example + Result + + + + + + + + lo_create + + lo_create(loid oid, string bytea) + + oid + + Create a large object and store data there, returning its OID. + Pass 0 to have the system choose an OID. + + lo_create(0, E'\\xffffff00') + 24528 + + + + + + lo_put + + lo_put(loid oid, offset bigint, str bytea) + + void + + Write data at the given offset. + + lo_put(24528, 1, E'\\xaa') + + + + + + + lo_get + + lo_get(loid oid , from bigint, for int) + + bytea + + Extract contents or a substring thereof. + + lo_get(24528, 0, 3) + \xffaaff + + + + +
+ + + There are additional server-side functions corresponding to each of the + client-side functions described earlier; indeed, for the most part the + client-side functions are simply interfaces to the equivalent server-side + functions. The ones just as convenient to call via SQL commands are lo_creatlo_creat, lo_createlo_create, lo_unlinklo_unlink, -- cgit v1.2.3