iliaa           Wed Oct  3 23:30:46 2007 UTC

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

  Modified files:              
    /php-src/ext/pgsql  pgsql.c 
  Log:
  
  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.2.1&r2=1.331.2.13.2.24.2.2&diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.1 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.2
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.1       Thu Sep 27 18:00:42 2007
+++ php-src/ext/pgsql/pgsql.c   Wed Oct  3 23:30:46 2007
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.1 2007/09/27 18:00:42 dmitry Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.2 2007/10/03 23:30:46 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/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