Обсуждение: Thread-safe PREPARE in ecpg

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

Thread-safe PREPARE in ecpg

От
ITAGAKI Takahiro
Дата:
Here is a WIP patch to make prepared statements thread-safe in ecpg.
The variable prep_stmts was global but not protected by any locks.
I divided it into per-connection field so that we can access prepared
statements separately in each thread.

I needed to change the following exported functions, but it will
introduce an incompatibility issue. It might be ok for CVS HEAD,
but I'd like to port the fix to back versions. Do you have any
thoughts on how we can accomplish this better?

From:
  - bool ECPGdeallocate(int, int, const char *name);
  - bool ECPGdeallocate_all(int, int);
  - char *ECPGprepared_statement(const char *name, int);
To:
  - bool ECPGdeallocate(int, int, const char *connection_name, const char *name);
  - bool ECPGdeallocate_all(int, int, const char *connection_name);
  - char *ECPGprepared_statement(const char *connection_name, const char *name, int);
(connection_name argument is added.)

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center


Вложения

Re: Thread-safe PREPARE in ecpg

От
Michael Meskes
Дата:
On Tue, Sep 25, 2007 at 03:22:13PM +0900, ITAGAKI Takahiro wrote:
> Here is a WIP patch to make prepared statements thread-safe in ecpg.
> The variable prep_stmts was global but not protected by any locks.
> I divided it into per-connection field so that we can access prepared
> statements separately in each thread.

Thanks a lot. This is exactly how I was planning to implement it, but I
haven't even found the time to start coding yet. :-)

Could you please create a small example that we could add to the
regression suite?

> I needed to change the following exported functions, but it will
> introduce an incompatibility issue. It might be ok for CVS HEAD,
> but I'd like to port the fix to back versions. Do you have any
> thoughts on how we can accomplish this better?

No idea at the moment, sorry.

Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

Re: Thread-safe PREPARE in ecpg

От
ITAGAKI Takahiro
Дата:
Here is a revised patch against CVS HEAD.
I fixed a bug in ECPGdeallocate_all().

Michael Meskes <meskes@postgresql.org> wrote:

> Could you please create a small example that we could add to the
> regression suite?

The attached prep.pgc is an example for this fix,
that repeats EXEC SQL PREPARE and EXECUTE in loops.
It works with pthread and Win32 thread.

> > I needed to change the following exported functions, but it will
> > introduce an incompatibility issue. It might be ok for CVS HEAD,
> > but I'd like to port the fix to back versions. Do you have any
> > thoughts on how we can accomplish this better?
>
> No idea at the moment, sorry.

For porting back to 8.2, I'm planning to keep ECPGdeallocate,
ECPGdeallocate_all and ECPGprepared_statement as their original names,
and add new versions with different names. If users use only thread
default connection, the simplified version would work enough.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center


Вложения

Re: Thread-safe PREPARE in ecpg

От
Michael Meskes
Дата:
On Wed, Sep 26, 2007 at 01:43:34PM +0900, ITAGAKI Takahiro wrote:
> Here is a revised patch against CVS HEAD.
> I fixed a bug in ECPGdeallocate_all().

Applied to CVS HEAD. I also added your example to the regression tests.

Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!