Skip to content

Commit 99bc012

Browse files
committed
Minor cleanup of indxpath.c.
Eliminate some superfluous notational complexity around match_clause_to_indexcol(), and rip out the DoneMatchingIndexKeys crock.
1 parent d1d8462 commit 99bc012

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

src/backend/optimizer/path/indxpath.c

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
#include "utils/selfuncs.h"
3838

3939

40-
/*
41-
* DoneMatchingIndexKeys() - MACRO
42-
*/
43-
#define DoneMatchingIndexKeys(families) (families[0] == InvalidOid)
44-
4540
#define IsBooleanOpfamily(opfamily) \
4641
((opfamily) == BOOL_BTREE_FAM_OID || (opfamily) == BOOL_HASH_FAM_OID)
4742

@@ -83,7 +78,7 @@ static PathClauseUsage *classify_index_clause_usage(Path *path,
8378
static void find_indexpath_quals(Path *bitmapqual, List **quals, List **preds);
8479
static int find_list_position(Node *node, List **nodelist);
8580
static bool match_clause_to_indexcol(IndexOptInfo *index,
86-
int indexcol, Oid opfamily,
81+
int indexcol,
8782
RestrictInfo *rinfo,
8883
Relids outer_relids,
8984
SaOpControl saop_control);
@@ -1053,7 +1048,6 @@ group_clauses_by_indexkey(IndexOptInfo *index,
10531048
List *clausegroup_list = NIL;
10541049
bool found_outer_clause = false;
10551050
int indexcol = 0;
1056-
Oid *families = index->opfamily;
10571051

10581052
*found_clause = false; /* default result */
10591053

@@ -1062,7 +1056,6 @@ group_clauses_by_indexkey(IndexOptInfo *index,
10621056

10631057
do
10641058
{
1065-
Oid curFamily = families[0];
10661059
List *clausegroup = NIL;
10671060
ListCell *l;
10681061

@@ -1074,7 +1067,6 @@ group_clauses_by_indexkey(IndexOptInfo *index,
10741067
Assert(IsA(rinfo, RestrictInfo));
10751068
if (match_clause_to_indexcol(index,
10761069
indexcol,
1077-
curFamily,
10781070
rinfo,
10791071
outer_relids,
10801072
saop_control))
@@ -1094,7 +1086,6 @@ group_clauses_by_indexkey(IndexOptInfo *index,
10941086
Assert(IsA(rinfo, RestrictInfo));
10951087
if (match_clause_to_indexcol(index,
10961088
indexcol,
1097-
curFamily,
10981089
rinfo,
10991090
outer_relids,
11001091
saop_control))
@@ -1113,9 +1104,8 @@ group_clauses_by_indexkey(IndexOptInfo *index,
11131104
clausegroup_list = lappend(clausegroup_list, clausegroup);
11141105

11151106
indexcol++;
1116-
families++;
11171107

1118-
} while (!DoneMatchingIndexKeys(families));
1108+
} while (indexcol < index->ncolumns);
11191109

11201110
if (!*found_clause && !found_outer_clause)
11211111
return NIL; /* no indexable clauses anywhere */
@@ -1185,7 +1175,6 @@ group_clauses_by_indexkey(IndexOptInfo *index,
11851175
static bool
11861176
match_clause_to_indexcol(IndexOptInfo *index,
11871177
int indexcol,
1188-
Oid opfamily,
11891178
RestrictInfo *rinfo,
11901179
Relids outer_relids,
11911180
SaOpControl saop_control)
@@ -1196,6 +1185,7 @@ match_clause_to_indexcol(IndexOptInfo *index,
11961185
Relids left_relids;
11971186
Relids right_relids;
11981187
Oid expr_op;
1188+
Oid opfamily = index->opfamily[indexcol];
11991189
bool plain_op;
12001190

12011191
/*
@@ -1582,23 +1572,18 @@ matches_any_index(RestrictInfo *rinfo, RelOptInfo *rel, Relids outer_relids)
15821572
{
15831573
IndexOptInfo *index = (IndexOptInfo *) lfirst(l);
15841574
int indexcol = 0;
1585-
Oid *families = index->opfamily;
15861575

15871576
do
15881577
{
1589-
Oid curFamily = families[0];
1590-
15911578
if (match_clause_to_indexcol(index,
15921579
indexcol,
1593-
curFamily,
15941580
rinfo,
15951581
outer_relids,
15961582
SAOP_ALLOW))
15971583
return true;
15981584

15991585
indexcol++;
1600-
families++;
1601-
} while (!DoneMatchingIndexKeys(families));
1586+
} while (indexcol < index->ncolumns);
16021587
}
16031588

16041589
return false;
@@ -1621,11 +1606,10 @@ eclass_matches_any_index(EquivalenceClass *ec, EquivalenceMember *em,
16211606
{
16221607
IndexOptInfo *index = (IndexOptInfo *) lfirst(l);
16231608
int indexcol = 0;
1624-
Oid *families = index->opfamily;
16251609

16261610
do
16271611
{
1628-
Oid curFamily = families[0];
1612+
Oid curFamily = index->opfamily[indexcol];
16291613

16301614
/*
16311615
* If it's a btree index, we can reject it if its opfamily isn't
@@ -1643,8 +1627,7 @@ eclass_matches_any_index(EquivalenceClass *ec, EquivalenceMember *em,
16431627
return true;
16441628

16451629
indexcol++;
1646-
families++;
1647-
} while (!DoneMatchingIndexKeys(families));
1630+
} while (indexcol < index->ncolumns);
16481631
}
16491632

16501633
return false;
@@ -2379,15 +2362,14 @@ expand_indexqual_conditions(IndexOptInfo *index, List *clausegroups)
23792362
List *resultquals = NIL;
23802363
ListCell *clausegroup_item;
23812364
int indexcol = 0;
2382-
Oid *families = index->opfamily;
23832365

23842366
if (clausegroups == NIL)
23852367
return NIL;
23862368

23872369
clausegroup_item = list_head(clausegroups);
23882370
do
23892371
{
2390-
Oid curFamily = families[0];
2372+
Oid curFamily = index->opfamily[indexcol];
23912373
ListCell *l;
23922374

23932375
foreach(l, (List *) lfirst(clausegroup_item))
@@ -2447,8 +2429,7 @@ expand_indexqual_conditions(IndexOptInfo *index, List *clausegroups)
24472429
clausegroup_item = lnext(clausegroup_item);
24482430

24492431
indexcol++;
2450-
families++;
2451-
} while (clausegroup_item != NULL && !DoneMatchingIndexKeys(families));
2432+
} while (clausegroup_item != NULL && indexcol < index->ncolumns);
24522433

24532434
Assert(clausegroup_item == NULL); /* else more groups than indexkeys */
24542435

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