Skip to content

Commit 226d0a6

Browse files
committed
Restructure DECLARE_INDEX arguments
Separate the table name from the index declaration. We need that anyway later for the ALTER TABLE / USING INDEX commands, so we might as well structure the declarations like that to begin with. Discussion: https://www.postgresql.org/message-id/flat/75ae5875-3abc-dafc-8aec-73247ed41cde@eisentraut.org
1 parent b5934bf commit 226d0a6

Some content is hidden

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

67 files changed

+133
-133
lines changed

src/backend/catalog/Catalog.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ sub ParseHeader
117117
(?<index_name>\w+),\s*
118118
(?<index_oid>\d+),\s*
119119
(?<index_oid_macro>\w+),\s*
120+
(?<table_name>\w+),\s*
120121
(?<index_decl>.+)\s*
121122
\)/x
122123
)

src/backend/catalog/genbki.pl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,18 @@
135135
foreach my $index (@{ $catalog->{indexing} })
136136
{
137137
push @index_decls,
138-
sprintf "declare %sindex %s %s %s\n",
138+
sprintf "declare %sindex %s %s on %s using %s\n",
139139
$index->{is_unique} ? 'unique ' : '',
140140
$index->{index_name}, $index->{index_oid},
141+
$index->{table_name},
141142
$index->{index_decl};
142143
$oidcounts{ $index->{index_oid} }++;
143144

144145
if ($index->{is_unique})
145146
{
146-
$index->{index_decl} =~ /on (\w+) using/;
147-
my $tblname = $1;
148147
push @system_constraints,
149148
sprintf "ALTER TABLE %s ADD %s USING INDEX %s;",
150-
$tblname,
149+
$index->{table_name},
151150
$index->{is_pkey} ? "PRIMARY KEY" : "UNIQUE",
152151
$index->{index_name};
153152
}

src/include/catalog/genbki.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@
7676
* The first two arguments are the index's name and OID. The third argument
7777
* is the name of a #define to generate for its OID. References to the index
7878
* in the C code should always use these #defines, not the actual index name
79-
* (much less the numeric OID). The rest is much like a standard 'create
80-
* index' SQL command.
79+
* (much less the numeric OID). The fourth argument is the table name. The
80+
* rest is much like a standard 'create index' SQL command.
8181
*
8282
* The macro definitions are just to keep the C compiler from spitting up.
8383
*/
84-
#define DECLARE_INDEX(name,oid,oidmacro,decl) extern int no_such_variable
85-
#define DECLARE_UNIQUE_INDEX(name,oid,oidmacro,decl) extern int no_such_variable
86-
#define DECLARE_UNIQUE_INDEX_PKEY(name,oid,oidmacro,decl) extern int no_such_variable
84+
#define DECLARE_INDEX(name,oid,oidmacro,tblname,decl) extern int no_such_variable
85+
#define DECLARE_UNIQUE_INDEX(name,oid,oidmacro,tblname,decl) extern int no_such_variable
86+
#define DECLARE_UNIQUE_INDEX_PKEY(name,oid,oidmacro,tblname,decl) extern int no_such_variable
8787

8888
/*
8989
* These lines inform genbki.pl about manually-assigned OIDs that do not

src/include/catalog/pg_aggregate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ typedef FormData_pg_aggregate *Form_pg_aggregate;
110110

111111
DECLARE_TOAST(pg_aggregate, 4159, 4160);
112112

113-
DECLARE_UNIQUE_INDEX_PKEY(pg_aggregate_fnoid_index, 2650, AggregateFnoidIndexId, on pg_aggregate using btree(aggfnoid oid_ops));
113+
DECLARE_UNIQUE_INDEX_PKEY(pg_aggregate_fnoid_index, 2650, AggregateFnoidIndexId, pg_aggregate, btree(aggfnoid oid_ops));
114114

115115
#ifdef EXPOSE_TO_CLIENT_CODE
116116

src/include/catalog/pg_am.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ CATALOG(pg_am,2601,AccessMethodRelationId)
4747
*/
4848
typedef FormData_pg_am *Form_pg_am;
4949

50-
DECLARE_UNIQUE_INDEX(pg_am_name_index, 2651, AmNameIndexId, on pg_am using btree(amname name_ops));
51-
DECLARE_UNIQUE_INDEX_PKEY(pg_am_oid_index, 2652, AmOidIndexId, on pg_am using btree(oid oid_ops));
50+
DECLARE_UNIQUE_INDEX(pg_am_name_index, 2651, AmNameIndexId, pg_am, btree(amname name_ops));
51+
DECLARE_UNIQUE_INDEX_PKEY(pg_am_oid_index, 2652, AmOidIndexId, pg_am, btree(oid oid_ops));
5252

5353
#ifdef EXPOSE_TO_CLIENT_CODE
5454

src/include/catalog/pg_amop.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ CATALOG(pg_amop,2602,AccessMethodOperatorRelationId)
8787
*/
8888
typedef FormData_pg_amop *Form_pg_amop;
8989

90-
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));
91-
DECLARE_UNIQUE_INDEX(pg_amop_opr_fam_index, 2654, AccessMethodOperatorIndexId, on pg_amop using btree(amopopr oid_ops, amoppurpose char_ops, amopfamily oid_ops));
92-
DECLARE_UNIQUE_INDEX_PKEY(pg_amop_oid_index, 2756, AccessMethodOperatorOidIndexId, on pg_amop using btree(oid oid_ops));
90+
DECLARE_UNIQUE_INDEX(pg_amop_fam_strat_index, 2653, AccessMethodStrategyIndexId, pg_amop, btree(amopfamily oid_ops, amoplefttype oid_ops, amoprighttype oid_ops, amopstrategy int2_ops));
91+
DECLARE_UNIQUE_INDEX(pg_amop_opr_fam_index, 2654, AccessMethodOperatorIndexId, pg_amop, btree(amopopr oid_ops, amoppurpose char_ops, amopfamily oid_ops));
92+
DECLARE_UNIQUE_INDEX_PKEY(pg_amop_oid_index, 2756, AccessMethodOperatorOidIndexId, pg_amop, btree(oid oid_ops));
9393

