@@ -466,19 +466,18 @@ vodkajsonbconsistent(PG_FUNCTION_ARGS)
466466int32 nkeys = PG_GETARG_INT32 (3 );
467467bool * recheck = (bool * )PG_GETARG_POINTER (4 );
468468VodkaKey * queryKeys = (VodkaKey * )PG_GETARG_POINTER (5 );
469+ ExtractedNode * root ;
469470bool res ;
470471int32 i ;
471472
472473switch (strategy )
473474{
474475case JsonbContainsStrategyNumber :
475- /* result is not lossy */
476- * recheck = false;
477- /* must have all elements in check[] true, and no nulls */
476+ * recheck = true;
478477res = true;
479478for (i = 0 ;i < nkeys ;i ++ )
480479{
481- if (!check [i ]|| queryKeys [ i ]. isnull )
480+ if (!check [i ])
482481{
483482res = false;
484483break ;
@@ -487,10 +486,12 @@ vodkajsonbconsistent(PG_FUNCTION_ARGS)
487486break ;
488487
489488case JsQueryMatchStrategyNumber :
489+ root = (ExtractedNode * )queryKeys [0 ].extra ;
490+ * recheck = root -> indirect ;
490491if (nkeys == 0 )
491492res = true;
492493else
493- res = execRecursive (( ExtractedNode * ) queryKeys [ 0 ]. extra ,check );
494+ res = execRecursive (root ,check );
494495break ;
495496
496497default :
@@ -516,6 +517,7 @@ vodkajsonbtriconsistent(PG_FUNCTION_ARGS)
516517
517518/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
518519VodkaKey * queryKeys = (VodkaKey * )PG_GETARG_POINTER (4 );
520+ ExtractedNode * root ;
519521VodkaTernaryValue res ;
520522int32 i ;
521523
@@ -539,12 +541,13 @@ vodkajsonbtriconsistent(PG_FUNCTION_ARGS)
539541break ;
540542
541543case JsQueryMatchStrategyNumber :
544+ root = (ExtractedNode * )queryKeys [0 ].extra ;
542545if (nkeys == 0 )
543546res = GIN_MAYBE ;
544547else
545- res = execRecursiveTristate (( ExtractedNode * ) queryKeys [ 0 ]. extra ,check );
548+ res = execRecursiveTristate (root ,check );
546549
547- if (res == GIN_TRUE )
550+ if (root -> indirect && res == GIN_TRUE )
548551res = GIN_MAYBE ;
549552
550553break ;