mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
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.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/lockcmds.c,v 1.22 2009/05/12 00:56:05 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/lockcmds.c,v 1.23 2009/05/12 03:11:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
#include "access/heapam.h"
|
||||
#include "catalog/namespace.h"
|
||||
#include "catalog/pg_inherits.h"
|
||||
#include "catalog/pg_inherits_fn.h"
|
||||
#include "commands/lockcmds.h"
|
||||
#include "miscadmin.h"
|
||||
#include "parser/parse_clause.h"
|
||||
@ -48,8 +48,9 @@ LockTableCommand(LockStmt *lockstmt)
|
||||
|
||||
reloid = RangeVarGetRelid(relation, false);
|
||||
|
||||
/* XXX NoLock here is not really a good idea */
|
||||
if (recurse)
|
||||
children_and_self = find_all_inheritors(reloid);
|
||||
children_and_self = find_all_inheritors(reloid, NoLock);
|
||||
else
|
||||
children_and_self = list_make1_oid(reloid);
|
||||
|
||||
|
Reference in New Issue
Block a user