Re: jsonb and nested hstore

From: "David E(dot) Wheeler" <david(at)justatheory(dot)com>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Teodor Sigaev <teodor(at)sigaev(dot)ru>, Josh Berkus <josh(at)agliodbs(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Christophe Pettus <xof(at)thebuild(dot)com>, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: jsonb and nested hstore
Date: 2014-03-07 21:51:58
Message-ID: EC333C99-61C0-4259-82BB-0B989EC9934D@justatheory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mar 6, 2014, at 1:51 AM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:

>> It's true for perl. Syntax of hstore is close to hash/array syntax and it's
>> easy serialize/deserialize hstore to/from perl. Syntax of hstore was
>> inspired by perl.
>
> I understand that. There is a module on CPAN called Pg::hstore that
> will do this; it appears to have been around since 2011. I don't use
> Perl, so I don't know a lot about it. Perhaps David Wheeler has an
> opinion on the value of Perl-like syntax, as a long time Perl
> enthusiast?

HSTORE was inspired by the syntax of Perl hash declarations, but it is not compatible. Notably, HSTORE the HSTORE can have a value `NULL`, while in Perl hashes it’s `undef`. So you cannot simply `eval` an HSTORE to get a Perl hash unless you are certain there are no NULLs.

Besides, string eval in Perl is considered unsafe. Parsing is *much* safer.

> In any case, Perl has excellent support for JSON, just like every
> other language - you are at no particular advantage in Perl by having
> a format that happens to more closely resemble the format of Perl
> hashes and arrays. I really feel that we should concentrate our
> efforts on one standardized format here. It makes the effort to
> integrate your good work, in a way that makes it available to everyone
> so much easier.

I agree. I like HSTORE, but now that JSON is so standard (in fact, as of this week, a *real* standard! http://rfc7159.net/rfc7159), and its support is so much better than that of HSTORE, including in Perl, I believe that it should be priority over HSTORE. I’m happy if HSTORE has the same functionality as JSONB, but given the choice, all other things being equal, as a Perl hacker I will always choose JSONB.

Best,

David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter LaDow 2014-03-07 22:05:24 Re: on_exit_reset fails to clear DSM-related exit actions
Previous Message Robert Haas 2014-03-07 21:36:01 Re: Next CommitFest Deadlines