lo_import() of an empty file

Поиск
Список
Период
Сортировка
Искать

lo_import() of an empty file

От:
Bruce Momjian <bruce@momjian.us>
Дата:
I have just discovered if you try to lo_import() an empty file, and oid
is returned, but nothing is added to pg_largeobject:

	$ > /rtmp/a
	$ psql test

	SELECT lo_import('/rtmp/a');
	 lo_import
	-----------
	     16385
	
	SELECT * from pg_largeobject;
	 loid | pageno | data
	------+--------+------

However, the oid is incremented for each call:

	SELECT lo_import('/rtmp/a');
	 lo_import
	-----------
	     16386
	
	SELECT lo_import('/rtmp/a');
	 lo_import
	-----------
	     16387
	
	SELECT lo_import('/rtmp/a');
	 lo_import
	-----------
	     16388

An lo_export() of a non-existant oid does create an empty file.  I guess
this is an optimization of allowing empty file imports to consume no
space in pg_largeobject, but it does seem odd.

I am asking hackers in case someone can see an error here, or something
that should be documented.

-- 
  Bruce Momjian          http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +

Re: lo_import() of an empty file

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian  writes:
> I have just discovered if you try to lo_import() an empty file, and oid
> is returned, but nothing is added to pg_largeobject:

Why would you expect there to be?  There's no data to store.

There should be an entry in pg_largeobject_metadata, though.

			regards, tom lane

Re: lo_import() of an empty file

От:
Bruce Momjian <bruce@momjian.us>
Дата:
On Fri, Mar 30, 2018 at 02:22:49PM -0400, Tom Lane wrote:
> Bruce Momjian  writes:
> > I have just discovered if you try to lo_import() an empty file, and oid
> > is returned, but nothing is added to pg_largeobject:
> 
> Why would you expect there to be?  There's no data to store.
> 
> There should be an entry in pg_largeobject_metadata, though.

Ah, yes, there is a row there.  Thanks.  No problem here.

-- 
  Bruce Momjian          http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +

FAQ