From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Fix corner-case failures in has_foo_privilege() family of functi |
Date: | 2018-10-02 15:54:59 |
Message-ID: | E1g7N0l-0000Vw-Ds@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix corner-case failures in has_foo_privilege() family of functions.
The variants of these functions that take numeric inputs (OIDs or
column numbers) are supposed to return NULL rather than failing
on bad input; this rule reduces problems with snapshot skew when
queries apply the functions to all rows of a catalog.
has_column_privilege() had careless handling of the case where the
table OID didn't exist. You might get something like this:
select has_column_privilege(9999,'nosuchcol','select');
ERROR: column "nosuchcol" of relation "(null)" does not exist
or you might get a crash, depending on the platform's printf's response
to a null string pointer.
In addition, while applying the column-number variant to a dropped
column returned NULL as desired, applying the column-name variant
did not:
select has_column_privilege('mytable','........pg.dropped.2........','select');
ERROR: column "........pg.dropped.2........" of relation "mytable" does not exist
It seems better to make this case return NULL as well.
Also, the OID-accepting variants of has_foreign_data_wrapper_privilege,
has_server_privilege, and has_tablespace_privilege didn't follow the
principle of returning NULL for nonexistent OIDs. Superusers got TRUE,
everybody else got an error.
Per investigation of Jaime Casanova's report of a new crash in HEAD.
These behaviors have been like this for a long time, so back-patch to
all supported branches.
Patch by me; thanks to Stephen Frost for discussion and review
Discussion: https://postgr.es/m/CAJGNTeP=-6Gyqq5TN9OvYEydi7Fv1oGyYj650LGTnW44oAzYCg@mail.gmail.com
Branch
------
REL9_6_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/6d73983be61adde122b876308dbc6b6d52113419
Modified Files
--------------
src/backend/utils/adt/acl.c | 95 ++++++++++++++++++++++++++++----
src/test/regress/expected/privileges.out | 57 +++++++++++++++++++
src/test/regress/sql/privileges.sql | 17 ++++++
3 files changed, 159 insertions(+), 10 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-10-02 16:41:48 | pgsql: Set snprintf.c's maximum number of NL arguments to be 31. |
Previous Message | Tom Lane | 2018-10-02 14:15:28 | Re: pgsql: Improve autovacuum logging for aggressive and anti-wraparound ru |