postgresql/src/backend/commands
Robert Haas 4240e429d0 Try to acquire relation locks in RangeVarGetRelid.
In the previous coding, we would look up a relation in RangeVarGetRelid,
lock the resulting OID, and then AcceptInvalidationMessages().  While
this was sufficient to ensure that we noticed any changes to the
relation definition before building the relcache entry, it didn't
handle the possibility that the name we looked up no longer referenced
the same OID.  This was particularly problematic in the case where a
table had been dropped and recreated: we'd latch on to the entry for
the old relation and fail later on.  Now, we acquire the relation lock
inside RangeVarGetRelid, and retry the name lookup if we notice that
invalidation messages have been processed meanwhile.  Many operations
that would previously have failed with an error in the presence of
concurrent DDL will now succeed.

There is a good deal of work remaining to be done here: many callers
of RangeVarGetRelid still pass NoLock for one reason or another.  In
addition, nothing in this patch guards against the possibility that
the meaning of an unqualified name might change due to the creation
of a relation in a schema earlier in the user's search path than the
one where it was previously found.  Furthermore, there's nothing at
all here to guard against similar race conditions for non-relations.
For all that, it's a start.

Noah Misch and Robert Haas
2011-07-08 22:19:30 -04:00
..
aggregatecmds.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
alter.c Try to acquire relation locks in RangeVarGetRelid. 2011-07-08 22:19:30 -04:00
analyze.c Fix thinko in previous patch to always update pg_class.reltuples/relpages. 2011-06-19 14:00:48 -04:00
async.c Preserve caller's memory context in ProcessCompletedNotifies(). 2011-05-27 12:10:32 -04:00
cluster.c Remove extra copying of TupleDescs for heap_create_with_catalog 2011-06-20 10:50:23 -04:00
collationcmds.c Remove rel.h from objectaddress.h; only relcache.h is necessary. 2011-06-28 17:08:29 -04:00
comment.c Remove rel.h from objectaddress.h; only relcache.h is necessary. 2011-06-28 17:08:29 -04:00
constraint.c Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00
conversioncmds.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
copy.c Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00
dbcommands.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
define.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
discard.c Refactor the executor's API to support data-modifying CTEs better. 2011-02-27 13:44:12 -05:00
explain.c Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00
extension.c Fix another oversight in logging of changes in postgresql.conf settings. 2011-07-08 17:02:58 -04:00
foreigncmds.c Call FDW validator functions even when the options list is empty. 2011-07-05 18:21:12 -04:00
functioncmds.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
indexcmds.c Try to acquire relation locks in RangeVarGetRelid. 2011-07-08 22:19:30 -04:00
lockcmds.c Try to acquire relation locks in RangeVarGetRelid. 2011-07-08 22:19:30 -04:00
Makefile DDL support for collations 2011-02-12 15:55:18 +02:00
opclasscmds.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
operatorcmds.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
portalcmds.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
prepare.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
proclang.c Core support for "extensions", which are packages of SQL objects. 2011-02-08 16:13:22 -05:00
schemacmds.c Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00
seclabel.c Remove rel.h from objectaddress.h; only relcache.h is necessary. 2011-06-28 17:08:29 -04:00
sequence.c Try to acquire relation locks in RangeVarGetRelid. 2011-07-08 22:19:30 -04:00
tablecmds.c Try to acquire relation locks in RangeVarGetRelid. 2011-07-08 22:19:30 -04:00
tablespace.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
trigger.c Try to acquire relation locks in RangeVarGetRelid. 2011-07-08 22:19:30 -04:00
tsearchcmds.c Pgindent run before 9.1 beta2. 2011-06-09 14:32:50 -04:00
typecmds.c Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00
user.c Add postmaster/postgres undocumented -b option for binary upgrades. 2011-04-25 12:00:21 -04:00
vacuum.c Try to acquire relation locks in RangeVarGetRelid. 2011-07-08 22:19:30 -04:00
vacuumlazy.c Make the visibility map crash-safe. 2011-06-21 23:04:40 -04:00
variable.c Pgindent run before 9.1 beta2. 2011-06-09 14:32:50 -04:00
view.c Fix bugs in relpersistence handling during table creation. 2011-07-03 17:34:47 -04:00