lo_create(oid, bytea) breaks every extant release of libpq

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: lo_create(oid, bytea) breaks every extant release of libpq
Date: 2014-06-12 03:57:20
Message-ID: 5618.1402545440@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 function requires 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gurjeet Singh 2014-06-12 04:01:16 Re: Proposing pg_hibernate
Previous Message Amit Kapila 2014-06-12 03:36:51 Re: postgresql.auto.conf read from wrong directory