Skip to content

Commit b01788e

Browse files
author
Arseny Kositsyn
committed
[PGPRO-11599] Code review. Part 2.
Tags: rum
1 parent d49bb6e commit b01788e

File tree

1 file changed

+7
-31
lines changed

1 file changed

+7
-31
lines changed

src/rumget.c

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -760,31 +760,6 @@ scan_entry_cmp(const void *p1, const void *p2, void *arg)
760760
return -cmpEntries(arg, e1, e2);
761761
}
762762

763-
/*
764-
* The entryGetItem() function from rumget.c write the results to curItem
765-
* in a specific order. The functions below allow you to understand the order
766-
* in which the results will be returned. This is important in a multi-column
767-
* RUM index, when the results will be returned in different order for
768-
* different subquery conditions.
769-
*/
770-
static bool
771-
isEntryOrderedByAddInfo(RumState *rumstate, RumScanEntry entry)
772-
{
773-
if (rumstate->useAlternativeOrder)
774-
return (rumstate->attrnAddToColumn == entry->attnumOrig);
775-
else
776-
return false;
777-
}
778-
779-
static bool
780-
isKeyOrderedByAddInfo(RumState *rumstate, RumScanKey key)
781-
{
782-
if (rumstate->useAlternativeOrder)
783-
return (rumstate->attrnAddToColumn == key->attnumOrig);
784-
else
785-
return false;
786-
}
787-
788763
static bool
789764
isScanWithAltOrderKeys(RumScanOpaque so)
790765
{
@@ -798,7 +773,8 @@ isScanWithAltOrderKeys(RumScanOpaque so)
798773

799774
for (int i = 0; i < so->nkeys; i++)
800775
{
801-
if (isKeyOrderedByAddInfo(rumstate, so->keys[i]))
776+
if (rumstate->useAlternativeOrder &&
777+
rumstate->attrnAddToColumn == so->keys[i]->attnumOrig)
802778
withAltKeys = true;
803779
else
804780
withUsualKeys = true;
@@ -861,7 +837,7 @@ startScan(IndexScanDesc scan)
861837
*/
862838
if (isScanWithAltOrderKeys(so))
863839
{
864-
so->scanWithAltOrderKeys= true;
840+
so->scanWithAltOrderKeys = true;
865841
so->tbm = rum_tbm_create(work_mem * 1024L, NULL);
866842
}
867843

@@ -1611,7 +1587,7 @@ scanGetItemRegular(IndexScanDesc scan, RumItem *advancePast,
16111587
for (int i = 0; i < so->nkeys; i++)
16121588
{
16131589
if (so->keys[i]->orderBy ||
1614-
isKeyOrderedByAddInfo(rumstate, so->keys[i]))
1590+
rumstate->attrnAddToColumn == so->keys[i]->attnumOrig)
16151591
continue;
16161592

16171593
cur_key_tbm = rum_tbm_create(work_mem * 1024L, NULL);
@@ -1648,7 +1624,7 @@ scanGetItemRegular(IndexScanDesc scan, RumItem *advancePast,
16481624

16491625
/* In the case of scanning with altOrderKeys, skip the usual keys */
16501626
if (so->scanWithAltOrderKeys &&
1651-
isEntryOrderedByAddInfo(rumstate, entry) == false)
1627+
rumstate->attrnAddToColumn != entry->attnumOrig)
16521628
continue;
16531629

16541630
while (entry->isFinished == false &&
@@ -1687,7 +1663,7 @@ scanGetItemRegular(IndexScanDesc scan, RumItem *advancePast,
16871663

16881664
/* In the case of scanning with altOrderKeys, skip the usual keys */
16891665
if (key->orderBy || (so->scanWithAltOrderKeys &&
1690-
isKeyOrderedByAddInfo(rumstate, key) == false))
1666+
rumstate->attrnAddToColumn != so->keys[i]->attnumOrig))
16911667
continue;
16921668

16931669
keyGetItem(&so->rumstate, so->tempCtx, key);
@@ -1718,7 +1694,7 @@ scanGetItemRegular(IndexScanDesc scan, RumItem *advancePast,
17181694

17191695
/* In the case of scanning with altOrderKeys, skip the usual keys */
17201696
if (key->orderBy || (so->scanWithAltOrderKeys &&
1721-
isKeyOrderedByAddInfo(rumstate, key) == false))
1697+
rumstate->attrnAddToColumn != so->keys[i]->attnumOrig))
17221698
continue;
17231699

17241700
if (key->curItemMatches)

0 commit comments

Comments
 (0)