Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b4c9695

Browse files
committed
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: John Naylor <john.naylor@enterprisedb.com> Discussion: https://www.postgresql.org/message-id/flat/c7cc82d6-f976-75d6-2e3e-b03d2cab26bb@2ndquadrant.com
1 parent 623644f commit b4c9695

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+105
-89
lines changed

doc/src/sgml/bki.sgml

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
the catalog has, as well as some other basic properties such as its OID.
2525
Other critical files defining the catalog structure
2626
include <filename>indexing.h</filename>, which defines the indexes present
27-
on all the system catalogs, and <filename>toasting.h</filename>, which
28-
defines TOAST tables for catalogs that need one.
27+
on all the system catalogs.
2928
</para>
3029

3130
<para>

src/backend/catalog/Makefile

+1-4
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,8 @@ CATALOG_HEADERS := \
7272

7373
GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h
7474

75-
# In the list of headers used to assemble postgres.bki, indexing.h needs
76-
# be last, and toasting.h just before it. This ensures we don't try to
77-
# create indexes or toast tables before their catalogs exist.
7875
POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,\
79-
$(CATALOG_HEADERS) toasting.h indexing.h \
76+
$(CATALOG_HEADERS) indexing.h \
8077
)
8178

8279
# The .dat files we need can just be listed alphabetically.

src/backend/catalog/catalog.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include "catalog/pg_subscription.h"
4141
#include "catalog/pg_tablespace.h"
4242
#include "catalog/pg_type.h"
43-
#include "catalog/toasting.h"
4443
#include "miscadmin.h"
4544
#include "storage/fd.h"
4645
#include "utils/fmgroids.h"
@@ -268,7 +267,7 @@ IsSharedRelation(Oid relationId)
268267
relationId == SubscriptionObjectIndexId ||
269268
relationId == SubscriptionNameIndexId)
270269
return true;
271-
/* These are their toast tables and toast indexes (see toasting.h) */
270+
/* These are their toast tables and toast indexes */
272271
if (relationId == PgAuthidToastTable ||
273272
relationId == PgAuthidToastIndex ||
274273
relationId == PgDatabaseToastTable ||

src/backend/catalog/toasting.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ needs_toast_table(Relation rel)
391391
/*
392392
* Ignore attempts to create toast tables on catalog tables after initdb.
393393
* Which catalogs get toast tables is explicitly chosen in
394-
* catalog/toasting.h. (We could get here via some ALTER TABLE command if
394+
* catalog/pg_*.h. (We could get here via some ALTER TABLE command if
395395
* the catalog doesn't have a toast table.)
396396
*/
397397
if (IsCatalogRelation(rel) && !IsBootstrapProcessingMode())

src/include/catalog/duplicate_oids

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ chdir $FindBin::RealBin or die "could not cd to $FindBin::RealBin: $!\n";
2626
use lib "$FindBin::RealBin/../../backend/catalog/";
2727
use Catalog;
2828

29-
my @input_files = (glob("pg_*.h"), qw(indexing.h toasting.h));
29+
my @input_files = (glob("pg_*.h"), qw(indexing.h));
3030

3131
my $oids = Catalog::FindAllOidsFromHeaders(@input_files);
3232

src/include/catalog/genbki.h

+13
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@
4141
*/
4242
#define BKI_LOOKUP(catalog)
4343

44+
/*
45+
* These lines are processed by genbki.pl to create the statements
46+
* the bootstrap parser will turn into BootstrapToastTable commands.
47+
* Each line specifies the system catalog that needs a toast table,
48+
* the OID to assign to the toast table, and the OID to assign to the
49+
* toast table's index. The reason we hard-wire these OIDs is that we
50+
* need stable OIDs for shared relations, and that includes toast tables
51+
* of shared relations.
52+
*
53+
* The macro definition is just to keep the C compiler from spitting up.
54+
*/
55+
#define DECLARE_TOAST(name,toastoid,indexoid) extern int no_such_variable
56+
4457
/* The following are never defined; they are here only for documentation. */
4558

4659
/*

src/include/catalog/pg_aggregate.h

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ CATALOG(pg_aggregate,2600,AggregateRelationId)
108108
*/
109109
typedef FormData_pg_aggregate *Form_pg_aggregate;
110110

111+
DECLARE_TOAST(pg_aggregate, 4159, 4160);
112+
111113
#ifdef EXPOSE_TO_CLIENT_CODE
112114

113115
/*

src/include/catalog/pg_attrdef.h

+2
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ CATALOG(pg_attrdef,2604,AttrDefaultRelationId)
4646
*/
4747
typedef FormData_pg_attrdef *Form_pg_attrdef;
4848

49+
DECLARE_TOAST(pg_attrdef, 2830, 2831);
50+
4951
#endif /* PG_ATTRDEF_H */

src/include/catalog/pg_authid.h

+4
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,8 @@ CATALOG(pg_authid,1260,AuthIdRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(284
5555
*/
5656
typedef FormData_pg_authid *Form_pg_authid;
5757

58+
DECLARE_TOAST(pg_authid, 4175, 4176);
59+
#define PgAuthidToastTable 4175
60+
#define PgAuthidToastIndex 4176
61+
5862
#endif /* PG_AUTHID_H */

src/include/catalog/pg_constraint.h

+2
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
153153
*/
154154
typedef FormData_pg_constraint *Form_pg_constraint;
155155

156+
DECLARE_TOAST(pg_constraint, 2832, 2833);
157+
156158
#ifdef EXPOSE_TO_CLIENT_CODE
157159

158160
/* Valid values for contype */

src/include/catalog/pg_database.h

+4
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,8 @@ CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID
8080
*/
8181
typedef FormData_pg_database *Form_pg_database;
8282

83+
DECLARE_TOAST(pg_database, 4177, 4178);
84+
#define PgDatabaseToastTable 4177
85+
#define PgDatabaseToastIndex 4178
86+
8387
#endif /* PG_DATABASE_H */

src/include/catalog/pg_db_role_setting.h

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ CATALOG(pg_db_role_setting,2964,DbRoleSettingRelationId) BKI_SHARED_RELATION
4343

4444
typedef FormData_pg_db_role_setting * Form_pg_db_role_setting;
4545

46+
DECLARE_TOAST(pg_db_role_setting, 2966, 2967);
47+
#define PgDbRoleSettingToastTable 2966
48+
#define PgDbRoleSettingToastIndex 2967
49+
4650
/*
4751
* prototypes for functions in pg_db_role_setting.h
4852
*/

src/include/catalog/pg_default_acl.h

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ CATALOG(pg_default_acl,826,DefaultAclRelationId)
4747
*/
4848
typedef FormData_pg_default_acl *Form_pg_default_acl;
4949

50+
DECLARE_TOAST(pg_default_acl, 4143, 4144);
51+
5052
#ifdef EXPOSE_TO_CLIENT_CODE
5153

5254
/*

src/include/catalog/pg_depend.h

+2
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,6 @@ CATALOG(pg_depend,2608,DependRelationId)
7373
*/
7474
typedef FormData_pg_depend *Form_pg_depend;
7575

76+
DECLARE_TOAST(pg_depend, 8888, 8889);
77+
7678
#endif /* PG_DEPEND_H */

src/include/catalog/pg_description.h

+2
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,6 @@ CATALOG(pg_description,2609,DescriptionRelationId)
6363
*/
6464
typedef FormData_pg_description * Form_pg_description;
6565

66+
DECLARE_TOAST(pg_description, 2834, 2835);
67+
6668
#endif /* PG_DESCRIPTION_H */

src/include/catalog/pg_event_trigger.h

+2
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,6 @@ CATALOG(pg_event_trigger,3466,EventTriggerRelationId)
4848
*/
4949
typedef FormData_pg_event_trigger *Form_pg_event_trigger;
5050

51+
DECLARE_TOAST(pg_event_trigger, 4145, 4146);
52+
5153
#endif /* PG_EVENT_TRIGGER_H */

src/include/catalog/pg_extension.h

+2
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@ CATALOG(pg_extension,3079,ExtensionRelationId)
4949
*/
5050
typedef FormData_pg_extension *Form_pg_extension;
5151

52+
DECLARE_TOAST(pg_extension, 4147, 4148);
53+
5254
#endif /* PG_EXTENSION_H */

src/include/catalog/pg_foreign_data_wrapper.h

+2
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ CATALOG(pg_foreign_data_wrapper,2328,ForeignDataWrapperRelationId)
4747
*/
4848
typedef FormData_pg_foreign_data_wrapper *Form_pg_foreign_data_wrapper;
4949

50+
DECLARE_TOAST(pg_foreign_data_wrapper, 4149, 4150);
51+
5052
#endif /* PG_FOREIGN_DATA_WRAPPER_H */

src/include/catalog/pg_foreign_server.h

+2
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ CATALOG(pg_foreign_server,1417,ForeignServerRelationId)
4747
*/
4848
typedef FormData_pg_foreign_server *Form_pg_foreign_server;
4949

50+
DECLARE_TOAST(pg_foreign_server, 4151, 4152);
51+
5052
#endif /* PG_FOREIGN_SERVER_H */

src/include/catalog/pg_foreign_table.h

+2
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ CATALOG(pg_foreign_table,3118,ForeignTableRelationId)
4242
*/
4343
typedef FormData_pg_foreign_table *Form_pg_foreign_table;
4444

45+
DECLARE_TOAST(pg_foreign_table, 4153, 4154);
46+
4547
#endif /* PG_FOREIGN_TABLE_H */

src/include/catalog/pg_init_privs.h

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ CATALOG(pg_init_privs,3394,InitPrivsRelationId)
6262
*/
6363
typedef FormData_pg_init_privs * Form_pg_init_privs;
6464

65+
DECLARE_TOAST(pg_init_privs, 4155, 4156);
66+
6567
/*
6668
* It is important to know if the initial privileges are from initdb or from an
6769
* extension. This enum is used to provide that differentiation and the two

src/include/catalog/pg_language.h

+2
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,6 @@ CATALOG(pg_language,2612,LanguageRelationId)
6464
*/
6565
typedef FormData_pg_language *Form_pg_language;
6666

67+
DECLARE_TOAST(pg_language, 4157, 4158);
68+
6769
#endif /* PG_LANGUAGE_H */

src/include/catalog/pg_namespace.h

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ CATALOG(pg_namespace,2615,NamespaceRelationId)
5151
*/
5252
typedef FormData_pg_namespace *Form_pg_namespace;
5353

54+
DECLARE_TOAST(pg_namespace, 4163, 4164);
55+
5456
/*
5557
* prototypes for functions in pg_namespace.c
5658
*/

src/include/catalog/pg_partitioned_table.h

+2
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,6 @@ CATALOG(pg_partitioned_table,3350,PartitionedRelationId)
6464
*/
6565
typedef FormData_pg_partitioned_table *Form_pg_partitioned_table;
6666

67+
DECLARE_TOAST(pg_partitioned_table, 4165, 4166);
68+
6769
#endif /* PG_PARTITIONED_TABLE_H */

src/include/catalog/pg_policy.h

+2
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@ CATALOG(pg_policy,3256,PolicyRelationId)
4949
*/
5050
typedef FormData_pg_policy *Form_pg_policy;
5151

52+
DECLARE_TOAST(pg_policy, 4167, 4168);
53+
5254
#endif /* PG_POLICY_H */

src/include/catalog/pg_proc.h

+2
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ CATALOG(pg_proc,1255,ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81,Proce
132132
*/
133133
typedef FormData_pg_proc *Form_pg_proc;
134134

135+
DECLARE_TOAST(pg_proc, 2836, 2837);
136+
135137
#ifdef EXPOSE_TO_CLIENT_CODE
136138

137139
/*

src/include/catalog/pg_replication_origin.h

+4
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,8 @@ CATALOG(pg_replication_origin,6000,ReplicationOriginRelationId) BKI_SHARED_RELAT
5454

5555
typedef FormData_pg_replication_origin *Form_pg_replication_origin;
5656

57+
DECLARE_TOAST(pg_replication_origin, 4181, 4182);
58+
#define PgReplicationOriginToastTable 4181
59+
#define PgReplicationOriginToastIndex 4182
60+
5761
#endif /* PG_REPLICATION_ORIGIN_H */

src/include/catalog/pg_rewrite.h

+2
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ CATALOG(pg_rewrite,2618,RewriteRelationId)
5151
*/
5252
typedef FormData_pg_rewrite *Form_pg_rewrite;
5353

54+
DECLARE_TOAST(pg_rewrite, 2838, 2839);
55+
5456
#endif /* PG_REWRITE_H */

src/include/catalog/pg_seclabel.h

+2
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ CATALOG(pg_seclabel,3596,SecLabelRelationId)
3737
#endif
3838
} FormData_pg_seclabel;
3939

40+
DECLARE_TOAST(pg_seclabel, 3598, 3599);
41+
4042
#endif /* PG_SECLABEL_H */

src/include/catalog/pg_shdescription.h

+4
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,8 @@ CATALOG(pg_shdescription,2396,SharedDescriptionRelationId) BKI_SHARED_RELATION
5555
*/
5656
typedef FormData_pg_shdescription * Form_pg_shdescription;
5757

58+
DECLARE_TOAST(pg_shdescription, 2846, 2847);
59+
#define PgShdescriptionToastTable 2846
60+
#define PgShdescriptionToastIndex 2847
61+
5862
#endif /* PG_SHDESCRIPTION_H */

src/include/catalog/pg_shseclabel.h

+4
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ CATALOG(pg_shseclabel,3592,SharedSecLabelRelationId) BKI_SHARED_RELATION BKI_ROW
3838

3939
typedef FormData_pg_shseclabel * Form_pg_shseclabel;
4040

41+
DECLARE_TOAST(pg_shseclabel, 4060, 4061);
42+
#define PgShseclabelToastTable 4060
43+
#define PgShseclabelToastIndex 4061
44+
4145
#endif /* PG_SHSECLABEL_H */

src/include/catalog/pg_statistic.h

+2
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ CATALOG(pg_statistic,2619,StatisticRelationId)
133133
*/
134134
typedef FormData_pg_statistic *Form_pg_statistic;
135135

136+
DECLARE_TOAST(pg_statistic, 2840, 2841);
137+
136138
#ifdef EXPOSE_TO_CLIENT_CODE
137139

138140
/*

src/include/catalog/pg_statistic_ext.h

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ CATALOG(pg_statistic_ext,3381,StatisticExtRelationId)
6363
*/
6464
typedef FormData_pg_statistic_ext *Form_pg_statistic_ext;
6565

66+
DECLARE_TOAST(pg_statistic_ext, 3439, 3440);
67+
6668
#ifdef EXPOSE_TO_CLIENT_CODE
6769

6870
#define STATS_EXT_NDISTINCT 'd'

src/include/catalog/pg_statistic_ext_data.h

+2
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@ CATALOG(pg_statistic_ext_data,3429,StatisticExtDataRelationId)
4949
*/
5050
typedef FormData_pg_statistic_ext_data * Form_pg_statistic_ext_data;
5151

52+
DECLARE_TOAST(pg_statistic_ext_data, 3430, 3431);
53+
5254
#endif /* PG_STATISTIC_EXT_DATA_H */

src/include/catalog/pg_subscription.h

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
7070

7171
typedef FormData_pg_subscription *Form_pg_subscription;
7272

73+
DECLARE_TOAST(pg_subscription, 4183, 4184);
74+
#define PgSubscriptionToastTable 4183
75+
#define PgSubscriptionToastIndex 4184
76+
7377
typedef struct Subscription
7478
{
7579
Oid oid; /* Oid of the subscription */

src/include/catalog/pg_tablespace.h

+4
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ CATALOG(pg_tablespace,1213,TableSpaceRelationId) BKI_SHARED_RELATION
4545
*/
4646
typedef FormData_pg_tablespace *Form_pg_tablespace;
4747

48+
DECLARE_TOAST(pg_tablespace, 4185, 4186);
49+
#define PgTablespaceToastTable 4185
50+
#define PgTablespaceToastIndex 4186
51+
4852
#endif /* PG_TABLESPACE_H */

src/include/catalog/pg_trigger.h

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ CATALOG(pg_trigger,2620,TriggerRelationId)
7272
*/
7373
typedef FormData_pg_trigger *Form_pg_trigger;
7474

75+
DECLARE_TOAST(pg_trigger, 2336, 2337);
76+
7577
#ifdef EXPOSE_TO_CLIENT_CODE
7678

7779
/* Bits within tgtype */

src/include/catalog/pg_ts_dict.h

+2
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ CATALOG(pg_ts_dict,3600,TSDictionaryRelationId)
5151

5252
typedef FormData_pg_ts_dict *Form_pg_ts_dict;
5353

54+
DECLARE_TOAST(pg_ts_dict, 4169, 4170);
55+
5456
#endif /* PG_TS_DICT_H */

src/include/catalog/pg_type.h

+2
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
254254
*/
255255
typedef FormData_pg_type *Form_pg_type;
256256

257+
DECLARE_TOAST(pg_type, 4171, 4172);
258+
257259
#ifdef EXPOSE_TO_CLIENT_CODE
258260

259261
/*

src/include/catalog/pg_user_mapping.h

+2
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ CATALOG(pg_user_mapping,1418,UserMappingRelationId)
4545
*/
4646
typedef FormData_pg_user_mapping *Form_pg_user_mapping;
4747

48+
DECLARE_TOAST(pg_user_mapping, 4173, 4174);
49+
4850
#endif /* PG_USER_MAPPING_H */

src/include/catalog/renumber_oids.pl

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
}
6262

6363
# Collect all the existing assigned OIDs (including those to be remapped).
64-
my @header_files = (glob("pg_*.h"), qw(indexing.h toasting.h));
64+
my @header_files = (glob("pg_*.h"), qw(indexing.h));
6565
my $oids = Catalog::FindAllOidsFromHeaders(@header_files);
6666

6767
# Hash-ify the existing OIDs for convenient lookup.
@@ -173,7 +173,7 @@
173173
}
174174
}
175175

176-
# In indexing.h and toasting.h only, check for #define SYM nnnn,
176+
# In indexing.h only, check for #define SYM nnnn,
177177
# and replace if within mapped range.
178178
elsif ($line =~ m/^(\s*#\s*define\s+\w+\s+)(\d+)\b/)
179179
{

0 commit comments

Comments
 (0)