@@ -244,6 +244,18 @@ make_gin_key(JsonbValue *v, uint32 hash)
244244key -> type = v -> type | (v -> val .boolean ?GINKeyTrue :0 );
245245SET_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+ }
247259else if (v -> type == jbvNumeric )
248260{
249261key = (GINKey * )palloc (GINKeyLenNumeric (VARSIZE_ANY (v -> val .numeric )));
@@ -386,6 +398,10 @@ compare_gin_key_value(GINKey *arg1, GINKey *arg2)
386398{
387399case jbvNull :
388400return 0 ;
401+ case jbvArray :
402+ return 0 ;
403+ case jbvObject :
404+ return 0 ;
389405case jbvBool :
390406if (GINKeyIsTrue (arg1 )== GINKeyIsTrue (arg2 ))
391407return 0 ;
@@ -978,16 +994,20 @@ gin_extract_jsonb_hash_value_internal(Jsonb *jb, int32 *nentries)
978994switch (r )
979995{
980996case 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 ;
9811005case WJB_BEGIN_OBJECT :
1006+ entries [i ++ ]= PointerGetDatum (make_gin_key (& v ,stack -> hash ));
9821007tmp = stack ;
9831008stack = (PathHashStack * )palloc (sizeof (PathHashStack ));
9841009stack -> parent = tmp ;
9851010stack -> 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- }
9911011break ;
9921012case WJB_KEY :
9931013/* Initialize hash from parent */