From 0f03edfaf02611c13deba1f4e5179d59a2bd2ff1 Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Sun, 10 Jul 2022 14:33:51 +0700
Subject: [PATCH v1 2/2] Generate stubs for catalog tuple deforming functions

These are just the same macros as before, but gives some idea
how this would work. Manual work needed for FormData_pg_sequence_data,
since it's not a catalog in the usual sense, but we still need to
form/deform tuples for it.
---
 src/backend/catalog/Makefile                  |  2 +-
 src/backend/catalog/genbki.pl                 | 25 ++++++++++++++++++-
 src/include/access/htup_details.h             |  2 +-
 src/include/catalog/pg_aggregate.h            |  3 +++
 src/include/catalog/pg_am.h                   |  3 +++
 src/include/catalog/pg_amop.h                 |  3 +++
 src/include/catalog/pg_amproc.h               |  3 +++
 src/include/catalog/pg_attrdef.h              |  3 +++
 src/include/catalog/pg_attribute.h            |  3 +++
 src/include/catalog/pg_auth_members.h         |  3 +++
 src/include/catalog/pg_authid.h               |  3 +++
 src/include/catalog/pg_cast.h                 |  3 +++
 src/include/catalog/pg_class.h                |  3 +++
 src/include/catalog/pg_collation.h            |  3 +++
 src/include/catalog/pg_constraint.h           |  3 +++
 src/include/catalog/pg_conversion.h           |  3 +++
 src/include/catalog/pg_database.h             |  3 +++
 src/include/catalog/pg_db_role_setting.h      |  3 +++
 src/include/catalog/pg_default_acl.h          |  3 +++
 src/include/catalog/pg_depend.h               |  3 +++
 src/include/catalog/pg_description.h          |  3 +++
 src/include/catalog/pg_enum.h                 |  3 +++
 src/include/catalog/pg_event_trigger.h        |  3 +++
 src/include/catalog/pg_extension.h            |  3 +++
 src/include/catalog/pg_foreign_data_wrapper.h |  3 +++
 src/include/catalog/pg_foreign_server.h       |  3 +++
 src/include/catalog/pg_foreign_table.h        |  3 +++
 src/include/catalog/pg_index.h                |  3 +++
 src/include/catalog/pg_inherits.h             |  3 +++
 src/include/catalog/pg_init_privs.h           |  3 +++
 src/include/catalog/pg_language.h             |  3 +++
 src/include/catalog/pg_largeobject.h          |  3 +++
 src/include/catalog/pg_largeobject_metadata.h |  3 +++
 src/include/catalog/pg_namespace.h            |  3 +++
 src/include/catalog/pg_opclass.h              |  3 +++
 src/include/catalog/pg_operator.h             |  3 +++
 src/include/catalog/pg_opfamily.h             |  3 +++
 src/include/catalog/pg_parameter_acl.h        |  3 +++
 src/include/catalog/pg_partitioned_table.h    |  3 +++
 src/include/catalog/pg_policy.h               |  3 +++
 src/include/catalog/pg_proc.h                 |  3 +++
 src/include/catalog/pg_publication.h          |  3 +++
 .../catalog/pg_publication_namespace.h        |  3 +++
 src/include/catalog/pg_publication_rel.h      |  3 +++
 src/include/catalog/pg_range.h                |  3 +++
 src/include/catalog/pg_replication_origin.h   |  3 +++
 src/include/catalog/pg_rewrite.h              |  3 +++
 src/include/catalog/pg_sequence.h             |  3 +++
 src/include/catalog/pg_shdepend.h             |  3 +++
 src/include/catalog/pg_shdescription.h        |  3 +++
 src/include/catalog/pg_shseclabel.h           |  3 +++
 src/include/catalog/pg_statistic.h            |  3 +++
 src/include/catalog/pg_statistic_ext.h        |  3 +++
 src/include/catalog/pg_statistic_ext_data.h   |  3 +++
 src/include/catalog/pg_subscription.h         |  3 +++
 src/include/catalog/pg_subscription_rel.h     |  3 +++
 src/include/catalog/pg_tablespace.h           |  3 +++
 src/include/catalog/pg_transform.h            |  3 +++
 src/include/catalog/pg_trigger.h              |  3 +++
 src/include/catalog/pg_ts_config.h            |  3 +++
 src/include/catalog/pg_ts_config_map.h        |  3 +++
 src/include/catalog/pg_ts_dict.h              |  3 +++
 src/include/catalog/pg_ts_parser.h            |  3 +++
 src/include/catalog/pg_ts_template.h          |  3 +++
 src/include/catalog/pg_type.h                 |  3 +++
 src/include/catalog/pg_user_mapping.h         |  3 +++
 src/include/commands/sequence.h               |  3 +++
 67 files changed, 218 insertions(+), 3 deletions(-)

diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 89a0221ec9..d7bca52391 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -74,7 +74,7 @@ CATALOG_HEADERS := \
 	pg_sequence.h pg_publication.h pg_publication_namespace.h \
 	pg_publication_rel.h pg_subscription.h pg_subscription_rel.h
 
-GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h system_fk_info.h
+GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) $(CATALOG_HEADERS:%.h=%_deform.h) schemapg.h system_fk_info.h
 
 POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/, $(CATALOG_HEADERS))
 
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index 17b2c5e3f3..ad7a3aebd6 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -440,6 +440,11 @@ foreach my $catname (@catnames)
 	open my $def, '>', $def_file . $tmpext
 	  or die "can't open $def_file$tmpext: $!";
 
+	# Create one header with the tuple deforming function for each catalog.
+	my $deform_file = $output_path . $catname . '_deform.h';
+	open my $deform, '>', $deform_file . $tmpext
+	  or die "can't open $deform_file$tmpext: $!";
+
 	# Opening boilerplate for pg_*_d.h
 	printf $def <<EOM, $catname, $catname, uc $catname, uc $catname;
 /*-------------------------------------------------------------------------
@@ -462,6 +467,21 @@ foreach my $catname (@catnames)
 #ifndef %s_D_H
 #define %s_D_H
 
+EOM
+
+	# Opening boilerplate for pg_*_deform.h
+	printf $deform <<EOM, uc $catname, uc $catname;
+/* generated by src/backend/catalog/genbki.pl, do not edit */
+
+#ifndef %s_DEFORM_H
+#define %s_DEFORM_H
+
+EOM
+
+	# Emit tuple deforming function
+	# WIP: just the same macro we had before
+	print $deform <<EOM;
+#define Deform_$catname\_tuple(TUP) (Form_$catname) (TUP)
 EOM
 
 	# Emit OID macros for catalog's OID and rowtype OID, if wanted
@@ -673,10 +693,13 @@ EOM
 
 	print $bki "close $catname\n";
 	printf $def "\n#endif\t\t\t\t\t\t\t/* %s_D_H */\n", uc $catname;