9494
#ifdef EXPOSE_TO_CLIENT_CODE
9595

src/include/catalog/pg_amproc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ CATALOG(pg_amproc,2603,AccessMethodProcedureRelationId)
6767
*/
6868
typedef FormData_pg_amproc *Form_pg_amproc;
6969

70-
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));
71-
DECLARE_UNIQUE_INDEX_PKEY(pg_amproc_oid_index, 2757, AccessMethodProcedureOidIndexId, on pg_amproc using btree(oid oid_ops));
70+
DECLARE_UNIQUE_INDEX(pg_amproc_fam_proc_index, 2655, AccessMethodProcedureIndexId, pg_amproc, btree(amprocfamily oid_ops, amproclefttype oid_ops, amprocrighttype oid_ops, amprocnum int2_ops));
71+
DECLARE_UNIQUE_INDEX_PKEY(pg_amproc_oid_index, 2757, AccessMethodProcedureOidIndexId, pg_amproc, btree(oid oid_ops));
7272

7373
#endif /* PG_AMPROC_H */

src/include/catalog/pg_attrdef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ typedef FormData_pg_attrdef *Form_pg_attrdef;
5050

5151
DECLARE_TOAST(pg_attrdef, 2830, 2831);
5252

53-
DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index, 2656, AttrDefaultIndexId, on pg_attrdef using btree(adrelid oid_ops, adnum int2_ops));
54-
DECLARE_UNIQUE_INDEX_PKEY(pg_attrdef_oid_index, 2657, AttrDefaultOidIndexId, on pg_attrdef using btree(oid oid_ops));
53+
DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index, 2656, AttrDefaultIndexId, pg_attrdef, btree(adrelid oid_ops, adnum int2_ops));
54+
DECLARE_UNIQUE_INDEX_PKEY(pg_attrdef_oid_index, 2657, AttrDefaultOidIndexId, pg_attrdef, btree(oid oid_ops));
5555

5656
DECLARE_FOREIGN_KEY((adrelid, adnum), pg_attribute, (attrelid, attnum));
5757

src/include/catalog/pg_attribute.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
208208
*/
209209
typedef FormData_pg_attribute *Form_pg_attribute;
210210

211-
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index, 2658, AttributeRelidNameIndexId, on pg_attribute using btree(attrelid oid_ops, attname name_ops));
212-
DECLARE_UNIQUE_INDEX_PKEY(pg_attribute_relid_attnum_index, 2659, AttributeRelidNumIndexId, on pg_attribute using btree(attrelid oid_ops, attnum int2_ops));
211+
DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index, 2658, AttributeRelidNameIndexId, pg_attribute, btree(attrelid oid_ops, attname name_ops));
212+
DECLARE_UNIQUE_INDEX_PKEY(pg_attribute_relid_attnum_index, 2659, AttributeRelidNumIndexId, pg_attribute, btree(attrelid oid_ops, attnum int2_ops));
213213

214214
#ifdef EXPOSE_TO_CLIENT_CODE
215215

src/include/catalog/pg_auth_members.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ CATALOG(pg_auth_members,1261,AuthMemRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_
4545
*/
4646
typedef FormData_pg_auth_members *Form_pg_auth_members;
4747

48-
DECLARE_UNIQUE_INDEX_PKEY(pg_auth_members_oid_index, 6303, AuthMemOidIndexId, on pg_auth_members using btree(oid oid_ops));
49-
DECLARE_UNIQUE_INDEX(pg_auth_members_role_member_index, 2694, AuthMemRoleMemIndexId, on pg_auth_members using btree(roleid oid_ops, member oid_ops, grantor oid_ops));
50-
DECLARE_UNIQUE_INDEX(pg_auth_members_member_role_index, 2695, AuthMemMemRoleIndexId, on pg_auth_members using btree(member oid_ops, roleid oid_ops, grantor oid_ops));
51-
DECLARE_INDEX(pg_auth_members_grantor_index, 6302, AuthMemGrantorIndexId, on pg_auth_members using btree(grantor oid_ops));
48+
DECLARE_UNIQUE_INDEX_PKEY(pg_auth_members_oid_index, 6303, AuthMemOidIndexId, pg_auth_members, btree(oid oid_ops));
49+
DECLARE_UNIQUE_INDEX(pg_auth_members_role_member_index, 2694, AuthMemRoleMemIndexId, pg_auth_members, btree(roleid oid_ops, member oid_ops, grantor oid_ops));
50+
DECLARE_UNIQUE_INDEX(pg_auth_members_member_role_index, 2695, AuthMemMemRoleIndexId, pg_auth_members, btree(member oid_ops, roleid oid_ops, grantor oid_ops));
51+
DECLARE_INDEX(pg_auth_members_grantor_index, 6302, AuthMemGrantorIndexId, pg_auth_members, btree(grantor oid_ops));
5252

5353
#endif /* PG_AUTH_MEMBERS_H */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy