Thread: What is lo_insert?

What is lo_insert?

From
Bruce Momjian
Date:
The psql manual page mentions lo_insert:
          LASTOID              The value of the last affected OID, as returned
-->            from an INSERT or lo_insert command. This variable              is only guaranteed to be valid until
afterthe              result of the next SQL command has been displayed.
 

Should that be lo_import?  I don't see lo_insert used anywhere.  And it
doesn't seem lo_import sets LASTOID.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +


Re: What is lo_insert?

From
Robert Haas
Date:
On Wed, Jan 5, 2011 at 12:21 PM, Bruce Momjian <bruce@momjian.us> wrote:
> The psql manual page mentions lo_insert:
>
>           LASTOID
>               The value of the last affected OID, as returned
> -->            from an INSERT or lo_insert command. This variable
>               is only guaranteed to be valid until after the
>               result of the next SQL command has been displayed.
>
> Should that be lo_import?  I don't see lo_insert used anywhere.  And it
> doesn't seem lo_import sets LASTOID.

I think it's supposed to be lo_import.  It sets LASTOID if you do this:

rhaas=# \lo_import '/etc/passwd'
lo_import 16414
rhaas=# select :LASTOID;?column?
----------   16414
(1 row)

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: What is lo_insert?

From
Bruce Momjian
Date:
Robert Haas wrote:
> On Wed, Jan 5, 2011 at 12:21 PM, Bruce Momjian <bruce@momjian.us> wrote:
> > The psql manual page mentions lo_insert:
> >
> > ? ? ? ? ? LASTOID
> > ? ? ? ? ? ? ? The value of the last affected OID, as returned
> > --> ? ? ? ? ? ?from an INSERT or lo_insert command. This variable
> > ? ? ? ? ? ? ? is only guaranteed to be valid until after the
> > ? ? ? ? ? ? ? result of the next SQL command has been displayed.
> >
> > Should that be lo_import? ?I don't see lo_insert used anywhere. ?And it
> > doesn't seem lo_import sets LASTOID.
>
> I think it's supposed to be lo_import.  It sets LASTOID if you do this:
>
> rhaas=# \lo_import '/etc/passwd'
> lo_import 16414
> rhaas=# select :LASTOID;
>  ?column?
> ----------
>     16414
> (1 row)

OK, but it does not set :LASTOID if you do this:

    SELECT lo_import('/etc/motd');

I have updated the patch to say '\lo_import' and backpatched to 9.0.X.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 0c658d1..5f61561 100644
*** /tmp/pgdiff.3068/TTCobb_psql-ref.sgml    Wed Jan  5 21:29:31 2011
--- doc/src/sgml/ref/psql-ref.sgml    Wed Jan  5 21:29:28 2011
*************** bar
*** 2679,2685 ****
          <listitem>
          <para>
          The value of the last affected OID, as returned from an
!         <command>INSERT</command> or <command>lo_insert</command>
          command. This variable is only guaranteed to be valid until
          after the result of the next <acronym>SQL</acronym> command has
          been displayed.
--- 2679,2685 ----
          <listitem>
          <para>
          The value of the last affected OID, as returned from an
!         <command>INSERT</command> or <command>\lo_import</command>
          command. This variable is only guaranteed to be valid until
          after the result of the next <acronym>SQL</acronym> command has
          been displayed.