+	printf $deform "\n#endif\t\t\t\t\t\t\t/* %s_DEFORM_H */\n", uc $catname;
 
-	# Close and rename definition header
+	# Close and rename per-catalog headers
 	close $def;
 	Catalog::RenameTempFile($def_file, $tmpext);
+	close $deform;
+	Catalog::RenameTempFile($deform_file, $tmpext);
 }
 
 # Any information needed for the BKI that is not contained in a pg_*.h header
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 7310e3b2b8..9d5bd76d7b 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -651,7 +651,7 @@ struct MinimalTupleData
 /*
  * GETSTRUCT - given a HeapTuple pointer, return address of the user data
  */
-#define GETSTRUCT(CAT, TUP) ((Form_##CAT) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff))
+#define GETSTRUCT(CAT, TUP) Deform_##CAT##_tuple((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)
 
 /*
  * Accessor macros to be used with HeapTuple pointers.
diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h
index 593da9f76a..dae5116e2f 100644
--- a/src/include/catalog/pg_aggregate.h
+++ b/src/include/catalog/pg_aggregate.h
@@ -108,6 +108,9 @@ CATALOG(pg_aggregate,2600,AggregateRelationId)
  */
 typedef FormData_pg_aggregate *Form_pg_aggregate;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_aggregate_deform.h"
+
 DECLARE_TOAST(pg_aggregate, 4159, 4160);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_aggregate_fnoid_index, 2650, AggregateFnoidIndexId, on pg_aggregate using btree(aggfnoid oid_ops));
diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h
index 50a68fe4c3..c3dcb48184 100644
--- a/src/include/catalog/pg_am.h
+++ b/src/include/catalog/pg_am.h
@@ -47,6 +47,9 @@ CATALOG(pg_am,2601,AccessMethodRelationId)
  */
 typedef FormData_pg_am *Form_pg_am;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_am_deform.h"
+
 DECLARE_UNIQUE_INDEX(pg_am_name_index, 2651, AmNameIndexId, on pg_am using btree(amname name_ops));
 DECLARE_UNIQUE_INDEX_PKEY(pg_am_oid_index, 2652, AmOidIndexId, on pg_am using btree(oid oid_ops));
 
diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h
index 6c714b61ab..87e83b5760 100644
--- a/src/include/catalog/pg_amop.h
+++ b/src/include/catalog/pg_amop.h
@@ -87,6 +87,9 @@ CATALOG(pg_amop,2602,AccessMethodOperatorRelationId)
  */
 typedef FormData_pg_amop *Form_pg_amop;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_amop_deform.h"
+
 DECLARE_UNIQUE_INDEX(pg_amop_fam_strat_index, 2653, AccessMethodStrategyIndexId, on pg_amop using btree(amopfamily oid_ops, amoplefttype oid_ops, amoprighttype oid_ops, amopstrategy int2_ops));
 DECLARE_UNIQUE_INDEX(pg_amop_opr_fam_index, 2654, AccessMethodOperatorIndexId, on pg_amop using btree(amopopr oid_ops, amoppurpose char_ops, amopfamily oid_ops));
 DECLARE_UNIQUE_INDEX_PKEY(pg_amop_oid_index, 2756, AccessMethodOperatorOidIndexId, on pg_amop using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h
index f529fc6053..10026093c8 100644
--- a/src/include/catalog/pg_amproc.h
+++ b/src/include/catalog/pg_amproc.h
@@ -67,6 +67,9 @@ CATALOG(pg_amproc,2603,AccessMethodProcedureRelationId)
  */
 typedef FormData_pg_amproc *Form_pg_amproc;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_amproc_deform.h"
+
 DECLARE_UNIQUE_INDEX(pg_amproc_fam_proc_index, 2655, AccessMethodProcedureIndexId, on pg_amproc using btree(amprocfamily oid_ops, amproclefttype oid_ops, amprocrighttype oid_ops, amprocnum int2_ops));
 DECLARE_UNIQUE_INDEX_PKEY(pg_amproc_oid_index, 2757, AccessMethodProcedureOidIndexId, on pg_amproc using btree(oid oid_ops));
 
diff --git a/src/include/catalog/pg_attrdef.h b/src/include/catalog/pg_attrdef.h
index a21dd3812b..020c70a09e 100644
--- a/src/include/catalog/pg_attrdef.h
+++ b/src/include/catalog/pg_attrdef.h
@@ -48,6 +48,9 @@ CATALOG(pg_attrdef,2604,AttrDefaultRelationId)
  */
 typedef FormData_pg_attrdef *Form_pg_attrdef;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_attrdef_deform.h"
+
 DECLARE_TOAST(pg_attrdef, 2830, 2831);
 
 DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index, 2656, AttrDefaultIndexId, on pg_attrdef using btree(adrelid oid_ops, adnum int2_ops));
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index 053294c99f..081063afef 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -206,6 +206,9 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
  */
 typedef FormData_pg_attribute *Form_pg_attribute;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_attribute_deform.h"
+
 DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index, 2658, AttributeRelidNameIndexId, on pg_attribute using btree(attrelid oid_ops, attname name_ops));
 DECLARE_UNIQUE_INDEX_PKEY(pg_attribute_relid_attnum_index, 2659, AttributeRelidNumIndexId, on pg_attribute using btree(attrelid oid_ops, attnum int2_ops));
 
diff --git a/src/include/catalog/pg_auth_members.h b/src/include/catalog/pg_auth_members.h
index 1bc027f133..1288694b97 100644
--- a/src/include/catalog/pg_auth_members.h
+++ b/src/include/catalog/pg_auth_members.h
@@ -42,6 +42,9 @@ CATALOG(pg_auth_members,1261,AuthMemRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_
  */
 typedef FormData_pg_auth_members *Form_pg_auth_members;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_auth_members_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_auth_members_role_member_index, 2694, AuthMemRoleMemIndexId, on pg_auth_members using btree(roleid oid_ops, member oid_ops));
 DECLARE_UNIQUE_INDEX(pg_auth_members_member_role_index, 2695, AuthMemMemRoleIndexId, on pg_auth_members using btree(member oid_ops, roleid oid_ops));
 
