*** pgsql/src/backend/commands/dbcommands.c 2009/11/12 02:46:16 1.228 --- pgsql/src/backend/commands/dbcommands.c 2009/12/19 01:32:34 1.229 *************** *** 13,19 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.227 2009/10/07 22:14:18 alvherre Exp $ * *------------------------------------------------------------------------- */ --- 13,19 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.228 2009/11/12 02:46:16 tgl Exp $ * *------------------------------------------------------------------------- */ *************** *** 26,31 **** --- 26,32 ---- #include "access/genam.h" #include "access/heapam.h" + #include "access/transam.h" #include "access/xact.h" #include "access/xlogutils.h" #include "catalog/catalog.h" *************** *** 48,53 **** --- 49,55 ---- #include "storage/ipc.h" #include "storage/procarray.h" #include "storage/smgr.h" + #include "storage/standby.h" #include "utils/acl.h" #include "utils/builtins.h" #include "utils/fmgroids.h" *************** dbase_redo(XLogRecPtr lsn, XLogRecord *r *** 1941,1946 **** --- 1943,1968 ---- dst_path = GetDatabasePath(xlrec->db_id, xlrec->tablespace_id); + if (InHotStandby) + { + VirtualTransactionId *database_users; + + /* + * Find all users connected to this database and ask them + * politely to immediately kill their sessions before processing + * the drop database record, after the usual grace period. + * We don't wait for commit because drop database is + * non-transactional. + */ + database_users = GetConflictingVirtualXIDs(InvalidTransactionId, + xlrec->db_id, + false); + + ResolveRecoveryConflictWithVirtualXIDs(database_users, + "drop database", + CONFLICT_MODE_FATAL); + } + /* Drop pages for this database that are in the shared buffer cache */ DropDatabaseBuffers(xlrec->db_id);