pg_get_constraintdef failing with cache lookup error
Hi all,
pg_get_constraintdef() fails rather easily:
=# select pg_get_constraintdef(1);
ERROR: cache lookup failed for constraint 1
STATEMENT: select pg_get_constraintdef(1);
ERROR: XX000: cache lookup failed for constraint 1
LOCATION: pg_get_constraintdef_worker, ruleutils.c:1305
Now by looking at pg_get_constraintdef_worker()@ruleutils.c it is
commented that this error should never happen:
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for constraint %u",
constraintId);
But it happens.
Am I missing something? Shouldn't this error be changed into something
more informative?
Regards,
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Michael Paquier <michael.paquier@gmail.com> writes:
pg_get_constraintdef() fails rather easily:
=# select pg_get_constraintdef(1);
ERROR: cache lookup failed for constraint 1
It's expected that the caller will supply a valid pg_constraint OID.
I don't think it's necessary to go out of our way to throw a friendlier
error message if the OID isn't found.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
On Mon, Apr 27, 2015 at 11:16 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Michael Paquier <michael.paquier@gmail.com> writes:
pg_get_constraintdef() fails rather easily:
=# select pg_get_constraintdef(1);
ERROR: cache lookup failed for constraint 1It's expected that the caller will supply a valid pg_constraint OID.
I don't think it's necessary to go out of our way to throw a friendlier
error message if the OID isn't found.
It's clearly at least a bug in the comment to complain that it can't
happen if in fact it can. But I would argue that we should never hit
an elog just because of bad user input.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
On Tue, Apr 28, 2015 at 3:15 AM, Robert Haas <robertmhaas@gmail.com> wrote:
On Mon, Apr 27, 2015 at 11:16 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Michael Paquier <michael.paquier@gmail.com> writes:
pg_get_constraintdef() fails rather easily:
=# select pg_get_constraintdef(1);
ERROR: cache lookup failed for constraint 1It's expected that the caller will supply a valid pg_constraint OID.
I don't think it's necessary to go out of our way to throw a friendlier
error message if the OID isn't found.It's clearly at least a bug in the comment to complain that it can't
happen if in fact it can. But I would argue that we should never hit
an elog just because of bad user input.
Fine for me to just remove the comment, constraintdef is the only *def
function that has such one.
--
Michael