projects
/
users
/
simon
/
postgres.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c036066
)
Avoid using sprintf() for a simple octal conversion in PQescapeByteaInternal.
author
Tom Lane
<tgl@sss.pgh.pa.us>
Wed, 10 Sep 2008 17:01:17 +0000
(17:01 +0000)
committer
Tom Lane
<tgl@sss.pgh.pa.us>
Wed, 10 Sep 2008 17:01:17 +0000
(17:01 +0000)
Improves performance, per suggestion from Rudolf Leitgeb (bug #4414).
The backend did this right already, but not libpq.
src/interfaces/libpq/fe-exec.c
patch
|
blob
|
blame
|
history
diff --git
a/src/interfaces/libpq/fe-exec.c
b/src/interfaces/libpq/fe-exec.c
index 37f3f9946e2ad6cb57235da5a444f03937f21950..dbe75e6140c6cdc7695524be13c102ddba435a20 100644
(file)
--- a/
src/interfaces/libpq/fe-exec.c
+++ b/
src/interfaces/libpq/fe-exec.c
@@
-2763,10
+2763,14
@@
PQescapeByteaInternal(PGconn *conn,
{
if (*vp < 0x20 || *vp > 0x7e)
{
+ int val = *vp;
+
if (!std_strings)
*rp++ = '\\';
- (void) sprintf((char *) rp, "\\%03o", *vp);
- rp += 4;
+ *rp++ = '\\';
+ *rp++ = (val >> 6) + '0';
+ *rp++ = ((val >> 3) & 07) + '0';
+ *rp++ = (val & 07) + '0';
}
else if (*vp == '\'')
{