diff --git a/src/include/catalog/pg_authid.h b/src/include/catalog/pg_authid.h
index 3512601c80..08b833198f 100644
--- a/src/include/catalog/pg_authid.h
+++ b/src/include/catalog/pg_authid.h
@@ -55,6 +55,9 @@ CATALOG(pg_authid,1260,AuthIdRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(284
  */
 typedef FormData_pg_authid *Form_pg_authid;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_authid_deform.h"
+
 DECLARE_TOAST_WITH_MACRO(pg_authid, 4175, 4176, PgAuthidToastTable, PgAuthidToastIndex);
 
 DECLARE_UNIQUE_INDEX(pg_authid_rolname_index, 2676, AuthIdRolnameIndexId, on pg_authid using btree(rolname name_ops));
diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h
index 3c15df0053..4887ea16bd 100644
--- a/src/include/catalog/pg_cast.h
+++ b/src/include/catalog/pg_cast.h
@@ -56,6 +56,9 @@ CATALOG(pg_cast,2605,CastRelationId)
  */
 typedef FormData_pg_cast *Form_pg_cast;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_cast_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_cast_oid_index, 2660, CastOidIndexId, on pg_cast using btree(oid oid_ops));
 DECLARE_UNIQUE_INDEX(pg_cast_source_target_index, 2661, CastSourceTargetIndexId, on pg_cast using btree(castsource oid_ops, casttarget oid_ops));
 
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index e1f4eefa22..1405fa07f5 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -152,6 +152,9 @@ CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,Relat
  */
 typedef FormData_pg_class *Form_pg_class;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_class_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_class_oid_index, 2662, ClassOidIndexId, on pg_class using btree(oid oid_ops));
 DECLARE_UNIQUE_INDEX(pg_class_relname_nsp_index, 2663, ClassNameNspIndexId, on pg_class using btree(relname name_ops, relnamespace oid_ops));
 DECLARE_INDEX(pg_class_tblspc_relfilenode_index, 3455, ClassTblspcRelfilenodeIndexId, on pg_class using btree(reltablespace oid_ops, relfilenode oid_ops));
diff --git a/src/include/catalog/pg_collation.h b/src/include/catalog/pg_collation.h
index 2190ccb5b8..a5f6ab75a1 100644
--- a/src/include/catalog/pg_collation.h
+++ b/src/include/catalog/pg_collation.h
@@ -56,6 +56,9 @@ CATALOG(pg_collation,3456,CollationRelationId)
  */
 typedef FormData_pg_collation *Form_pg_collation;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_collation_deform.h"
+
 DECLARE_TOAST(pg_collation, 6175, 6176);
 
 DECLARE_UNIQUE_INDEX(pg_collation_name_enc_nsp_index, 3164, CollationNameEncNspIndexId, on pg_collation using btree(collname name_ops, collencoding int4_ops, collnamespace oid_ops));
diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h
index e7d967f137..184baf88ba 100644
--- a/src/include/catalog/pg_constraint.h
+++ b/src/include/catalog/pg_constraint.h
@@ -164,6 +164,9 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
  */
 typedef FormData_pg_constraint *Form_pg_constraint;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_constraint_deform.h"
+
 DECLARE_TOAST(pg_constraint, 2832, 2833);
 
 DECLARE_INDEX(pg_constraint_conname_nsp_index, 2664, ConstraintNameNspIndexId, on pg_constraint using btree(conname name_ops, connamespace oid_ops));
diff --git a/src/include/catalog/pg_conversion.h b/src/include/catalog/pg_conversion.h
index fb26123aa9..b652cc9c8d 100644
--- a/src/include/catalog/pg_conversion.h
+++ b/src/include/catalog/pg_conversion.h
@@ -60,6 +60,9 @@ CATALOG(pg_conversion,2607,ConversionRelationId)
  */
 typedef FormData_pg_conversion *Form_pg_conversion;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_conversion_deform.h"
+
 DECLARE_UNIQUE_INDEX(pg_conversion_default_index, 2668, ConversionDefaultIndexId, on pg_conversion using btree(connamespace oid_ops, conforencoding int4_ops, contoencoding int4_ops, oid oid_ops));
 DECLARE_UNIQUE_INDEX(pg_conversion_name_nsp_index, 2669, ConversionNameNspIndexId, on pg_conversion using btree(conname name_ops, connamespace oid_ops));
 DECLARE_UNIQUE_INDEX_PKEY(pg_conversion_oid_index, 2670, ConversionOidIndexId, on pg_conversion using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h
index 611c95656a..b01375996a 100644
--- a/src/include/catalog/pg_database.h
+++ b/src/include/catalog/pg_database.h
@@ -86,6 +86,9 @@ CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID
  */
 typedef FormData_pg_database *Form_pg_database;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_database_deform.h"
+
 DECLARE_TOAST_WITH_MACRO(pg_database, 4177, 4178, PgDatabaseToastTable, PgDatabaseToastIndex);
 
 DECLARE_UNIQUE_INDEX(pg_database_datname_index, 2671, DatabaseNameIndexId, on pg_database using btree(datname name_ops));
diff --git a/src/include/catalog/pg_db_role_setting.h b/src/include/catalog/pg_db_role_setting.h
index 45d478e9e7..519d90dafb 100644
--- a/src/include/catalog/pg_db_role_setting.h
+++ b/src/include/catalog/pg_db_role_setting.h
@@ -46,6 +46,9 @@ CATALOG(pg_db_role_setting,2964,DbRoleSettingRelationId) BKI_SHARED_RELATION
 
 typedef FormData_pg_db_role_setting * Form_pg_db_role_setting;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_db_role_setting_deform.h"
+
 DECLARE_TOAST_WITH_MACRO(pg_db_role_setting, 2966, 2967, PgDbRoleSettingToastTable, PgDbRoleSettingToastIndex);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_db_role_setting_databaseid_rol_index, 2965, DbRoleSettingDatidRolidIndexId, on pg_db_role_setting using btree(setdatabase oid_ops, setrole oid_ops));
diff --git a/src/include/catalog/pg_default_acl.h b/src/include/catalog/pg_default_acl.h
index 2a79155636..ebd3323930 100644
--- a/src/include/catalog/pg_default_acl.h
+++ b/src/include/catalog/pg_default_acl.h
@@ -49,6 +49,9 @@ CATALOG(pg_default_acl,826,DefaultAclRelationId)
  */
 typedef FormData_pg_default_acl *Form_pg_default_acl;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_default_acl_deform.h"
+
 DECLARE_TOAST(pg_default_acl, 4143, 4144);
 
 DECLARE_UNIQUE_INDEX(pg_default_acl_role_nsp_obj_index, 827, DefaultAclRoleNspObjIndexId, on pg_default_acl using btree(defaclrole oid_ops, defaclnamespace oid_ops, defaclobjtype char_ops));
diff --git a/src/include/catalog/pg_depend.h b/src/include/catalog/pg_depend.h
index 2f736ecd6c..971718e5f2 100644
--- a/src/include/catalog/pg_depend.h
+++ b/src/include/catalog/pg_depend.h
@@ -71,6 +71,9 @@ CATALOG(pg_depend,2608,DependRelationId)
  */
 typedef FormData_pg_depend *Form_pg_depend;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_depend_deform.h"
+
 DECLARE_INDEX(pg_depend_depender_index, 2673, DependDependerIndexId, on pg_depend using btree(classid oid_ops, objid oid_ops, objsubid int4_ops));
 DECLARE_INDEX(pg_depend_reference_index, 2674, DependReferenceIndexId, on pg_depend using btree(refclassid oid_ops, refobjid oid_ops, refobjsubid int4_ops));
 
