diff options
| author | Christopher Kings-Lynne <chriskl@php.net> | 2005-03-25 06:26:31 +0000 |
|---|---|---|
| committer | Christopher Kings-Lynne <chriskl@php.net> | 2005-03-25 06:26:31 +0000 |
| commit | 030ebaaa458f534871fe62a20fcea7e8ee1d5a57 (patch) | |
| tree | 335b349faeb4013067f3f12ccd6c98b6d9ac2ae8 /ext/pgsql/pgsql.c | |
| parent | 8817f64457abbe28d03b37503dd03c83535430c5 (diff) | |
| download | php-git-030ebaaa458f534871fe62a20fcea7e8ee1d5a57.tar.gz | |
(PHP pg_unescape_bytea) Use libpq version of PQunescapeBytea if it exists.
# The version in libpq is newer and faster than the one in PHP, but it is
# necessary for me to add a string copy for freeing purposes. This copy
# is only needed in Windows AFAIK, how can I detect that?
Diffstat (limited to 'ext/pgsql/pgsql.c')
| -rw-r--r-- | ext/pgsql/pgsql.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index f90f8fa66c..37402cd06a 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -3414,6 +3414,7 @@ PHP_FUNCTION(pg_escape_bytea) } /* }}} */ +#if !HAVE_PQUNESCAPEBYTEA /* PQunescapeBytea() from PostgreSQL 7.3 to provide bytea unescape feature to 7.2 users. Renamed to php_pgsql_unescape_bytea() */ /* @@ -3517,12 +3518,13 @@ static unsigned char * php_pgsql_unescape_bytea(unsigned char *strtext, size_t * *retbuflen = buflen; return buffer; } +#endif /* {{{ proto string pg_unescape_bytea(string data) Unescape binary for bytea type */ PHP_FUNCTION(pg_unescape_bytea) { - char *from = NULL, *to = NULL; + char *from = NULL, *to = NULL, *tmp = NULL; size_t to_len; int from_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", @@ -3530,7 +3532,13 @@ PHP_FUNCTION(pg_unescape_bytea) return; } +#if HAVE_PQUNESCAPEBYTEA + tmp = (char *)PQunescapeBytea((unsigned char*)from, &to_len); + to = estrndup(tmp, to_len); + PQfreemem(tmp); +#else to = (char *)php_pgsql_unescape_bytea((unsigned char*)from, &to_len); +#endif if (!to) { RETURN_FALSE; } |
