Modify find_inheritance_children() and find_all_inheritors() to add the
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 12 May 2009 03:11:02 +0000 (03:11 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 12 May 2009 03:11:02 +0000 (03:11 +0000)
commit10ec771ae7d437e6cee38ea71637f623bff2baf5
tree9df16389b9ac533b39b8f326dae2f5239972a7b1
parent3d8d53d227d5bff682c39c31fb4cc7bd6f02b40e
Modify find_inheritance_children() and find_all_inheritors() to add the
ability to lock relations as they scan pg_inherits, and to ignore any
relations that have disappeared by the time we get lock on them.  This
makes uses of these functions safe against concurrent DROP operations
on child tables: we will effectively ignore any just-dropped child,
rather than possibly throwing an error as in recent bug report from
Thomas Johansson (and similar past complaints).  The behavior should
not change otherwise, since the code was acquiring those same locks
anyway, just a little bit later.

An exception is LockTableCommand(), which is still behaving unsafely;
but that seems to require some more discussion before we change it.
src/backend/catalog/pg_inherits.c
src/backend/commands/lockcmds.c
src/backend/commands/tablecmds.c
src/backend/optimizer/prep/prepunion.c
src/backend/parser/parse_coerce.c
src/include/catalog/pg_inherits.h
src/include/catalog/pg_inherits_fn.h [new file with mode: 0644]