diff --git a/src/include/catalog/pg_description.h b/src/include/catalog/pg_description.h
index 67636ba926..0cb41eabf1 100644
--- a/src/include/catalog/pg_description.h
+++ b/src/include/catalog/pg_description.h
@@ -63,6 +63,9 @@ CATALOG(pg_description,2609,DescriptionRelationId)
  */
 typedef FormData_pg_description * Form_pg_description;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_description_deform.h"
+
 DECLARE_TOAST(pg_description, 2834, 2835);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_description_o_c_o_index, 2675, DescriptionObjIndexId, on pg_description using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops));
diff --git a/src/include/catalog/pg_enum.h b/src/include/catalog/pg_enum.h
index 9c6deddc6a..947368aa96 100644
--- a/src/include/catalog/pg_enum.h
+++ b/src/include/catalog/pg_enum.h
@@ -43,6 +43,9 @@ CATALOG(pg_enum,3501,EnumRelationId)
  */
 typedef FormData_pg_enum *Form_pg_enum;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_enum_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_enum_oid_index, 3502, EnumOidIndexId, on pg_enum using btree(oid oid_ops));
 DECLARE_UNIQUE_INDEX(pg_enum_typid_label_index, 3503, EnumTypIdLabelIndexId, on pg_enum using btree(enumtypid oid_ops, enumlabel name_ops));
 DECLARE_UNIQUE_INDEX(pg_enum_typid_sortorder_index, 3534, EnumTypIdSortOrderIndexId, on pg_enum using btree(enumtypid oid_ops, enumsortorder float4_ops));
diff --git a/src/include/catalog/pg_event_trigger.h b/src/include/catalog/pg_event_trigger.h
index 3fe0e8db78..ce3bcab135 100644
--- a/src/include/catalog/pg_event_trigger.h
+++ b/src/include/catalog/pg_event_trigger.h
@@ -49,6 +49,9 @@ CATALOG(pg_event_trigger,3466,EventTriggerRelationId)
  */
 typedef FormData_pg_event_trigger *Form_pg_event_trigger;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_event_trigger_deform.h"
+
 DECLARE_TOAST(pg_event_trigger, 4145, 4146);
 
 DECLARE_UNIQUE_INDEX(pg_event_trigger_evtname_index, 3467, EventTriggerNameIndexId, on pg_event_trigger using btree(evtname name_ops));
diff --git a/src/include/catalog/pg_extension.h b/src/include/catalog/pg_extension.h
index 43d16d4857..59aeb748a0 100644
--- a/src/include/catalog/pg_extension.h
+++ b/src/include/catalog/pg_extension.h
@@ -51,6 +51,9 @@ CATALOG(pg_extension,3079,ExtensionRelationId)
  */
 typedef FormData_pg_extension *Form_pg_extension;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_extension_deform.h"
+
 DECLARE_TOAST(pg_extension, 4147, 4148);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_extension_oid_index, 3080, ExtensionOidIndexId, on pg_extension using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_foreign_data_wrapper.h b/src/include/catalog/pg_foreign_data_wrapper.h
index 86db6546cc..1e1c73b8a9 100644
--- a/src/include/catalog/pg_foreign_data_wrapper.h
+++ b/src/include/catalog/pg_foreign_data_wrapper.h
@@ -50,6 +50,9 @@ CATALOG(pg_foreign_data_wrapper,2328,ForeignDataWrapperRelationId)
  */
 typedef FormData_pg_foreign_data_wrapper *Form_pg_foreign_data_wrapper;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_foreign_data_wrapper_deform.h"
+
 DECLARE_TOAST(pg_foreign_data_wrapper, 4149, 4150);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_foreign_data_wrapper_oid_index, 112, ForeignDataWrapperOidIndexId, on pg_foreign_data_wrapper using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_foreign_server.h b/src/include/catalog/pg_foreign_server.h
index dcef33de24..966853bf72 100644
--- a/src/include/catalog/pg_foreign_server.h
+++ b/src/include/catalog/pg_foreign_server.h
@@ -47,6 +47,9 @@ CATALOG(pg_foreign_server,1417,ForeignServerRelationId)
  */
 typedef FormData_pg_foreign_server *Form_pg_foreign_server;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_foreign_server_deform.h"
+
 DECLARE_TOAST(pg_foreign_server, 4151, 4152);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_foreign_server_oid_index, 113, ForeignServerOidIndexId, on pg_foreign_server using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_foreign_table.h b/src/include/catalog/pg_foreign_table.h
index 88753cd5f8..4d9101e248 100644
--- a/src/include/catalog/pg_foreign_table.h
+++ b/src/include/catalog/pg_foreign_table.h
@@ -42,6 +42,9 @@ CATALOG(pg_foreign_table,3118,ForeignTableRelationId)
  */
 typedef FormData_pg_foreign_table *Form_pg_foreign_table;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_foreign_table_deform.h"
+
 DECLARE_TOAST(pg_foreign_table, 4153, 4154);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_foreign_table_relid_index, 3119, ForeignTableRelidIndexId, on pg_foreign_table using btree(ftrelid oid_ops));
diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h
index f853846ee1..99903d8eff 100644
--- a/src/include/catalog/pg_index.h
+++ b/src/include/catalog/pg_index.h
@@ -69,6 +69,9 @@ CATALOG(pg_index,2610,IndexRelationId) BKI_SCHEMA_MACRO
  */
 typedef FormData_pg_index *Form_pg_index;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_index_deform.h"
+
 DECLARE_INDEX(pg_index_indrelid_index, 2678, IndexIndrelidIndexId, on pg_index using btree(indrelid oid_ops));
 DECLARE_UNIQUE_INDEX_PKEY(pg_index_indexrelid_index, 2679, IndexRelidIndexId, on pg_index using btree(indexrelid oid_ops));
 
diff --git a/src/include/catalog/pg_inherits.h b/src/include/catalog/pg_inherits.h
index b5a32755a6..c8a25994b7 100644
--- a/src/include/catalog/pg_inherits.h
+++ b/src/include/catalog/pg_inherits.h
@@ -44,6 +44,9 @@ CATALOG(pg_inherits,2611,InheritsRelationId)
  */
 typedef FormData_pg_inherits *Form_pg_inherits;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_inherits_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_inherits_relid_seqno_index, 2680, InheritsRelidSeqnoIndexId, on pg_inherits using btree(inhrelid oid_ops, inhseqno int4_ops));
 DECLARE_INDEX(pg_inherits_parent_index, 2187, InheritsParentIndexId, on pg_inherits using btree(inhparent oid_ops));
 
diff --git a/src/include/catalog/pg_init_privs.h b/src/include/catalog/pg_init_privs.h
index c226edc4a4..9697053907 100644
--- a/src/include/catalog/pg_init_privs.h
+++ b/src/include/catalog/pg_init_privs.h
@@ -63,6 +63,9 @@ CATALOG(pg_init_privs,3394,InitPrivsRelationId)
  */
 typedef FormData_pg_init_privs * Form_pg_init_privs;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_init_privs_deform.h"
