Bug #74703 [Opn]: db2_execute() inconsistently fails to bind a boolean value

From: Date: Wed, 07 Jun 2017 19:53:35 +0000
Subject: Bug #74703 [Opn]: db2_execute() inconsistently fails to bind a boolean value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209406@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74703&edit=1 ID: 74703 User updated by: smorozov at sugarcrm dot com Reported by: smorozov at sugarcrm dot com Summary: db2_execute() inconsistently fails to bind a boolean value Status: Open Type: Bug -Package: ibm_db2 +Package: opcache Operating System: CentOS 7, Ubuntu 16.04 PHP Version: 7.1.5 Block user comment: N Private report: N New Comment: Moved the issue from ibm_db2 category to Opcache as it's only reproducible with Opcache enabled. Previous Comments: ------------------------------------------------------------------------ [2017-06-07 00:52:45] smorozov at sugarcrm dot com Updated the summary to emphasize the inconsistent nature of the issue. ------------------------------------------------------------------------ [2017-06-07 00:49:11] smorozov at sugarcrm dot com Description: ------------ The issue is reproducible in the following environment: 1. PHP 7.1(.5), IBM DB2 10.5. Not reproducible on PHP 5.6.30 and PHP 7.0.19 in the exact same environment. 2. A boolean value is bound to an integer column (e.g. a SMALLINT). 3. The boolean value is not a literal but a result of comparison of an array element to a string literal (just comparing strings will not work, see example). 4. The query in question is not the first query executed after connecting to the DB. Test script: --------------- /* CREATE TABLE DB2_TEST ( ID smallint DEFAULT 0 ) */ $dsn = 'HOSTNAME=localhost;UID=db2inst1;PWD=Passw0rd;DATABASE=test'; $conn = db2_connect($dsn, null, null); if (!$conn) { echo db2_conn_errormsg(), PHP_EOL; exit(1); } printf('PHP: %s' . PHP_EOL, phpversion()); printf('ibm_db2: %s' . PHP_EOL, phpversion('ibm_db2')); $server = db2_server_info($conn); printf('DB2 NAME: %s, VERSION: %s' . PHP_EOL, $server->DBMS_NAME, $server->DBMS_VER); // without executing a query before the following one, the issue is not reproducible $stmt = db2_prepare($conn, 'SELECT 1 FROM SYSIBM.SYSDUMMY1'); $result = db2_execute($stmt); if (!$result) { echo db2_stmt_errormsg(), PHP_EOL; exit(1); } // the value of $true is the result of comparison of an array element value // with the same value. if it's just literal true, the issue is not reproducible $array = array('key' => 'value'); $true = $array['key'] == 'value'; $stmt = db2_prepare($conn, 'SELECT ID FROM DB2_TEST WHERE ID = ?'); $result = db2_execute($stmt, [$true]); if (!$result) { echo db2_stmt_errormsg(), PHP_EOL; exit(1); } echo 'OK', PHP_EOL; Expected result: ---------------- The second call to db2_execute() is expected to return TRUE. OK is displayed. Actual result: -------------- [IBM][CLI Driver] CLI0111E Numeric value out of range. SQLSTATE=22003 SQLCODE=-99999 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74703&edit=1

« previous php.bugs (#209406) next »