@@ -245,6 +245,18 @@ make_gin_key(JsonbValue *v, uint32 hash)
245245 key -> type = v -> type | (v -> val .boolean ? GINKeyTrue : 0 );
246246 SET_VARSIZE (key , GINKEYLEN );
247247 }
248+ else if (v -> type == jbvArray )
249+ {
250+ key = (GINKey * )palloc (GINKEYLEN );
251+ key -> type = v -> type ;
252+ SET_VARSIZE (key , GINKEYLEN );
253+ }
254+ else if (v -> type == jbvObject )
255+ {
256+ key = (GINKey * )palloc (GINKEYLEN );
257+ key -> type = v -> type ;
258+ SET_VARSIZE (key , GINKEYLEN );
259+ }
248260 else if (v -> type == jbvNumeric )
249261 {
250262 key = (GINKey * )palloc (GINKeyLenNumeric (VARSIZE_ANY (v -> val .numeric )));
@@ -387,6 +399,10 @@ compare_gin_key_value(GINKey *arg1, GINKey *arg2)
387399 {
388400 case jbvNull :
389401 return 0 ;
402+ case jbvArray :
403+ return 0 ;
404+ case jbvObject :
405+ return 0 ;
390406 case jbvBool :
391407 if (GINKeyIsTrue (arg1 ) == GINKeyIsTrue (arg2 ))
392408 return 0 ;
@@ -979,16 +995,20 @@ gin_extract_jsonb_hash_value_internal(Jsonb *jb, int32 *nentries)
979995 switch (r )
980996 {
981997 case WJB_BEGIN_ARRAY :
998+ entries [i ++ ] = PointerGetDatum (make_gin_key (& v , stack -> hash ));
999+ tmp = stack ;
1000+ stack = (PathHashStack * ) palloc (sizeof (PathHashStack ));
1001+ stack -> parent = tmp ;
1002+ stack -> hash = stack -> parent -> hash ;
1003+ stack -> hash = (stack -> hash << 1 ) | (stack -> hash >> 31 );
1004+ stack -> hash ^= JB_FARRAY ;
1005+ break ;
9821006 case WJB_BEGIN_OBJECT :
1007+ entries [i ++ ] = PointerGetDatum (make_gin_key (& v , stack -> hash ));
9831008 tmp = stack ;
9841009 stack = (PathHashStack * ) palloc (sizeof (PathHashStack ));
9851010 stack -> parent = tmp ;
9861011 stack -> hash = stack -> parent -> hash ;
987- if (r == WJB_BEGIN_ARRAY )
988- {
989- stack -> hash = (stack -> hash << 1 ) | (stack -> hash >> 31 );
990- stack -> hash ^= JB_FARRAY ;
991- }
9921012 break ;
9931013 case WJB_KEY :
9941014 /* Initialize hash from parent */
0 commit comments