lo_import() of an empty file

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: lo_import() of an empty file
Date: 2018-03-30 18:13:41
Message-ID: 20180330181341.GQ8476@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 <bruce(at)momjian(dot)us> 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 +

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-03-30 18:18:46 Re: [HACKERS] AdvanceXLInsertBuffer vs. WAL segment compressibility
Previous Message Jerry Sievers 2018-03-30 17:45:11 Re: Speedup of relation deletes during recovery