@@ -812,6 +812,7 @@ make_hash_entry_handler(ExtractedNode *node, Pointer extra)
812
812
GINKey * key ;
813
813
KeyExtra * keyExtra ;
814
814
int result ;
815
+ bool partialMatch = false;
815
816
816
817
Assert (node -> type == eScalar );
817
818
@@ -827,11 +828,23 @@ make_hash_entry_handler(ExtractedNode *node, Pointer extra)
827
828
if (!node -> bounds .inequality )
828
829
{
829
830
if (node -> bounds .exact -> type == jqiAny )
830
- return -1 ;
831
- key = make_gin_query_key (node -> bounds .exact , hash );
831
+ {
832
+ JsQueryValue value ;
833
+ value .jqBase = NULL ;
834
+ value .jqPos = 0 ;
835
+ value .type = jqiNull ;
836
+ key = make_gin_query_key (& value , hash );
837
+ partialMatch = true;
838
+ keyExtra -> lossy = true;
839
+ }
840
+ else
841
+ {
842
+ key = make_gin_query_key (node -> bounds .exact , hash );
843
+ }
832
844
}
833
845
else
834
846
{
847
+ partialMatch = true;
835
848
if (node -> bounds .leftBound )
836
849
{
837
850
key = make_gin_query_key (node -> bounds .leftBound , hash );
@@ -852,8 +865,7 @@ make_hash_entry_handler(ExtractedNode *node, Pointer extra)
852
865
keyExtra -> rightBound = NULL ;
853
866
}
854
867
}
855
- result = add_entry (e , PointerGetDatum (key ), (Pointer )keyExtra ,
856
- node -> bounds .inequality );
868
+ result = add_entry (e , PointerGetDatum (key ), (Pointer )keyExtra , partialMatch );
857
869
return result ;
858
870
}
859
871
@@ -893,7 +905,11 @@ gin_compare_partial_jsonb_hash_value(PG_FUNCTION_ARGS)
893
905
{
894
906
KeyExtra * extra_data = (KeyExtra * )PG_GETARG_POINTER (3 );
895
907
896
- if (extra_data -> inequality )
908
+ if (extra_data -> lossy )
909
+ {
910
+ result = 0 ;
911
+ }
912
+ else if (extra_data -> inequality )
897
913
{
898
914
result = 0 ;
899
915
if (!extra_data -> leftInclusive && compare_gin_key_value (key , partial_key ) <= 0 )
0 commit comments