iliaa Fri Oct 6 22:34:29 2006 UTC
Modified files:
/php-src/ext/pdo_pgsql config.m4 pgsql_driver.c
Log:
MFB: Make quote() in PostgreSQL use PQescapeByteaConn() whenever possible
for binary strings.
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_pgsql/config.m4?r1=1.14&r2=1.15&diff_format=u
Index: php-src/ext/pdo_pgsql/config.m4
diff -u php-src/ext/pdo_pgsql/config.m4:1.14
php-src/ext/pdo_pgsql/config.m4:1.15
--- php-src/ext/pdo_pgsql/config.m4:1.14 Wed Oct 4 23:53:54 2006
+++ php-src/ext/pdo_pgsql/config.m4 Fri Oct 6 22:34:29 2006
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.14 2006/10/04 23:53:54 iliaa Exp $
+dnl $Id: config.m4,v 1.15 2006/10/06 22:34:29 iliaa Exp $
dnl
if test "$PHP_PDO" != "no"; then
@@ -83,6 +83,7 @@
LDFLAGS="$LDFLAGS -L$PGSQL_LIBDIR"
AC_CHECK_LIB(pq, PQescapeString,AC_DEFINE(HAVE_PQESCAPE,1,[PostgreSQL 7.2.0
or later]))
AC_CHECK_LIB(pq, PQescapeStringConn,
AC_DEFINE(HAVE_PQESCAPE_CONN,1,[PostgreSQL 8.1.4 or later]))
+ AC_CHECK_LIB(pq, PQescapeByteaConn,
AC_DEFINE(HAVE_PQESCAPE_BYTEA_CONN,1,[PostgreSQL 8.1.4 or later]))
AC_CHECK_LIB(pq,
PQsetnonblocking,AC_DEFINE(HAVE_PQSETNONBLOCKING,1,[PostgreSQL 7.0.x or later]))
AC_CHECK_LIB(pq, PQcmdTuples,AC_DEFINE(HAVE_PQCMDTUPLES,1,[Broken libpq
under windows]))
AC_CHECK_LIB(pq, PQoidValue,AC_DEFINE(HAVE_PQOIDVALUE,1,[Older PostgreSQL]))
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_pgsql/pgsql_driver.c?r1=1.61&r2=1.62&diff_format=u
Index: php-src/ext/pdo_pgsql/pgsql_driver.c
diff -u php-src/ext/pdo_pgsql/pgsql_driver.c:1.61
php-src/ext/pdo_pgsql/pgsql_driver.c:1.62
--- php-src/ext/pdo_pgsql/pgsql_driver.c:1.61 Wed Oct 4 23:53:54 2006
+++ php-src/ext/pdo_pgsql/pgsql_driver.c Fri Oct 6 22:34:29 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pgsql_driver.c,v 1.61 2006/10/04 23:53:54 iliaa Exp $ */
+/* $Id: pgsql_driver.c,v 1.62 2006/10/06 22:34:29 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -251,11 +251,16 @@
static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int
unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype
TSRMLS_DC)
{
unsigned char *escaped;
+ pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
switch (paramtype) {
case PDO_PARAM_LOB:
/* escapedlen returned by PQescapeBytea() accounts for
trailing 0 */
+#ifdef HAVE_PQESCAPE_BYTEA_CONN
+ escaped = PQescapeByteaConn(H->server, unquoted,
unquotedlen, quotedlen);
+#else
escaped = PQescapeBytea(unquoted, unquotedlen,
quotedlen);
+#endif
*quotedlen += 1;
*quoted = emalloc(*quotedlen + 1);
memcpy((*quoted)+1, escaped, *quotedlen-2);
@@ -264,9 +269,7 @@
(*quoted)[*quotedlen] = '\0';
free(escaped);
break;
- default: {
- pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle
*)dbh->driver_data;
-
+ default:
*quoted = safe_emalloc(2, unquotedlen, 3);
(*quoted)[0] = '\'';
#ifndef HAVE_PQESCAPE_CONN
@@ -277,7 +280,6 @@
(*quoted)[*quotedlen + 1] = '\'';
(*quoted)[*quotedlen + 2] = '\0';
*quotedlen += 2;
- }
}
return 1;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php