iliaa           Wed Oct  3 23:31:58 2007 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/pgsql/tests    80_bug42783.phpt 

  Modified files:              
    /php-src/ext/pgsql  pgsql.c 
    /php-src    NEWS 
  Log:
  
  MFB: Fixed bug #42783 (pg_insert() does not accept an empty list for
  insertion)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24&r2=1.331.2.13.2.25&diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.25
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24   Wed Sep  5 13:03:59 2007
+++ php-src/ext/pgsql/pgsql.c   Wed Oct  3 23:31:58 2007
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24 2007/09/05 13:03:59 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.25 2007/10/03 23:31:58 iliaa Exp $ */
 
 #include <stdlib.h>
 
@@ -5366,7 +5366,11 @@
        assert(Z_TYPE_P(var_array) == IS_ARRAY);
 
        if (zend_hash_num_elements(Z_ARRVAL_P(var_array)) == 0) {
-               return FAILURE;
+               smart_str_appends(&querystr, "INSERT INTO ");
+               smart_str_appends(&querystr, table);
+               smart_str_appends(&querystr, " DEFAULT VALUES");
+
+               goto no_values;
        }
 
        /* convert input array if needed */
@@ -5424,6 +5428,9 @@
        /* Remove the trailing "," */
        querystr.len--;
        smart_str_appends(&querystr, ");");
+
+no_values:
+
        smart_str_0(&querystr);
 
        if ((opt & (PGSQL_DML_EXEC|PGSQL_DML_ASYNC)) &&
@@ -5435,7 +5442,7 @@
        }
        
 cleanup:
-       if (!(opt & PGSQL_DML_NO_CONV)) {
+       if (!(opt & PGSQL_DML_NO_CONV) && converted) {
                zval_dtor(converted);                   
                FREE_ZVAL(converted);
        }
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.969&r2=1.2027.2.547.2.970&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.969 php-src/NEWS:1.2027.2.547.2.970
--- php-src/NEWS:1.2027.2.547.2.969     Wed Oct  3 09:47:23 2007
+++ php-src/NEWS        Wed Oct  3 23:31:58 2007
@@ -35,6 +35,8 @@
 - Fixed bug #42818 ($foo = clone(array()); leaks memory). (Dmitry)
 - Fixed bug #42785 (json_encode() formats doubles according to locale rather  
   then following standard syntax). (Ilia)
+- Fixed bug #42783 (pg_insert() does not accept an empty list for
+  insertion). (Ilia)
 - Fixed bug #42772 (Storing $this in a static var fails while handling a cast
   to string). (Dmitry)
 - Fixed bug #42767 (highlight_string() truncates trailing comment). (Ilia)

http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/tests/80_bug42783.phpt?view=markup&rev=1.1
Index: php-src/ext/pgsql/tests/80_bug42783.phpt
+++ php-src/ext/pgsql/tests/80_bug42783.phpt

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to