Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-05 Thread Hannu Krosing
On Fri, 2012-05-04 at 15:59 -0400, Robert Haas wrote: On Fri, May 4, 2012 at 3:49 PM, Hannu Krosing ha...@krosing.net wrote: On Fri, 2012-05-04 at 09:52 -0400, Tom Lane wrote: Hannu Krosing ha...@2ndquadrant.com writes: On Wed, 2012-05-02 at 12:06 -0700, Andrew Dunstan wrote: So given

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-05 Thread Hannu Krosing
On Fri, 2012-05-04 at 16:12 -0400, Tom Lane wrote: Robert Haas robertmh...@gmail.com writes: On Fri, May 4, 2012 at 3:49 PM, Hannu Krosing ha...@krosing.net wrote: Can we at least have the xxx_to_json() functions try cast to json first and fall back to text if the cast fails. I think

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-05 Thread Peter Eisentraut
On fre, 2012-05-04 at 13:43 -0400, Robert Haas wrote: For this particular case, I think you just need some place to store a pg_type - pg_proc mapping. I'm not exactly sure how to make that not a JSON-specific hack, since I certainly don't think we'd want to add a new catalog just for that. I

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-05 Thread Peter Eisentraut
On fre, 2012-05-04 at 12:30 -0400, Andrew Dunstan wrote: Yeah, what I've been thinking about in conjunction with similar problems is some sort of type registry, so that we could code for non-builtin types in certain cases. It certainly seems to come up a lot, but I'm not sure whether the two

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-05 Thread Peter Eisentraut
On fre, 2012-05-04 at 15:59 -0400, Robert Haas wrote: Can we at least have the xxx_to_json() functions try cast to json first and fall back to text if the cast fails. I think the idea that you can involve the casting machinery in this is misguided. sometextval::json has got to mean that

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-05 Thread Hannu Krosing
On Sat, 2012-05-05 at 12:16 +0300, Peter Eisentraut wrote: On fre, 2012-05-04 at 15:59 -0400, Robert Haas wrote: Can we at least have the xxx_to_json() functions try cast to json first and fall back to text if the cast fails. I think the idea that you can involve the casting

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-05 Thread Tom Lane
Hannu Krosing ha...@2ndquadrant.com writes: CAST is something that should convert one type to another, in this case a textual type to its json value representation and back. 'sometext'::text::json -- 'sometext' and 'sometext'::json::text -- 'sometext' Well, that's a pretty interesting

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-04 Thread Hannu Krosing
On Wed, 2012-05-02 at 12:06 -0700, Andrew Dunstan wrote: On Wed, May 2, 2012 at 2:29 AM, Hannu Krosing ha...@2ndquadrant.com wrote: I don't object to row_to_json() and array_to_json() functions being there as a convenience and as the

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-04 Thread Tom Lane
Hannu Krosing ha...@2ndquadrant.com writes: On Wed, 2012-05-02 at 12:06 -0700, Andrew Dunstan wrote: So given that do we do anything about this now, or wait till 9.3? I'd like the json support in 9.2 updated as follows I think it's too late to be entertaining proposals for such changes in

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-04 Thread Andrew Dunstan
On 05/04/2012 09:52 AM, Tom Lane wrote: Hannu Krosingha...@2ndquadrant.com writes: On Wed, 2012-05-02 at 12:06 -0700, Andrew Dunstan wrote: So given that do we do anything about this now, or wait till 9.3? I'd like the json support in 9.2 updated as follows I think it's too late to be

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-04 Thread Tom Lane
Andrew Dunstan and...@dunslane.net writes: Yeah, what I've been thinking about in conjunction with similar problems is some sort of type registry, so that we could code for non-builtin types in certain cases. Maybe we should add that the the developers' meeting agenda. Maybe. I don't want

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-04 Thread Robert Haas
On Fri, May 4, 2012 at 12:56 PM, Tom Lane t...@sss.pgh.pa.us wrote: Andrew Dunstan and...@dunslane.net writes: Yeah, what I've been thinking about in conjunction with similar problems is some sort of type registry, so that we could code for non-builtin types in certain cases. Maybe we should

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-04 Thread Hannu Krosing
On Fri, 2012-05-04 at 13:43 -0400, Robert Haas wrote: On Fri, May 4, 2012 at 12:56 PM, Tom Lane t...@sss.pgh.pa.us wrote: Andrew Dunstan and...@dunslane.net writes: Yeah, what I've been thinking about in conjunction with similar problems is some sort of type registry, so that we could code

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-04 Thread Hannu Krosing
On Fri, 2012-05-04 at 09:52 -0400, Tom Lane wrote: Hannu Krosing ha...@2ndquadrant.com writes: On Wed, 2012-05-02 at 12:06 -0700, Andrew Dunstan wrote: So given that do we do anything about this now, or wait till 9.3? I'd like the json support in 9.2 updated as follows I think it's too

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-04 Thread Robert Haas
On Fri, May 4, 2012 at 3:49 PM, Hannu Krosing ha...@krosing.net wrote: On Fri, 2012-05-04 at 09:52 -0400, Tom Lane wrote: Hannu Krosing ha...@2ndquadrant.com writes: On Wed, 2012-05-02 at 12:06 -0700, Andrew Dunstan wrote: So given that do we do anything about this now, or wait till 9.3?

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-04 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Fri, May 4, 2012 at 3:49 PM, Hannu Krosing ha...@krosing.net wrote: Can we at least have the xxx_to_json() functions try cast to json first and fall back to text if the cast fails. I think the idea that you can involve the casting machinery in this

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-04 Thread Hannu Krosing
On Fri, 2012-05-04 at 15:59 -0400, Robert Haas wrote: On Fri, May 4, 2012 at 3:49 PM, Hannu Krosing ha...@krosing.net wrote: On Fri, 2012-05-04 at 09:52 -0400, Tom Lane wrote: Hannu Krosing ha...@2ndquadrant.com writes: On Wed, 2012-05-02 at 12:06 -0700, Andrew Dunstan wrote: So given

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-04 Thread David Johnston
in 9.2 - Could we have just one to_json() function instead of two separate versions ? On Fri, 2012-05-04 at 15:59 -0400, Robert Haas wrote: On Fri, May 4, 2012 at 3:49 PM, Hannu Krosing ha...@krosing.net wrote: On Fri, 2012-05-04 at 09:52 -0400, Tom Lane wrote: Hannu Krosing ha

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-02 Thread Hannu Krosing
On Tue, 2012-05-01 at 21:22 -0400, David Johnston wrote: On May 1, 2012, at 20:41, Hannu Krosing ha...@2ndquadrant.com wrote: Most people don't work in strongly-typed environment, and thus would work around such restriction if they need a simple JSON value at the other end of the

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-02 Thread Hannu Krosing
On Tue, 2012-05-01 at 19:11 -0400, Tom Lane wrote: Andrew Dunstan and...@dunslane.net writes: On Tue, May 1, 2012 at 9:56 AM, Joey Adams joeyadams3.14...@gmail.comwrote: No, the RFC says (emphasis mine): A JSON *text* is a serialized object or array. If we let the JSON type

[HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Hannu Krosing
Hi hackers After playing around with array_to_json() and row_to_json() functions a bit it I have a question - why do we even have 2 variants *_to_json() Collapsing array_to_json() and row_to_json() into just to_json() As the

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Merlin Moncure
On Tue, May 1, 2012 at 7:02 AM, Hannu Krosing ha...@2ndquadrant.com wrote: Hi hackers After playing around with array_to_json() and row_to_json() functions a bit it I have a question - why do we even have 2 variants *_to_json() Collapsing array_to_json() and row_to_json() into just to_json()

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Hannu Krosing
On Tue, 2012-05-01 at 08:18 -0500, Merlin Moncure wrote: On Tue, May 1, 2012 at 7:02 AM, Hannu Krosing ha...@2ndquadrant.com wrote: Hi hackers After playing around with array_to_json() and row_to_json() functions a bit it I have a question - why do we even have 2 variants *_to_json()

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Joey Adams
On Tue, May 1, 2012 at 8:02 AM, Hannu Krosing ha...@2ndquadrant.com wrote: Hi hackers After playing around with array_to_json() and row_to_json() functions a bit it I have a question - why do we even have 2 variants *_to_json() Here's the discussion where that decision was made:

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Merlin Moncure
On Tue, May 1, 2012 at 10:49 AM, Joey Adams joeyadams3.14...@gmail.com wrote: On Tue, May 1, 2012 at 8:02 AM, Hannu Krosing ha...@2ndquadrant.com wrote: Hi hackers After playing around with array_to_json() and row_to_json() functions a bit it I have a question - why do we even have 2 variants

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Hannu Krosing
On Tue, 2012-05-01 at 11:49 -0400, Joey Adams wrote: On Tue, May 1, 2012 at 8:02 AM, Hannu Krosing ha...@2ndquadrant.com wrote: Hi hackers After playing around with array_to_json() and row_to_json() functions a bit it I have a question - why do we even have 2 variants *_to_json()

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Andrew Dunstan
On Tue, May 1, 2012 at 9:05 AM, Merlin Moncure mmonc...@gmail.com wrote: On Tue, May 1, 2012 at 10:49 AM, Joey Adams joeyadams3.14...@gmail.com wrote: On Tue, May 1, 2012 at 8:02 AM, Hannu Krosing ha...@2ndquadrant.com wrote: Hi hackers After playing around with array_to_json() and

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Merlin Moncure
On Tue, May 1, 2012 at 11:22 AM, Andrew Dunstan and...@dunslane.net wrote: On Tue, May 1, 2012 at 9:05 AM, Merlin Moncure mmonc...@gmail.com wrote: On Tue, May 1, 2012 at 10:49 AM, Joey Adams joeyadams3.14...@gmail.com wrote: On Tue, May 1, 2012 at 8:02 AM, Hannu Krosing

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Tom Lane
Andrew Dunstan and...@dunslane.net writes: Let me just point out two things. First, we are approaching a beta release. The time for changing this is long since gone, IMNSHO. This is our last chance to get it right, so that argument doesn't seem to me to carry a lot of weight ... Second, RFC

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Joey Adams
On Tue, May 1, 2012 at 12:22 PM, Andrew Dunstan and...@dunslane.net wrote: Second, RFC 4627 is absolutely clear: a valid JSON value can only be an object or an array, so this thing about converting arbitrary datum values to JSON is a fantasy. If anything, we should adjust the JSON input

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Andrew Dunstan
On Tue, May 1, 2012 at 9:56 AM, Joey Adams joeyadams3.14...@gmail.comwrote: On Tue, May 1, 2012 at 12:22 PM, Andrew Dunstan and...@dunslane.net wrote: Second, RFC 4627 is absolutely clear: a valid JSON value can only be an object or an array, so this thing about converting arbitrary datum

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Hannu Krosing
On Tue, 2012-05-01 at 12:54 -0400, Tom Lane wrote: Andrew Dunstan and...@dunslane.net writes: Let me just point out two things. First, we are approaching a beta release. The time for changing this is long since gone, IMNSHO. This is our last chance to get it right, so that argument doesn't

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Hannu Krosing
On Tue, 2012-05-01 at 11:11 -0700, Andrew Dunstan wrote: On Tue, May 1, 2012 at 9:56 AM, Joey Adams joeyadams3.14...@gmail.com wrote: ... No, the RFC says (emphasis mine): A JSON *text* is a serialized object or array. If we let

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Hannu Krosing
On Tue, 2012-05-01 at 09:22 -0700, Andrew Dunstan wrote: On Tue, May 1, 2012 at 9:05 AM, Merlin Moncure mmonc...@gmail.com wrote: On Tue, May 1, 2012 at 10:49 AM, Joey Adams joeyadams3.14...@gmail.com wrote: On Tue, May 1, 2012 at 8:02 AM, Hannu Krosing

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread David Johnston
-Original Message- From: pgsql-hackers-ow...@postgresql.org [mailto:pgsql-hackers- ow...@postgresql.org] On Behalf Of Hannu Krosing Sent: Tuesday, May 01, 2012 5:29 PM The reason I am whining now is that with minor adjustments in implementation it could all be made much more

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Tom Lane
Andrew Dunstan and...@dunslane.net writes: On Tue, May 1, 2012 at 9:56 AM, Joey Adams joeyadams3.14...@gmail.comwrote: No, the RFC says (emphasis mine): A JSON *text* is a serialized object or array. If we let the JSON type correspond to a *value* instead, this restriction does not apply,

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread Hannu Krosing
On Tue, 2012-05-01 at 18:35 -0400, David Johnston wrote: -Original Message- From: pgsql-hackers-ow...@postgresql.org [mailto:pgsql-hackers- ow...@postgresql.org] On Behalf Of Hannu Krosing Sent: Tuesday, May 01, 2012 5:29 PM The reason I am whining now is that with minor

Re: [HACKERS] JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?

2012-05-01 Thread David Johnston
On May 1, 2012, at 20:41, Hannu Krosing ha...@2ndquadrant.com wrote: Most people don't work in strongly-typed environment, and thus would work around such restriction if they need a simple JSON value at the other end of the interchange. My personal take it is have it fail since any