diff options
| author | Ilia Alshanetsky <iliaa@php.net> | 2006-10-06 22:34:16 +0000 |
|---|---|---|
| committer | Ilia Alshanetsky <iliaa@php.net> | 2006-10-06 22:34:16 +0000 |
| commit | b43e18a70ea0811eea93dbe755180f5ab7a70bd3 (patch) | |
| tree | 77b4fc746afd408f6e65a3b30d8a6793819c26f2 /ext/pdo_pgsql/pgsql_driver.c | |
| parent | fab29dcbcfb665bed9262583105590b7ce8d5436 (diff) | |
| download | php-git-b43e18a70ea0811eea93dbe755180f5ab7a70bd3.tar.gz | |
Make quote() in PostgreSQL use PQescapeByteaConn() whenever possible for
binary strings.
Diffstat (limited to 'ext/pdo_pgsql/pgsql_driver.c')
| -rw-r--r-- | ext/pdo_pgsql/pgsql_driver.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 24e66adba9..2e672ba040 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -309,11 +309,16 @@ static long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM 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); @@ -322,9 +327,7 @@ static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote (*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 @@ -335,7 +338,6 @@ static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote (*quoted)[*quotedlen + 1] = '\''; (*quoted)[*quotedlen + 2] = '\0'; *quotedlen += 2; - } } return 1; } |
