Need to do BufferSync at end of DROP DATABASE as well as CREATE DATABASE.
authorTom Lane
Sun, 14 Jan 2001 22:14:10 +0000 (22:14 +0000)
committerTom Lane
Sun, 14 Jan 2001 22:14:10 +0000 (22:14 +0000)
Otherwise, newly connecting backends will still think the deleted DB is
valid, and will generate unexpected error messages.

src/backend/commands/dbcommands.c

index 6e8e27a74853ef55302168e2493373da4947eacc..6f2923e6a8d58b28143203a2166930912ebad717 100644 (file)
@@ -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();
 }