diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2006-10-04 23:53:36 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2006-10-04 23:53:36 +0000 |
commit | 40765184be9523a3fb4f8e4a1750bbfd6eb6a877 (patch) | |
tree | 047e1e650f62d8c9c6afa063943213851080fe1e /ext/pdo_pgsql/pgsql_driver.c | |
parent | e8c70bfa99f20ab02208aebcab01cf5e702fd067 (diff) | |
download | php-git-40765184be9523a3fb4f8e4a1750bbfd6eb6a877.tar.gz |
Added support for character sets in PDO quote() method for PostgreSQL
8.1.4 and higher.
Diffstat (limited to 'ext/pdo_pgsql/pgsql_driver.c')
-rw-r--r-- | ext/pdo_pgsql/pgsql_driver.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 11f320e416..24e66adba9 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -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); |