summaryrefslogtreecommitdiff
path: root/ext/pgsql/pgsql.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-10-03 23:30:46 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-10-03 23:30:46 +0000
commitf6b761b0ac061fd503c5c7caa663a9c9f8fd472a (patch)
treead0741bfc62ff1f90ffe26cf4caadf570dc26c5f /ext/pgsql/pgsql.c
parent2448b05b4f17b0a2516f96c17cef412a7f6a30f5 (diff)
downloadphp-git-f6b761b0ac061fd503c5c7caa663a9c9f8fd472a.tar.gz
Fixed bug #42783 (pg_insert() does not accept an empty list for insertion)
Diffstat (limited to 'ext/pgsql/pgsql.c')
-rw-r--r--ext/pgsql/pgsql.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index c0c99dd996..92ceec2683 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -5366,7 +5366,11 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var
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 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var
/* 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 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var
}
cleanup:
- if (!(opt & PGSQL_DML_NO_CONV)) {
+ if (!(opt & PGSQL_DML_NO_CONV) && converted) {
zval_dtor(converted);
FREE_ZVAL(converted);
}