lo_create(oid, bytea) breaks every extant release of libpq - Mailing list pgsql-hackers

From Tom Lane
Subject lo_create(oid, bytea) breaks every extant release of libpq
Date
Msg-id 5618.1402545440@sss.pgh.pa.us
Whole thread Raw
Responses Re: lo_create(oid, bytea) breaks every extant release of libpq  (Tatsuo Ishii <ishii@postgresql.org>)
Re: lo_create(oid, bytea) breaks every extant release of libpq  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
While investigating a different issue, I was astonished to find that
pg_restore in HEAD is incapable of restoring dumps containing large
objects: it fails with messages like

pg_restore: [archiver] could not create large object 100000: ERROR:  function call message contains 1 arguments but
functionrequires 2
 

After some investigation, I find that:

1. Commit c50b7c09d added a function lo_create(oid, bytea).

2. libpq's lo_initialize function, in fe-lobj.c, assumes that
the pg_catalog schema will contain *only one* function named
lo_create (and likewise for lo_open and a dozen other names).
With more than one lo_create function, it's luck of the draw
which one's OID ends up in the PGlobjfuncs struct.  If it's
the wrong one, subsequent attempts to use libpq's lo_create()
function fail as above.

While there's certainly a good argument to be made for making
lo_initialize do that query differently, there's no way that we
can fix every copy of libpq that's in the field.  I think we have to
consider that "there can be only one lo_create" is effectively part of
the protocol spec for the foreseeable future.  (It'd be easy enough
to add a check in the opr_sanity regression test to catch violations
of this rule.)

It's also extremely unfortunate that the regression tests don't
create (or at least don't leave behind) any large objects, as we
might then have possibly caught this bug much earlier.

Meanwhile, we have to either revert the addition of lo_create(oid,
bytea) altogether, or choose a different name for it.  Suggestions?
        regards, tom lane



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: postgresql.auto.conf read from wrong directory
Next
From: Gurjeet Singh
Date:
Subject: Re: Proposing pg_hibernate