Skip to content

Commit c380a0d

Browse files
committed
Prevent ORDER BY for partial match
1 parent 6291a92 commit c380a0d

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

rumget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ callConsistentFn(RumState * rumstate, RumScanKey key)
9797

9898
for (i = 0; i < key->nentries; i++)
9999
{
100-
if (key->entryRes[i] && key->addInfoIsNull[0] == false)
100+
if (key->entryRes[i] && key->addInfoIsNull[i] == false)
101101
{
102102
key->outerAddInfoIsNull = false;
103103

rumscan.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ freeScanKeys(RumScanOpaque so)
302302
}
303303

304304
static void
305-
initScanKey(RumScanOpaque so, ScanKey skey, bool *hasNullQuery)
305+
initScanKey(RumScanOpaque so, ScanKey skey, bool *hasNullQuery,
306+
bool *hasPartialMatch)
306307
{
307308
Datum *queryValues;
308309
int32 nQueryValues = 0;
@@ -389,6 +390,15 @@ initScanKey(RumScanOpaque so, ScanKey skey, bool *hasNullQuery)
389390
queryValues, (RumNullCategory *) nullFlags,
390391
partial_matches, extra_data,
391392
(skey->sk_flags & SK_ORDER_BY) ? true : false);
393+
394+
if (partial_matches && hasPartialMatch)
395+
{
396+
int32 j;
397+
RumScanKey key = so->keys[so->nkeys - 1];
398+
399+
for (j = 0; *hasPartialMatch == false && j < key->nentries; j++)
400+
*hasPartialMatch |= key->scanEntry[j]->isPartialMatch;
401+
}
392402
}
393403

394404
static ScanDirection
@@ -494,6 +504,7 @@ rumNewScanKey(IndexScanDesc scan)
494504
int i;
495505
bool hasNullQuery = false;
496506
bool checkEmptyEntry = false;
507+
bool hasPartialMatch = false;
497508
MemoryContext oldCtx;
498509
enum {
499510
haofNone = 0x00,
@@ -520,7 +531,7 @@ rumNewScanKey(IndexScanDesc scan)
520531

521532
for (i = 0; i < scan->numberOfKeys; i++)
522533
{
523-
initScanKey(so, &scan->keyData[i], &hasNullQuery);
534+
initScanKey(so, &scan->keyData[i], &hasNullQuery, &hasPartialMatch);
524535
if (so->isVoidRes)
525536
break;
526537
}
@@ -542,7 +553,7 @@ rumNewScanKey(IndexScanDesc scan)
542553

543554
for (i = 0; i < scan->numberOfOrderBys; i++)
544555
{
545-
initScanKey(so, &scan->orderByData[i], &hasNullQuery);
556+
initScanKey(so, &scan->orderByData[i], &hasNullQuery, NULL);
546557
if (so->isVoidRes)
547558
break;
548559
}
@@ -610,6 +621,8 @@ rumNewScanKey(IndexScanDesc scan)
610621
}
611622

612623
adjustScanDirection(so);
624+
if (scan->numberOfOrderBys > 0 && hasPartialMatch)
625+
elog(ERROR,"Partial match and order by index couldn't be used together");
613626

614627
/* initialize expansible array of RumScanEntry pointers */
615628
so->totalentries = 0;

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