Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbacf7b2

Browse files
committed
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.
1 parent3c221c3 commitbacf7b2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

‎src/interfaces/libpq/fe-exec.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.196 2008/06/23 21:10:49 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.197 2008/09/10 17:01:07 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2763,10 +2763,14 @@ PQescapeByteaInternal(PGconn *conn,
27632763
{
27642764
if (*vp<0x20||*vp>0x7e)
27652765
{
2766+
intval=*vp;
2767+
27662768
if (!std_strings)
27672769
*rp++='\\';
2768-
(void)sprintf((char*)rp,"\\%03o",*vp);
2769-
rp+=4;
2770+
*rp++='\\';
2771+
*rp++= (val >>6)+'0';
2772+
*rp++= ((val >>3)&07)+'0';
2773+
*rp++= (val&07)+'0';
27702774
}
27712775
elseif (*vp=='\'')
27722776
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp