ECPG and multiple threads

Поиск
Список
Период
Сортировка
Искать

ECPG and multiple threads

От:
"Adam" <adam.ciazynski@gmail.com>
Дата:
Hi,

I'm porting an embedded-SQL application to PostgreSQL so embedded sql
is a must for me. My application is multi-threaded. SQL queries are
used by several threads. The program keeps terminating unexpectedly in
deemingly "innocent" places.
I figured out that ecpg library can be responsible for this.
Here:
http://www.postgresql.org/docs/8.1/interactive/ecpg-process.html
I found the information that:
"The ecpg library is thread-safe if it is built using the
--enable-thread-safety command-line option to configure."
However my instance of PostgreSQL was installed from _binaries_ that I
downloaded from http://www.postgresql.org

The questions:
1. How do I know how my copy of libecpg.lib was built and if it is
thread-safe?
2. Is there a place I could get the thread-safe version of this
library if I don't want to get into building the whole stuff from the
source code?

Thanks in advance.

Adam.

Re: ECPG and multiple threads

От:
"Albe Laurenz" <all@adv.magwien.gv.at>
Дата:
> I'm porting an embedded-SQL application to PostgreSQL so embedded sql
> is a must for me. My application is multi-threaded. SQL queries are
> used by several threads. The program keeps terminating unexpectedly in
> deemingly "innocent" places.
> I figured out that ecpg library can be responsible for this.
> Here:
> http://www.postgresql.org/docs/8.1/interactive/ecpg-process.html
> I found the information that:
> "The ecpg library is thread-safe if it is built using the
> --enable-thread-safety command-line option to configure."
> However my instance of PostgreSQL was installed from _binaries_ that I
> downloaded from http://www.postgresql.org
> 
> The questions:
> 1. How do I know how my copy of libecpg.lib was built and if it is
> thread-safe?
> 2. Is there a place I could get the thread-safe version of this
> library if I don't want to get into building the whole stuff from the
> source code?

1. You can call 'pg_config' in the bin directory,
   it will tell you the build flags.

2. You did not mention the operating system you use.

Yours,
Laurenz Albe

Re: ECPG and multiple threads

От:
Martijn van Oosterhout <kleptog@svana.org>
Дата:
Вложения:
On Fri, Nov 10, 2006 at 12:23:19AM -0800, Adam wrote:
> Hi,
> 
> I'm porting an embedded-SQL application to PostgreSQL so embedded sql
> is a must for me. My application is multi-threaded. SQL queries are
> used by several threads. The program keeps terminating unexpectedly in
> deemingly "innocent" places.

Note, you might be able to make ECPG and libpq thread-safe, however
even then you *cannot* use the same connection simultaneously from
different threads. You will have to open a new connection for each
parallel connection you want to handle. Or use locking.

Have a nice day,
-- 
Martijn van Oosterhout      http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.
FAQ