Re: Bug in ecpg lib ?

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>, <leif(at)crysberg(dot)dk>
Cc: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Bug in ecpg lib ?
Date: 2009-07-08 07:02:19
Message-ID: D960CB61B694CF459DCFB4B0128514C203937E0E@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I wrote:
> What I notice about your program is that you connect to the database
> in the main thread, then start a new thread and use the connection in that
> new thread.
>
> I don't know, but I'd expect that since ecpg keeps a thread-specific
> sqlca, this could cause problems. Indeed I find with the debugger that in
> your sample sqlca is allocated and initialized twice, once when the
> catabase connection is attempted, and once when the SQL statement is run.
>
> I think that the "good" way to do it would be:
> - start a thread
> - connect to the database
> - do work
> - disconnect from the database
> - terminate the thread

I thought some more about that, and it is obvioisly nonsense.
Why shouldn't you use a connection object in a different thread?

I'll try to come up with some more findings to help figure out
what's going on.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message leif 2009-07-08 07:41:42 Re: Bug in ecpg lib ?
Previous Message Mark Gabriel Paylaga 2009-07-08 06:30:23 Polygon data type