On 02/18/2018 01:33 PM, Joe Conway wrote:
> On 02/18/2018 11:18 AM, Tom Lane wrote:
>> I'm fairly suspicious of toasting anything that the toast mechanism itself
>> depends on, actually, and that would include at least pg_attribute and
>> pg_index as well as pg_class.  Maybe we could get away with it because
>> there would never be any actual recursion only potential recursion ...
>> but it seems scary.
> 
> Well that is the other approach we could pursue -- instead of justifying
> which system catalogs need toast tables we could create an exclusion
> list of which ones should not have toast tables, with the current
> candidates being pg_class, pg_attribute, and pg_index.

The attached does exactly this. Gives all system tables toast tables
except pg_class, pg_attribute, and pg_index, and includes cat version
bump and regression test in misc_sanity.

Any further discussion, comments, complaints?

Joe

-- 
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 809749add9..813b3b87cc 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -258,7 +258,19 @@ IsSharedRelation(Oid relationId)
 		relationId == PgDbRoleSettingToastTable ||
 		relationId == PgDbRoleSettingToastIndex ||
 		relationId == PgShseclabelToastTable ||
-		relationId == PgShseclabelToastIndex)
+		relationId == PgShseclabelToastIndex ||
+		relationId == PgAuthidToastTable ||
+		relationId == PgAuthidToastIndex ||
+		relationId == PgDatabaseToastTable ||
+		relationId == PgDatabaseToastIndex ||
+		relationId == PgPlTemplateToastTable ||
+		relationId == PgPlTemplateToastIndex ||
+		relationId == PgReplicationOriginToastTable ||
+		relationId == PgReplicationOriginToastIndex ||
+		relationId == PgSubscriptionToastTable ||
+		relationId == PgSubscriptionToastIndex ||
+		relationId == PgTablespaceToastTable ||
+		relationId == PgTablespaceToastIndex)
 		return true;
 	return false;
 }
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 433d6db4f6..202072c3c7 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
  */
 
 /*							yyyymmddN */
-#define CATALOG_VERSION_NO	201802061
+#define CATALOG_VERSION_NO	201802191
 
 #endif
diff --git a/src/include/catalog/toasting.h b/src/include/catalog/toasting.h
index f6387ae143..4586ac93b2 100644
--- a/src/include/catalog/toasting.h
+++ b/src/include/catalog/toasting.h
@@ -46,25 +46,61 @@ extern void BootstrapToastTable(char *relName,
  */
 
 /* normal catalogs */
+DECLARE_TOAST(pg_aggregate, 4139, 4140);
 DECLARE_TOAST(pg_attrdef, 2830, 2831);
+DECLARE_TOAST(pg_collation, 4141, 4142);
 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);
 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_shdescription, 2846, 2847);
-#define PgShdescriptionToastTable 2846
-#define PgShdescriptionToastIndex 2847
+DECLARE_TOAST(pg_authid, 4175, 4176);
+#define PgAuthidToastTable 4175
+#define PgAuthidToastIndex 4176
+DECLARE_TOAST(pg_database, 4177, 4178);
+#define PgDatabaseToastTable 4177
+#define PgDatabaseToastIndex 4178
 DECLARE_TOAST(pg_db_role_setting, 2966, 2967);
 #define PgDbRoleSettingToastTable 2966
 #define PgDbRoleSettingToastIndex 2967
+DECLARE_TOAST(pg_pltemplate, 4179, 4180);
+#define PgPlTemplateToastTable 4179
+#define PgPlTemplateToastIndex 4180
+DECLARE_TOAST(pg_replication_origin, 4181, 4182);
+#define PgReplicationOriginToastTable 4181
+#define PgReplicationOriginToastIndex 4182
+DECLARE_TOAST(pg_shdescription, 2846, 2847);
+#define PgShdescriptionToastTable 2846
+#define PgShdescriptionToastIndex 2847
 DECLARE_TOAST(pg_shseclabel, 4060, 4061);
 #define PgShseclabelToastTable 4060
 #define PgShseclabelToastIndex 4061
+DECLARE_TOAST(pg_subscription, 4183, 4184);
+#define PgSubscriptionToastTable 4183
+#define PgSubscriptionToastIndex 4184
+DECLARE_TOAST(pg_tablespace, 4185, 4186);
+#define PgTablespaceToastTable 4185
+#define PgTablespaceToastIndex 4186
 
 #endif							/* TOASTING_H */
diff --git a/src/test/regress/expected/misc_sanity.out b/src/test/regress/expected/misc_sanity.out
index 5aaae6c39f..0be74d2b46 100644
--- a/src/test/regress/expected/misc_sanity.out
+++ b/src/test/regress/expected/misc_sanity.out
@@ -76,3 +76,27 @@ NOTICE:  pg_database contains unpinned initdb-created object(s)
 NOTICE:  pg_extension contains unpinned initdb-created object(s)
 NOTICE:  pg_rewrite contains unpinned initdb-created object(s)
 NOTICE:  pg_tablespace contains unpinned initdb-created object(s)
+-- **************** pg_class ****************
+-- Look for system tables with varlena columns but no toast table.
+-- All system tables with toastable columns should have toast tables,
+-- except pg_class, pg_attribute, and pg_index due to fear of
+-- recursive dependencies.
+SELECT relname, attname, atttypid::regtype
+FROM pg_class c join pg_attribute a on c.oid = attrelid
+WHERE c.oid < 16384 AND
+      reltoastrelid = 0 AND
+      relkind = 'r' AND
+      attstorage != 'p'
+ORDER BY 1,2;
+   relname    |    attname    |   atttypid   
+--------------+---------------+--------------
+ pg_attribute | attacl        | aclitem[]
+ pg_attribute | attfdwoptions | text[]
+ pg_attribute | attoptions    | text[]
+ pg_class     | relacl        | aclitem[]
+ pg_class     | reloptions    | text[]
+ pg_class     | relpartbound  | pg_node_tree
+ pg_index     | indexprs      | pg_node_tree
+ pg_index     | indpred       | pg_node_tree
+(8 rows)
+
diff --git a/src/test/regress/sql/misc_sanity.sql b/src/test/regress/sql/misc_sanity.sql
index b921117fa5..1386525170 100644
--- a/src/test/regress/sql/misc_sanity.sql
+++ b/src/test/regress/sql/misc_sanity.sql
@@ -72,3 +72,18 @@ loop
   end if;
 end loop;
 end$$;
+
+-- **************** pg_class ****************
+
+-- Look for system tables with varlena columns but no toast table.
+-- All system tables with toastable columns should have toast tables,
+-- except pg_class, pg_attribute, and pg_index due to fear of
+-- recursive dependencies.
+
+SELECT relname, attname, atttypid::regtype
+FROM pg_class c join pg_attribute a on c.oid = attrelid
+WHERE c.oid < 16384 AND
+      reltoastrelid = 0 AND
+      relkind = 'r' AND
+      attstorage != 'p'
+ORDER BY 1,2;

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to