postgresql/src/backend/commands
Tom Lane 19de0ab23c Fix inadequate locking during get_rel_oids().
get_rel_oids used to not take any relation locks at all, but that stopped
being a good idea with commit 3c3bb9933, which inserted a syscache lookup
into the function.  A concurrent DROP TABLE could now produce "cache lookup
failed", which we don't want to have happen in normal operation.  The best
solution seems to be to transiently take a lock on the relation named by
the RangeVar (which also makes the result of RangeVarGetRelid a lot less
spongy).  But we shouldn't hold the lock beyond this function, because we
don't want VACUUM to lock more than one table at a time.  (That would not
be a big problem right now, but it will become one after the pending
feature patch to allow multiple tables to be named in VACUUM.)

In passing, adjust vacuum_rel and analyze_rel to document that we don't
trust the passed RangeVar to be accurate, and allow the RangeVar to
possibly be NULL --- which it is anyway for a whole-database VACUUM,
though we accidentally didn't crash for that case.

The passed RangeVar is in fact inaccurate when dealing with a child
partition, as of v10, and it has been wrong for a whole long time in the
case of vacuum_rel() recursing to a TOAST table.  None of these things
present visible bugs up to now, because the passed RangeVar is in fact
only consulted for autovacuum logging, and in that particular context it's
always accurate because autovacuum doesn't let vacuum.c expand partitions
nor recurse to toast tables.  Still, this seems like trouble waiting to
happen, so let's nail the door at least partly shut.  (Further cleanup
is planned, in HEAD only, as part of the pending feature patch.)

Fix some sadly inaccurate/obsolete comments too.  Back-patch to v10.

Michael Paquier and Tom Lane

Discussion: https://postgr.es/m/25023.1506107590@sss.pgh.pa.us
2017-09-29 16:26:31 -04:00
..
aggregatecmds.c
alter.c
amcmds.c
analyze.c Fix inadequate locking during get_rel_oids(). 2017-09-29 16:26:31 -04:00
async.c
cluster.c Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n). 2017-08-20 11:19:07 -07:00
collationcmds.c Don't install ICU collation keyword variants 2017-08-21 19:21:07 -04:00
comment.c
constraint.c
conversioncmds.c
copy.c Fix saving and restoring umask 2017-09-22 17:10:36 -04:00
createas.c Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n). 2017-08-20 11:19:07 -07:00
dbcommands.c
define.c
discard.c
dropcmds.c
event_trigger.c
explain.c Make ExplainOpenGroup and ExplainCloseGroup public. 2017-09-18 16:01:16 -04:00
extension.c
foreigncmds.c
functioncmds.c
indexcmds.c Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n). 2017-08-20 11:19:07 -07:00
lockcmds.c
Makefile
matview.c Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n). 2017-08-20 11:19:07 -07:00
opclasscmds.c Introduce 64-bit hash functions with a 64-bit seed. 2017-08-31 22:21:21 -04:00
operatorcmds.c
policy.c
portalcmds.c Reduce excessive dereferencing of function pointers 2017-09-07 13:56:09 -04:00
prepare.c
proclang.c
publicationcmds.c Message style fixes 2017-09-11 11:21:27 -04:00
schemacmds.c
seclabel.c Reduce excessive dereferencing of function pointers 2017-09-07 13:56:09 -04:00
sequence.c For wal_consistency_checking, mask page checksum as well as page LSN. 2017-09-22 14:28:22 -04:00
statscmds.c Message style fixes 2017-09-11 11:21:27 -04:00
subscriptioncmds.c ... and the very same bug in publicationListToArray(). 2017-09-23 15:16:48 -04:00
tablecmds.c Fix inconsistent capitalization. 2017-09-14 11:11:12 -04:00
tablespace.c
trigger.c Fix possible dangling pointer dereference in trigger.c. 2017-09-17 14:50:01 -04:00
tsearchcmds.c
typecmds.c Revert to 9.6 treatment of ALTER TYPE enumtype ADD VALUE. 2017-09-27 16:14:43 -04:00
user.c
vacuum.c Fix inadequate locking during get_rel_oids(). 2017-09-29 16:26:31 -04:00
vacuumlazy.c Fix freezing of a dead HOT-updated tuple 2017-09-28 16:44:01 +02:00
variable.c
view.c Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n). 2017-08-20 11:19:07 -07:00