@@ -466,19 +466,18 @@ vodkajsonbconsistent(PG_FUNCTION_ARGS)
466
466
int32 nkeys = PG_GETARG_INT32 (3 );
467
467
bool * recheck = (bool * ) PG_GETARG_POINTER (4 );
468
468
VodkaKey * queryKeys = (VodkaKey * ) PG_GETARG_POINTER (5 );
469
+ ExtractedNode * root ;
469
470
bool res ;
470
471
int32 i ;
471
472
472
473
switch (strategy )
473
474
{
474
475
case JsonbContainsStrategyNumber :
475
- /* result is not lossy */
476
- * recheck = false;
477
- /* must have all elements in check[] true, and no nulls */
476
+ * recheck = true;
478
477
res = true;
479
478
for (i = 0 ; i < nkeys ; i ++ )
480
479
{
481
- if (!check [i ] || queryKeys [ i ]. isnull )
480
+ if (!check [i ])
482
481
{
483
482
res = false;
484
483
break ;
@@ -487,10 +486,12 @@ vodkajsonbconsistent(PG_FUNCTION_ARGS)
487
486
break ;
488
487
489
488
case JsQueryMatchStrategyNumber :
489
+ root = (ExtractedNode * )queryKeys [0 ].extra ;
490
+ * recheck = root -> indirect ;
490
491
if (nkeys == 0 )
491
492
res = true;
492
493
else
493
- res = execRecursive (( ExtractedNode * ) queryKeys [ 0 ]. extra , check );
494
+ res = execRecursive (root , check );
494
495
break ;
495
496
496
497
default :
@@ -516,6 +517,7 @@ vodkajsonbtriconsistent(PG_FUNCTION_ARGS)
516
517
517
518
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
518
519
VodkaKey * queryKeys = (VodkaKey * ) PG_GETARG_POINTER (4 );
520
+ ExtractedNode * root ;
519
521
VodkaTernaryValue res ;
520
522
int32 i ;
521
523
@@ -539,12 +541,13 @@ vodkajsonbtriconsistent(PG_FUNCTION_ARGS)
539
541
break ;
540
542
541
543
case JsQueryMatchStrategyNumber :
544
+ root = (ExtractedNode * )queryKeys [0 ].extra ;
542
545
if (nkeys == 0 )
543
546
res = GIN_MAYBE ;
544
547
else
545
- res = execRecursiveTristate (( ExtractedNode * ) queryKeys [ 0 ]. extra , check );
548
+ res = execRecursiveTristate (root , check );
546
549
547
- if (res == GIN_TRUE )
550
+ if (root -> indirect && res == GIN_TRUE )
548
551
res = GIN_MAYBE ;
549
552
550
553
break ;
0 commit comments