diff options
author | Tom Lane | 2009-08-12 20:53:31 +0000 |
---|---|---|
committer | Tom Lane | 2009-08-12 20:53:31 +0000 |
commit | 04011cc97060798a5d28219b731b3603dd112ab6 (patch) | |
tree | 8d001affc00fefdccb7d0a400fc146d9da8ed6b2 /src/include | |
parent | a1f0c9bab99edc6029dee3bf702348aa7eab0099 (diff) |
Allow backends to start up without use of the flat-file copy of pg_database.
To make this work in the base case, pg_database now has a nailed-in-cache
relation descriptor that is initialized using hardwired knowledge in
relcache.c. This means pg_database is added to the set of relations that
need to have a Schema_pg_xxx macro maintained in pg_attribute.h. When this
path is taken, we'll have to do a seqscan of pg_database to find the row
we need.
In the normal case, we are able to do an indexscan to find the database's row
by name. This is made possible by storing a global relcache init file that
describes only the shared catalogs and their indexes (and therefore is usable
by all backends in any database). A new backend loads this cache file,
finds its database OID after an indexscan on pg_database, and then loads
the local relcache init file for that database.
This change should effectively eliminate number of databases as a factor
in backend startup time, even with large numbers of databases. However,
the real reason for doing it is as a first step towards getting rid of
the flat files altogether. There are still several other sub-projects
to be tackled before that can happen.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/pg_attribute.h | 25 | ||||
-rw-r--r-- | src/include/catalog/pg_type.h | 6 | ||||
-rw-r--r-- | src/include/miscadmin.h | 4 | ||||
-rw-r--r-- | src/include/storage/proc.h | 6 | ||||
-rw-r--r-- | src/include/utils/relcache.h | 9 |
5 files changed, 37 insertions, 13 deletions
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index ff5ed5981fe..f3c19d7475d 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.151 2009/08/04 04:04:11 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.152 2009/08/12 20:53:30 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -466,6 +466,29 @@ DATA(insert ( 1259 cmax 29 0 0 4 -6 0 -1 -1 t p i t f f t 0 _null_)); DATA(insert ( 1259 tableoid 26 0 0 4 -7 0 -1 -1 t p i t f f t 0 _null_)); /* ---------------- + * pg_database + * + * pg_database is not bootstrapped in the same way as the other relations that + * have hardwired pg_attribute entries in this file. However, we do need + * a "Schema_xxx" macro for it --- see relcache.c. + * ---------------- + */ +#define Schema_pg_database \ +{ 1262, {"datname"}, 19, -1, 0, NAMEDATALEN, 1, 0, -1, -1, false, 'p', 'c', true, false, false, true, 0, { 0 } }, \ +{ 1262, {"datdba"}, 26, -1, 0, 4, 2, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0, { 0 } }, \ +{ 1262, {"encoding"}, 23, -1, 0, 4, 3, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0, { 0 } }, \ +{ 1262, {"datcollate"}, 19, -1, 0, NAMEDATALEN, 4, 0, -1, -1, false, 'p', 'c', true, false, false, true, 0, { 0 } }, \ +{ 1262, {"datctype"}, 19, -1, 0, NAMEDATALEN, 5, 0, -1, -1, false, 'p', 'c', true, false, false, true, 0, { 0 } }, \ +{ 1262, {"datistemplate"}, 16, -1, 0, 1, 6, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \ +{ 1262, {"datallowconn"}, 16, -1, 0, 1, 7, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \ +{ 1262, {"datconnlimit"}, 23, -1, 0, 4, 8, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0, { 0 } }, \ +{ 1262, {"datlastsysoid"}, 26, -1, 0, 4, 9, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0, { 0 } }, \ +{ 1262, {"datfrozenxid"}, 28, -1, 0, 4, 10, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0, { 0 } }, \ +{ 1262, {"dattablespace"}, 26, -1, 0, 4, 11, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0, { 0 } }, \ +{ 1262, {"datconfig"}, 1009, -1, 0, -1, 12, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0, { 0 } }, \ +{ 1262, {"datacl"}, 1034, -1, 0, -1, 13, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0, { 0 } } + +/* ---------------- * pg_index * * pg_index is not bootstrapped in the same way as the other relations that diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 5b0d6fba652..2111161751e 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.207 2009/07/11 21:15:32 petere Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.208 2009/08/12 20:53:30 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -333,13 +333,9 @@ DESCR("array of oids, used in system tables"); /* hand-built rowtype entries for bootstrapped catalogs: */ DATA(insert OID = 71 ( pg_type PGNSP PGUID -1 f c C f t \054 1247 0 0 record_in record_out record_recv record_send - - - d x f 0 -1 0 _null_ _null_ )); -#define PG_TYPE_RELTYPE_OID 71 DATA(insert OID = 75 ( pg_attribute PGNSP PGUID -1 f c C f t \054 1249 0 0 record_in record_out record_recv record_send - - - d x f 0 -1 0 _null_ _null_ )); -#define PG_ATTRIBUTE_RELTYPE_OID 75 DATA(insert OID = 81 ( pg_proc PGNSP PGUID -1 f c C f t \054 1255 0 0 record_in record_out record_recv record_send - - - d x f 0 -1 0 _null_ _null_ )); -#define PG_PROC_RELTYPE_OID 81 DATA(insert OID = 83 ( pg_class PGNSP PGUID -1 f c C f t \054 1259 0 0 record_in record_out record_recv record_send - - - d x f 0 -1 0 _null_ _null_ )); -#define PG_CLASS_RELTYPE_OID 83 /* OIDS 100 - 199 */ DATA(insert OID = 142 ( xml PGNSP PGUID -1 f b U f t \054 0 0 143 xml_in xml_out xml_recv xml_send - - - i x f 0 -1 0 _null_ _null_ )); diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index e4c5d66475d..eac73aae814 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.211 2009/06/11 14:49:08 momjian Exp $ + * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.212 2009/08/12 20:53:30 tgl Exp $ * * NOTES * some of the information in this file should be moved to other files. @@ -324,7 +324,7 @@ extern ProcessingMode Mode; /* in utils/init/postinit.c */ extern bool InitPostgres(const char *in_dbname, Oid dboid, const char *username, - char **out_dbname); + char *out_dbname); extern void BaseInit(void); /* in utils/init/miscinit.c */ diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index b250d3f0f2d..98bb41103d2 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.112 2009/02/23 09:28:50 heikki Exp $ + * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.113 2009/08/12 20:53:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -84,7 +84,9 @@ struct PGPROC * vacuum must not remove tuples deleted by * xid >= xmin ! */ - int pid; /* This backend's process id, or 0 */ + int pid; /* Backend's process ID; 0 if prepared xact */ + + /* These fields are zero while a backend is still starting up: */ BackendId backendId; /* This backend's backend ID (if assigned) */ Oid databaseId; /* OID of database this backend is using */ Oid roleId; /* OID of role using this backend */ diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h index 3c5b8680588..007532fb0e5 100644 --- a/src/include/utils/relcache.h +++ b/src/include/utils/relcache.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.63 2009/01/01 17:24:02 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.64 2009/08/12 20:53:31 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -54,6 +54,7 @@ extern void RelationInitIndexAccessInfo(Relation relation); */ extern void RelationCacheInitialize(void); extern void RelationCacheInitializePhase2(void); +extern void RelationCacheInitializePhase3(void); /* * Routine to create a relcache entry for an about-to-be-created relation @@ -81,13 +82,15 @@ extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, extern void RelationCacheMarkNewRelfilenode(Relation rel); /* - * Routines to help manage rebuilding of relcache init file + * Routines to help manage rebuilding of relcache init files */ extern bool RelationIdIsInInitFile(Oid relationId); extern void RelationCacheInitFileInvalidate(bool beforeSend); -extern void RelationCacheInitFileRemove(const char *dbPath); +extern void RelationCacheInitFileRemove(void); /* should be used only by relcache.c and catcache.c */ extern bool criticalRelcachesBuilt; +/* should be used only by relcache.c and postinit.c */ +extern bool criticalSharedRelcachesBuilt; #endif /* RELCACHE_H */ |