Skip to content

Commit 6a6389a

Browse files
committed
Add index OID macro argument to DECLARE_INDEX
Instead of defining symbols such as AmOidIndexId explicitly, include them as an argument of DECLARE_INDEX() and have genbki.pl generate the way as the table OID symbols from the CATALOG() declaration. Reviewed-by: John Naylor <john.naylor@enterprisedb.com> Discussion: https://www.postgresql.org/message-id/flat/ccef1e46-a404-25b1-9b4c-85f2c08e1f28%40enterprisedb.com
1 parent 445e36a commit 6a6389a

Some content is hidden

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

66 files changed

+133
-243
lines changed

src/backend/catalog/Catalog.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,16 @@ sub ParseHeader
9595
{ parent_table => $1, toast_oid => $2, toast_index_oid => $3 };
9696
}
9797
elsif (
98-
/^DECLARE_(UNIQUE_)?INDEX(_PKEY)?\(\s*(\w+),\s*(\d+),\s*(.+)\)/)
98+
/^DECLARE_(UNIQUE_)?INDEX(_PKEY)?\(\s*(\w+),\s*(\d+),\s*(\w+),\s*(.+)\)/)
9999
{
100100
push @{ $catalog{indexing} },
101101
{
102102
is_unique => $1 ? 1 : 0,
103103
is_pkey => $2 ? 1 : 0,
104104
index_name => $3,
105105
index_oid => $4,
106-
index_decl => $5
106+
index_oid_macro => $5,
107+
index_decl => $6
107108
};
108109
}
109110
elsif (

src/backend/catalog/genbki.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,14 @@
469469
printf $def "#define %s %s\n",
470470
$catalog->{rowtype_oid_macro}, $catalog->{rowtype_oid}
471471
if $catalog->{rowtype_oid_macro};
472+
473+
foreach my $index (@{ $catalog->{indexing} })
474+
{
475+
printf $def "#define %s %s\n",
476+
$index->{index_oid_macro}, $index->{index_oid}
477+
if $index->{index_oid_macro};
478+
}
479+
472480
print $def "\n";
473481
474482
# .bki CREATE command for this catalog

src/backend/utils/cache/syscache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@
9696
9797
There must be a unique index underlying each syscache (ie, an index
9898
whose key is the same as that of the cache). If there is not one
99-
already, add definitions for it to include/catalog/pg_*.h: you need
100-
to add a DECLARE_UNIQUE_INDEX macro and a #define for the index OID.
99+
already, add the definition for it to include/catalog/pg_*.h using
100+
DECLARE_UNIQUE_INDEX.
101101
(Adding an index requires a catversion.h update, while simply
102102
adding/deleting caches only requires a recompile.)
103103

src/include/catalog/genbki.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@
7676
*
7777
* The macro definitions are just to keep the C compiler from spitting up.
7878
*/
79-
#define DECLARE_INDEX(name,oid,decl) extern int no_such_variable
80-
#define DECLARE_UNIQUE_INDEX(name,oid,decl) extern int no_such_variable
81-
#define DECLARE_UNIQUE_INDEX_PKEY(name,oid,decl) extern int no_such_variable
79+
#define DECLARE_INDEX(name,oid,oidmacro,decl) extern int no_such_variable
80+
#define DECLARE_UNIQUE_INDEX(name,oid,oidmacro,decl) extern int no_such_variable
81+
#define DECLARE_UNIQUE_INDEX_PKEY(name,oid,oidmacro,decl) extern int no_such_variable
8282

8383
/*
8484
* These lines are processed by genbki.pl to create a table for use

src/include/catalog/pg_aggregate.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +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, on pg_aggregate using btree(aggfnoid oid_ops));
114-
#define AggregateFnoidIndexId 2650
113+
DECLARE_UNIQUE_INDEX_PKEY(pg_aggregate_fnoid_index, 2650, AggregateFnoidIndexId, on pg_aggregate using btree(aggfnoid oid_ops));
115114

116115
#ifdef EXPOSE_TO_CLIENT_CODE
117116

src/include/catalog/pg_am.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +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, on pg_am using btree(amname name_ops));
51-
#define AmNameIndexId 2651
52-
DECLARE_UNIQUE_INDEX_PKEY(pg_am_oid_index, 2652, on pg_am using btree(oid oid_ops));
53-
#define AmOidIndexId 2652
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));
5452

5553
#ifdef EXPOSE_TO_CLIENT_CODE
5654

src/include/catalog/pg_amop.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +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, on pg_amop using btree(amopfamily oid_ops, amoplefttype oid_ops, amoprighttype oid_ops, amopstrategy int2_ops));
91-
#define AccessMethodStrategyIndexId 2653
92-
DECLARE_UNIQUE_INDEX(pg_amop_opr_fam_index, 2654, on pg_amop using btree(amopopr oid_ops, amoppurpose char_ops, amopfamily oid_ops));
93-
#define AccessMethodOperatorIndexId 2654
94-
DECLARE_UNIQUE_INDEX_PKEY(pg_amop_oid_index, 2756, on pg_amop using btree(oid oid_ops));
95-
#define AccessMethodOperatorOidIndexId 2756
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));
9693

9794
#ifdef EXPOSE_TO_CLIENT_CODE
9895

src/include/catalog/pg_amproc.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +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, on pg_amproc using btree(amprocfamily oid_ops, amproclefttype oid_ops, amprocrighttype oid_ops, amprocnum int2_ops));
71-
#define AccessMethodProcedureIndexId 2655
72-
DECLARE_UNIQUE_INDEX_PKEY(pg_amproc_oid_index, 2757, on pg_amproc using btree(oid oid_ops));
73-
#define AccessMethodProcedureOidIndexId 2757
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));
7472

7573
#endif /* PG_AMPROC_H */

src/include/catalog/pg_attrdef.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ typedef FormData_pg_attrdef *Form_pg_attrdef;
4949

5050
DECLARE_TOAST(pg_attrdef, 2830, 2831);
5151

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

5755
DECLARE_FOREIGN_KEY((adrelid, adnum), pg_attribute, (attrelid, attnum));
5856

src/include/catalog/pg_attribute.h

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

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

214212
#ifdef EXPOSE_TO_CLIENT_CODE
215213

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