Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit40eba06

Browse files
committed
Use DECLARE_TOAST_WITH_MACRO() to simplify toast-table declarations.
This is needed so that renumber_oids.pl can handle renumberingshared catalog declarations, which need to provide C macros forthe OIDs of the shared toast table and index. The previousmethod of writing a C macro separately was error-prone anyway.Also teach renumber_oids.pl about DECLARE_UNIQUE_INDEX_PKEY,as we missed doing when inventing that macro.There are no changes to postgres.bki here, so no need for acatversion bump.Discussion:https://postgr.es/m/2995325.1650487527@sss.pgh.pa.us
1 parent4eea220 commit40eba06

13 files changed

+58
-32
lines changed

‎src/backend/catalog/Catalog.pm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ sub ParseHeader
9494
push @{$catalog{toasting} },
9595
{parent_table=>$1,toast_oid=>$2,toast_index_oid=>$3 };
9696
}
97+
elsif (/^DECLARE_TOAST_WITH_MACRO\(\s*(\w+),\s*(\d+),\s*(\d+),\s*(\w+),\s*(\w+)\)/)
98+
{
99+
push @{$catalog{toasting} },
100+
{
101+
parent_table=>$1,
102+
toast_oid=>$2,
103+
toast_index_oid=>$3,
104+
toast_oid_macro=>$4,
105+
toast_index_oid_macro=>$5
106+
};
107+
}
97108
elsif (
98109
/^DECLARE_(UNIQUE_)?INDEX(_PKEY)?\(\s*(\w+),\s*(\d+),\s*(\w+),\s*(.+)\)/)
99110
{

‎src/backend/catalog/genbki.pl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,16 @@
472472
$catalog->{rowtype_oid_macro},$catalog->{rowtype_oid}
473473
if$catalog->{rowtype_oid_macro};
474474
475+
# Likewise for macros for toast and index OIDs
476+
foreach my$toast (@{$catalog->{toasting} })
477+
{
478+
printf$def "#define%s%s\n",
479+
$toast->{toast_oid_macro},$toast->{toast_oid}
480+
if$toast->{toast_oid_macro};
481+
printf$def "#define%s%s\n",
482+
$toast->{toast_index_oid_macro},$toast->{toast_index_oid}
483+
if$toast->{toast_index_oid_macro};
484+
}
475485
foreach my$index (@{$catalog->{indexing} })
476486
{
477487
printf$def "#define%s%s\n",

‎src/include/catalog/genbki.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@
5555
* need stable OIDs for shared relations, and that includes toast tables
5656
* of shared relations.
5757
*
58-
* The macro definition is just to keep the C compiler from spitting up.
58+
* The DECLARE_TOAST_WITH_MACRO variant is used when C macros are needed
59+
* for the toast table/index OIDs (usually only for shared catalogs).
60+
*
61+
* The macro definitions are just to keep the C compiler from spitting up.
5962
*/
6063
#defineDECLARE_TOAST(name,toastoid,indexoid) extern int no_such_variable
64+
#defineDECLARE_TOAST_WITH_MACRO(name,toastoid,indexoid,toastoidmacro,indexoidmacro) extern int no_such_variable
6165

6266
/*
6367
* These lines are processed by genbki.pl to create the statements

‎src/include/catalog/pg_authid.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ CATALOG(pg_authid,1260,AuthIdRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(284
5555
*/
5656
typedefFormData_pg_authid*Form_pg_authid;
5757

58-
DECLARE_TOAST(pg_authid,4175,4176);
59-
#definePgAuthidToastTable 4175
60-
#definePgAuthidToastIndex 4176
58+
DECLARE_TOAST_WITH_MACRO(pg_authid,4175,4176,PgAuthidToastTable,PgAuthidToastIndex);
6159

6260
DECLARE_UNIQUE_INDEX(pg_authid_rolname_index,2676,AuthIdRolnameIndexId,onpg_authidusingbtree(rolnamename_ops));
6361
DECLARE_UNIQUE_INDEX_PKEY(pg_authid_oid_index,2677,AuthIdOidIndexId,onpg_authidusingbtree(oidoid_ops));

‎src/include/catalog/pg_database.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID
8686
*/
8787
typedefFormData_pg_database*Form_pg_database;
8888

89-
DECLARE_TOAST(pg_database,4177,4178);
90-
#definePgDatabaseToastTable4177
91-
#definePgDatabaseToastIndex4178
89+
DECLARE_TOAST_WITH_MACRO(pg_database,4177,4178,PgDatabaseToastTable,PgDatabaseToastIndex);
9290

9391
DECLARE_UNIQUE_INDEX(pg_database_datname_index,2671,DatabaseNameIndexId,onpg_databaseusingbtree(datnamename_ops));
9492
DECLARE_UNIQUE_INDEX_PKEY(pg_database_oid_index,2672,DatabaseOidIndexId,onpg_databaseusingbtree(oidoid_ops));

‎src/include/catalog/pg_db_role_setting.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ CATALOG(pg_db_role_setting,2964,DbRoleSettingRelationId) BKI_SHARED_RELATION
4646

4747
typedefFormData_pg_db_role_setting*Form_pg_db_role_setting;
4848

49-
DECLARE_TOAST(pg_db_role_setting,2966,2967);
50-
#definePgDbRoleSettingToastTable 2966
51-
#definePgDbRoleSettingToastIndex 2967
49+
DECLARE_TOAST_WITH_MACRO(pg_db_role_setting,2966,2967,PgDbRoleSettingToastTable,PgDbRoleSettingToastIndex);
5250

5351
DECLARE_UNIQUE_INDEX_PKEY(pg_db_role_setting_databaseid_rol_index,2965,DbRoleSettingDatidRolidIndexId,onpg_db_role_settingusingbtree(setdatabaseoid_ops,setroleoid_ops));
5452

‎src/include/catalog/pg_parameter_acl.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ CATALOG(pg_parameter_acl,8924,ParameterAclRelationId) BKI_SHARED_RELATION
4848
*/
4949
typedefFormData_pg_parameter_acl*Form_pg_parameter_acl;
5050

51-
DECLARE_TOAST(pg_parameter_acl,8925,8926);
52-
#definePgParameterAclToastTable 8925
53-
#definePgParameterAclToastIndex 8926
51+
DECLARE_TOAST_WITH_MACRO(pg_parameter_acl,8925,8926,PgParameterAclToastTable,PgParameterAclToastIndex);
5452

5553
DECLARE_UNIQUE_INDEX(pg_parameter_acl_parname_index,8927,ParameterAclParnameIndexId,onpg_parameter_aclusingbtree(parnametext_ops));
5654
DECLARE_UNIQUE_INDEX_PKEY(pg_parameter_acl_oid_index,8928,ParameterAclOidIndexId,onpg_parameter_aclusingbtree(oidoid_ops));

‎src/include/catalog/pg_replication_origin.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ CATALOG(pg_replication_origin,6000,ReplicationOriginRelationId) BKI_SHARED_RELAT
5454

5555
typedefFormData_pg_replication_origin*Form_pg_replication_origin;
5656

57-
DECLARE_TOAST(pg_replication_origin,4181,4182);
58-
#definePgReplicationOriginToastTable 4181
59-
#definePgReplicationOriginToastIndex 4182
57+
DECLARE_TOAST_WITH_MACRO(pg_replication_origin,4181,4182,PgReplicationOriginToastTable,PgReplicationOriginToastIndex);
6058

6159
DECLARE_UNIQUE_INDEX_PKEY(pg_replication_origin_roiident_index,6001,ReplicationOriginIdentIndex,onpg_replication_originusingbtree(roidentoid_ops));
6260
DECLARE_UNIQUE_INDEX(pg_replication_origin_roname_index,6002,ReplicationOriginNameIndex,onpg_replication_originusingbtree(ronametext_ops));

‎src/include/catalog/pg_shdescription.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ CATALOG(pg_shdescription,2396,SharedDescriptionRelationId) BKI_SHARED_RELATION
5555
*/
5656
typedefFormData_pg_shdescription*Form_pg_shdescription;
5757

58-
DECLARE_TOAST(pg_shdescription,2846,2847);
59-
#definePgShdescriptionToastTable 2846
60-
#definePgShdescriptionToastIndex 2847
58+
DECLARE_TOAST_WITH_MACRO(pg_shdescription,2846,2847,PgShdescriptionToastTable,PgShdescriptionToastIndex);
6159

6260
DECLARE_UNIQUE_INDEX_PKEY(pg_shdescription_o_c_index,2397,SharedDescriptionObjIndexId,onpg_shdescriptionusingbtree(objoidoid_ops,classoidoid_ops));
6361

‎src/include/catalog/pg_shseclabel.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ CATALOG(pg_shseclabel,3592,SharedSecLabelRelationId) BKI_SHARED_RELATION BKI_ROW
3939

4040
typedefFormData_pg_shseclabel*Form_pg_shseclabel;
4141

42-
DECLARE_TOAST(pg_shseclabel,4060,4061);
43-
#definePgShseclabelToastTable 4060
44-
#definePgShseclabelToastIndex 4061
42+
DECLARE_TOAST_WITH_MACRO(pg_shseclabel,4060,4061,PgShseclabelToastTable,PgShseclabelToastIndex);
4543

4644
DECLARE_UNIQUE_INDEX_PKEY(pg_shseclabel_object_index,3593,SharedSecLabelObjectIndexId,onpg_shseclabelusingbtree(objoidoid_ops,classoidoid_ops,providertext_ops));
4745

‎src/include/catalog/pg_subscription.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
9292

9393
typedefFormData_pg_subscription*Form_pg_subscription;
9494

95-
DECLARE_TOAST(pg_subscription,4183,4184);
96-
#definePgSubscriptionToastTable 4183
97-
#definePgSubscriptionToastIndex 4184
95+
DECLARE_TOAST_WITH_MACRO(pg_subscription,4183,4184,PgSubscriptionToastTable,PgSubscriptionToastIndex);
9896

9997
DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_oid_index,6114,SubscriptionObjectIndexId,onpg_subscriptionusingbtree(oidoid_ops));
10098
DECLARE_UNIQUE_INDEX(pg_subscription_subname_index,6115,SubscriptionNameIndexId,onpg_subscriptionusingbtree(subdbidoid_ops,subnamename_ops));

‎src/include/catalog/pg_tablespace.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ CATALOG(pg_tablespace,1213,TableSpaceRelationId) BKI_SHARED_RELATION
4747
*/
4848
typedefFormData_pg_tablespace*Form_pg_tablespace;
4949

50-
DECLARE_TOAST(pg_tablespace,4185,4186);
51-
#definePgTablespaceToastTable 4185
52-
#definePgTablespaceToastIndex 4186
50+
DECLARE_TOAST_WITH_MACRO(pg_tablespace,4185,4186,PgTablespaceToastTable,PgTablespaceToastIndex);
5351

5452
DECLARE_UNIQUE_INDEX_PKEY(pg_tablespace_oid_index,2697,TablespaceOidIndexId,onpg_tablespaceusingbtree(oidoid_ops));
5553
DECLARE_UNIQUE_INDEX(pg_tablespace_spcname_index,2698,TablespaceNameIndexId,onpg_tablespaceusingbtree(spcnamename_ops));

‎src/include/catalog/renumber_oids.pl

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,33 @@
140140
$changed = 1;
141141
}
142142
}
143+
elsif ($line =~m/^(DECLARE_TOAST_WITH_MACRO\(\s*\w+,\s*)(\d+)(,\s*)(\d+)(,\s*\w+,\s*\w+)\)/)
144+
{
145+
my$oid2 =$2;
146+
my$oid4 =$4;
147+
if (exists$maphash{$oid2})
148+
{
149+
$oid2 =$maphash{$oid2};
150+
my$repl =$1 .$oid2 .$3 .$oid4 .$5 .")";
151+
$line =~s/^DECLARE_TOAST_WITH_MACRO\(\s*\w+,\s*\d+,\s*\d+,\s*\w+,\s*\w+\)/$repl/;
152+
$changed = 1;
153+
}
154+
if (exists$maphash{$oid4})
155+
{
156+
$oid4 =$maphash{$oid4};
157+
my$repl =$1 .$oid2 .$3 .$oid4 .$5 .")";
158+
$line =~s/^DECLARE_TOAST_WITH_MACRO\(\s*\w+,\s*\d+,\s*\d+,\s*\w+,\s*\w+\)/$repl/;
159+
$changed = 1;
160+
}
161+
}
143162
elsif (
144-
$line =~m/^(DECLARE_(UNIQUE_)?INDEX\(\s*\w+,\s*)(\d+)(,\s*.+)\)/)
163+
$line =~m/^(DECLARE_(UNIQUE_)?INDEX(_PKEY)?\(\s*\w+,\s*)(\d+)(,\s*.+)\)/)
145164
{
146-
if (exists$maphash{$3})
165+
if (exists$maphash{$4})
147166
{
148-
my$repl =$1 .$maphash{$3} .$4 .")";
167+
my$repl =$1 .$maphash{$4} .$5 .")";
149168
$line =~
150-
s/^DECLARE_(UNIQUE_)?INDEX\(\s*\w+,\s*\d+,\s*.+\)/$repl/;
169+
s/^DECLARE_(UNIQUE_)?INDEX(_PKEY)?\(\s*\w+,\s*\d+,\s*.+\)/$repl/;
151170
$changed = 1;
152171
}
153172
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp