From: Bruce Momjian <maillist@candle.pha.pa.us>
To: tgl@sss.pgh.pa.us
Cc: goran@bildbasen.se
Cc: pgsql-interfaces@postgreSQL.org
Cc: hackers@postgreSQL.org
Subject: Re: [HACKERS] thread-safe libpq and DBD::Pg
Date: Sat, 8 Aug 1998 23:50:55 -0400 (EDT)
Message-ID: <199808090350.XAA00137@candle.pha.pa.us> (raw)
In-Reply-To: <3278.902623878@sss.pgh.pa.us>
> I also noticed that PQoidStatus() returns a pointer to a static
> char array, which is a classic thread-safety booboo. I am thinking
> that the cleanest solution is for it to copy the OID number into
> conn->errorMessage and return a pointer to that. This would mean
> that the value would not be good after the next operation on the
> PGconn object, but I wouldn't imagine that any apps hold onto the
> pointer very long anyway --- they probably always feed it to atoi
> immediately. (Actually, why the dickens doesn't this routine
> return an Oid value directly? It could return InvalidOid in
> case of trouble, just like PQftype does... but I suppose we don't
> want to break application code just to make the API a tad cleaner.)
Yes, it is very silly that PQoidStatus() returns a char*. I believe it
was only done that way because it was pulling the oid out of the
cmdStatus field. We really should return an int. Perhaps we don't
because we would be hardcoding the oid type on the client side. By
default, we return all types as char *. I don't think we do this
anywhere else in the protocol.
This is a complete guess. I believe it was added by Vadim in 6.2 or
6.3.
Perhaps we could double-use the cmdStatus field, perhaps when they ask
for the oid, we put a null after the oid value, and return a pointer to
the inside of the cmdStatus field. If the call for PQcmdStatus(), we
remove the null and return the string. Strange, I admit.
--
Bruce Momjian | 830 Blythe Avenue
maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: maillist@candle.pha.pa.us, tgl@sss.pgh.pa.us, goran@bildbasen.se, hackers@postgreSQL.org
Subject: Re: [HACKERS] thread-safe libpq and DBD::Pg
In-Reply-To: <199808090350.XAA00137@candle.pha.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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