Re: register_hstore does DB queries, does not play well with async connections

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Jan Urbański <wulczer(at)wulczer(dot)org>
Cc: Psycopg List <psycopg(at)postgresql(dot)org>
Subject: Re: register_hstore does DB queries, does not play well with async connections
Date: 2011-02-21 09:24:59
Message-ID: AANLkTimjXMnHPbpm--5WcXZcpARc8OtDj2yNZMUER4c2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Sun, Feb 20, 2011 at 10:08 PM, Jan Urbański <wulczer(at)wulczer(dot)org> wrote:
> Hi,
>
> as per $SUBJECT. If you have an async connection and try to do
> register_hstore, it does a query to get hstore's OID, and does not do
> poll(), which results in an error in fetchone().
>
> I think the solution is to allow people to pass the OID in
> register_hstore and document that you have to do it if using async
> connections. Currently I'm doing the select myself (asynchronously) and
> monkeypatching HstoreAdapter's get_oids to just return the OID.

It seems an useful feature. Added
(https://github.com/dvarrazzo/psycopg/commit/143dc2e9).

> BTW: the query assumes you have hstore installed in the "public" schema,
> which might not be correct... How about allowing passing the
> fully-qualified type name to register_hstore?

Is this really a real use case? the 'public' schema is specified in
contrib/hstore.sql so you would need to hack the installer to put the
hstore somewhere else. Even if someone did this, the oid parameter
would allow to specify the type working around the hardcoded schema in
get_oids. Then there are the casts: I assume if the installation
schema was in the search_path they would work anyway, but I haven't
done any test after seeing that the installer always put hstore in
public: if installing hstore somewhere else is really something people
do we can think about that. Otherwise I would avoid further
complicating the interface of a function with already 4 parameters.

Thank you, bye!

-- Daniele

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Jan Urbański 2011-02-21 09:32:19 Re: register_hstore does DB queries, does not play well with async connections
Previous Message Jan Urbański 2011-02-20 22:08:44 register_hstore does DB queries, does not play well with async connections