pgsql: Fix "unexpected relkind" error when denying permissions on toast

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix "unexpected relkind" error when denying permissions on toast
Date: 2019-11-05 18:40:53
Message-ID: [email protected]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix "unexpected relkind" error when denying permissions on toast tables.

get_relkind_objtype, and hence get_object_type, failed when applied to a
toast table. This is not a good thing, because it prevents reporting of
perfectly legitimate permissions errors. (At present, these functions
are in fact *only* used to determine the ObjectType argument for
acl_error() calls.) It seems best to have them fall back to returning
OBJECT_TABLE in every case where they can't determine an object type
for a pg_class entry, so do that.

In passing, make some edits to alter.c to make it more obvious that
those calls of get_object_type() are used only for error reporting.
This might save a few cycles in the non-error code path, too.

Back-patch to v11 where this issue originated.

John Hsu, Michael Paquier, Tom Lane

Discussion: https://postgr.es/m/[email protected]

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2bfe015b5626be7f9837b0d1b31438fa896da427

Modified Files
--------------
src/backend/catalog/objectaddress.c | 28 +++++++++++++++++++++-------
src/backend/commands/alter.c | 12 +++++-------
src/test/regress/expected/create_index.out | 9 +++++++++
src/test/regress/sql/create_index.sql | 7 +++++++
4 files changed, 42 insertions(+), 14 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2019-11-05 19:29:36 pgsql: Avoid logging complaints about abandoned connections when using
Previous Message Tom Lane 2019-11-05 16:42:38 pgsql: Generate EquivalenceClass members for partitionwise child join r