Re: Cache lookup error when using jsonb, json_build_object and a WITH clause

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cache lookup error when using jsonb, json_build_object and a WITH clause
Date: 2014-05-09 15:35:41
Message-ID: 20435.1399649741@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> I guess this is my fault. I recall some discussions when some of this
> was first being written about the best way to make the type based
> decisions, not sure at this remove whether on list or off. The origin of
> it is in 9.2, so if you're going to adjust it you should probably go
> back that far.

Right, will back-patch.

> I was aware of the domain problem, but in 2 years or so nobody has
> complained about it, so I guess nobody is defining domains over json.

Actually, I was more concerned about domains over other types.
For instance

regression=# create domain dd as int;
CREATE DOMAIN
regression=# select json_build_object('foo', 43);
json_build_object
-------------------
{"foo" : 43}
(1 row)

regression=# select json_build_object('foo', 43::dd);
json_build_object
-------------------
{"foo" : "43"}
(1 row)

With the attached patch, you get 43 without any quotes, which seems
right to me. However, given the lack of complaints, it might be better
to not make this behavioral change in the back branches. I'll omit
the getBaseType() call from the back-patches.

Draft HEAD patch attached.

regards, tom lane

Attachment Content-Type Size
fix-json-type-categorization.patch text/x-diff 22.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-05-09 15:42:49 Re: Cache lookup error when using jsonb, json_build_object and a WITH clause
Previous Message Alvaro Herrera 2014-05-09 15:32:15 Re: Sending out a request for more buildfarm animals?