*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.146 2004/10/28 00:39:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.147 2004/11/18 01:14:26 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/*
* 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...)
+ * the source database, but bufmgr.c provides no API for that.)
*/
BufferSync(-1, -1);
/* Update indexes */
CatalogUpdateIndexes(pg_database_rel, tuple);
- /* 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
* will see the new database in pg_database right away. (They'll see
* an uncommitted tuple, but they don't care; see GetRawDatabaseInfo.)
*/
- BufferSync(-1, -1);
+ FlushRelationBuffers(pg_database_rel, MaxBlockNumber);
+
+ /* Close pg_database, but keep exclusive lock till commit */
+ heap_close(pg_database_rel, NoLock);
}
*/
DeleteComments(db_id, RelationGetRelid(pgdbrel), 0);
- /*
- * Close pg_database, but keep exclusive lock till commit to ensure
- * that any new backend scanning pg_database will see the tuple dead.
- */
- heap_close(pgdbrel, NoLock);
-
/*
* Drop pages for this database that are in the shared buffer cache.
* This is important to ensure that no remaining backend tries to
* (They'll see an uncommitted deletion, but they don't care; see
* GetRawDatabaseInfo.)
*/
- BufferSync(-1, -1);
+ FlushRelationBuffers(pgdbrel, MaxBlockNumber);
+
+ /* Close pg_database, but keep exclusive lock till commit */
+ heap_close(pgdbrel, NoLock);
}
CatalogUpdateIndexes(rel, newtup);
systable_endscan(scan);
- heap_close(rel, NoLock);
/*
* Force dirty buffers out to disk, so that newly-connecting backends
* see an uncommitted tuple, but they don't care; see
* GetRawDatabaseInfo.)
*/
- BufferSync(-1, -1);
+ FlushRelationBuffers(rel, MaxBlockNumber);
+
+ /* Close pg_database, but keep exclusive lock till commit */
+ heap_close(rel, NoLock);
}
valuestr = flatten_set_variable_args(stmt->variable, stmt->value);
- rel = heap_openr(DatabaseRelationName, RowExclusiveLock);
+ /*
+ * We need AccessExclusiveLock so we can safely do FlushRelationBuffers.
+ */
+ rel = heap_openr(DatabaseRelationName, AccessExclusiveLock);
ScanKeyInit(&scankey,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
CatalogUpdateIndexes(rel, newtuple);
systable_endscan(scan);
+
+ /*
+ * Force dirty buffers out to disk, so that newly-connecting backends
+ * will see the altered row in pg_database right away. (They'll
+ * see an uncommitted tuple, but they don't care; see
+ * GetRawDatabaseInfo.)
+ */
+ FlushRelationBuffers(rel, MaxBlockNumber);
+
+ /* Close pg_database, but keep exclusive lock till commit */
heap_close(rel, NoLock);
}
SysScanDesc scan;
Form_pg_database datForm;
- rel = heap_openr(DatabaseRelationName, RowExclusiveLock);
+ /*
+ * We need AccessExclusiveLock so we can safely do FlushRelationBuffers.
+ */
+ rel = heap_openr(DatabaseRelationName, AccessExclusiveLock);
ScanKeyInit(&scankey,
Anum_pg_database_datname,
BTEqualStrategyNumber, F_NAMEEQ,
CatalogUpdateIndexes(rel, newtuple);
heap_freetuple(newtuple);
+
+ /* must release buffer pins before FlushRelationBuffers */
+ systable_endscan(scan);
+
+ /*
+ * Force dirty buffers out to disk, so that newly-connecting backends
+ * will see the altered row in pg_database right away. (They'll
+ * see an uncommitted tuple, but they don't care; see
+ * GetRawDatabaseInfo.)
+ */
+ FlushRelationBuffers(rel, MaxBlockNumber);
}
+ else
+ systable_endscan(scan);
- systable_endscan(scan);
+ /* Close pg_database, but keep exclusive lock till commit */
heap_close(rel, NoLock);
}
/*
* 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...)
+ * the source database, but bufmgr.c provides no API for that.)
*/
BufferSync(-1, -1);