From: | Bosco Rama <postgres(at)boscorama(dot)com> |
---|---|
To: | Leif Jensen <leif(at)crysberg(dot)dk> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Postgres 8.3.5 - ECPG and the use of descriptors and cursors in multi-threaded programs |
Date: | 2011-05-23 18:27:42 |
Message-ID: | 4DDAA71E.20102@boscorama.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Leif Jensen wrote:
>
> This seems to be working most of the time, but looking at the generated C
> code from the ecpg compiler and the associated library functions, we are
> not sure whether we should put mutex locks around the 'select' part to
> avoid several threads are using "the same" execdesc at the same time.
>
> We have made sure that each thread uses their own and only their own
> database connection, but are unsure whether the ecpg library functions is
> able to handle multiple use of the statical name "execdesc" ?
You are most probably trashing memory by using the same descriptor name in
multiple threads. However, given that you have already spent the effort to
have the connections 'thread-dedicated' I think that rather than creating a
critical path through an area that is intentionally supposed to be mutli-
hreaded, I'd be inclined to use the connection name (or some derivation of
it) as the name of the descriptor. I haven't used descriptors in ecpg so I
don't know if the syntax works, but you could try:
exec sql char *dname = _thisDbConn; // Or some derivation
EXEC SQL AT :_thisDbConn ALLOCATE DESCRIPTOR :dname;
...
EXEC SQL AT :_thisDbConn FETCH IN execcurs INTO SQL DESCRIPTOR :dname;
...
EXEC SQL DEALLOCATE DESCRIPTOR :dname;
Just a thought.
Bosco.
From | Date | Subject | |
---|---|---|---|
Next Message | John R Pierce | 2011-05-23 19:39:59 | Re: Postgre Client only Install on Linux- 8.4.7 |
Previous Message | Bosco Rama | 2011-05-23 16:37:22 | Re: Using right() in a view |