From: Peter Geoghegan Date: Wed, 19 Mar 2014 09:13:42 +0000 (-0700) Subject: Revert "For jsonb_hash_ops, hash less" X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=2cea5213dba011625fc0d5c6b447e838080087b1;p=users%2Fandresfreund%2Fpostgres.git Revert "For jsonb_hash_ops, hash less" This might be workable with another approach, but leave it for now. This reverts commit b8199ee3c2506ab81b47a0b440363fc90c0d6956. --- diff --git a/src/backend/utils/adt/jsonb_gin.c b/src/backend/utils/adt/jsonb_gin.c index c7cec4ffc9..034f3935e6 100644 --- a/src/backend/utils/adt/jsonb_gin.c +++ b/src/backend/utils/adt/jsonb_gin.c @@ -22,7 +22,7 @@ typedef struct PathHashStack { - uint32 hash; + uint32 hash_state; struct PathHashStack *next; } PathHashStack; @@ -493,12 +493,12 @@ gin_extract_jsonb_hash(PG_FUNCTION_ARGS) it = JsonbIteratorInit(VARDATA(jb)); tail.next = NULL; - tail.hash = 0; - + tail.hash_state = 0; stack = &tail; while ((r = JsonbIteratorNext(&it, &v, false)) != WJB_DONE) { + uint32 temphash; PathHashStack *tmp; if (i >= total) @@ -526,23 +526,15 @@ gin_extract_jsonb_hash(PG_FUNCTION_ARGS) break; case WJB_KEY: /* Calc hash of key and separated into preserved stack item */ - stack->hash = stack->next->hash; - hash_scalar_value(&v, &stack->hash); + stack->hash_state = stack->next->hash_state; + hash_scalar_value(&v, &stack->hash_state); break; case WJB_VALUE: case WJB_ELEM: - /* - * Since jsonb_hash_ops does not support existence operator, - * it's okay to lump together pair values and elements. For a - * key/value pair, the hash value has both values mixed in - * together. For deeply nested key/value pairs (and elements) - * the container hash value is mixed in too. - */ - stack->hash = stack->next->hash; - hash_scalar_value(&v, &stack->hash); - /* Only store entries at the least nested level */ - if (!it->parent) - entries[i++] = stack->hash; + stack->hash_state = stack->next->hash_state; + hash_scalar_value(&v, &stack->hash_state); + temphash = stack->hash_state; + entries[i++] = temphash; break; case WJB_END_ARRAY: case WJB_END_OBJECT: