php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63243 SQL select statement returns results that do not match the query
Submitted: 2012-10-08 19:42 UTC Modified: 2015-08-17 14:36 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: cbeck at good-sam dot com Assigned: rangercairns (profile)
Status: Not a bug Package: ibm_db2 (PECL)
PHP Version: Irrelevant OS: IBM i 7.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cbeck at good-sam dot com
New email:
PHP Version: OS:

 

 [2012-10-08 19:42 UTC] cbeck at good-sam dot com
Description:
------------
If an SQL select is issued with more data in the where clause than the size of the 
field and the first part of the string matches it will return the record(s) 
anyway.  

This was confirmed by Zend Support and suggested I log a bug here: ref #00041272 

ib_db2 module version = 1.9.0

Test script:
---------------
$i5 = db2_connect(null,null,null);

@db2_exec($i5, 'CREATE SCHEMA DB2TEST');
@db2_exec($i5,'CREATE TABLE DB2TEST.DB2TEST (FIELD1 CHAR (10 ) NOT NULL WITH DEFAULT)');

db2_exec($i5,"INSERT INTO DB2TEST.DB2TEST (FIELD1) VALUES('TESTVALUEX')");

$stmt = db2_prepare($i5, 'select * from DB2TEST.DB2TEST where FIELD1 = ?');
db2_execute($stmt, array('TESTVALUEX1234567890'));

var_dump(db2_fetch_assoc($stmt));

db2_exec($i5,"DELETE FROM DB2TEST.DB2TEST");


Expected result:
----------------
I would expect the dump to show no records 

Actual result:
--------------
One record is shown in the dump.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-12 20:06 UTC] adc at us dot ibm dot com
V7.1 results do not show issue using ibm_db2 1.9.6 

bash-4.2$ php zz63243.php 
value is ...
NULL
... end

zz63243.php:
require "connection.inc";
$i5 = db2_connect($db,$uid,$pwd);
@db2_exec($i5,'CREATE TABLE DB2TEST (FIELD1 CHAR (10 ) NOT NULL WITH DEFAULT)');
db2_exec($i5,"INSERT INTO DB2TEST (FIELD1) VALUES('TESTVALUEX')");
$stmt = db2_prepare($i5, 'select * from DB2TEST where FIELD1 = ?');
db2_execute($stmt, array('TESTVALUEX1234567890'));
echo "value is ...\n";
var_dump(db2_fetch_assoc($stmt));
echo "... end\n";
db2_exec($i5,"DELETE FROM DB2TEST");
echo "\n";
 [2015-06-17 06:12 UTC] rahulpriyadarshi@php.net
-Assigned To: +Assigned To: rangercairns
 [2015-08-17 14:36 UTC] rangercairns@php.net
-Status: Assigned +Status: Not a bug
 [2015-08-17 14:36 UTC] rangercairns@php.net
Our IBM i DB2 CLI expert states truncated compare is working as designed (within SQL specifications). Therefore, I am closing this issues as 'not a bug'.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC