Re: [HACKERS] patch: General purpose utility functions used by the JSON data type

2010-08-13 Thread Andrew Dunstan
On 08/13/2010 03:46 PM, Joseph Adams wrote: On Fri, Aug 13, 2010 at 2:02 PM, David Fetter wrote: On Fri, Aug 13, 2010 at 01:33:06PM -0400, Robert Haas wrote: Maybe so, but it's not clear the interface that Joseph implemented is the one everyone wants... Fair enough. What's the interface no

Re: [HACKERS] patch: General purpose utility functions used by the JSON data type

2010-08-13 Thread Joseph Adams
On Fri, Aug 13, 2010 at 2:02 PM, David Fetter wrote: > On Fri, Aug 13, 2010 at 01:33:06PM -0400, Robert Haas wrote: >> Maybe so, but it's not clear the interface that Joseph implemented is >> the one everyone wants... > > Fair enough.  What's the interface now in a nutshell?  Lack of > nutshells m

Re: [HACKERS] patch: General purpose utility functions used by the JSON data type

2010-08-13 Thread David Fetter
On Fri, Aug 13, 2010 at 01:33:06PM -0400, Robert Haas wrote: > On Fri, Aug 13, 2010 at 1:05 PM, David Fetter wrote: > > On Fri, Aug 13, 2010 at 12:59:48PM -0400, Robert Haas wrote: > >> On Fri, Aug 13, 2010 at 12:55 PM, Joseph Adams > >> wrote: > >> > Indeed, a built-in JSON data type will certai

Re: [HACKERS] patch: General purpose utility functions used by the JSON data type

2010-08-13 Thread Robert Haas
On Fri, Aug 13, 2010 at 1:05 PM, David Fetter wrote: > On Fri, Aug 13, 2010 at 12:59:48PM -0400, Robert Haas wrote: >> On Fri, Aug 13, 2010 at 12:55 PM, Joseph Adams >> wrote: >> > Indeed, a built-in JSON data type will certainly not need it. >> > However, users may want to return enums from proc

Re: [HACKERS] patch: General purpose utility functions used by the JSON data type

2010-08-13 Thread David Fetter
On Fri, Aug 13, 2010 at 12:59:48PM -0400, Robert Haas wrote: > On Fri, Aug 13, 2010 at 12:55 PM, Joseph Adams > wrote: > > Indeed, a built-in JSON data type will certainly not need it. > > However, users may want to return enums from procedures written in > > C, and this function provides a way to

Re: [HACKERS] patch: General purpose utility functions used by the JSON data type

2010-08-13 Thread Tom Lane
Joseph Adams writes: > On Fri, Aug 13, 2010 at 10:46 AM, Robert Haas wrote: >> + if (sub_end + len > e) >> + { >> + Assert(false); /* Clipped multibyte >> character */ >> + break; >> + } > If I simply

Re: [HACKERS] patch: General purpose utility functions used by the JSON data type

2010-08-13 Thread Robert Haas
On Fri, Aug 13, 2010 at 12:55 PM, Joseph Adams wrote: > Indeed, a built-in JSON data type will certainly not need it. > However, users may want to return enums from procedures written in C, > and this function provides a way to do it. Yeah, but I can't see accepting it on speculation. We'll add

Re: [HACKERS] patch: General purpose utility functions used by the JSON data type

2010-08-13 Thread Joseph Adams
On Fri, Aug 13, 2010 at 10:46 AM, Robert Haas wrote: > On Fri, Aug 13, 2010 at 5:45 AM, Joseph Adams > wrote: >> getEnumLabelOids >>  * Useful-ometer: ()---o >>  * Rationale: There is currently no streamlined way to return a custom >> enum value from a PostgreSQL f

Re: [HACKERS] patch: General purpose utility functions used by the JSON data type

2010-08-13 Thread Robert Haas
On Fri, Aug 13, 2010 at 5:45 AM, Joseph Adams wrote: > getEnumLabelOids >  * Useful-ometer: ()---o >  * Rationale: There is currently no streamlined way to return a custom > enum value from a PostgreSQL function written in C.  This function > performs a batch lookup

Re: [HACKERS] patch: General purpose utility functions used by the JSON data type

2010-08-13 Thread Mike Fowler
On 13/08/10 10:45, Joseph Adams wrote: This patch doesn't include tests . How would I go about writing them? I have made the JSON data type built-in, and I will post that patch shortly (it depends on this one). The built-in JSON data type uses all of these utility functions, and the tests for

[HACKERS] patch: General purpose utility functions used by the JSON data type

2010-08-13 Thread Joseph Adams
I factored out the general-purpose utility functions in the JSON data type code into a patch against HEAD. I have made a few changes to them since I posted about them earlier ( http://archives.postgresql.org/pgsql-hackers/2010-08/msg00692.php ). A summary of the utility functions along with some