ports/129277: databases/php5-pdo_sqlite doesn't manage BLOB types
Lapo Luchini
lapo at lapo.it
Sat Nov 29 13:30:03 UTC 2008
>Number: 129277
>Category: ports
>Synopsis: databases/php5-pdo_sqlite doesn't manage BLOB types
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sat Nov 29 13:30:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Lapo Luchini
>Release: FreeBSD 7.1-PRERELEASE amd64
>Organization:
>Environment:
System: FreeBSD deepie.home.lapo.it 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #11: Sun Oct 19 15:29:12 CEST 2008 root at deepie.home.lapo.it:/usr/obj/usr/src/sys/DEEPIE amd64
>Description:
PHP's 5.3 SQLite PDO doesn't really support PARAM_LOB type,
it falls through to PARAM_STR, thus the DB doesn't know the
data received is meant to be a BLOB type.
>How-To-Repeat:
1. insert some binary data in the DB
2. SELECT TYPEOF(column), LENGTH(column) FROM table;
3. notice the TEXT type in the first column
4. notice the wrong length in the second column (ends at first \0)
>Fix:
An official patch from
http://bugs.php.net/bug.php?id=42443
seems to have landed in 5.3+.
This is the patch from the comment applied on the current sources,
ready for the files/ subdirectory.
--- patch-sqlite_statement.c begins here ---
--- sqlite_statement.c.orig 2007-12-31 08:20:10.000000000 +0100
+++ sqlite_statement.c 2008-11-29 14:00:33.074007425 +0100
@@ -104,6 +104,21 @@ static int pdo_sqlite_stmt_param_hook(pd
pdo_sqlite_error_stmt(stmt);
return 0;
+ case PDO_PARAM_INT:
+ case PDO_PARAM_BOOL:
+ if (Z_TYPE_P(param->parameter) == IS_NULL) {
+ if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) {
+ return 1;
+ }
+ } else {
+ convert_to_long(param->parameter);
+ if (SQLITE_OK == sqlite3_bind_int(S->stmt, param->paramno + 1, Z_LVAL_P(param->parameter))) {
+ return 1;
+ }
+ }
+ pdo_sqlite_error_stmt(stmt);
+ return 0;
+
case PDO_PARAM_LOB:
if (Z_TYPE_P(param->parameter) == IS_RESOURCE) {
php_stream *stm;
@@ -117,8 +132,24 @@ static int pdo_sqlite_stmt_param_hook(pd
pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource" TSRMLS_CC);
return 0;
}
+ } else if (Z_TYPE_P(param->parameter) == IS_NULL) {
+ if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) {
+ return 1;
+ }
+ pdo_sqlite_error_stmt(stmt);
+ return 0;
+ } else {
+ convert_to_string(param->parameter);
+ }
+
+ if (SQLITE_OK == sqlite3_bind_blob(S->stmt, param->paramno + 1,
+ Z_STRVAL_P(param->parameter),
+ Z_STRLEN_P(param->parameter),
+ SQLITE_STATIC)) {
+ return 1;
}
- /* fall through */
+ pdo_sqlite_error_stmt(stmt);
+ return 0;
case PDO_PARAM_STR:
default:
--- patch-sqlite_statement.c ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list