diff options
| author | Edin Kadribasic <edink@php.net> | 2005-02-06 01:27:27 +0000 |
|---|---|---|
| committer | Edin Kadribasic <edink@php.net> | 2005-02-06 01:27:27 +0000 |
| commit | accdde8c19e674abfd4a5fbad8d63c01d9113d14 (patch) | |
| tree | 977db5998fb704801b5dc1f56e2801d94b5ffe8e /ext | |
| parent | 0d9b0606b967322611fee22c6776f2cde896642e (diff) | |
| download | php-git-accdde8c19e674abfd4a5fbad8d63c01d9113d14.tar.gz | |
Finalized pgsql LOB support using native pgsql bytea type.
If paramater is bound with type PDO_PARAM_LOB the quoter function
gets a hint that specific LOB type quoting should be used:
$stmt->bindParam(":lob", $lob, PDO_PARAM_LOB);
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/pdo_pgsql/pgsql_driver.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 5fc5820993..ca14b2c1b5 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -169,12 +169,28 @@ 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) { - *quoted = emalloc(2*unquotedlen + 3); - (*quoted)[0] = '\''; - *quotedlen = PQescapeString(*quoted + 1, unquoted, unquotedlen); - (*quoted)[*quotedlen + 1] = '\''; - (*quoted)[*quotedlen + 2] = '\0'; - *quotedlen += 2; + unsigned char *escaped; + + switch (paramtype) { + case PDO_PARAM_LOB: + /* escapedlen returned by PQescapeBytea() accounts for trailing 0 */ + escaped = PQescapeBytea(unquoted, unquotedlen, quotedlen); + *quotedlen += 1; + *quoted = emalloc(*quotedlen + 1); + memcpy((*quoted)+1, escaped, *quotedlen-2); + (*quoted)[0] = '\''; + (*quoted)[*quotedlen-1] = '\''; + (*quoted)[*quotedlen] = '\0'; + free(escaped); + break; + default: + *quoted = emalloc(2*unquotedlen + 3); + (*quoted)[0] = '\''; + *quotedlen = PQescapeString(*quoted + 1, unquoted, unquotedlen); + (*quoted)[*quotedlen + 1] = '\''; + (*quoted)[*quotedlen + 2] = '\0'; + *quotedlen += 2; + } return 1; } |
