Re: BUG #14220: pg_get_expr() with an incorrect relation id crashes the server

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: christopher(dot)m(dot)hanks(at)gmail(dot)com
Cc: PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14220: pg_get_expr() with an incorrect relation id crashes the server
Date: 2016-06-30 20:42:26
Message-ID: CAEepm=1P-5cm858uxvXG7sPiO5Z7DUCy-iwujCLYerfC30WCZg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Jun 30, 2016 at 10:43 AM, <christopher(dot)m(dot)hanks(at)gmail(dot)com> wrote:
> The following bug has been logged on the website:
>
> Bug reference: 14220
> Logged by: Chris Hanks
> Email address: christopher(dot)m(dot)hanks(at)gmail(dot)com
> PostgreSQL version: 9.5.3
> Operating system: Linux Mint 17.2 64-bit
> Description:
>
> SELECT version():
> "PostgreSQL 9.5.3 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu
> 4.8.2-19ubuntu1) 4.8.2, 64-bit"
>
> Reproduction:
>
> CREATE TABLE "test_table" ("id" serial PRIMARY KEY, "column_1" int4 NOT
> NULL, "column_2" int4);
>
> CREATE INDEX "idx" ON "test_table" ("column_1") WHERE ("column_2" = 4);
>
> SELECT pg_get_expr(i.indpred, i.indexrelid) FROM pg_index i;
>
> I realize that the query is incorrect, in order to retrieve the filter
> expression as SQL I need to call pg_get_expr(i.indpred, i.indrelid). But it
> seems like it should raise an error, rather than causing the server to
> crash.

Maybe the attnum bounds check should be an error rather than an
assertion, like in the attached. Thought perhaps with a better
message...

--
Thomas Munro
http://www.enterprisedb.com

Attachment Content-Type Size
reject-bogus-attnum.patch application/octet-stream 591 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Phil McGuinness 2016-06-30 21:45:24 Re: PostGres 9.5 [ and earlier ] "SET SEARCH_PATH TO "+ cSchema + ";"
Previous Message Andres Freund 2016-06-30 17:00:19 Re: BUG #14208: Inconsistent code modification - 3