@@ -244,6 +244,18 @@ make_gin_key(JsonbValue *v, uint32 hash)
244244 key -> type = v -> type | (v -> val .boolean ? GINKeyTrue : 0 );
245245 SET_VARSIZE (key , GINKEYLEN );
246246 }
247+ else if (v -> type == jbvArray )
248+ {
249+ key = (GINKey * )palloc (GINKEYLEN );
250+ key -> type = v -> type ;
251+ SET_VARSIZE (key , GINKEYLEN );
252+ }
253+ else if (v -> type == jbvObject )
254+ {
255+ key = (GINKey * )palloc (GINKEYLEN );
256+ key -> type = v -> type ;
257+ SET_VARSIZE (key , GINKEYLEN );
258+ }
247259 else if (v -> type == jbvNumeric )
248260 {
249261 key = (GINKey * )palloc (GINKeyLenNumeric (VARSIZE_ANY (v -> val .numeric )));
@@ -386,6 +398,10 @@ compare_gin_key_value(GINKey *arg1, GINKey *arg2)
386398 {
387399 case jbvNull :
388400 return 0 ;
401+ case jbvArray :
402+ return 0 ;
403+ case jbvObject :
404+ return 0 ;
389405 case jbvBool :
390406 if (GINKeyIsTrue (arg1 ) == GINKeyIsTrue (arg2 ))
391407 return 0 ;
@@ -978,16 +994,20 @@ gin_extract_jsonb_hash_value_internal(Jsonb *jb, int32 *nentries)
978994 switch (r )
979995 {
980996 case WJB_BEGIN_ARRAY :
997+ entries [i ++ ] = PointerGetDatum (make_gin_key (& v , stack -> hash ));
998+ tmp = stack ;
999+ stack = (PathHashStack * ) palloc (sizeof (PathHashStack ));
1000+ stack -> parent = tmp ;
1001+ stack -> hash = stack -> parent -> hash ;
1002+ stack -> hash = (stack -> hash << 1 ) | (stack -> hash >> 31 );
1003+ stack -> hash ^= JB_FARRAY ;
1004+ break ;
9811005 case WJB_BEGIN_OBJECT :
1006+ entries [i ++ ] = PointerGetDatum (make_gin_key (& v , stack -> hash ));
9821007 tmp = stack ;
9831008 stack = (PathHashStack * ) palloc (sizeof (PathHashStack ));
9841009 stack -> parent = tmp ;
9851010 stack -> hash = stack -> parent -> hash ;
986- if (r == WJB_BEGIN_ARRAY )
987- {
988- stack -> hash = (stack -> hash << 1 ) | (stack -> hash >> 31 );
989- stack -> hash ^= JB_FARRAY ;
990- }
9911011 break ;
9921012 case WJB_KEY :
9931013 /* Initialize hash from parent */
0 commit comments