Re: json, jsonb, and casts - Mailing list pgsql-hackers

From Tom Lane
Subject Re: json, jsonb, and casts
Date
Msg-id 15685.1415307515@sss.pgh.pa.us
Whole thread Raw
In response to json, jsonb, and casts  (Andrew Dunstan <andrew.dunstan@pgexperts.com>)
Responses Re: json, jsonb, and casts  (Andrew Dunstan <andrew.dunstan@pgexperts.com>)
List pgsql-hackers
Andrew Dunstan <andrew.dunstan@pgexperts.com> writes:
> In 9.3 we changed the way json generating functions worked by taking 
> account of cast functions to json from non-builtin types, such as hstore.

> In 9.5 I am proposing to provide similar functionality for jsonb. The 
> patch actually takes account of cast functions to both jsonb and json 
> (with jsonb preferred). If there is a cast to jsonb, we use it and then 
> merge the result into the jsonb being accumulated. If there is just a 
> cast to json, we use it, and then parse that directly into the result 
> datum.

> It was arguably a bit of an oversight not to take account of casts to 
> jsonb in 9.4 in datum_to_json(). So I'm thinking of rolling into this 
> patch changes to json.c::datum_to_json() and friends to take analogous 
> account of casts to jsonb (i.e. call the cast function, turn the 
> resulting jsonb into a cstring and append it to the result).

Meh.  This leaves it very ambiguous which cast function would be applied
if both are available.  I think it's overcomplicated anyway.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Re: Proposal: Log inability to lock pages during vacuum
Next
From: Kevin Grittner
Date:
Subject: Re: Tweaking Foreign Keys for larger tables