pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_get_constraintdef failing with cache lookup error
4+ messages / 3 participants
[nested] [flat]

* pg_get_constraintdef failing with cache lookup error
@ 2015-04-27 07:24 Michael Paquier <michael.paquier@gmail.com>
  2015-04-27 15:16 ` Re: pg_get_constraintdef failing with cache lookup error Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Michael Paquier @ 2015-04-27 07:24 UTC (permalink / raw)
  To: pgsql-bugs

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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_get_constraintdef failing with cache lookup error
  2015-04-27 07:24 pg_get_constraintdef failing with cache lookup error Michael Paquier <michael.paquier@gmail.com>
@ 2015-04-27 15:16 ` Tom Lane <tgl@sss.pgh.pa.us>
  2015-04-27 18:15   ` Re: pg_get_constraintdef failing with cache lookup error Robert Haas <robertmhaas@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2015-04-27 15:16 UTC (permalink / raw)
  To: Michael Paquier <michael.paquier@gmail.com>; +Cc: 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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_get_constraintdef failing with cache lookup error
  2015-04-27 07:24 pg_get_constraintdef failing with cache lookup error Michael Paquier <michael.paquier@gmail.com>
  2015-04-27 15:16 ` Re: pg_get_constraintdef failing with cache lookup error Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-04-27 18:15   ` Robert Haas <robertmhaas@gmail.com>
  2015-04-28 01:35     ` Re: pg_get_constraintdef failing with cache lookup error Michael Paquier <michael.paquier@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Robert Haas @ 2015-04-27 18:15 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Michael Paquier <michael.paquier@gmail.com>; 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 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.

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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_get_constraintdef failing with cache lookup error
  2015-04-27 07:24 pg_get_constraintdef failing with cache lookup error Michael Paquier <michael.paquier@gmail.com>
  2015-04-27 15:16 ` Re: pg_get_constraintdef failing with cache lookup error Tom Lane <tgl@sss.pgh.pa.us>
  2015-04-27 18:15   ` Re: pg_get_constraintdef failing with cache lookup error Robert Haas <robertmhaas@gmail.com>
@ 2015-04-28 01:35     ` Michael Paquier <michael.paquier@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Michael Paquier @ 2015-04-28 01:35 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; 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 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.
>
> 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

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

20150428_constraint_def_fix_comment.patch (application/x-patch, 521B) download diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 5ffb712..d959142 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -1332,7 +1332,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, UnregisterSnapshot(snapshot); - if (!HeapTupleIsValid(tup)) /* should not happen */ + if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for constraint %u", constraintId); conForm = (Form_pg_constraint) GETSTRUCT(tup);
^ permalink raw reply [nested|flat] 4+ messages in thread


end of thread, other threads:[~2015-04-28 01:35 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-04-27 07:24 pg_get_constraintdef failing with cache lookup error Michael Paquier <michael.paquier@gmail.com>
2015-04-27 15:16 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-04-27 18:15   ` Robert Haas <robertmhaas@gmail.com>
2015-04-28 01:35     ` Michael Paquier <michael.paquier@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox