Re: What is lo_insert?

Lists: pgsql-hackers
From: Bruce Momjian <bruce(at)momjian(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: What is lo_insert?
Date: 2011-01-05 17:21:58
Message-ID: 201101051721.p05HLwf14279@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: What is lo_insert?
Date: 2011-01-06 02:20:34
Message-ID: AANLkTik0YcgjvHPm3eoi7Uax3CoO9h3t4uEOc+5yskaY@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jan 5, 2011 at 12:21 PM, Bruce Momjian <bruce(at)momjian(dot)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


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: What is lo_insert?
Date: 2011-01-06 02:32:40
Message-ID: 201101060232.p062Weq04289@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas wrote:
> On Wed, Jan 5, 2011 at 12:21 PM, Bruce Momjian <bruce(at)momjian(dot)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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/rtmp/diff text/x-diff 977 bytes