From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Defend against self-referential views in relation_is_updatable()
Date: Thu, 21 Nov 2019 21:22:11 +0000
Message-ID: <E1iXttz-0006NF-GW@gemulon.postgresql.org> (raw)
Defend against self-referential views in relation_is_updatable().
While a self-referential view doesn't actually work, it's possible
to create one, and it turns out that this breaks some of the
information_schema views. Those views call relation_is_updatable(),
which neglected to consider the hazards of being recursive. In
older PG versions you get a "stack depth limit exceeded" error,
but since v10 it'd recurse to the point of stack overrun and crash,
because commit a4c35ea1c took out the expression_returns_set() call
that was incidentally checking the stack depth.
Since this function is only used by information_schema views, it
seems like it'd be better to return "not updatable" than suffer
an error. Hence, add tracking of what views we're examining,
in just the same way that the nearby fireRIRrules() code detects
self-referential views. I added a check_stack_depth() call too,
just to be defensive.
Per private report from Manuel Rigger. Back-patch to all
supported versions.
Branch
------
REL_12_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/5186f7625e5fc0e3ae85419099a75d6aa93d8351
Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 21 +++++++++++++++++++++
src/backend/utils/adt/misc.c | 4 ++--
src/include/rewrite/rewriteHandler.h | 1 +
3 files changed, 24 insertions(+), 2 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Defend against self-referential views in relation_is_updatable()
In-Reply-To: <E1iXttz-0006NF-GW@gemulon.postgresql.org>
References: <E1iXttz-0006NF-GW@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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