+
 DECLARE_TOAST(pg_init_privs, 4155, 4156);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_init_privs_o_c_o_index, 3395, InitPrivsObjIndexId, on pg_init_privs using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops));
diff --git a/src/include/catalog/pg_language.h b/src/include/catalog/pg_language.h
index 4b9c259554..8a7dd7eddc 100644
--- a/src/include/catalog/pg_language.h
+++ b/src/include/catalog/pg_language.h
@@ -64,6 +64,9 @@ CATALOG(pg_language,2612,LanguageRelationId)
  */
 typedef FormData_pg_language *Form_pg_language;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_language_deform.h"
+
 DECLARE_TOAST(pg_language, 4157, 4158);
 
 DECLARE_UNIQUE_INDEX(pg_language_name_index, 2681, LanguageNameIndexId, on pg_language using btree(lanname name_ops));
diff --git a/src/include/catalog/pg_largeobject.h b/src/include/catalog/pg_largeobject.h
index 1fd076d799..c1cf040e00 100644
--- a/src/include/catalog/pg_largeobject.h
+++ b/src/include/catalog/pg_largeobject.h
@@ -44,6 +44,9 @@ CATALOG(pg_largeobject,2613,LargeObjectRelationId)
  */
 typedef FormData_pg_largeobject *Form_pg_largeobject;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_largeobject_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_largeobject_loid_pn_index, 2683, LargeObjectLOidPNIndexId, on pg_largeobject using btree(loid oid_ops, pageno int4_ops));
 
 extern Oid	LargeObjectCreate(Oid loid);
diff --git a/src/include/catalog/pg_largeobject_metadata.h b/src/include/catalog/pg_largeobject_metadata.h
index ec1c3bf755..22b9b732a9 100644
--- a/src/include/catalog/pg_largeobject_metadata.h
+++ b/src/include/catalog/pg_largeobject_metadata.h
@@ -46,6 +46,9 @@ CATALOG(pg_largeobject_metadata,2995,LargeObjectMetadataRelationId)
  */
 typedef FormData_pg_largeobject_metadata *Form_pg_largeobject_metadata;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_largeobject_metadata_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_largeobject_metadata_oid_index, 2996, LargeObjectMetadataOidIndexId, on pg_largeobject_metadata using btree(oid oid_ops));
 
 #endif							/* PG_LARGEOBJECT_METADATA_H */
diff --git a/src/include/catalog/pg_namespace.h b/src/include/catalog/pg_namespace.h
index ba56e44d61..d220737615 100644
--- a/src/include/catalog/pg_namespace.h
+++ b/src/include/catalog/pg_namespace.h
@@ -51,6 +51,9 @@ CATALOG(pg_namespace,2615,NamespaceRelationId)
  */
 typedef FormData_pg_namespace *Form_pg_namespace;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_namespace_deform.h"
+
 DECLARE_TOAST(pg_namespace, 4163, 4164);
 
 DECLARE_UNIQUE_INDEX(pg_namespace_nspname_index, 2684, NamespaceNameIndexId, on pg_namespace using btree(nspname name_ops));
diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h
index 3a3a19b83b..91faa3eebf 100644
--- a/src/include/catalog/pg_opclass.h
+++ b/src/include/catalog/pg_opclass.h
@@ -82,6 +82,9 @@ CATALOG(pg_opclass,2616,OperatorClassRelationId)
  */
 typedef FormData_pg_opclass *Form_pg_opclass;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_opclass_deform.h"
+
 DECLARE_UNIQUE_INDEX(pg_opclass_am_name_nsp_index, 2686, OpclassAmNameNspIndexId, on pg_opclass using btree(opcmethod oid_ops, opcname name_ops, opcnamespace oid_ops));
 DECLARE_UNIQUE_INDEX_PKEY(pg_opclass_oid_index, 2687, OpclassOidIndexId, on pg_opclass using btree(oid oid_ops));
 
diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h
index 51263f550f..873b4f73d7 100644
--- a/src/include/catalog/pg_operator.h
+++ b/src/include/catalog/pg_operator.h
@@ -82,6 +82,9 @@ CATALOG(pg_operator,2617,OperatorRelationId)
  */
 typedef FormData_pg_operator *Form_pg_operator;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_operator_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_operator_oid_index, 2688, OperatorOidIndexId, on pg_operator using btree(oid oid_ops));
 DECLARE_UNIQUE_INDEX(pg_operator_oprname_l_r_n_index, 2689, OperatorNameNspIndexId, on pg_operator using btree(oprname name_ops, oprleft oid_ops, oprright oid_ops, oprnamespace oid_ops));
 
diff --git a/src/include/catalog/pg_opfamily.h b/src/include/catalog/pg_opfamily.h
index 8dc9ce01bb..7339fd9cd2 100644
--- a/src/include/catalog/pg_opfamily.h
+++ b/src/include/catalog/pg_opfamily.h
@@ -50,6 +50,9 @@ CATALOG(pg_opfamily,2753,OperatorFamilyRelationId)
  */
 typedef FormData_pg_opfamily *Form_pg_opfamily;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_opfamily_deform.h"
+
 DECLARE_UNIQUE_INDEX(pg_opfamily_am_name_nsp_index, 2754, OpfamilyAmNameNspIndexId, on pg_opfamily using btree(opfmethod oid_ops, opfname name_ops, opfnamespace oid_ops));
 DECLARE_UNIQUE_INDEX_PKEY(pg_opfamily_oid_index, 2755, OpfamilyOidIndexId, on pg_opfamily using btree(oid oid_ops));
 
diff --git a/src/include/catalog/pg_parameter_acl.h b/src/include/catalog/pg_parameter_acl.h
index 4bd52c2d7d..210fd7b2b8 100644
--- a/src/include/catalog/pg_parameter_acl.h
+++ b/src/include/catalog/pg_parameter_acl.h
@@ -48,6 +48,9 @@ CATALOG(pg_parameter_acl,6243,ParameterAclRelationId) BKI_SHARED_RELATION
  */
 typedef FormData_pg_parameter_acl * Form_pg_parameter_acl;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_parameter_acl_deform.h"
+
 DECLARE_TOAST_WITH_MACRO(pg_parameter_acl, 6244, 6245, PgParameterAclToastTable, PgParameterAclToastIndex);
 
 DECLARE_UNIQUE_INDEX(pg_parameter_acl_parname_index, 6246, ParameterAclParnameIndexId, on pg_parameter_acl using btree(parname text_ops));
diff --git a/src/include/catalog/pg_partitioned_table.h b/src/include/catalog/pg_partitioned_table.h
index 9b78f84cd5..f2fd24794d 100644
--- a/src/include/catalog/pg_partitioned_table.h
+++ b/src/include/catalog/pg_partitioned_table.h
@@ -64,6 +64,9 @@ CATALOG(pg_partitioned_table,3350,PartitionedRelationId)
  */
 typedef FormData_pg_partitioned_table *Form_pg_partitioned_table;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_partitioned_table_deform.h"
