]> granicus.if.org Git - php/commitdiff
Added support for character sets in PDO quote() method for PostgreSQL
authorIlia Alshanetsky <iliaa@php.net>
Wed, 4 Oct 2006 23:53:36 +0000 (23:53 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 4 Oct 2006 23:53:36 +0000 (23:53 +0000)
8.1.4 and higher.

NEWS
ext/pdo_pgsql/config.m4
ext/pdo_pgsql/pgsql_driver.c

diff --git a/NEWS b/NEWS
index 096e7957faf625831e7a1d837d5179a7636ac3c5..be687953d507eb662f3c489f1ab3961f2434027b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP                                                                        NEWS
 - Added ability to make SOAP call userspace PHP<->XML converters. (Dmitry)
 - Added support for character sets in pg_escape_string() for PostgreSQL
   8.1.4 and higher. (Ilia)
+- Added support for character sets in PDO quote() method for PostgreSQL
+  8.1.4 and higher. (Ilia)
 - Fixed infinite loop when a wrong color index is given to imagefill (Pierre)
 - Fixed mess with CGI/CLI -d option (now it works with cgi; constants are
   working exactly like in php.ini; with FastCGI -d affects all requests).
index 9f356db64afb712136920013af1c2416ae5660c6..b466655fa482aaf2cda1d8b9ea1049746ba10931 100644 (file)
@@ -82,6 +82,7 @@ if test "$PHP_PDO_PGSQL" != "no"; then
   old_LDFLAGS=$LDFLAGS
   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, 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]))
index 11f320e4167221e76bf33d622a1ff15a6293774e..24e66adba94c5be1617fbbe03b2d0a985f05ee42 100644 (file)
@@ -322,13 +322,20 @@ static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote
                        (*quoted)[*quotedlen] = '\0';
                        free(escaped);
                        break;
-               default:
-                       *quoted = emalloc(2*unquotedlen + 3);
+               default: {
+                       pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
+
+                       *quoted = safe_emalloc(2, unquotedlen, 3);
                        (*quoted)[0] = '\'';
+#ifndef HAVE_PQESCAPE_CONN
                        *quotedlen = PQescapeString(*quoted + 1, unquoted, unquotedlen);
+#else
+                       *quotedlen = PQescapeStringConn(H->server, *quoted + 1, unquoted, unquotedlen, NULL);
+#endif
                        (*quoted)[*quotedlen + 1] = '\'';
                        (*quoted)[*quotedlen + 2] = '\0';
                        *quotedlen += 2;
+               }
        }
        return 1;
 }
@@ -355,7 +362,11 @@ static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned
                size_t l = strlen(name);
         
                name_escaped = safe_emalloc(l, 2, 1);
+#ifndef HAVE_PQESCAPE_CONN
                PQescapeString(name_escaped, name, l);
+#else
+               PQescapeStringConn(H->server, name_escaped, name, l, NULL);
+#endif
                spprintf(&q, 0, "SELECT CURRVAL('%s')", name_escaped);
                res = PQexec(H->server, q);
                efree(name_escaped);