Re: BUG #14220: pg_get_expr() with an incorrect relation id crashes the server - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: BUG #14220: pg_get_expr() with an incorrect relation id crashes the server
Date
Msg-id CAB7nPqRhsKK8BP1yo=s4ZKH42gzSwTfDWHVT2C_PbK6cqzTkJg@mail.gmail.com
Whole thread Raw
In response to Re: BUG #14220: pg_get_expr() with an incorrect relation id crashes the server  (Thomas Munro <thomas.munro@enterprisedb.com>)
Responses Re: BUG #14220: pg_get_expr() with an incorrect relation id crashes the server
List pgsql-bugs
On Fri, Jul 1, 2016 at 5:42 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> Maybe the attnum bounds check should be an error rather than an
> assertion, like in the attached.  Thought perhaps with a better
> message...

Quite interesting report. It looks right to me to do so with an elog(ERROR).

+        if (attnum > colinfo->num_cols)
+            elog(ERROR, "cannot decompile bogus attnum: %d", attnum);
Why not "incorrect number of arguments: specified %d but found %d" instead?

I have poked at this bug report yesterday and today, and found that it
is as well possible to hit the second assertion two lines below with a
dropped column. So I would like to propose the patch attached to
replace both assertions with an elog(ERROR). Test cases are included,
though I am not sure if they bring much value.
--
Michael

Attachment

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Postgres 9.5 Installation on OS X
Next
From: lishengxian123@163.com
Date:
Subject: BUG #14221: using postgresql 9.1.22 to 9.3.13 failed using pg_upgrade