+
 DECLARE_TOAST(pg_partitioned_table, 4165, 4166);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_partitioned_table_partrelid_index, 3351, PartitionedRelidIndexId, on pg_partitioned_table using btree(partrelid oid_ops));
diff --git a/src/include/catalog/pg_policy.h b/src/include/catalog/pg_policy.h
index 56b0ea100b..3c294d04f1 100644
--- a/src/include/catalog/pg_policy.h
+++ b/src/include/catalog/pg_policy.h
@@ -50,6 +50,9 @@ CATALOG(pg_policy,3256,PolicyRelationId)
  */
 typedef FormData_pg_policy *Form_pg_policy;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_policy_deform.h"
+
 DECLARE_TOAST(pg_policy, 4167, 4168);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_policy_oid_index, 3257, PolicyOidIndexId, on pg_policy using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 76310d4cc9..362edeac08 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -135,6 +135,9 @@ CATALOG(pg_proc,1255,ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81,Proce
  */
 typedef FormData_pg_proc *Form_pg_proc;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_proc_deform.h"
+
 DECLARE_TOAST(pg_proc, 2836, 2837);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_proc_oid_index, 2690, ProcedureOidIndexId, on pg_proc using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.h
index 48205ba429..11106a7227 100644
--- a/src/include/catalog/pg_publication.h
+++ b/src/include/catalog/pg_publication.h
@@ -63,6 +63,9 @@ CATALOG(pg_publication,6104,PublicationRelationId)
  */
 typedef FormData_pg_publication *Form_pg_publication;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_publication_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_publication_oid_index, 6110, PublicationObjectIndexId, on pg_publication using btree(oid oid_ops));
 DECLARE_UNIQUE_INDEX(pg_publication_pubname_index, 6111, PublicationNameIndexId, on pg_publication using btree(pubname name_ops));
 
diff --git a/src/include/catalog/pg_publication_namespace.h b/src/include/catalog/pg_publication_namespace.h
index d166600b26..930050358f 100644
--- a/src/include/catalog/pg_publication_namespace.h
+++ b/src/include/catalog/pg_publication_namespace.h
@@ -41,6 +41,9 @@ CATALOG(pg_publication_namespace,6237,PublicationNamespaceRelationId)
  */
 typedef FormData_pg_publication_namespace *Form_pg_publication_namespace;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_publication_namespace_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_publication_namespace_oid_index, 6238, PublicationNamespaceObjectIndexId, on pg_publication_namespace using btree(oid oid_ops));
 DECLARE_UNIQUE_INDEX(pg_publication_namespace_pnnspid_pnpubid_index, 6239, PublicationNamespacePnnspidPnpubidIndexId, on pg_publication_namespace using btree(pnnspid oid_ops, pnpubid oid_ops));
 
diff --git a/src/include/catalog/pg_publication_rel.h b/src/include/catalog/pg_publication_rel.h
index ecd3739f1a..c0cd7dc555 100644
--- a/src/include/catalog/pg_publication_rel.h
+++ b/src/include/catalog/pg_publication_rel.h
@@ -45,6 +45,9 @@ CATALOG(pg_publication_rel,6106,PublicationRelRelationId)
  */
 typedef FormData_pg_publication_rel *Form_pg_publication_rel;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_publication_rel_deform.h"
+
 DECLARE_TOAST(pg_publication_rel, 6228, 6229);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_publication_rel_oid_index, 6112, PublicationRelObjectIndexId, on pg_publication_rel using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_range.h b/src/include/catalog/pg_range.h
index faa57e8cea..a1979f7484 100644
--- a/src/include/catalog/pg_range.h
+++ b/src/include/catalog/pg_range.h
@@ -57,6 +57,9 @@ CATALOG(pg_range,3541,RangeRelationId)
  */
 typedef FormData_pg_range *Form_pg_range;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_range_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_range_rngtypid_index, 3542, RangeTypidIndexId, on pg_range using btree(rngtypid oid_ops));
 DECLARE_UNIQUE_INDEX(pg_range_rngmultitypid_index, 2228, RangeMultirangeTypidIndexId, on pg_range using btree(rngmultitypid oid_ops));
 
diff --git a/src/include/catalog/pg_replication_origin.h b/src/include/catalog/pg_replication_origin.h
index 3b11cd21cb..7eb9063ac0 100644
--- a/src/include/catalog/pg_replication_origin.h
+++ b/src/include/catalog/pg_replication_origin.h
@@ -54,6 +54,9 @@ CATALOG(pg_replication_origin,6000,ReplicationOriginRelationId) BKI_SHARED_RELAT
 
 typedef FormData_pg_replication_origin *Form_pg_replication_origin;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_replication_origin_deform.h"
+
 DECLARE_TOAST_WITH_MACRO(pg_replication_origin, 4181, 4182, PgReplicationOriginToastTable, PgReplicationOriginToastIndex);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_replication_origin_roiident_index, 6001, ReplicationOriginIdentIndex, on pg_replication_origin using btree(roident oid_ops));
diff --git a/src/include/catalog/pg_rewrite.h b/src/include/catalog/pg_rewrite.h
index c647f26aca..cace6f2a28 100644
--- a/src/include/catalog/pg_rewrite.h
+++ b/src/include/catalog/pg_rewrite.h
@@ -51,6 +51,9 @@ CATALOG(pg_rewrite,2618,RewriteRelationId)
  */
 typedef FormData_pg_rewrite *Form_pg_rewrite;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_rewrite_deform.h"
+
 DECLARE_TOAST(pg_rewrite, 2838, 2839);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_rewrite_oid_index, 2692, RewriteOidIndexId, on pg_rewrite using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_sequence.h b/src/include/catalog/pg_sequence.h
index 82b35aa65b..946d336174 100644
--- a/src/include/catalog/pg_sequence.h
+++ b/src/include/catalog/pg_sequence.h
@@ -39,6 +39,9 @@ CATALOG(pg_sequence,2224,SequenceRelationId)
  */
 typedef FormData_pg_sequence *Form_pg_sequence;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_sequence_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_sequence_seqrelid_index, 5002, SequenceRelidIndexId, on pg_sequence using btree(seqrelid oid_ops));
 
 #endif							/* PG_SEQUENCE_H */
diff --git a/src/include/catalog/pg_shdepend.h b/src/include/catalog/pg_shdepend.h
index 8119b28e44..68e5fc2021 100644
--- a/src/include/catalog/pg_shdepend.h
+++ b/src/include/catalog/pg_shdepend.h
@@ -72,6 +72,9 @@ CATALOG(pg_shdepend,1214,SharedDependRelationId) BKI_SHARED_RELATION
  */
 typedef FormData_pg_shdepend *Form_pg_shdepend;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_shdepend_deform.h"
