Skip to content

Commit 73b7912

Browse files
committed
Support * for jsonb_hash_value_ops.
1 parent 832649c commit 73b7912

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

jsonb_gin_ops.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,7 @@ make_hash_entry_handler(ExtractedNode *node, Pointer extra)
812812
GINKey *key;
813813
KeyExtra *keyExtra;
814814
int result;
815+
bool partialMatch = false;
815816

816817
Assert(node->type == eScalar);
817818

@@ -827,11 +828,23 @@ make_hash_entry_handler(ExtractedNode *node, Pointer extra)
827828
if (!node->bounds.inequality)
828829
{
829830
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+
}
832844
}
833845
else
834846
{
847+
partialMatch = true;
835848
if (node->bounds.leftBound)
836849
{
837850
key = make_gin_query_key(node->bounds.leftBound, hash);
@@ -852,8 +865,7 @@ make_hash_entry_handler(ExtractedNode *node, Pointer extra)
852865
keyExtra->rightBound = NULL;
853866
}
854867
}
855-
result = add_entry(e, PointerGetDatum(key), (Pointer)keyExtra,
856-
node->bounds.inequality);
868+
result = add_entry(e, PointerGetDatum(key), (Pointer)keyExtra, partialMatch);
857869
return result;
858870
}
859871

@@ -893,7 +905,11 @@ gin_compare_partial_jsonb_hash_value(PG_FUNCTION_ARGS)
893905
{
894906
KeyExtra *extra_data = (KeyExtra *)PG_GETARG_POINTER(3);
895907

896-
if (extra_data->inequality)
908+
if (extra_data->lossy)
909+
{
910+
result = 0;
911+
}
912+
else if (extra_data->inequality)
897913
{
898914
result = 0;
899915
if (!extra_data->leftInclusive && compare_gin_key_value(key, partial_key) <= 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