From: gregkiyomi at digitaljunkies dot ca Operating system: linux PHP version: 5.0.0b2 (beta2) PHP Bug Type: PostgreSQL related Bug description: pg_convert sets NULL incorrectly for character data types
Description: ------------ When using pg_convert() with PGSQL_CONV_FORCE_NULL option set the resulting value for character data types (text,char,varchar) is set as 'NULL' instead of NULL. This therefore inserts the string 'NULL' into the database instead of the desired NULL value. This also obviously doesn't fail a NOT NULL check as it should. The culprit is ext/pgsql/pgsql.c *** pgsql.c~ Mon Dec 15 00:17:01 2003 --- pgsql.c Mon Dec 15 01:28:56 2003 *************** *** 3785,3790 **** --- 3785,3791 ---- if (Z_STRLEN_PP(val) == 0) { if (opt & PGSQL_CONV_FORCE_NULL) { ZVAL_STRING(new_val, "NULL", 1); + break; } else { ZVAL_STRING(new_val, empty_string, 1); This prevents the NULL value from being passed through php_pgsql_add_quotes(). This is also present in php 4.3.3. Reproduce code: --------------- $con_str = "host=localhost dbname=database user=user password=pass"; $con = pg_connect($con_str); $data = array("varchar_field1"=>"test", "varchar_field2"=>NULL, "varchar_field3"=>""); $array = pg_convert($con,"test_table",$data,4); echo("<pre>"); print_r($array); echo("</pre>"); Expected result: ---------------- Array ( [varchar_field1] => 'test' [varchar_field2] => NULL [varchar_field3] => NULL ) Actual result: -------------- Array ( [varchar_field1] => 'test' [varchar_field2] => NULL [varchar_field3] => 'NULL' ) -- Edit bug report at http://bugs.php.net/?id=26625&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26625&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26625&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26625&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26625&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26625&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=26625&r=needscript Try newer version: http://bugs.php.net/fix.php?id=26625&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26625&r=support Expected behavior: http://bugs.php.net/fix.php?id=26625&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26625&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26625&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26625&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26625&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26625&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26625&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26625&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26625&r=float