Modify find_inheritance_children() and find_all_inheritors() to add the
commitfe0b9be3d9faeab3b90075c3f91f8842fec1f7f2
authortgl <tgl>
Tue, 12 May 2009 03:11:02 +0000 (12 03:11 +0000)
committertgl <tgl>
Tue, 12 May 2009 03:11:02 +0000 (12 03:11 +0000)
tree3063ebedaad40efb64df3dd401e33e68403335f6
parent5b001cdf88f0c8a4093086ee65de07246503842b
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]