Home Explore Blog CI



postgresql

7th chunk of `doc/src/sgml/lobj.sgml`
4a558718a1e256b453583e188f77510b943842f7817c02c10000000100000fa0
 current
     read/write location is greater than 2GB.
</para>

<para>
     <function>lo_tell64</function> is new as of <productname>PostgreSQL</productname>
     9.3.  If this function is run against an older server version, it will
     fail and return -1.
</para>
</sect2>

<sect2 id="lo-truncate">
<title>Truncating a Large Object</title>

<para>
     <indexterm><primary>lo_truncate</primary></indexterm>
     To truncate a large object to a given length, call
<synopsis>
int lo_truncate(PGconn *conn, int fd, size_t len);
</synopsis>
     This function truncates the large object
     descriptor <parameter>fd</parameter> to length <parameter>len</parameter>.  The
     <parameter>fd</parameter> argument must have been returned by a
     previous <function>lo_open</function>.  If <parameter>len</parameter> is
     greater than the large object's current length, the large object
     is extended to the specified length with null bytes ('\0').
     On success, <function>lo_truncate</function> returns
     zero.  On error, the return value is -1.
</para>

<para>
     The read/write location associated with the descriptor
     <parameter>fd</parameter> is not changed.
</para>

<para>
     Although the <parameter>len</parameter> parameter is declared as
     <type>size_t</type>, <function>lo_truncate</function> will reject length
     values larger than <literal>INT_MAX</literal>.
</para>

<para>
     <indexterm><primary>lo_truncate64</primary></indexterm>
     When dealing with large objects that might exceed 2GB in size,
     instead use
<synopsis>
int lo_truncate64(PGconn *conn, int fd, int64_t len);
</synopsis>
     This function has the same
     behavior as <function>lo_truncate</function>, but it can accept a
     <parameter>len</parameter> value exceeding 2GB.
</para>

<para>
     <function>lo_truncate</function> is new as of <productname>PostgreSQL</productname>
     8.3; if this function is run against an older server version, it will
     fail and return -1.
</para>

<para>
     <function>lo_truncate64</function> is new as of <productname>PostgreSQL</productname>
     9.3; if this function is run against an older server version, it will
     fail and return -1.
</para>
</sect2>

<sect2 id="lo-close">
<title>Closing a Large Object Descriptor</title>

<para>
     <indexterm><primary>lo_close</primary></indexterm>
     A large object descriptor can be closed by calling
<synopsis>
int lo_close(PGconn *conn, int fd);
</synopsis>
     where <parameter>fd</parameter> is a
     large object descriptor returned by <function>lo_open</function>.
     On success, <function>lo_close</function> returns zero.  On
     error, the return value is -1.
</para>

<para>
     Any large  object  descriptors that remain open at the end of a
     transaction will be closed automatically.
</para>
</sect2>

   <sect2 id="lo-unlink">
    <title>Removing a Large Object</title>

    <para>
     <indexterm><primary>lo_unlink</primary></indexterm>
     To remove a large object from the database, call
<synopsis>
int lo_unlink(PGconn *conn, Oid lobjId);
</synopsis>
     The <parameter>lobjId</parameter> argument specifies the OID of the
     large object to remove.  Returns 1 if successful, -1 on failure.
    </para>
   </sect2>

</sect1>

<sect1 id="lo-funcs">
<title>Server-Side Functions</title>

  <para>
   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="1">
     <thead>
      <row>
       <entry role="func_table_entry"><para role="func_signature">
        Function
       </para>
       <para>
        Description
       </para>
       <para>
        Example(s)
       </para></entry>
      </row>
     </thead>

     <tbody>
      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <indexterm>
         <primary>lo_from_bytea</primary>
       

Title: PostgreSQL Large Object Functions
Summary
The provided section describes various PostgreSQL functions for manipulating large objects, including truncation, closing, and removing large objects, as well as server-side functions tailored for SQL manipulation, with details on function signatures, parameters, and return values, along with compatibility information for different PostgreSQL versions.