diff options
author | Noah Misch <noah@leadboat.com> | 2013-10-27 22:42:46 -0400 |
---|---|---|
committer | Noah Misch <noah@leadboat.com> | 2013-10-27 22:56:54 -0400 |
commit | c50b7c09d852b6dc292bf24c72a0ffcac6cb2cab (patch) | |
tree | ee9cc909b6b1c7040c4c81e427d25d215e1d900f /doc/src | |
parent | 9c339eb4f853e44c462f53587f69e4a11e89c09b (diff) | |
download | postgresql-c50b7c09d852b6dc292bf24c72a0ffcac6cb2cab.tar.gz postgresql-c50b7c09d852b6dc292bf24c72a0ffcac6cb2cab.zip |
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.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/func.sgml | 3 | ||||
-rw-r--r-- | doc/src/sgml/lobj.sgml | 78 |
2 files changed, 75 insertions, 6 deletions
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'); <para> See also the aggregate function <function>string_agg</function> in - <xref linkend="functions-aggregate">. + <xref linkend="functions-aggregate"> and the large object functions + in <xref linkend="lo-funcs">. </para> </sect1> 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); <title>Server-side Functions</title> <para> - 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 <xref linkend="lo-funcs-table">. + </para> + + <table id="lo-funcs-table"> + <title>SQL-oriented Large Object Functions</title> + <tgroup cols="5"> + <thead> + <row> + <entry>Function</entry> + <entry>Return Type</entry> + <entry>Description</entry> + <entry>Example</entry> + <entry>Result</entry> + </row> + </thead> + + <tbody> + <row> + <entry> + <indexterm> + <primary>lo_create</primary> + </indexterm> + <literal><function>lo_create(<parameter>loid</parameter> <type>oid</type>, <parameter>string</parameter> <type>bytea</type>)</function></literal> + </entry> + <entry><type>oid</type></entry> + <entry> + Create a large object and store data there, returning its OID. + Pass <literal>0</> to have the system choose an OID. + </entry> + <entry><literal>lo_create(0, E'\\xffffff00')</literal></entry> + <entry><literal>24528</literal></entry> + </row> + + <row> + <entry> + <indexterm> + <primary>lo_put</primary> + </indexterm> + <literal><function>lo_put(<parameter>loid</parameter> <type>oid</type>, <parameter>offset</parameter> <type>bigint</type>, <parameter>str</parameter> <type>bytea</type>)</function></literal> + </entry> + <entry><type>void</type></entry> + <entry> + Write data at the given offset. + </entry> + <entry><literal>lo_put(24528, 1, E'\\xaa')</literal></entry> + <entry></entry> + </row> + + <row> + <entry> + <indexterm> + <primary>lo_get</primary> + </indexterm> + <literal><function>lo_get(<parameter>loid</parameter> <type>oid</type> <optional>, <parameter>from</parameter> <type>bigint</type>, <parameter>for</parameter> <type>int</type></optional>)</function></literal> + </entry> + <entry><type>bytea</type></entry> + <entry> + Extract contents or a substring thereof. + </entry> + <entry><literal>lo_get(24528, 0, 3)</literal></entry> + <entry><literal>\xffaaff</literal></entry> + </row> + + </tbody> + </tgroup> + </table> + + <para> + 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 <function>lo_creat</function><indexterm><primary>lo_creat</></>, <function>lo_create</function><indexterm><primary>lo_create</></>, <function>lo_unlink</function><indexterm><primary>lo_unlink</></>, |