|
23 | 23 | * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
24 | 24 | * Portions Copyright (c) 1994, Regents of the University of California
|
25 | 25 | *
|
26 |
| - * $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.22 2006/11/05 22:42:09 tgl Exp $ |
| 26 | + * $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.23 2006/11/05 23:40:31 tgl Exp $ |
27 | 27 | *
|
28 | 28 | *-------------------------------------------------------------------------
|
29 | 29 | */
|
|
36 | 36 | #include "access/transam.h"
|
37 | 37 | #include "access/twophase_rmgr.h"
|
38 | 38 | #include "access/xact.h"
|
| 39 | +#include "catalog/catalog.h" |
39 | 40 | #include "catalog/pg_auth_members.h"
|
40 | 41 | #include "catalog/pg_authid.h"
|
41 | 42 | #include "catalog/pg_database.h"
|
|
47 | 48 | #include "storage/pmsignal.h"
|
48 | 49 | #include "utils/builtins.h"
|
49 | 50 | #include "utils/flatfiles.h"
|
| 51 | +#include "utils/relcache.h" |
50 | 52 | #include "utils/resowner.h"
|
51 | 53 |
|
52 | 54 |
|
@@ -165,9 +167,14 @@ name_okay(const char *str)
|
165 | 167 | *
|
166 | 168 | * A side effect is to determine the oldest database's datfrozenxid
|
167 | 169 | * so we can set or update the XID wrap limit.
|
| 170 | + * |
| 171 | + * Also, if "startup" is true, we tell relcache.c to clear out the relcache |
| 172 | + * init file in each database. That's a bit nonmodular, but scanning |
| 173 | + * pg_database twice during system startup seems too high a price for keeping |
| 174 | + * things better separated. |
168 | 175 | */
|
169 | 176 | static void
|
170 |
| -write_database_file(Relation drel) |
| 177 | +write_database_file(Relation drel, bool startup) |
171 | 178 | {
|
172 | 179 | char *filename,
|
173 | 180 | *tempname;
|
@@ -248,6 +255,17 @@ write_database_file(Relation drel)
|
248 | 255 | fputs_quote(datname, fp);
|
249 | 256 | fprintf(fp, " %u %u %u\n",
|
250 | 257 | datoid, dattablespace, datfrozenxid);
|
| 258 | + |
| 259 | + /* |
| 260 | + * Also clear relcache init file for each DB if starting up. |
| 261 | + */ |
| 262 | + if (startup) |
| 263 | + { |
| 264 | + char *dbpath = GetDatabasePath(datoid, dattablespace); |
| 265 | + |
| 266 | + RelationCacheInitFileRemove(dbpath); |
| 267 | + pfree(dbpath); |
| 268 | + } |
251 | 269 | }
|
252 | 270 | heap_endscan(scan);
|
253 | 271 |
|
@@ -669,6 +687,9 @@ write_auth_file(Relation rel_authid, Relation rel_authmem)
|
669 | 687 | * policy means we need not force initdb to change the format of the
|
670 | 688 | * flat files.
|
671 | 689 | *
|
| 690 | + * We also cause relcache init files to be flushed, for largely the same |
| 691 | + * reasons. |
| 692 | + * |
672 | 693 | * In a standalone backend we pass database_only = true to skip processing
|
673 | 694 | * the auth file. We won't need it, and building it could fail if there's
|
674 | 695 | * something corrupt in the authid/authmem catalogs.
|
@@ -699,7 +720,7 @@ BuildFlatFiles(bool database_only)
|
699 | 720 |
|
700 | 721 | /* No locking is needed because no one else is alive yet */
|
701 | 722 | rel_db = XLogOpenRelation(rnode);
|
702 |
| - write_database_file(rel_db); |
| 723 | + write_database_file(rel_db, true); |
703 | 724 |
|
704 | 725 | if (!database_only)
|
705 | 726 | {
|
@@ -811,7 +832,7 @@ AtEOXact_UpdateFlatFiles(bool isCommit)
|
811 | 832 | if (database_file_update_subid != InvalidSubTransactionId)
|
812 | 833 | {
|
813 | 834 | database_file_update_subid = InvalidSubTransactionId;
|
814 |
| - write_database_file(drel); |
| 835 | + write_database_file(drel, false); |
815 | 836 | heap_close(drel, NoLock);
|
816 | 837 | }
|
817 | 838 |
|
|
0 commit comments