Edit report at http://bugs.php.net/bug.php?id=47199&edit=1
ID: 47199
User updated by: andrew at labyrinth-it dot co dot uk
Reported by: andrew at labyrinth-it dot co dot uk
Summary: pg_delete fails on NULL
Status: Closed
Type: Bug
Package: PostgreSQL related
Operating System: Linux (Fedora)
-PHP Version: 5.2.10
+PHP Version: 5.3.5
Assigned To: felipe
Block user comment: N
Private report: N
New Comment:
OK, Sorry. I have downloaded and tested 5.3.5 and this is working
perfectly!
Thanks for fixing this.
Previous Comments:
------------------------------------------------------------------------
[2010-12-09 18:58:51] felipe@php.net
Hello, the fix was committed to 5.3.x branch and trunk, not to 5.2.x.
------------------------------------------------------------------------
[2010-12-09 18:52:14] andrew at labyrinth-it dot co dot uk
Hi,
I have just downloaded the latest 5.2 version from SVN, and tested this
again.
It is still
not working. I have created a more complete test case that can be used.
===========Start===========
<?php
$linenum=0;
function _print($str) {
global $linenum;
print($linenum++."\t".$str."\n");
}
_print('PHP_VERSION : '.PHP_VERSION);
_print('PHP_OS : '.PHP_OS);
$db = pg_connect("dbname=test");
if (! $db) {
die("Not connected");
}
//Create a test table
$create = 'create table testcase (id integer, col1 varchar(20))';
$result = pg_query($db,$create);
//Insert some test data
$row = array('id'=>1, 'col1'=>'I');
_print(pg_insert($db,'testcase',$row,PGSQL_DML_STRING));
pg_insert($db,'testcase',$row);
$row = array('id'=>2, 'col1'=>'');
_print(pg_insert($db,'testcase',$row,PGSQL_DML_STRING));
pg_insert($db,'testcase',$row);
$row = array('id'=>3, 'col1'=>null);
_print(pg_insert($db,'testcase',$row,PGSQL_DML_STRING));
pg_insert($db,'testcase',$row);
//Selects
$search = array('col1'=>'I');
_print(pg_select($db,'testcase',$search,PGSQL_DML_STRING));
$result = pg_select($db,'testcase',$search);
if ($result) {
_print($result[0]['id']."\t".$result[0]['col1']);
} else {
_print('Not found');
}
$search = array('col1'=>'');
_print(pg_select($db,'testcase',$search,PGSQL_DML_STRING));
$result = pg_select($db,'testcase',$search);
if ($result) {
_print($result[0]['id']."\t".$result[0]['col1']);
} else {
_print('Not found');
}
$search = array('col1'=>null);
_print(pg_select($db,'testcase',$search,PGSQL_DML_STRING));
$result = pg_select($db,'testcase',$search);
if ($result) {
_print($result[0]['id']."\t".$result[0]['col1']);
} else {
_print('Not found');
}
//Updates
$data = array('id'=>5);
$condition = array('col1'=>'I');
_print(pg_update($db,'testcase',$data,$condition,PGSQL_DML_STRING));
$condition = array('col1'=>'');
_print(pg_update($db,'testcase',$data,$condition,PGSQL_DML_STRING));
$condition = array('col1'=>null);
_print(pg_update($db,'testcase',$data,$condition,PGSQL_DML_STRING));
//Deletes
$condition = array('col1'=>'I');
_print(pg_delete($db,'testcase',$condition,PGSQL_DML_STRING));
$condition = array('col1'=>'');
_print(pg_delete($db,'testcase',$condition,PGSQL_DML_STRING));
$condition = array('col1'=>null);
_print(pg_delete($db,'testcase',$condition,PGSQL_DML_STRING));
//clean up
$drop = 'drop table testcase';
$result = pg_query($db,$drop);
=============End===============
The generated output from this script is:
0 PHP_VERSION : 5.2.16-dev
1 PHP_OS : Linux
2 INSERT INTO testcase (id,col1) VALUES (1,'I');
3 INSERT INTO testcase (id,col1) VALUES (2,'');
4 INSERT INTO testcase (id,col1) VALUES (3,NULL);
5 SELECT * FROM testcase WHERE col1='I';
6 1 I
7 SELECT * FROM testcase WHERE col1='';
8 2
9
10 Not found
11 UPDATE testcase SET id=5 WHERE col1='I';
12 UPDATE testcase SET id=5 WHERE col1='';
13 UPDATE testcase SET id=5 WHERE col1=NULL;
14 DELETE FROM testcase WHERE col1='I';
15 DELETE FROM testcase WHERE col1='';
16 DELETE FROM testcase WHERE col1=NULL;
Notes:
Line 0: php version 5.2.16-dev - latest version just downloaded.
Line 9: No SELECT string is generated if the parameter contains NULL
Line 10: No data is found when searching for NULL
Line 13: Still using col1=NULL instead of col1 IS NULL
Line 16: Still using col1=NULL instead of col1 IS NULL
Has the patch been merged with the version at snaps.php.net?
------------------------------------------------------------------------
[2010-11-06 18:44:54] felipe@php.net
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Thanks for the patch!
------------------------------------------------------------------------
[2010-11-06 18:43:27] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=305130
Log: - Fixed bug #47199 (pg_delete() fails on NULL)
patch by: ewgraf at gmail dot com
------------------------------------------------------------------------
[2010-02-10 16:40:12] ewgraf at gmail dot com
Patch for this bug:
http://news.php.net/php.internals/46974
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=47199
--
Edit this bug report at http://bugs.php.net/bug.php?id=47199&edit=1