mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Avoid using sprintf() for a simple octal conversion in PQescapeByteaInternal.
Improves performance, per suggestion from Rudolf Leitgeb (bug #4414). The backend did this right already, but not libpq.
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.194 2008/01/01 19:46:00 momjian Exp $
|
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.194.2.1 2008/09/10 17:01:17 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -2760,10 +2760,14 @@ PQescapeByteaInternal(PGconn *conn,
|
|||||||
{
|
{
|
||||||
if (*vp < 0x20 || *vp > 0x7e)
|
if (*vp < 0x20 || *vp > 0x7e)
|
||||||
{
|
{
|
||||||
|
int val = *vp;
|
||||||
|
|
||||||
if (!std_strings)
|
if (!std_strings)
|
||||||
*rp++ = '\\';
|
*rp++ = '\\';
|
||||||
(void) sprintf((char *) rp, "\\%03o", *vp);
|
*rp++ = '\\';
|
||||||
rp += 4;
|
*rp++ = (val >> 6) + '0';
|
||||||
|
*rp++ = ((val >> 3) & 07) + '0';
|
||||||
|
*rp++ = (val & 07) + '0';
|
||||||
}
|
}
|
||||||
else if (*vp == '\'')
|
else if (*vp == '\'')
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user