+
 DECLARE_INDEX(pg_shdepend_depender_index, 1232, SharedDependDependerIndexId, on pg_shdepend using btree(dbid oid_ops, classid oid_ops, objid oid_ops, objsubid int4_ops));
 DECLARE_INDEX(pg_shdepend_reference_index, 1233, SharedDependReferenceIndexId, on pg_shdepend using btree(refclassid oid_ops, refobjid oid_ops));
 
diff --git a/src/include/catalog/pg_shdescription.h b/src/include/catalog/pg_shdescription.h
index da2b9f6fdf..5bd5d777f8 100644
--- a/src/include/catalog/pg_shdescription.h
+++ b/src/include/catalog/pg_shdescription.h
@@ -55,6 +55,9 @@ CATALOG(pg_shdescription,2396,SharedDescriptionRelationId) BKI_SHARED_RELATION
  */
 typedef FormData_pg_shdescription * Form_pg_shdescription;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_shdescription_deform.h"
+
 DECLARE_TOAST_WITH_MACRO(pg_shdescription, 2846, 2847, PgShdescriptionToastTable, PgShdescriptionToastIndex);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_shdescription_o_c_index, 2397, SharedDescriptionObjIndexId, on pg_shdescription using btree(objoid oid_ops, classoid oid_ops));
diff --git a/src/include/catalog/pg_shseclabel.h b/src/include/catalog/pg_shseclabel.h
index fc1b97f46f..6cc96bc66e 100644
--- a/src/include/catalog/pg_shseclabel.h
+++ b/src/include/catalog/pg_shseclabel.h
@@ -39,6 +39,9 @@ CATALOG(pg_shseclabel,3592,SharedSecLabelRelationId) BKI_SHARED_RELATION BKI_ROW
 
 typedef FormData_pg_shseclabel * Form_pg_shseclabel;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_shseclabel_deform.h"
+
 DECLARE_TOAST_WITH_MACRO(pg_shseclabel, 4060, 4061, PgShseclabelToastTable, PgShseclabelToastIndex);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_shseclabel_object_index, 3593, SharedSecLabelObjectIndexId, on pg_shseclabel using btree(objoid oid_ops, classoid oid_ops, provider text_ops));
diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h
index cdf7448139..dd1c324af8 100644
--- a/src/include/catalog/pg_statistic.h
+++ b/src/include/catalog/pg_statistic.h
@@ -134,6 +134,9 @@ CATALOG(pg_statistic,2619,StatisticRelationId)
  */
 typedef FormData_pg_statistic *Form_pg_statistic;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_statistic_deform.h"
+
 DECLARE_TOAST(pg_statistic, 2840, 2841);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_statistic_relid_att_inh_index, 2696, StatisticRelidAttnumInhIndexId, on pg_statistic using btree(starelid oid_ops, staattnum int2_ops, stainherit bool_ops));
diff --git a/src/include/catalog/pg_statistic_ext.h b/src/include/catalog/pg_statistic_ext.h
index b8520ba923..d3b0ae8fde 100644
--- a/src/include/catalog/pg_statistic_ext.h
+++ b/src/include/catalog/pg_statistic_ext.h
@@ -68,6 +68,9 @@ CATALOG(pg_statistic_ext,3381,StatisticExtRelationId)
  */
 typedef FormData_pg_statistic_ext *Form_pg_statistic_ext;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_statistic_ext_deform.h"
+
 DECLARE_TOAST(pg_statistic_ext, 3439, 3440);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_statistic_ext_oid_index, 3380, StatisticExtOidIndexId, on pg_statistic_ext using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_statistic_ext_data.h b/src/include/catalog/pg_statistic_ext_data.h
index 0ea3c41b5b..dc4461a0cf 100644
--- a/src/include/catalog/pg_statistic_ext_data.h
+++ b/src/include/catalog/pg_statistic_ext_data.h
@@ -52,6 +52,9 @@ CATALOG(pg_statistic_ext_data,3429,StatisticExtDataRelationId)
  */
 typedef FormData_pg_statistic_ext_data *Form_pg_statistic_ext_data;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_statistic_ext_data_deform.h"
+
 DECLARE_TOAST(pg_statistic_ext_data, 3430, 3431);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_statistic_ext_data_stxoid_inh_index, 3433, StatisticExtDataStxoidInhIndexId, on pg_statistic_ext_data using btree(stxoid oid_ops, stxdinherit bool_ops));
diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_subscription.h
index d1260f590c..b3e136e64b 100644
--- a/src/include/catalog/pg_subscription.h
+++ b/src/include/catalog/pg_subscription.h
@@ -92,6 +92,9 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
 
 typedef FormData_pg_subscription *Form_pg_subscription;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_subscription_deform.h"
+
 DECLARE_TOAST_WITH_MACRO(pg_subscription, 4183, 4184, PgSubscriptionToastTable, PgSubscriptionToastIndex);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_oid_index, 6114, SubscriptionObjectIndexId, on pg_subscription using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_subscription_rel.h b/src/include/catalog/pg_subscription_rel.h
index 9df99c3418..0ff6a25882 100644
--- a/src/include/catalog/pg_subscription_rel.h
+++ b/src/include/catalog/pg_subscription_rel.h
@@ -49,6 +49,9 @@ CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
 
 typedef FormData_pg_subscription_rel *Form_pg_subscription_rel;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_subscription_rel_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_rel_srrelid_srsubid_index, 6117, SubscriptionRelSrrelidSrsubidIndexId, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
 
 #ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/catalog/pg_tablespace.h b/src/include/catalog/pg_tablespace.h
index 572eeeb8a6..74a766f001 100644
--- a/src/include/catalog/pg_tablespace.h
+++ b/src/include/catalog/pg_tablespace.h
@@ -47,6 +47,9 @@ CATALOG(pg_tablespace,1213,TableSpaceRelationId) BKI_SHARED_RELATION
  */
 typedef FormData_pg_tablespace *Form_pg_tablespace;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_tablespace_deform.h"
+
 DECLARE_TOAST_WITH_MACRO(pg_tablespace, 4185, 4186, PgTablespaceToastTable, PgTablespaceToastIndex);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_tablespace_oid_index, 2697, TablespaceOidIndexId, on pg_tablespace using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_transform.h b/src/include/catalog/pg_transform.h
index 2a02691510..665e4d0165 100644
--- a/src/include/catalog/pg_transform.h
+++ b/src/include/catalog/pg_transform.h
@@ -42,6 +42,9 @@ CATALOG(pg_transform,3576,TransformRelationId)
  */
 typedef FormData_pg_transform *Form_pg_transform;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_transform_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_transform_oid_index, 3574, TransformOidIndexId, on pg_transform using btree(oid oid_ops));
 DECLARE_UNIQUE_INDEX(pg_transform_type_lang_index, 3575, TransformTypeLangIndexId, on pg_transform using btree(trftype oid_ops, trflang oid_ops));
 
