postgresql/src/include
Robert Haas 1575fbcb79 Prevent adding relations to a concurrently dropped schema.
In the previous coding, it was possible for a relation to be created
via CREATE TABLE, CREATE VIEW, CREATE SEQUENCE, CREATE FOREIGN TABLE,
etc.  in a schema while that schema was meanwhile being concurrently
dropped.  This led to a pg_class entry with an invalid relnamespace
value.  The same problem could occur if a relation was moved using
ALTER .. SET SCHEMA while the target schema was being concurrently
dropped.  This patch prevents both of those scenarios by locking the
schema to which the relation is being added using AccessShareLock,
which conflicts with the AccessExclusiveLock taken by DROP.

As a desirable side effect, this also prevents the use of CREATE OR
REPLACE VIEW to queue for an AccessExclusiveLock on a relation on which
you have no rights: that will now fail immediately with a permissions
error, before trying to obtain a lock.

We need similar protection for all other object types, but as everything
other than relations uses a slightly different set of code paths, I'm
leaving that for a separate commit.

Original complaint (as far as I could find) about CREATE by Nikhil
Sontakke; risk for ALTER .. SET SCHEMA pointed out by Tom Lane;
further details by Dan Farina; patch by me; review by Hitoshi Harada.
2012-01-16 09:49:34 -05:00
..
access Remove useless 'needlock' argument from GetXLogInsertRecPtr. It was always 2012-01-11 11:01:47 +02:00
bootstrap Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
catalog Prevent adding relations to a concurrently dropped schema. 2012-01-16 09:49:34 -05:00
commands Improve behavior of concurrent ALTER TABLE, and do some refactoring. 2012-01-06 22:42:26 -05:00
datatype Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
executor Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
foreign Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
lib Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
libpq Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
mb Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
nodes Rename the internal structures of the CREATE TABLE (LIKE ...) facility 2012-01-07 23:02:33 +02:00
optimizer Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
parser Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
port Support for building with MS Visual Studio 2010. 2012-01-03 08:44:26 -05:00
portability Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
postmaster Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
regex Teach regular expression operators to honor collations. 2011-04-10 18:03:09 -04:00
replication Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
rewrite Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
snowball Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
storage Use __sync_lock_test_and_set() for spinlocks on ARM, if available. 2012-01-07 15:38:52 -05:00
tcop Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
tsearch Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
utils Fix CLUSTER/VACUUM FULL for toast values owned by recently-updated rows. 2012-01-12 16:40:14 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
c.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
fmgr.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
funcapi.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
getaddrinfo.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
getopt_long.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
Makefile Fix server header file installation with vpath builds 2011-11-10 20:52:54 +02:00
miscadmin.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
pg_config.h.in Use __sync_lock_test_and_set() for spinlocks on ARM, if available. 2012-01-07 15:38:52 -05:00
pg_config.h.win32 Remove support for on_exit() 2011-12-27 20:57:59 +02:00
pg_config_manual.h Use LWSYNC in place of SYNC/ISYNC in PPC spinlocks, where possible. 2012-01-02 00:02:02 -05:00
pg_trace.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
pgstat.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
pgtime.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
port.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
postgres.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
postgres_ext.h Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
postgres_fe.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
rusagestub.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
windowapi.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00