@@ -302,7 +302,8 @@ freeScanKeys(RumScanOpaque so)
302
302
}
303
303
304
304
static void
305
- initScanKey (RumScanOpaque so , ScanKey skey , bool * hasNullQuery )
305
+ initScanKey (RumScanOpaque so , ScanKey skey , bool * hasNullQuery ,
306
+ bool * hasPartialMatch )
306
307
{
307
308
Datum * queryValues ;
308
309
int32 nQueryValues = 0 ;
@@ -389,6 +390,15 @@ initScanKey(RumScanOpaque so, ScanKey skey, bool *hasNullQuery)
389
390
queryValues , (RumNullCategory * ) nullFlags ,
390
391
partial_matches , extra_data ,
391
392
(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
+ }
392
402
}
393
403
394
404
static ScanDirection
@@ -494,6 +504,7 @@ rumNewScanKey(IndexScanDesc scan)
494
504
int i ;
495
505
bool hasNullQuery = false;
496
506
bool checkEmptyEntry = false;
507
+ bool hasPartialMatch = false;
497
508
MemoryContext oldCtx ;
498
509
enum {
499
510
haofNone = 0x00 ,
@@ -520,7 +531,7 @@ rumNewScanKey(IndexScanDesc scan)
520
531
521
532
for (i = 0 ; i < scan -> numberOfKeys ; i ++ )
522
533
{
523
- initScanKey (so , & scan -> keyData [i ], & hasNullQuery );
534
+ initScanKey (so , & scan -> keyData [i ], & hasNullQuery , & hasPartialMatch );
524
535
if (so -> isVoidRes )
525
536
break ;
526
537
}
@@ -542,7 +553,7 @@ rumNewScanKey(IndexScanDesc scan)
542
553
543
554
for (i = 0 ; i < scan -> numberOfOrderBys ; i ++ )
544
555
{
545
- initScanKey (so , & scan -> orderByData [i ], & hasNullQuery );
556
+ initScanKey (so , & scan -> orderByData [i ], & hasNullQuery , NULL );
546
557
if (so -> isVoidRes )
547
558
break ;
548
559
}
@@ -610,6 +621,8 @@ rumNewScanKey(IndexScanDesc scan)
610
621
}
611
622
612
623
adjustScanDirection (so );
624
+ if (scan -> numberOfOrderBys > 0 && hasPartialMatch )
625
+ elog (ERROR ,"Partial match and order by index couldn't be used together" );
613
626
614
627
/* initialize expansible array of RumScanEntry pointers */
615
628
so -> totalentries = 0 ;
0 commit comments