From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Nov 29 13:30:03 2008 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0B8CF1065672 for ; Sat, 29 Nov 2008 13:30:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E5E1A8FC17 for ; Sat, 29 Nov 2008 13:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id mATDU1QV015294 for ; Sat, 29 Nov 2008 13:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id mATDU1O9015290; Sat, 29 Nov 2008 13:30:01 GMT (envelope-from gnats) Resent-Date: Sat, 29 Nov 2008 13:30:01 GMT Resent-Message-Id: <200811291330.mATDU1O9015290@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Lapo Luchini Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4AA2D106564A; Sat, 29 Nov 2008 13:21:34 +0000 (UTC) (envelope-from lapo@deepie.home.lapo.it) Received: from deepie.home.lapo.it (unknown [IPv6:2002:514a:2847::1]) by mx1.freebsd.org (Postfix) with ESMTP id 317F98FC08; Sat, 29 Nov 2008 13:21:28 +0000 (UTC) (envelope-from lapo@deepie.home.lapo.it) Received: from deepie.home.lapo.it (localhost [127.0.0.1]) by deepie.home.lapo.it (8.14.3/8.14.3) with ESMTP id mATDL5EI054336; Sat, 29 Nov 2008 14:21:05 +0100 (CET) (envelope-from lapo@deepie.home.lapo.it) Received: (from lapo@localhost) by deepie.home.lapo.it (8.14.3/8.14.3/Submit) id mATDL4Th054335; Sat, 29 Nov 2008 14:21:04 +0100 (CET) (envelope-from lapo) Message-Id: <200811291321.mATDL4Th054335@deepie.home.lapo.it> Date: Sat, 29 Nov 2008 14:21:04 +0100 (CET) From: Lapo Luchini To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Lapo Luchini , Alex Dupre Subject: ports/129277: databases/php5-pdo_sqlite doesn't manage BLOB types X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Lapo Luchini List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Nov 2008 13:30:03 -0000 >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@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: