Re: hstores in pl/python

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 17:05:31
Message-ID: 81DE1AD1-4B10-44FD-87B2-9C91852431B7@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Dec 13, 2010, at 11:37 PM, Jan Urbański wrote:

> A function with a hstore parameter called x would get a Python dictionary as its input. A function said to be returning a hstore could return a dictionary and if it would have only string keys/values, it would be changed into a hstore (and if not, throw an ERROR). See the README for pyhstore and take out pyhstore.parse/serialize.

It doesn't turn a returned dictionary into a RECORD? That's what PL/Perl does, FBOFW.

> There is already type conversion infrastructure in plpython, in the form of two functions with a switch that takes the input/output type's OID. It'd be adding a branch to the switches and taking the code from my pyhstore module to parse the hstore to and fro.
>
> Then there's the compatibility argument. Hstores used to be passed as strings, so it will break user code. I hate behaviour-changing GUCs as much as anyone, but it seems the only option...

Can you overload the stringification of a dictionary to return the hstore string representation?

> How about going the other way around? Hstore would produce hstore_plpython.so apart from hstore.so, if compiling with --with-python. Loading hstore_plpython would register parser functions for hstores in plpython. Additionally this could lead to hstore_plperl in the future etc.
>
> We would need to design some infrastructure for using such hooks in plpython (and in embedded PLs in general) but then we sidestep the whole issue.

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.

Best,

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2010-12-14 17:06:05 Re: hstores in pl/python
Previous Message Tom Lane 2010-12-14 17:05:28 Re: Transaction-scope advisory locks