pgsql: Defend against self-referential views in relation_is_updatable()

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Defend against self-referential views in relation_is_updatable()
Дата
Msg-id E1iXttz-0006NI-H1@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/669138ebd1465944119340397bcf31bab3050404

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(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Remove configure --disable-float4-byval
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: pgsql: Make DROP DATABASE command generate less WAL records.