Re: Further issues with jsonb semantics, documentation

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Further issues with jsonb semantics, documentation
Date: 2015-06-05 22:21:50
Message-ID: CAM3SWZRZ=FaBn8GV1radGxcdcUtSAnJ6ftmkDEB0Gei-4bdriQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 5, 2015 at 1:05 PM, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
> So probably the least invasive change would be to rename the text[] variant
> operator to something like "#-" and rename the corresponding function to
> jsonb_delete_path.
>
> We could also decide not to keep an operator at all, on the ground that we
> think we'll implement a type that encapsulates json pointer in 9.6, and just
> keep the renamed function.

Obviously I prefer the latter option, but the former is still an
improvement. To repeat myself, ambiguities around operators are not
the only problem: It seems no good to me that there is no way to
accomplish an equivalent outcome to that shown below with the
similarly-spelled operator you talk about (that is, the operator
currently spelled "operator jsonb - text[]"):

postgres=# select '["a", "c", "a"]'::jsonb - 'a';
?column?
----------
["c"]
(1 row)

With the operator currently spelled "operator jsonb - text[]", at the
very least you have to do this instead:

postgres=# select '["a", "c", "a"]'::jsonb - '{0}'::text[] - '{1}'::text[];
?column?
----------
["c"]
(1 row)

If nothing else, these operators are too dissimilar for overloading to
be helpful.
--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2015-06-05 23:03:04 Re: could not truncate directory "pg_subtrans": apparent wraparound
Previous Message Robert Haas 2015-06-05 22:15:59 Re: [HACKERS] 9.4.1 -> 9.4.2 problem: could not access status of transaction 1