diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y index 4c72989..9f5a3b9 100644 --- a/src/backend/bootstrap/bootparse.y +++ b/src/backend/bootstrap/bootparse.y @@ -27,10 +27,13 @@ #include "catalog/heap.h" #include "catalog/namespace.h" #include "catalog/pg_am.h" +#include "catalog/pg_amproc.h" #include "catalog/pg_attribute.h" #include "catalog/pg_authid.h" #include "catalog/pg_class.h" +#include "catalog/pg_index.h" #include "catalog/pg_namespace.h" +#include "catalog/pg_opclass.h" #include "catalog/pg_tablespace.h" #include "catalog/toasting.h" #include "commands/defrem.h" @@ -255,6 +258,23 @@ Boot_CreateStmt: InvalidOid, NULL); elog(DEBUG4, "relation created with OID %u", id); + + /* + * Create a toast table for all non-shared catalogs + * that have any varlena attributes, except for pg_index. + * We also exclude catalogs that need to be populated + * in order for toast tables to be created. These don't + * currently have varlenas, so this is just future-proofing. + */ + if (!shared_relation + && id != IndexRelationId + && id != AccessMethodRelationId + && id != OperatorClassRelationId + && id != AccessMethodProcedureRelationId) + { + NewRelationCreateToastTable(id, (Datum) 0); + } + elog(DEBUG4, "creating toast table for table \"%s\"", $2); } do_end(); } diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile index 0865240..48a871a 100644 --- a/src/backend/catalog/Makefile +++ b/src/backend/catalog/Makefile @@ -27,12 +27,13 @@ include $(top_srcdir)/src/backend/common.mk # Note: the order of this list determines the order in which the catalog # header files are assembled into postgres.bki. BKI_BOOTSTRAP catalogs -# must appear first, and there are reputedly other, undocumented ordering -# dependencies. +# must appear first, followed by catalogs needed for creating toast tables. +# There are reputedly other, undocumented ordering dependencies. CATALOG_HEADERS := \ pg_proc.h pg_type.h pg_attribute.h pg_class.h \ - pg_attrdef.h pg_constraint.h pg_inherits.h pg_index.h pg_operator.h \ - pg_opfamily.h pg_opclass.h pg_am.h pg_amop.h pg_amproc.h \ + pg_index.h pg_am.h pg_opclass.h pg_amproc.h \ + pg_operator.h pg_opfamily.h pg_amop.h \ + pg_attrdef.h pg_constraint.h pg_inherits.h \ pg_language.h pg_largeobject_metadata.h pg_largeobject.h pg_aggregate.h \ pg_statistic_ext.h \ pg_statistic.h pg_rewrite.h pg_trigger.h pg_event_trigger.h pg_description.h \ diff --git a/src/include/catalog/toasting.h b/src/include/catalog/toasting.h index 1387569..df2595e 100644 --- a/src/include/catalog/toasting.h +++ b/src/include/catalog/toasting.h @@ -42,37 +42,14 @@ extern void BootstrapToastTable(char *relName, * the OID to assign to the toast table, and the OID to assign to the * toast table's index. The reason we hard-wire these OIDs is that we * need stable OIDs for shared relations, and that includes toast tables - * of shared relations. + * of shared relations. Most non-shared catalogs get a toast table + * at the time they're created, but that won't work for bootstrap catalogs, + * so just hard-wire the toast declarations for them here. */ -/* normal catalogs */ -DECLARE_TOAST(pg_aggregate, 4187, 4188); -DECLARE_TOAST(pg_attrdef, 2830, 2831); -DECLARE_TOAST(pg_collation, 4189, 4190); -DECLARE_TOAST(pg_constraint, 2832, 2833); -DECLARE_TOAST(pg_default_acl, 4143, 4144); -DECLARE_TOAST(pg_description, 2834, 2835); -DECLARE_TOAST(pg_event_trigger, 4145, 4146); -DECLARE_TOAST(pg_extension, 4147, 4148); -DECLARE_TOAST(pg_foreign_data_wrapper, 4149, 4150); -DECLARE_TOAST(pg_foreign_server, 4151, 4152); -DECLARE_TOAST(pg_foreign_table, 4153, 4154); -DECLARE_TOAST(pg_init_privs, 4155, 4156); -DECLARE_TOAST(pg_language, 4157, 4158); -DECLARE_TOAST(pg_largeobject, 4159, 4160); -DECLARE_TOAST(pg_largeobject_metadata, 4161, 4162); -DECLARE_TOAST(pg_namespace, 4163, 4164); -DECLARE_TOAST(pg_partitioned_table, 4165, 4166); -DECLARE_TOAST(pg_policy, 4167, 4168); +/* bootstrap catalogs, excluding pg_class and pg_attribute */ DECLARE_TOAST(pg_proc, 2836, 2837); -DECLARE_TOAST(pg_rewrite, 2838, 2839); -DECLARE_TOAST(pg_seclabel, 3598, 3599); -DECLARE_TOAST(pg_statistic, 2840, 2841); -DECLARE_TOAST(pg_statistic_ext, 3439, 3440); -DECLARE_TOAST(pg_trigger, 2336, 2337); -DECLARE_TOAST(pg_ts_dict, 4169, 4170); DECLARE_TOAST(pg_type, 4171, 4172); -DECLARE_TOAST(pg_user_mapping, 4173, 4174); /* shared catalogs */ DECLARE_TOAST(pg_authid, 4175, 4176);