From: | "David E(dot) Wheeler" <david(at)kineticode(dot)com> |
---|---|
To: | Jan Urbański <wulczer(at)wulczer(dot)org> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Postgres - Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: hstores in pl/python |
Date: | 2010-12-14 19:59:38 |
Message-ID: | 71FB716D-CEFF-4AF8-94A0-9210F5647A49@kineticode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Dec 14, 2010, at 11:52 AM, Jan Urbański wrote:
> If the function is declared to return a hstore, it transforms the
> dictionary to a hstore.
Oh, right. Duh.
>> Can you overload the stringification of a dictionary to return the hstore string representation?
>
> Mmm, interesting thought. I don't particularily like it, because mucking
> with the stringification of a built-in type is a big POLA violation (and
> there would be other problems as well). And you still have to go through
> the Python dict -> string -> hstore cycle, instead of cutting the string
> step out.
Could you do it with a subclass of Dictionary? I'm thinking only of the params passed to the function here, not returned. It doesn't matter what the return value stringifies as if you can use functions to do the transformation from dict to hstore.
>> It would be better if there was some core support for the hash/ditionary/hstore/json/whatever data type, so that you didn't have to write a parser.
>
> I'm not writing the parser, that's the point. You could provide a
> pure-Python solution that would do the parsing, but that's fragile, slow
> and ugly. The idea is: PL/Python notices that the function is supposed
> to return a hstore. It takes the output of the Python call and uses
> functions from hstore.so to construct the hstore and return it. Same
> thing would happen with json.
Right, that sounds great. No reason why we couldn't support many of these hash-like things, eh? The question then is just identifying those types. That would be fantastic for PL/Perl, too.
Best,
David
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-12-14 20:18:40 | Re: Triggered assertion "!(tp.t_data->t_infomask & HEAP_XMAX_INVALID)" in heap_delete() on HEAD [PATCH] |
Previous Message | Jan Urbański | 2010-12-14 19:52:30 | Re: hstores in pl/python |