Commit b4c9695e authored by Peter Eisentraut's avatar Peter Eisentraut

Move catalog toast table declarations

Move the system catalog toast table declarations from
catalog/toasting.h to the respective parent tables' catalog/pg_*.h
files.  The original reason for having it split was that the old
genbki system produced the output in the order of the catalog files it
read, so all the toasting stuff needed to come separately.  But this
is no longer the case, and keeping it together makes more sense.
Reviewed-by: default avatarJohn Naylor <john.naylor@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/flat/c7cc82d6-f976-75d6-2e3e-b03d2cab26bb@2ndquadrant.com
parent 623644f0
......@@ -24,8 +24,7 @@
the catalog has, as well as some other basic properties such as its OID.
Other critical files defining the catalog structure
include <filename>indexing.h</filename>, which defines the indexes present
on all the system catalogs, and <filename>toasting.h</filename>, which
defines TOAST tables for catalogs that need one.
on all the system catalogs.
</para>
<para>
......
......@@ -72,11 +72,8 @@ CATALOG_HEADERS := \
GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h
# In the list of headers used to assemble postgres.bki, indexing.h needs
# be last, and toasting.h just before it. This ensures we don't try to
# create indexes or toast tables before their catalogs exist.
POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,\
$(CATALOG_HEADERS) toasting.h indexing.h \
$(CATALOG_HEADERS) indexing.h \
)
# The .dat files we need can just be listed alphabetically.
......
......@@ -40,7 +40,6 @@
#include "catalog/pg_subscription.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "catalog/toasting.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include "utils/fmgroids.h"
......@@ -268,7 +267,7 @@ IsSharedRelation(Oid relationId)
relationId == SubscriptionObjectIndexId ||
relationId == SubscriptionNameIndexId)
return true;
/* These are their toast tables and toast indexes (see toasting.h) */
/* These are their toast tables and toast indexes */
if (relationId == PgAuthidToastTable ||
relationId == PgAuthidToastIndex ||
relationId == PgDatabaseToastTable ||
......
......@@ -391,7 +391,7 @@ needs_toast_table(Relation rel)
/*
* Ignore attempts to create toast tables on catalog tables after initdb.
* Which catalogs get toast tables is explicitly chosen in
* catalog/toasting.h. (We could get here via some ALTER TABLE command if
* catalog/pg_*.h. (We could get here via some ALTER TABLE command if
* the catalog doesn't have a toast table.)
*/
if (IsCatalogRelation(rel) && !IsBootstrapProcessingMode())
......
......@@ -26,7 +26,7 @@ chdir $FindBin::RealBin or die "could not cd to $FindBin::RealBin: $!\n";
use lib "$FindBin::RealBin/../../backend/catalog/";
use Catalog;
my @input_files = (glob("pg_*.h"), qw(indexing.h toasting.h));
my @input_files = (glob("pg_*.h"), qw(indexing.h));
my $oids = Catalog::FindAllOidsFromHeaders(@input_files);
......
......@@ -41,6 +41,19 @@
*/
#define BKI_LOOKUP(catalog)
/*
* These lines are processed by genbki.pl to create the statements
* the bootstrap parser will turn into BootstrapToastTable commands.
* Each line specifies the system catalog that needs a toast table,
* 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.
*
* The macro definition is just to keep the C compiler from spitting up.
*/
#define DECLARE_TOAST(name,toastoid,indexoid) extern int no_such_variable
/* The following are never defined; they are here only for documentation. */
/*
......
......@@ -108,6 +108,8 @@ CATALOG(pg_aggregate,2600,AggregateRelationId)
*/
typedef FormData_pg_aggregate *Form_pg_aggregate;
DECLARE_TOAST(pg_aggregate, 4159, 4160);
#ifdef EXPOSE_TO_CLIENT_CODE
/*
......
......@@ -46,4 +46,6 @@ CATALOG(pg_attrdef,2604,AttrDefaultRelationId)
*/
typedef FormData_pg_attrdef *Form_pg_attrdef;
DECLARE_TOAST(pg_attrdef, 2830, 2831);
#endif /* PG_ATTRDEF_H */
......@@ -55,4 +55,8 @@ CATALOG(pg_authid,1260,AuthIdRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(284
*/
typedef FormData_pg_authid *Form_pg_authid;
DECLARE_TOAST(pg_authid, 4175, 4176);
#define PgAuthidToastTable 4175
#define PgAuthidToastIndex 4176
#endif /* PG_AUTHID_H */
......@@ -153,6 +153,8 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
*/
typedef FormData_pg_constraint *Form_pg_constraint;
DECLARE_TOAST(pg_constraint, 2832, 2833);
#ifdef EXPOSE_TO_CLIENT_CODE
/* Valid values for contype */
......
......@@ -80,4 +80,8 @@ CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID
*/
typedef FormData_pg_database *Form_pg_database;
DECLARE_TOAST(pg_database, 4177, 4178);
#define PgDatabaseToastTable 4177
#define PgDatabaseToastIndex 4178
#endif /* PG_DATABASE_H */
......@@ -43,6 +43,10 @@ CATALOG(pg_db_role_setting,2964,DbRoleSettingRelationId) BKI_SHARED_RELATION
typedef FormData_pg_db_role_setting * Form_pg_db_role_setting;
DECLARE_TOAST(pg_db_role_setting, 2966, 2967);
#define PgDbRoleSettingToastTable 2966
#define PgDbRoleSettingToastIndex 2967
/*
* prototypes for functions in pg_db_role_setting.h
*/
......
......@@ -47,6 +47,8 @@ CATALOG(pg_default_acl,826,DefaultAclRelationId)
*/
typedef FormData_pg_default_acl *Form_pg_default_acl;
DECLARE_TOAST(pg_default_acl, 4143, 4144);
#ifdef EXPOSE_TO_CLIENT_CODE
/*
......
......@@ -73,4 +73,6 @@ CATALOG(pg_depend,2608,DependRelationId)
*/
typedef FormData_pg_depend *Form_pg_depend;
DECLARE_TOAST(pg_depend, 8888, 8889);
#endif /* PG_DEPEND_H */
......@@ -63,4 +63,6 @@ CATALOG(pg_description,2609,DescriptionRelationId)
*/
typedef FormData_pg_description * Form_pg_description;
DECLARE_TOAST(pg_description, 2834, 2835);
#endif /* PG_DESCRIPTION_H */
......@@ -48,4 +48,6 @@ CATALOG(pg_event_trigger,3466,EventTriggerRelationId)
*/
typedef FormData_pg_event_trigger *Form_pg_event_trigger;
DECLARE_TOAST(pg_event_trigger, 4145, 4146);
#endif /* PG_EVENT_TRIGGER_H */
......@@ -49,4 +49,6 @@ CATALOG(pg_extension,3079,ExtensionRelationId)
*/
typedef FormData_pg_extension *Form_pg_extension;
DECLARE_TOAST(pg_extension, 4147, 4148);
#endif /* PG_EXTENSION_H */
......@@ -47,4 +47,6 @@ CATALOG(pg_foreign_data_wrapper,2328,ForeignDataWrapperRelationId)
*/
typedef FormData_pg_foreign_data_wrapper *Form_pg_foreign_data_wrapper;
DECLARE_TOAST(pg_foreign_data_wrapper, 4149, 4150);
#endif /* PG_FOREIGN_DATA_WRAPPER_H */
......@@ -47,4 +47,6 @@ CATALOG(pg_foreign_server,1417,ForeignServerRelationId)
*/
typedef FormData_pg_foreign_server *Form_pg_foreign_server;
DECLARE_TOAST(pg_foreign_server, 4151, 4152);
#endif /* PG_FOREIGN_SERVER_H */
......@@ -42,4 +42,6 @@ CATALOG(pg_foreign_table,3118,ForeignTableRelationId)
*/
typedef FormData_pg_foreign_table *Form_pg_foreign_table;
DECLARE_TOAST(pg_foreign_table, 4153, 4154);
#endif /* PG_FOREIGN_TABLE_H */
......@@ -62,6 +62,8 @@ CATALOG(pg_init_privs,3394,InitPrivsRelationId)
*/
typedef FormData_pg_init_privs * Form_pg_init_privs;
DECLARE_TOAST(pg_init_privs, 4155, 4156);
/*
* It is important to know if the initial privileges are from initdb or from an
* extension. This enum is used to provide that differentiation and the two
......
......@@ -64,4 +64,6 @@ CATALOG(pg_language,2612,LanguageRelationId)
*/
typedef FormData_pg_language *Form_pg_language;
DECLARE_TOAST(pg_language, 4157, 4158);
#endif /* PG_LANGUAGE_H */
......@@ -51,6 +51,8 @@ CATALOG(pg_namespace,2615,NamespaceRelationId)
*/
typedef FormData_pg_namespace *Form_pg_namespace;
DECLARE_TOAST(pg_namespace, 4163, 4164);
/*
* prototypes for functions in pg_namespace.c
*/
......
......@@ -64,4 +64,6 @@ CATALOG(pg_partitioned_table,3350,PartitionedRelationId)
*/
typedef FormData_pg_partitioned_table *Form_pg_partitioned_table;
DECLARE_TOAST(pg_partitioned_table, 4165, 4166);
#endif /* PG_PARTITIONED_TABLE_H */
......@@ -49,4 +49,6 @@ CATALOG(pg_policy,3256,PolicyRelationId)
*/
typedef FormData_pg_policy *Form_pg_policy;
DECLARE_TOAST(pg_policy, 4167, 4168);
#endif /* PG_POLICY_H */
......@@ -132,6 +132,8 @@ CATALOG(pg_proc,1255,ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81,Proce
*/
typedef FormData_pg_proc *Form_pg_proc;
DECLARE_TOAST(pg_proc, 2836, 2837);
#ifdef EXPOSE_TO_CLIENT_CODE
/*
......
......@@ -54,4 +54,8 @@ CATALOG(pg_replication_origin,6000,ReplicationOriginRelationId) BKI_SHARED_RELAT
typedef FormData_pg_replication_origin *Form_pg_replication_origin;
DECLARE_TOAST(pg_replication_origin, 4181, 4182);
#define PgReplicationOriginToastTable 4181
#define PgReplicationOriginToastIndex 4182
#endif /* PG_REPLICATION_ORIGIN_H */
......@@ -51,4 +51,6 @@ CATALOG(pg_rewrite,2618,RewriteRelationId)
*/
typedef FormData_pg_rewrite *Form_pg_rewrite;
DECLARE_TOAST(pg_rewrite, 2838, 2839);
#endif /* PG_REWRITE_H */
......@@ -37,4 +37,6 @@ CATALOG(pg_seclabel,3596,SecLabelRelationId)
#endif
} FormData_pg_seclabel;
DECLARE_TOAST(pg_seclabel, 3598, 3599);
#endif /* PG_SECLABEL_H */
......@@ -55,4 +55,8 @@ CATALOG(pg_shdescription,2396,SharedDescriptionRelationId) BKI_SHARED_RELATION
*/
typedef FormData_pg_shdescription * Form_pg_shdescription;
DECLARE_TOAST(pg_shdescription, 2846, 2847);
#define PgShdescriptionToastTable 2846
#define PgShdescriptionToastIndex 2847
#endif /* PG_SHDESCRIPTION_H */
......@@ -38,4 +38,8 @@ CATALOG(pg_shseclabel,3592,SharedSecLabelRelationId) BKI_SHARED_RELATION BKI_ROW
typedef FormData_pg_shseclabel * Form_pg_shseclabel;
DECLARE_TOAST(pg_shseclabel, 4060, 4061);
#define PgShseclabelToastTable 4060
#define PgShseclabelToastIndex 4061
#endif /* PG_SHSECLABEL_H */
......@@ -133,6 +133,8 @@ CATALOG(pg_statistic,2619,StatisticRelationId)
*/
typedef FormData_pg_statistic *Form_pg_statistic;
DECLARE_TOAST(pg_statistic, 2840, 2841);
#ifdef EXPOSE_TO_CLIENT_CODE
/*
......
......@@ -63,6 +63,8 @@ CATALOG(pg_statistic_ext,3381,StatisticExtRelationId)
*/
typedef FormData_pg_statistic_ext *Form_pg_statistic_ext;
DECLARE_TOAST(pg_statistic_ext, 3439, 3440);
#ifdef EXPOSE_TO_CLIENT_CODE
#define STATS_EXT_NDISTINCT 'd'
......
......@@ -49,4 +49,6 @@ CATALOG(pg_statistic_ext_data,3429,StatisticExtDataRelationId)
*/
typedef FormData_pg_statistic_ext_data * Form_pg_statistic_ext_data;
DECLARE_TOAST(pg_statistic_ext_data, 3430, 3431);
#endif /* PG_STATISTIC_EXT_DATA_H */
......@@ -70,6 +70,10 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
typedef FormData_pg_subscription *Form_pg_subscription;
DECLARE_TOAST(pg_subscription, 4183, 4184);
#define PgSubscriptionToastTable 4183
#define PgSubscriptionToastIndex 4184
typedef struct Subscription
{
Oid oid; /* Oid of the subscription */
......
......@@ -45,4 +45,8 @@ CATALOG(pg_tablespace,1213,TableSpaceRelationId) BKI_SHARED_RELATION
*/
typedef FormData_pg_tablespace *Form_pg_tablespace;
DECLARE_TOAST(pg_tablespace, 4185, 4186);
#define PgTablespaceToastTable 4185
#define PgTablespaceToastIndex 4186
#endif /* PG_TABLESPACE_H */
......@@ -72,6 +72,8 @@ CATALOG(pg_trigger,2620,TriggerRelationId)
*/
typedef FormData_pg_trigger *Form_pg_trigger;
DECLARE_TOAST(pg_trigger, 2336, 2337);
#ifdef EXPOSE_TO_CLIENT_CODE
/* Bits within tgtype */
......
......@@ -51,4 +51,6 @@ CATALOG(pg_ts_dict,3600,TSDictionaryRelationId)
typedef FormData_pg_ts_dict *Form_pg_ts_dict;
DECLARE_TOAST(pg_ts_dict, 4169, 4170);
#endif /* PG_TS_DICT_H */
......@@ -254,6 +254,8 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
*/
typedef FormData_pg_type *Form_pg_type;
DECLARE_TOAST(pg_type, 4171, 4172);
#ifdef EXPOSE_TO_CLIENT_CODE
/*
......
......@@ -45,4 +45,6 @@ CATALOG(pg_user_mapping,1418,UserMappingRelationId)
*/
typedef FormData_pg_user_mapping *Form_pg_user_mapping;
DECLARE_TOAST(pg_user_mapping, 4173, 4174);
#endif /* PG_USER_MAPPING_H */
......@@ -61,7 +61,7 @@ if ($output_path ne '' && substr($output_path, -1) ne '/')
}
# Collect all the existing assigned OIDs (including those to be remapped).
my @header_files = (glob("pg_*.h"), qw(indexing.h toasting.h));
my @header_files = (glob("pg_*.h"), qw(indexing.h));
my $oids = Catalog::FindAllOidsFromHeaders(@header_files);
# Hash-ify the existing OIDs for convenient lookup.
......@@ -173,7 +173,7 @@ foreach my $input_file (@header_files)
}
}
# In indexing.h and toasting.h only, check for #define SYM nnnn,
# In indexing.h only, check for #define SYM nnnn,
# and replace if within mapped range.
elsif ($line =~ m/^(\s*#\s*define\s+\w+\s+)(\d+)\b/)
{
......
......@@ -3,9 +3,6 @@
* toasting.h
* This file provides some definitions to support creation of toast tables
*
* Caution: all #define's with numeric values in this file had better be
* object OIDs, else renumber_oids.pl might change them inappropriately.
*
*
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
......@@ -30,76 +27,4 @@ extern void AlterTableCreateToastTable(Oid relOid, Datum reloptions,
extern void BootstrapToastTable(char *relName,
Oid toastOid, Oid toastIndexOid);
/*
* This macro is just to keep the C compiler from spitting up on the
* upcoming commands for Catalog.pm.
*/
#define DECLARE_TOAST(name,toastoid,indexoid) extern int no_such_variable
/*
* What follows are lines processed by genbki.pl to create the statements
* the bootstrap parser will turn into BootstrapToastTable commands.
* Each line specifies the system catalog that needs a toast table,
* 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.
*/
/* normal catalogs */
DECLARE_TOAST(pg_aggregate, 4159, 4160);
DECLARE_TOAST(pg_attrdef, 2830, 2831);
DECLARE_TOAST(pg_constraint, 2832, 2833);
DECLARE_TOAST(pg_default_acl, 4143, 4144);
DECLARE_TOAST(pg_depend, 8888, 8889);
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_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_statistic_ext_data, 3430, 3431);
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);
#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_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 */
......@@ -28,7 +28,7 @@ chdir $FindBin::RealBin or die "could not cd to $FindBin::RealBin: $!\n";
use lib "$FindBin::RealBin/../../backend/catalog/";
use Catalog;
my @input_files = (glob("pg_*.h"), qw(indexing.h toasting.h));
my @input_files = (glob("pg_*.h"), qw(indexing.h));
my $oids = Catalog::FindAllOidsFromHeaders(@input_files);
......
......@@ -762,7 +762,6 @@ EOF
$mf =~ /^CATALOG_HEADERS\s*:?=(.*)$/gm
|| croak "Could not find CATALOG_HEADERS in Makefile\n";
my @bki_srcs = split /\s+/, $1;
push @bki_srcs, 'toasting.h';
push @bki_srcs, 'indexing.h';
$mf =~ /^POSTGRES_BKI_DATA\s*:?=[^,]+,(.*)\)$/gm
|| croak "Could not find POSTGRES_BKI_DATA in Makefile\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment