pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedLibpq and PGConn
4+ messages / 2 participants
[nested] [flat]
* Libpq and PGConn
@ 2006-03-29 16:55 Keary Suska <hierophant@pcisys.net>
0 siblings, 1 reply; 4+ messages in thread
From: Keary Suska @ 2006-03-29 16:55 UTC (permalink / raw)
To: pgsql-interfaces
What happens if a null pointer is sent to any libpq function for the PGConn
parameter?
Thanks,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Libpq and PGConn
@ 2006-03-29 17:15 Tom Lane <tgl@sss.pgh.pa.us>
parent: Keary Suska <hierophant@pcisys.net>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2006-03-29 17:15 UTC (permalink / raw)
To: Keary Suska <hierophant@pcisys.net>; +Cc: pgsql-interfaces
Keary Suska <hierophant@pcisys.net> writes:
> What happens if a null pointer is sent to any libpq function for the PGConn
> parameter?
AFAIR they all check for that and fail in a reasonably clean fashion.
Have you found one that doesn't?
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Libpq and PGConn
@ 2006-03-29 21:18 Keary Suska <hierophant@pcisys.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Keary Suska @ 2006-03-29 21:18 UTC (permalink / raw)
To: pgsql-interfaces
on 3/29/06 10:15 AM, tgl@sss.pgh.pa.us purportedly said:
> Keary Suska <hierophant@pcisys.net> writes:
>> What happens if a null pointer is sent to any libpq function for the PGConn
>> parameter?
>
> AFAIR they all check for that and fail in a reasonably clean fashion.
> Have you found one that doesn't?
Not as of yet. I am building a custom wrapper to libpq and trying to account
for situations such as an attempt to call a libpq function on a PGconn
object that has not been initialized, such as returned from PQconnectdb and
the like. Same goes for PGresult objects.
Is it safe to assume that in these cases--where a PGconn or Pgresult has not
been initialized, but has not been finished() either--that all functions
won't (or shouldn't) choke, will set an error message, and return a defined
value?
Thanks,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Libpq and PGConn
@ 2006-03-29 22:09 Tom Lane <tgl@sss.pgh.pa.us>
parent: Keary Suska <hierophant@pcisys.net>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2006-03-29 22:09 UTC (permalink / raw)
To: Keary Suska <hierophant@pcisys.net>; +Cc: pgsql-interfaces
Keary Suska <hierophant@pcisys.net> writes:
> Is it safe to assume that in these cases--where a PGconn or Pgresult has not
> been initialized, but has not been finished() either--that all functions
> won't (or shouldn't) choke, will set an error message, and return a defined
> value?
Well, there isn't any place to "set an error message" if you don't have
a PGconn. I think it's reasonable to expect libpq functions not to
crash on NULL pointer inputs, but there's a limit to what we can do
beyond not crashing. Also, if you pass pointers to garbage memory
(rather than NULL pointers) all bets are off; which limits the value of
worrying about the NULL case anyway. Ultimately, if the calling app is
broken enough to pass bad pointers there isn't a lot that a library can
do to defend itself.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2006-03-29 22:09 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-03-29 16:55 Libpq and PGConn Keary Suska <hierophant@pcisys.net>
2006-03-29 17:15 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-03-29 21:18 ` Keary Suska <hierophant@pcisys.net>
2006-03-29 22:09 ` Tom Lane <tgl@sss.pgh.pa.us>
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