Re: PATCH: Add hstore_to_json()

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: PATCH: Add hstore_to_json()
Дата
Msg-id 4B2BD042.4090908@dunslane.net
обсуждение исходный текст
Ответ на Re: PATCH: Add hstore_to_json()  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: PATCH: Add hstore_to_json()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers

Robert Haas wrote:
> On Fri, Dec 18, 2009 at 11:32 AM, David E. Wheeler <david@kineticode.com> wrote:
>   
>> On Dec 18, 2009, at 4:49 AM, Peter Eisentraut wrote:
>>
>>     
>>> Should we create a json type before adding all kinds of json formatted
>>> data?  Or are we content with json as text?
>>>       
>> json_data_type++
>>     
>
> What would that do for us?
>
> I'm not opposed to it, but it seems like the more important thing
> would be to provide functions or operators that can do things like
> extract an array, extract a hash key, identify whether something is a
> hash, list, or scalar, etc.
>
>
>   

In principle it's not a bad idea to have a JSON type for several 
reasons. First, it's a better match than hstore for serializing an 
arbitrary tuple, because unlike hstore it can have nested arrays and 
composites, just as tuples can. Second, it might well be very useful if 
we could easily return results as JSON to AJAX applications, which are 
increasingly becoming the norm. And similarly we might be able to reduce 
application load if Postgres could perform operations on JSON, rather 
than having to return it all to the client to process.

I think it would be useful if someone produced a JSON module as, say, a 
pgFoundry project, to start with, and we would then be better able to 
assess its usefulness. An interesting question would be how one might 
sanely index such things.

You're correct that we don't necessarily need a new type, we could just 
make it text and have a bunch of operations, but that seems to violate 
the principle of data type abstraction a bit. If the operations can be 
sure that the object is valid JSON they could skip a bunch of sanity 
checks that they would otherwise need to do if just handed an arbitrary 
piece of text.

cheers

andrew





В списке pgsql-hackers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: question about implementing XA-ish functions
Следующее
От: Greg Smith
Дата:
Сообщение: Re: Closing out CommitFest 2009-11