postgresql/src/backend
Michael Paquier f841ceb26d Improve TRUNCATE by avoiding early lock queue
A caller of TRUNCATE could previously queue for an access exclusive lock
on a relation it may not have permission to truncate, potentially
interfering with users authorized to work on it.  This can be very
intrusive depending on the lock attempted to be taken.  For example,
pg_authid could be blocked, preventing any authentication attempt to
happen on a PostgreSQL instance.

This commit fixes the case of TRUNCATE so as RangeVarGetRelidExtended is
used with a callback doing the necessary ACL checks at an earlier stage,
avoiding lock queuing issues, so as an immediate failure happens for
unprivileged users instead of waiting on a lock that would not be
taken.

This is rather similar to the type of work done in cbe24a6 for CLUSTER,
and the code of TRUNCATE is this time refactored so as there is no
user-facing changes.  As the commit for CLUSTER, no back-patch is done.

Reported-by: Lloyd Albin, Jeremy Schneider
Author: Michael Paquier
Reviewed by: Nathan Bossart, Kyotaro Horiguchi
Discussion: https://postgr.es/m/152512087100.19803.12733865831237526317@wrigleys.postgresql.org
Discussion: https://postgr.es/m/20180806165816.GA19883@paquier.xyz
2018-08-10 18:26:59 +02:00
..
access Fix typo in SP-GiST error message 2018-08-10 17:28:48 +03:00
bootstrap Use a ResourceOwner to track buffer pins in all cases. 2018-07-18 12:15:16 -04:00
catalog Add table relcache invalidation to index builds. 2018-08-03 15:11:31 -07:00
commands Improve TRUNCATE by avoiding early lock queue 2018-08-10 18:26:59 +02:00
executor Fix buffer usage stats for parallel nodes. 2018-08-03 11:02:02 +05:30
foreign Remove bogus "extern" annotations on function definitions. 2018-02-19 12:07:44 -05:00
jit LLVMJIT: Check for 'noinline' attribute in recursively inlined functions. 2018-07-25 16:23:59 -07:00
lib doc: Update redirecting links 2018-07-16 10:48:05 +02:00
libpq Remove support for tls-unique channel binding. 2018-08-05 13:44:21 +03:00
main Update copyright for 2018 2018-01-02 23:30:12 -05:00
nodes Fix run-time partition pruning for appends with multiple source rels. 2018-08-01 19:42:52 -04:00
optimizer Spell "partitionwise" consistently. 2018-08-09 10:43:18 +03:00
parser Fix INSERT ON CONFLICT UPDATE through a view that isn't just SELECT *. 2018-08-04 19:38:58 -04:00
partitioning Remove bogus Assert in make_partitionedrel_pruneinfo(). 2018-08-08 20:02:32 -04:00
po Translation updates 2018-06-25 12:37:18 +02:00
port Pad semaphores to avoid false sharing. 2018-07-25 11:00:29 +12:00
postmaster Don't run atexit callbacks in quickdie signal handlers. 2018-08-08 19:10:32 +03:00
regex Clean up warnings from -Wimplicit-fallthrough. 2018-05-01 19:35:08 -04:00
replication Don't run atexit callbacks in quickdie signal handlers. 2018-08-08 19:10:32 +03:00
rewrite Fix INSERT ON CONFLICT UPDATE through a view that isn't just SELECT *. 2018-08-04 19:38:58 -04:00
snowball Avoid unnecessary use of pg_strcasecmp for already-downcased identifiers. 2018-01-26 18:25:14 -05:00
statistics Fix bogus code for extracting extended-statistics data from syscache. 2018-05-02 12:23:00 -04:00
storage Fix inadequate buffer locking in FSM and VM page re-initialization. 2018-07-13 11:53:10 -04:00
tcop Don't run atexit callbacks in quickdie signal handlers. 2018-08-08 19:10:32 +03:00
tsearch Hand code string to integer conversion for performance. 2018-07-22 14:58:23 -07:00
utils Further fixes for quoted-list GUC values in pg_dump and ruleutils.c. 2018-07-31 13:00:14 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2018-06-25 12:37:18 +02:00