From: andrew at labyrinth-it dot co dot uk
Operating system: Linux (Fedora)
PHP version: 5.2.8
PHP Bug Type: PostgreSQL related
Bug description: pg_delete fails on NULL
Description:
------------
pg_delete uses incorrect syntax for NULL columns. The code generated
compares values with "col = NULL" instead of "col IS NULL". As a result,
the row is not matched so is not deleted.
Reproduce code:
---------------
<?php
$db = pg_connect("host=localhost dbname=andrew user=andrew
password=andrew");
$sql = 'SELECT * FROM demo';
$qry = pg_query($sql);
while ($row = pg_fetch_array($qry, null, PGSQL_ASSOC)) {
print_r($row);
pg_delete($db,'demo',$row); //1
print(pg_delete($db,'demo',$row,PGSQL_DML_STRING))
}
pg_free_result($qry);
$qry = pg_query($sql);
while ($row = pg_fetch_array($qry, null, PGSQL_ASSOC)) {
print_r($row); //2
}
pg_free_result($qry);
pg_close($db);
Expected result:
----------------
The first loop should read and display all rows in the table, and then
delete the rows. The second loop should not display any data at all.
---
Array
(
[id] => 1
[col1] =>
)
DELETE FROM demo WHERE id=1 AND col1 IS NULL;
Actual result:
--------------
When this runs, the second loop displays results for tables that have NULL
columns at the start of the run.
---
Array
(
[id] => 1
[col1] =>
)
DELETE FROM demo WHERE id=1 AND col1=NULL;
Array
(
[id] => 1
[col1] =>
)
--
Edit bug report at http://bugs.php.net/?id=47199&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47199&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47199&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47199&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47199&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47199&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47199&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47199&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47199&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47199&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47199&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47199&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47199&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47199&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47199&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47199&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47199&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47199&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47199&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47199&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47199&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47199&r=mysqlcfg