From a3cac3a03b088257d90080e905ca525ad76f206c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 14 Jan 2001 22:14:10 +0000 Subject: [PATCH] Need to do BufferSync at end of DROP DATABASE as well as CREATE DATABASE. Otherwise, newly connecting backends will still think the deleted DB is valid, and will generate unexpected error messages. --- src/backend/commands/dbcommands.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 6e8e27a748..6f2923e6a8 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.70 2000/11/30 08:46:22 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.71 2001/01/14 22:14:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -153,7 +153,8 @@ createdb(const char *dbname, const char *dbpath, elog(ERROR, "database path may not contain single quotes"); /* ... otherwise we'd be open to shell exploits below */ - /* Force dirty buffers out to disk, to ensure source database is + /* + * Force dirty buffers out to disk, to ensure source database is * up-to-date for the copy. (We really only need to flush buffers * for the source database...) */ @@ -253,7 +254,8 @@ createdb(const char *dbname, const char *dbpath, /* Close pg_database, but keep lock till commit */ heap_close(pg_database_rel, NoLock); - /* Force dirty buffers out to disk, so that newly-connecting backends + /* + * Force dirty buffers out to disk, so that newly-connecting backends * will see the new database in pg_database right away. (They'll see * an uncommitted tuple, but they don't care; see GetRawDatabaseInfo.) */ @@ -369,6 +371,14 @@ dropdb(const char *dbname) * Remove the database's subdirectory and everything in it. */ remove_dbdirs(nominal_loc, alt_loc); + + /* + * Force dirty buffers out to disk, so that newly-connecting backends + * will see the database tuple marked dead in pg_database right away. + * (They'll see an uncommitted deletion, but they don't care; see + * GetRawDatabaseInfo.) + */ + BufferSync(); } -- 2.40.0