Re: Getting ERROR: bogus varno: 2

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neel Patel <neel(dot)patel(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Getting ERROR: bogus varno: 2
Date: 2019-03-12 17:57:19
Message-ID: 10562.1552413439@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Neel Patel <neel(dot)patel(at)enterprisedb(dot)com> writes:
>> Is this error message expected or what should be the behaviour ?

> It's certainly a bug.

Oh, no, I take that back: it's not a bug, you're just abusing
pg_get_expr() to try to do something it can't do, which is make
sense of an expression involving more than one relation.
(OLD and NEW are different relations in a trigger WHEN clause.)

You can use pg_get_triggerdef() to decompile a trigger WHEN clause,
although that might do more than you want.

Not sure if there's any value in trying to make the failure
message more user-friendly. You can get weird errors by
misusing pg_get_expr() in other ways too, such as giving it
the wrong relation OID.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Paul Ramsey 2019-03-12 18:08:15 Re: Compressed TOAST Slicing
Previous Message Tom Lane 2019-03-12 17:43:07 Re: Getting ERROR: bogus varno: 2