I wrote: > Neel Patel <neel.pa...@enterprisedb.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