1--TEST-- 2Bug #47199 (pg_delete fails on NULL) 3--EXTENSIONS-- 4pgsql 5--SKIPIF-- 6<?php 7require_once('skipif.inc'); 8?> 9--FILE-- 10<?php 11 12require_once('config.inc'); 13 14$dbh = pg_connect($conn_str); 15$tbl_name = 'test_47199'; 16@pg_query($dbh, "DROP TABLE $tbl_name"); 17pg_query($dbh, "CREATE TABLE $tbl_name (null_field INT, not_null_field INT NOT NULL)"); 18 19pg_insert($dbh, $tbl_name, array('null_field' => null, 'not_null_field' => 1)); 20pg_insert($dbh, $tbl_name, array('null_field' => null, 'not_null_field' => 2)); 21 22var_dump(pg_fetch_all(pg_query($dbh, 'SELECT * FROM '. $tbl_name))); 23 24$query = pg_delete($dbh, $tbl_name, array('null_field' => NULL,'not_null_field' => 2), PGSQL_DML_STRING|PGSQL_DML_EXEC); 25 26echo $query, "\n"; 27 28$query = pg_update($dbh, $tbl_name, array('null_field' => NULL, 'not_null_field' => 0), array('not_null_field' => 1, 'null_field' => ''), PGSQL_DML_STRING|PGSQL_DML_EXEC); 29 30echo $query, "\n"; 31 32var_dump(pg_fetch_all(pg_query($dbh, 'SELECT * FROM '. $tbl_name))); 33 34@pg_query($dbh, "DROP TABLE $tbl_name"); 35pg_close($dbh); 36 37echo PHP_EOL."Done".PHP_EOL; 38 39?> 40--EXPECT-- 41array(2) { 42 [0]=> 43 array(2) { 44 ["null_field"]=> 45 NULL 46 ["not_null_field"]=> 47 string(1) "1" 48 } 49 [1]=> 50 array(2) { 51 ["null_field"]=> 52 NULL 53 ["not_null_field"]=> 54 string(1) "2" 55 } 56} 57DELETE FROM "test_47199" WHERE "null_field" IS NULL AND "not_null_field"=2; 58UPDATE "test_47199" SET "null_field"=NULL,"not_null_field"=0 WHERE "not_null_field"=1 AND "null_field" IS NULL; 59array(1) { 60 [0]=> 61 array(2) { 62 ["null_field"]=> 63 NULL 64 ["not_null_field"]=> 65 string(1) "0" 66 } 67} 68 69Done 70