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

Re: PQescapeString handling of \0

From: Igor Shevchenko <igor(at)carcass(dot)ath(dot)cx>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: PQescapeString handling of \0
Date: 2003-09-29 19:15:20
Message-ID: 200309292215.20949.igor@carcass.ath.cx (view raw or flat)
Thread:
Lists: pgsql-interfaces
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.

On Monday 29 September 2003 21:22, Tom Lane wrote:
> Igor Shevchenko <igor(at)carcass(dot)ath(dot)cx> writes:
> > Here's a patch which makes PQescapeString stop escaping when \0 is seen.
>
> 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 ...
>
> 			regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html

-- 
Best regards,
Igor Shevchenko


In response to

Responses

pgsql-interfaces by date

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

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