From eb63cc3da82cec03c54a9534a6c91d287078abd1 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Tue, 16 Jan 2007 13:28:57 +0000 Subject: Arrange for autovacuum to be killed when another operation wants to be alone accessing it, like DROP DATABASE. This allows the regression tests to pass with autovacuum enabled, which open the gates for finally enabling autovacuum by default. --- src/backend/commands/dbcommands.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/backend/commands/dbcommands.c') diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index ef0aff99ac8..18340481d23 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.188 2007/01/05 22:19:25 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.189 2007/01/16 13:28:56 alvherre Exp $ * *------------------------------------------------------------------------- */ @@ -250,11 +250,11 @@ createdb(const CreatedbStmt *stmt) * (exception is to allow CREATE DB while connected to template1). * Otherwise we might copy inconsistent data. */ - if (DatabaseHasActiveBackends(src_dboid, true)) + if (DatabaseCancelAutovacuumActivity(src_dboid, true)) ereport(ERROR, (errcode(ERRCODE_OBJECT_IN_USE), - errmsg("source database \"%s\" is being accessed by other users", - dbtemplate))); + errmsg("source database \"%s\" is being accessed by other users", + dbtemplate))); /* If encoding is defaulted, use source's encoding */ if (encoding < 0) @@ -602,7 +602,7 @@ dropdb(const char *dbname, bool missing_ok) * Check for active backends in the target database. (Because we hold the * database lock, no new ones can start after this.) */ - if (DatabaseHasActiveBackends(db_id, false)) + if (DatabaseCancelAutovacuumActivity(db_id, false)) ereport(ERROR, (errcode(ERRCODE_OBJECT_IN_USE), errmsg("database \"%s\" is being accessed by other users", @@ -706,7 +706,7 @@ RenameDatabase(const char *oldname, const char *newname) * Make sure the database does not have active sessions. This is the same * concern as above, but applied to other sessions. */ - if (DatabaseHasActiveBackends(db_id, false)) + if (DatabaseCancelAutovacuumActivity(db_id, false)) ereport(ERROR, (errcode(ERRCODE_OBJECT_IN_USE), errmsg("database \"%s\" is being accessed by other users", -- cgit v1.2.3