postgresql/src/backend/access
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
..
common Enable CHECK constraints to be declared NOT VALID 2011-06-30 11:24:31 -04:00
gin Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00
gist Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00
hash Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00
heap Try to acquire relation locks in RangeVarGetRelid. 2011-07-08 22:19:30 -04:00
index Avoid having two copies of the HOT-chain search logic. 2011-06-27 10:27:17 -04:00
nbtree Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00
transam Introduce a pipe between postmaster and each backend, which can be used to 2011-07-08 18:44:07 +03:00
Makefile Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00