BUG #11103: to_json() does not convert correctly DOMAINs type since 9.3.5 (int expected instead of string) ? - Mailing list pgsql-bugs

From dgrelaud@ideolys.com
Subject BUG #11103: to_json() does not convert correctly DOMAINs type since 9.3.5 (int expected instead of string) ?
Date
Msg-id 20140731152456.2708.35688@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #11103: to_json() does not convert correctly DOMAINs type since 9.3.5 (int expected instead of string) ?  (Michael Paquier <michael.paquier@gmail.com>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      11103
Logged by:          David GRELAUD
Email address:      dgrelaud@ideolys.com
PostgreSQL version: 9.3.5
Operating system:   Ubuntu 12.04 or Mac OS X 10.9
Description:

Hi,

The function to_json() does not convert correctly (= as before) DOMAINs
since 9.3.5. It was OK in 9.3.4.

Here is a minimal test case :

CREATE DOMAIN UNSIGNED_INT4 AS INT4 CHECK (VALUE >= 0);
SELECT to_json(2::UNSIGNED_INT4);

With 9.3.5,  it returns a JSON string : '2' (with quotes)
With 9.3.4,  it returns a JSON int : 2 (without quotes)

The same behavior happens with array_to_json() and maybe others related
functions...

If we do not use domains, SELECT to_json(2::INT4) returns always a JSON int
(even with 9.3.5).

Is it related to the change made by Tom Lane?
commit 0ca6bda8e7501947c05f30c127f6d12ff90b5a64 and the release note 9.3.5
"Fix identification of input type category in to_json() and friends (Tom
Lane)"?

Is it volontary? If so, don't worry, I will find a workaround.

Thank you very much for maintaining this wonderfull Open Source database.

David.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Is this a bug?
Next
From: Andrew Sackville-West
Date:
Subject: regression, deadlock in high frequency single-row UPDATE