pgsql: Fix ExecCheckPermissions call in RI_Initial_Check

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix ExecCheckPermissions call in RI_Initial_Check
Date: 2023-05-04 17:58:26
Message-ID: E1pudDm-000Tck-BV@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix ExecCheckPermissions call in RI_Initial_Check

RI_Initial_Check was setting up a list of RTEPermissionInfo for
ExecCheckPermissions() wrong, and the problem is subtle enough that it
doesn't have any immediate effect in core code. However, if an
extension is using the ExecutorCheckPerms_hook, then it would get the
wrong parameters and perhaps arrive at a wrong conclusion, or outright
malfunction. Fix by constructing that list and the RTE list more
honestly.

We also add an assertion check to verify that these lists match. This
new assertion would have caught this bug.

Co-authored-by: Олег Целебровский (Oleg Tselebrovskii) <o(dot)tselebrovskiy(at)postgrespro(dot)ru>
Co-authored-by: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Reviewed-by: Amit Langote <amitlangote09(at)gmail(dot)com>
Discussion: https://postgr.es/m/3722b7a2cbe27a1796ee40824bd86dd1@postgrespro.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f75cec4fff877ef24e4932a628fc974f3116ed16

Modified Files
--------------
src/backend/executor/execMain.c | 22 +++++++++++++++++++
src/backend/utils/adt/ri_triggers.c | 42 +++++++++++++++++++++----------------
2 files changed, 46 insertions(+), 18 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2023-05-04 23:27:54 pgsql: Move return statements out of PG_TRY blocks.
Previous Message Tom Lane 2023-05-04 15:48:40 pgsql: In array_position()/array_positions(), beware of empty input arr