Re: jsonb and nested hstore

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Oleg Bartunov <obartunov(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Teodor Sigaev <teodor(at)sigaev(dot)ru>, Josh Berkus <josh(at)agliodbs(dot)com>, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>, Maciek Sakrejda <maciek(at)heroku(dot)com>
Subject: Re: jsonb and nested hstore
Date: 2014-03-10 10:47:55
Message-ID: CAPpHfdu4uMB=othGDEbx+AB5Vy=v6Ek6wY1k+n+-yEHQ+L_rGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 10, 2014 at 2:19 PM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:

> On Mon, Mar 10, 2014 at 3:00 AM, Alexander Korotkov
> <aekorotkov(at)gmail(dot)com> wrote:
> > I din't get comment about "leftmost" element. There is absolutely no
> > distinguish between array elements. All elements are extracted into same
> > keys independent of their indexes. It seems to have no change since I
> wrote
> > hstore_hash_ops. Could you share test case to illustrate what you mean?
>
> I don't have time to post that at the moment, but offhand I *think*
> your confusion may be due to the fact that the json_hash_ops opclass
> (as I call it) was previously consistent with the behavior of the
> other GIN opclass (the default). The problem is that they (well, at
> least the default GIN and GiST opclasses) were inconsistent with how
> the containment operator behaved in respect of jsonb array elements
> generally.
>
> Here is the commit on our feature branch where I fixed the problem for
> the default GIN opclass:
>
>
> https://github.com/feodor/postgres/commit/6f5e4fe9fc34f9512919b1c8b6a54952ab288640s
>
> If it doesn't explain the problem, you may still wish to comment on
> the correctness of this fix. I am still waiting on feedback from Oleg
> and Teodor.
>

Apparently, there is bug in calculation of hashes. Array elements were
hashed incrementally while each of them should be hashed separately. That
cause an effect of distinguishing array elements by their indexes. Not sure
about when this bug was added.
Fix is attached.

------
With best regards,
Alexander Korotkov.

Attachment Content-Type Size
jsonb-hash-ops-fix.patch application/octet-stream 1006 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2014-03-10 11:04:20 Re: jsonb and nested hstore
Previous Message Peter Geoghegan 2014-03-10 10:44:59 Re: jsonb and nested hstore