https://github.com/postgres/postgres
Revision 01c7a87df98c2d012e321f38b070b99bddc54449 authored by Tom Lane on 02 October 2018, 15:54:13 UTC, committed by Tom Lane on 02 October 2018, 15:54:13 UTC
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
1 parent 4b2fb12
History
Tip revision: 01c7a87df98c2d012e321f38b070b99bddc54449 authored by Tom Lane on 02 October 2018, 15:54:13 UTC
Fix corner-case failures in has_foo_privilege() family of functions.
Tip revision: 01c7a87
File Mode Size
config
contrib
doc
src
.gitignore -rw-r--r-- 392 bytes
COPYRIGHT -rw-r--r-- 1.2 KB
GNUmakefile.in -rw-r--r-- 3.5 KB
HISTORY -rw-r--r-- 284 bytes
Makefile -rw-r--r-- 1.6 KB
README -rw-r--r-- 1.2 KB
README.git -rw-r--r-- 728 bytes
aclocal.m4 -rw-r--r-- 385 bytes
configure -rwxr-xr-x 892.4 KB
configure.in -rw-r--r-- 68.0 KB

README

back to top