Skip site navigation (1) Skip section navigation (2)

Re: PQescapeString handling of \0

From: greg(at)turnstep(dot)com
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: PQescapeString handling of \0
Date: 2003-10-03 13:37:34
Message-ID: c4029001e28eb9350effc9118d391bc9@biglumber.com (view raw or flat)
Thread:
Lists: pgsql-interfaces
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Tom Lane wrote:
> Hm.  Is that really the right behavior?  Given that the function is
> defined to take a counted string rather than a null-terminated string,
> I'd sort of expect it to turn \0 into "\000" or some such.  Of course,
> given that this could overflow the specified size of the return buffer,
> one might simply conclude that the defined API is broken ...

Igor Shevchenko replied:
> If the purpose of PQescapeString is to make a safe variant of a given string 
> (NULL-terminated or counted), where safity means ability to simply add it to 
> the query (which is char* and is passed directly to PQexec), then either 
> length should return what strlen would return for the given string or \0 
> should be escaped somehow.

Has we reached a consensus on this? I'd like to have DBD::Pg and PQescapeString 
consistent. Right now, we (DBD::Pg) are leaning toward the "bail if we hit \0" 
theory, but it would be nice to have something definitive in the API.

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200310030936

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE/fXvlvJuQZxSWSsgRAsc9AKDbn7QdDCk0lGDVP17249I0VbN9ygCg+BH4
UJxIs5PakXA0Mkth0td0jHw=
=KMEd
-----END PGP SIGNATURE-----



In response to

Responses

pgsql-interfaces by date

Next:From: Tom LaneDate: 2003-10-03 15:31:02
Subject: Re: PQescapeString handling of \0
Previous:From: Carsten KleinDate: 2003-10-01 22:57:37
Subject: Embedded SQL: Putting a guard around included stdio.h for convenience

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group