- 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)
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 */
/* Remove the trailing "," */
querystr.len--;
smart_str_appends(&querystr, ");");
+
+no_values:
+
smart_str_0(&querystr);
if ((opt & (PGSQL_DML_EXEC|PGSQL_DML_ASYNC)) &&
}
cleanup:
- if (!(opt & PGSQL_DML_NO_CONV)) {
+ if (!(opt & PGSQL_DML_NO_CONV) && converted) {
zval_dtor(converted);
FREE_ZVAL(converted);
}
--- /dev/null
+--TEST--
+Bug #42783 (pg_insert() does not support an empty value array)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+require_once('config.inc');
+
+$dbh = @pg_connect($conn_str);
+if (!$dbh) {
+ die ("Could not connect to the server");
+}
+
+pg_query("CREATE TABLE php_test (id SERIAL PRIMARY KEY, time TIMESTAMP NOT NULL DEFAULT now())");
+
+pg_insert($dbh, 'php_test', array());
+
+var_dump(pg_fetch_assoc(pg_query("SELECT * FROM php_test")));
+
+pg_query($dbh, "DROP TABLE php_test");
+pg_close($dbh);
+?>
+===DONE===
+--EXPECTF--
+array(2) {
+ ["id"]=>
+ string(%d) "%d"
+ ["time"]=>
+ string(%d) "%s"
+}
+===DONE===