problem with precendence order in JSONB merge operator - Mailing list pgsql-hackers

From Peter Krauss
Subject problem with precendence order in JSONB merge operator
Date
Msg-id CAHEREtuOz=_R+aoF+21T0NSmRrbrur7ZGo512jChXA_Ahg7ekw@mail.gmail.com
Whole thread Raw
Responses Re: problem with precendence order in JSONB merge operator
List pgsql-hackers
Seems that parser not using precedence ideal order, and that casting obligation losts performance.
  
The first problem is self-evident in this example:
SELECT '{"x":1}'::jsonb || (('{"A":{"y":2}}'::jsonb)->'A')  -- it is ok, expected result with (x,y)

SELECT '{"x":1}'::jsonb || '{"A":{"y":2}}'::jsonb)->'A'    -- non-expected result (y).

Higher precedence most be for -> operator, that is like an object-oriented path operator, always higher than algebric ones.


Other problem is using this operation as SQL function,

  CREATE FUNCTION term_lib.junpack(jsonb,text) RETURNS JSONB AS $f$       SELECT ($1-$2)::JSONB || ($1->>$2)::JSONB;  $f$ LANGUAGE SQL IMMUTABLE;

without casting produce error. Perhaps will be "more friendly" without cast obligation, 

and it is a performance problem, the abusive use of castings losts performance.



pgsql-hackers by date:

Previous
From: Grzegorz Sampolski
Date:
Subject: Re: pam auth - add rhost item
Next
From: Alvaro Herrera
Date:
Subject: Re: WIP: Access method extendability