diff --git a/src/include/catalog/pg_trigger.h b/src/include/catalog/pg_trigger.h
index 194277bca5..bbf6569766 100644
--- a/src/include/catalog/pg_trigger.h
+++ b/src/include/catalog/pg_trigger.h
@@ -79,6 +79,9 @@ CATALOG(pg_trigger,2620,TriggerRelationId)
  */
 typedef FormData_pg_trigger *Form_pg_trigger;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_trigger_deform.h"
+
 DECLARE_TOAST(pg_trigger, 2336, 2337);
 
 DECLARE_INDEX(pg_trigger_tgconstraint_index, 2699, TriggerConstraintIndexId, on pg_trigger using btree(tgconstraint oid_ops));
diff --git a/src/include/catalog/pg_ts_config.h b/src/include/catalog/pg_ts_config.h
index e5a308475c..6d85628b64 100644
--- a/src/include/catalog/pg_ts_config.h
+++ b/src/include/catalog/pg_ts_config.h
@@ -47,6 +47,9 @@ CATALOG(pg_ts_config,3602,TSConfigRelationId)
 
 typedef FormData_pg_ts_config *Form_pg_ts_config;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_config_deform.h"
+
 DECLARE_UNIQUE_INDEX(pg_ts_config_cfgname_index, 3608, TSConfigNameNspIndexId, on pg_ts_config using btree(cfgname name_ops, cfgnamespace oid_ops));
 DECLARE_UNIQUE_INDEX_PKEY(pg_ts_config_oid_index, 3712, TSConfigOidIndexId, on pg_ts_config using btree(oid oid_ops));
 
diff --git a/src/include/catalog/pg_ts_config_map.h b/src/include/catalog/pg_ts_config_map.h
index c10e0c5164..fa4fa584db 100644
--- a/src/include/catalog/pg_ts_config_map.h
+++ b/src/include/catalog/pg_ts_config_map.h
@@ -44,6 +44,9 @@ CATALOG(pg_ts_config_map,3603,TSConfigMapRelationId)
 
 typedef FormData_pg_ts_config_map *Form_pg_ts_config_map;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_config_map_deform.h"
+
 DECLARE_UNIQUE_INDEX_PKEY(pg_ts_config_map_index, 3609, TSConfigMapIndexId, on pg_ts_config_map using btree(mapcfg oid_ops, maptokentype int4_ops, mapseqno int4_ops));
 
 #endif							/* PG_TS_CONFIG_MAP_H */
diff --git a/src/include/catalog/pg_ts_dict.h b/src/include/catalog/pg_ts_dict.h
index 4b6188f4fa..6311d702c0 100644
--- a/src/include/catalog/pg_ts_dict.h
+++ b/src/include/catalog/pg_ts_dict.h
@@ -51,6 +51,9 @@ CATALOG(pg_ts_dict,3600,TSDictionaryRelationId)
 
 typedef FormData_pg_ts_dict *Form_pg_ts_dict;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_dict_deform.h"
+
 DECLARE_TOAST(pg_ts_dict, 4169, 4170);
 
 DECLARE_UNIQUE_INDEX(pg_ts_dict_dictname_index, 3604, TSDictionaryNameNspIndexId, on pg_ts_dict using btree(dictname name_ops, dictnamespace oid_ops));
diff --git a/src/include/catalog/pg_ts_parser.h b/src/include/catalog/pg_ts_parser.h
index c2d474dca7..4f2602ccac 100644
--- a/src/include/catalog/pg_ts_parser.h
+++ b/src/include/catalog/pg_ts_parser.h
@@ -54,6 +54,9 @@ CATALOG(pg_ts_parser,3601,TSParserRelationId)
 
 typedef FormData_pg_ts_parser *Form_pg_ts_parser;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_parser_deform.h"
+
 DECLARE_UNIQUE_INDEX(pg_ts_parser_prsname_index, 3606, TSParserNameNspIndexId, on pg_ts_parser using btree(prsname name_ops, prsnamespace oid_ops));
 DECLARE_UNIQUE_INDEX_PKEY(pg_ts_parser_oid_index, 3607, TSParserOidIndexId, on pg_ts_parser using btree(oid oid_ops));
 
diff --git a/src/include/catalog/pg_ts_template.h b/src/include/catalog/pg_ts_template.h
index 2a553fef52..f30f5008dc 100644
--- a/src/include/catalog/pg_ts_template.h
+++ b/src/include/catalog/pg_ts_template.h
@@ -45,6 +45,9 @@ CATALOG(pg_ts_template,3764,TSTemplateRelationId)
 
 typedef FormData_pg_ts_template *Form_pg_ts_template;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_ts_template_deform.h"
+
 DECLARE_UNIQUE_INDEX(pg_ts_template_tmplname_index, 3766, TSTemplateNameNspIndexId, on pg_ts_template using btree(tmplname name_ops, tmplnamespace oid_ops));
 DECLARE_UNIQUE_INDEX_PKEY(pg_ts_template_oid_index, 3767, TSTemplateOidIndexId, on pg_ts_template using btree(oid oid_ops));
 
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index 48a2559137..e31425a2a5 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -260,6 +260,9 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
  */
 typedef FormData_pg_type *Form_pg_type;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_type_deform.h"
+
 DECLARE_TOAST(pg_type, 4171, 4172);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_type_oid_index, 2703, TypeOidIndexId, on pg_type using btree(oid oid_ops));
diff --git a/src/include/catalog/pg_user_mapping.h b/src/include/catalog/pg_user_mapping.h
index 56150611be..2f29c6dd23 100644
--- a/src/include/catalog/pg_user_mapping.h
+++ b/src/include/catalog/pg_user_mapping.h
@@ -47,6 +47,9 @@ CATALOG(pg_user_mapping,1418,UserMappingRelationId)
  */
 typedef FormData_pg_user_mapping *Form_pg_user_mapping;
 
+/* now that we've defined the struct type, include the deform function */
+#include "catalog/pg_user_mapping_deform.h"
+
 DECLARE_TOAST(pg_user_mapping, 4173, 4174);
 
 DECLARE_UNIQUE_INDEX_PKEY(pg_user_mapping_oid_index, 174, UserMappingOidIndexId, on pg_user_mapping using btree(oid oid_ops));
diff --git a/src/include/commands/sequence.h b/src/include/commands/sequence.h
index d38c0e2388..a3876de82b 100644
--- a/src/include/commands/sequence.h
+++ b/src/include/commands/sequence.h
@@ -31,6 +31,9 @@ typedef struct FormData_pg_sequence_data
 
 typedef FormData_pg_sequence_data *Form_pg_sequence_data;
 
+/* this is not a real catalog, so define by hand */
+#define Deform_pg_sequence_data_tuple(TUP) (Form_pg_sequence_data) (TUP)
+
 /*
  * Columns of a sequence relation
  */
-- 
2.36.1

