pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedIs this valid?
4+ messages / 3 participants
[nested] [flat]
* Is this valid?
@ 2002-08-12 23:21 Wei Weng <wweng@kencast.com>
0 siblings, 2 replies; 4+ messages in thread
From: Wei Weng @ 2002-08-12 23:21 UTC (permalink / raw)
To: pgsql-sql
I am not sure if this is the right mailing list I talk to. Please let me
know if I had violated any unwritten rules. :)
I have a global variable PGconn* m_pgconn that is the connection handle
for connecting to the postgresql database. Can I access/use the handle
from multiple threads? Say I have a thread that does some insertion
through this handle/database connection(m_pgconn) and also another
thread that do some insertion *on the same table* through this
handle(m_pgconn), will that break?
Thanks
--
Wei Weng
Network Software Engineer
KenCast Inc.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Is this valid?
@ 2002-08-13 00:10 Robert Treat <xzilla@users.sourceforge.net>
parent: Wei Weng <wweng@kencast.com>
1 sibling, 0 replies; 4+ messages in thread
From: Robert Treat @ 2002-08-13 00:10 UTC (permalink / raw)
To: Wei Weng <wweng@kencast.com>; +Cc: pgsql-sql
I'm going to ask the crazy question of what language/interface are you
using to interact with postgres? Based on my interpretation of your
question I'd say that won't break (though one of your queries might
fail) but then again I may be totally misreading what you wrote...
Robert Treat
On Mon, 2002-08-12 at 19:21, Wei Weng wrote:
> I am not sure if this is the right mailing list I talk to. Please let me
> know if I had violated any unwritten rules. :)
>
> I have a global variable PGconn* m_pgconn that is the connection handle
> for connecting to the postgresql database. Can I access/use the handle
> from multiple threads? Say I have a thread that does some insertion
> through this handle/database connection(m_pgconn) and also another
> thread that do some insertion *on the same table* through this
> handle(m_pgconn), will that break?
>
> Thanks
>
>
> --
> Wei Weng
> Network Software Engineer
> KenCast Inc.
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Is this valid?
@ 2002-08-13 03:58 Weiping He <laser@zhengmai.com.cn>
parent: Wei Weng <wweng@kencast.com>
1 sibling, 1 reply; 4+ messages in thread
From: Weiping He @ 2002-08-13 03:58 UTC (permalink / raw)
To: Wei Weng <wweng@kencast.com>; +Cc: pgsql-sql
Wei Weng wrote:
>I am not sure if this is the right mailing list I talk to. Please let me
>know if I had violated any unwritten rules. :)
>
>I have a global variable PGconn* m_pgconn that is the connection handle
>for connecting to the postgresql database. Can I access/use the handle
>from multiple threads? Say I have a thread that does some insertion
>through this handle/database connection(m_pgconn) and also another
>thread that do some insertion *on the same table* through this
>handle(m_pgconn), will that break?
>
>Thanks
>
>
>
>
I don't think it's a good idea to use global variable
in multi-thread environment.
I think use different handle in differents is better.
libpq is thread safe, but it doesn't necessary mean
that you could free of your own code.
regards laser
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Is this valid?
@ 2002-08-13 14:27 Wei Weng <wweng@kencast.com>
parent: Weiping He <laser@zhengmai.com.cn>
0 siblings, 0 replies; 4+ messages in thread
From: Wei Weng @ 2002-08-13 14:27 UTC (permalink / raw)
To: Weiping He <laser@zhengmai.com.cn>; +Cc: pgsql-sql
On Mon, 2002-08-12 at 23:58, Weiping He wrote:
> Wei Weng wrote:
>
> >I am not sure if this is the right mailing list I talk to. Please let me
> >know if I had violated any unwritten rules. :)
> >
> >I have a global variable PGconn* m_pgconn that is the connection handle
> >for connecting to the postgresql database. Can I access/use the handle
> >from multiple threads? Say I have a thread that does some insertion
> >through this handle/database connection(m_pgconn) and also another
> >thread that do some insertion *on the same table* through this
> >handle(m_pgconn), will that break?
> >
> >Thanks
> >
> >
> >
> >
> I don't think it's a good idea to use global variable
> in multi-thread environment.
> I think use different handle in differents is better.
>
> libpq is thread safe, but it doesn't necessary mean
> that you could free of your own code.
>
Is it going to be resource draining if I make lots of connections in a
very short time?
--
Wei Weng
Network Software Engineer
KenCast Inc.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2002-08-13 14:27 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-08-12 23:21 Is this valid? Wei Weng <wweng@kencast.com>
2002-08-13 00:10 ` Robert Treat <xzilla@users.sourceforge.net>
2002-08-13 03:58 ` Weiping He <laser@zhengmai.com.cn>
2002-08-13 14:27 ` Wei Weng <wweng@kencast.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox