Skip to content

Commit c9c875a

Browse files
committed
Rename IndexInfo.ii_KeyAttrNumbers array
Rename ii_KeyAttrNumbers to ii_IndexAttrNumbers to prevent confusion with ii_NumIndexAttrs/ii_NumIndexKeyAttrs. ii_IndexAttrNumbers contains all attributes including "including" columns, not only key attribute. Discussion: https://www.postgresql.org/message-id/13123421-1d52-d0e4-c95c-6d69011e0595%40sigaev.ru
1 parent 9e9befa commit c9c875a

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

src/backend/catalog/index.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ index_check_primary_key(Relation heapRel,
239239
cmds = NIL;
240240
for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
241241
{
242-
AttrNumber attnum = indexInfo->ii_KeyAttrNumbers[i];
242+
AttrNumber attnum = indexInfo->ii_IndexAttrNumbers[i];
243243
HeapTuple atttuple;
244244
Form_pg_attribute attform;
245245

@@ -324,7 +324,7 @@ ConstructTupleDescriptor(Relation heapRelation,
324324
*/
325325
for (i = 0; i < numatts; i++)
326326
{
327-
AttrNumber atnum = indexInfo->ii_KeyAttrNumbers[i];
327+
AttrNumber atnum = indexInfo->ii_IndexAttrNumbers[i];
328328
Form_pg_attribute to = TupleDescAttr(indexTupDesc, i);
329329
HeapTuple tuple;
330330
Form_pg_type typeTup;
@@ -607,7 +607,7 @@ UpdateIndexRelation(Oid indexoid,
607607
*/
608608
indkey = buildint2vector(NULL, indexInfo->ii_NumIndexAttrs);
609609
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
610-
indkey->values[i] = indexInfo->ii_KeyAttrNumbers[i];
610+
indkey->values[i] = indexInfo->ii_IndexAttrNumbers[i];
611611
indcollation = buildoidvector(collationOids, indexInfo->ii_NumIndexAttrs);
612612
indclass = buildoidvector(classOids, indexInfo->ii_NumIndexKeyAttrs);
613613
indoption = buildint2vector(coloptions, indexInfo->ii_NumIndexAttrs);
@@ -1041,11 +1041,11 @@ index_create(Relation heapRelation,
10411041
/* Create auto dependencies on simply-referenced columns */
10421042
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
10431043
{
1044-
if (indexInfo->ii_KeyAttrNumbers[i] != 0)
1044+
if (indexInfo->ii_IndexAttrNumbers[i] != 0)
10451045
{
10461046
referenced.classId = RelationRelationId;
10471047
referenced.objectId = heapRelationId;
1048-
referenced.objectSubId = indexInfo->ii_KeyAttrNumbers[i];
1048+
referenced.objectSubId = indexInfo->ii_IndexAttrNumbers[i];
10491049

10501050
recordDependencyOn(&myself, &referenced, deptype);
10511051

@@ -1297,7 +1297,7 @@ index_constraint_create(Relation heapRelation,
12971297
true,
12981298
parentConstraintId,
12991299
RelationGetRelid(heapRelation),
1300-
indexInfo->ii_KeyAttrNumbers,
1300+
indexInfo->ii_IndexAttrNumbers,
13011301
indexInfo->ii_NumIndexKeyAttrs,
13021302
indexInfo->ii_NumIndexAttrs,
13031303
InvalidOid, /* no domain */
@@ -1757,7 +1757,7 @@ BuildIndexInfo(Relation index)
17571757
Assert(ii->ii_NumIndexKeyAttrs <= ii->ii_NumIndexAttrs);
17581758

17591759
for (i = 0; i < numAtts; i++)
1760-
ii->ii_KeyAttrNumbers[i] = indexStruct->indkey.values[i];
1760+
ii->ii_IndexAttrNumbers[i] = indexStruct->indkey.values[i];
17611761

17621762
/* fetch any expressions needed for expressional indexes */
17631763
ii->ii_Expressions = RelationGetIndexExpressions(index);
@@ -1840,13 +1840,13 @@ CompareIndexInfo(IndexInfo *info1, IndexInfo *info2,
18401840
*/
18411841
for (i = 0; i < info1->ii_NumIndexAttrs; i++)
18421842
{
1843-
if (maplen < info2->ii_KeyAttrNumbers[i])
1843+
if (maplen < info2->ii_IndexAttrNumbers[i])
18441844
elog(ERROR, "incorrect attribute map");
18451845

18461846
/* ignore expressions at this stage */
1847-
if ((info1->ii_KeyAttrNumbers[i] != InvalidAttrNumber) &&
1848-
(attmap[info2->ii_KeyAttrNumbers[i] - 1] !=
1849-
info1->ii_KeyAttrNumbers[i]))
1847+
if ((info1->ii_IndexAttrNumbers[i] != InvalidAttrNumber) &&
1848+
(attmap[info2->ii_IndexAttrNumbers[i] - 1] !=
1849+
info1->ii_IndexAttrNumbers[i]))
18501850
return false;
18511851

18521852
if (collations1[i] != collations2[i])
@@ -2007,7 +2007,7 @@ FormIndexDatum(IndexInfo *indexInfo,
20072007

20082008
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
20092009
{
2010-
int keycol = indexInfo->ii_KeyAttrNumbers[i];
2010+
int keycol = indexInfo->ii_IndexAttrNumbers[i];
20112011
Datum iDatum;
20122012
bool isNull;
20132013

src/backend/catalog/toasting.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
304304
indexInfo = makeNode(IndexInfo);
305305
indexInfo->ii_NumIndexAttrs = 2;
306306
indexInfo->ii_NumIndexKeyAttrs = 2;
307-
indexInfo->ii_KeyAttrNumbers[0] = 1;
308-
indexInfo->ii_KeyAttrNumbers[1] = 2;
307+
indexInfo->ii_IndexAttrNumbers[0] = 1;
308+
indexInfo->ii_IndexAttrNumbers[1] = 2;
309309
indexInfo->ii_Expressions = NIL;
310310
indexInfo->ii_ExpressionsState = NIL;
311311
indexInfo->ii_Predicate = NIL;

src/backend/commands/analyze.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ do_analyze_rel(Relation onerel, int options, VacuumParams *params,
495495
tcnt = 0;
496496
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
497497
{
498-
int keycol = indexInfo->ii_KeyAttrNumbers[i];
498+
int keycol = indexInfo->ii_IndexAttrNumbers[i];
499499

500500
if (keycol == 0)
501501
{

src/backend/commands/indexcmds.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ DefineIndex(Oid relationId,
724724

725725
for (j = 0; j < indexInfo->ii_NumIndexAttrs; j++)
726726
{
727-
if (key->partattrs[i] == indexInfo->ii_KeyAttrNumbers[j])
727+
if (key->partattrs[i] == indexInfo->ii_IndexAttrNumbers[j])
728728
{
729729
found = true;
730730
break;
@@ -753,7 +753,7 @@ DefineIndex(Oid relationId,
753753
*/
754754
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
755755
{
756-
AttrNumber attno = indexInfo->ii_KeyAttrNumbers[i];
756+
AttrNumber attno = indexInfo->ii_IndexAttrNumbers[i];
757757

758758
if (attno < 0 && attno != ObjectIdAttributeNumber)
759759
ereport(ERROR,
@@ -1428,7 +1428,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
14281428
attribute->name)));
14291429
}
14301430
attform = (Form_pg_attribute) GETSTRUCT(atttuple);
1431-
indexInfo->ii_KeyAttrNumbers[attn] = attform->attnum;
1431+
indexInfo->ii_IndexAttrNumbers[attn] = attform->attnum;
14321432
atttype = attform->atttypid;
14331433
attcollation = attform->attcollation;
14341434
ReleaseSysCache(atttuple);
@@ -1461,11 +1461,11 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
14611461
* User wrote "(column)" or "(column COLLATE something)".
14621462
* Treat it like simple attribute anyway.
14631463
*/
1464-
indexInfo->ii_KeyAttrNumbers[attn] = ((Var *) expr)->varattno;
1464+
indexInfo->ii_IndexAttrNumbers[attn] = ((Var *) expr)->varattno;
14651465
}
14661466
else
14671467
{
1468-
indexInfo->ii_KeyAttrNumbers[attn] = 0; /* marks expression */
1468+
indexInfo->ii_IndexAttrNumbers[attn] = 0; /* marks expression */
14691469
indexInfo->ii_Expressions = lappend(indexInfo->ii_Expressions,
14701470
expr);
14711471

src/backend/utils/cache/relcache.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5065,7 +5065,7 @@ RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind attrKind)
50655065
/* Collect simple attribute references */
50665066
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
50675067
{
5068-
int attrnum = indexInfo->ii_KeyAttrNumbers[i];
5068+
int attrnum = indexInfo->ii_IndexAttrNumbers[i];
50695069

50705070
/*
50715071
* Since we have covering indexes with non-key columns, we must

src/backend/utils/sort/tuplesort.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -3718,7 +3718,7 @@ comparetup_cluster(const SortTuple *a, const SortTuple *b,
37183718
datum2;
37193719
bool isnull1,
37203720
isnull2;
3721-
AttrNumber leading = state->indexInfo->ii_KeyAttrNumbers[0];
3721+
AttrNumber leading = state->indexInfo->ii_IndexAttrNumbers[0];
37223722

37233723
/* Be prepared to compare additional sort keys */
37243724
ltup = (HeapTuple) a->tuple;
@@ -3761,7 +3761,7 @@ comparetup_cluster(const SortTuple *a, const SortTuple *b,
37613761

37623762
for (; nkey < state->nKeys; nkey++, sortKey++)
37633763
{
3764-
AttrNumber attno = state->indexInfo->ii_KeyAttrNumbers[nkey];
3764+
AttrNumber attno = state->indexInfo->ii_IndexAttrNumbers[nkey];
37653765

37663766
datum1 = heap_getattr(ltup, attno, tupDesc, &isnull1);
37673767
datum2 = heap_getattr(rtup, attno, tupDesc, &isnull2);
@@ -3833,11 +3833,11 @@ copytup_cluster(Tuplesortstate *state, SortTuple *stup, void *tup)
38333833
* set up first-column key value, and potentially abbreviate, if it's a
38343834
* simple column
38353835
*/
3836-
if (state->indexInfo->ii_KeyAttrNumbers[0] == 0)
3836+
if (state->indexInfo->ii_IndexAttrNumbers[0] == 0)
38373837
return;
38383838

38393839
original = heap_getattr(tuple,
3840-
state->indexInfo->ii_KeyAttrNumbers[0],
3840+
state->indexInfo->ii_IndexAttrNumbers[0],
38413841
state->tupDesc,
38423842
&stup->isnull1);
38433843

@@ -3881,7 +3881,7 @@ copytup_cluster(Tuplesortstate *state, SortTuple *stup, void *tup)
38813881

38823882
tuple = (HeapTuple) mtup->tuple;
38833883
mtup->datum1 = heap_getattr(tuple,
3884-
state->indexInfo->ii_KeyAttrNumbers[0],
3884+
state->indexInfo->ii_IndexAttrNumbers[0],
38853885
state->tupDesc,
38863886
&mtup->isnull1);
38873887
}
@@ -3935,9 +3935,9 @@ readtup_cluster(Tuplesortstate *state, SortTuple *stup,
39353935
&tuplen, sizeof(tuplen));
39363936
stup->tuple = (void *) tuple;
39373937
/* set up first-column key value, if it's a simple column */
3938-
if (state->indexInfo->ii_KeyAttrNumbers[0] != 0)
3938+
if (state->indexInfo->ii_IndexAttrNumbers[0] != 0)
39393939
stup->datum1 = heap_getattr(tuple,
3940-
state->indexInfo->ii_KeyAttrNumbers[0],
3940+
state->indexInfo->ii_IndexAttrNumbers[0],
39413941
state->tupDesc,
39423942
&stup->isnull1);
39433943
}

src/include/nodes/execnodes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ typedef struct IndexInfo
150150
NodeTag type;
151151
int ii_NumIndexAttrs; /* total number of columns in index */
152152
int ii_NumIndexKeyAttrs; /* number of key columns in index */
153-
AttrNumber ii_KeyAttrNumbers[INDEX_MAX_KEYS];
153+
AttrNumber ii_IndexAttrNumbers[INDEX_MAX_KEYS];
154154
List *ii_Expressions; /* list of Expr */
155155
List *ii_ExpressionsState; /* list of ExprState */
156156
List *ii_Predicate; /* list of Expr */

0 commit comments

Comments
 (0)