From ebd957f69e6f27dce0d37c95fc7754c57aa34ca5 Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Mon, 22 Apr 2002 08:18:19 +0000 Subject: [PATCH] hash keys lengths include the NUL-byte, so we need to copy one byte less. also add missing commas in the INSERT clause. Noticed by: Yasuo Ohgaki --- ext/pgsql/pgsql.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index fc1d8fc311..fe49782b36 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -3908,9 +3908,11 @@ PHPAPI int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var_array, get_active_function_name(TSRMLS_C)); goto cleanup; } - smart_str_appendl(&querystr, fld, fld_len); + smart_str_appendl(&querystr, fld, fld_len - 1); + smart_str_appendc(&querystr, ','); zend_hash_move_forward_ex(Z_ARRVAL_P(var_array), &pos); } + querystr.len--; smart_str_appends(&querystr, ") VALUES ("); /* make values string */ @@ -4004,7 +4006,7 @@ static inline int build_assignment_string(smart_str *querystr, HashTable *ht, co get_active_function_name(TSRMLS_C)); return -1; } - smart_str_appendl(querystr, fld, fld_len); + smart_str_appendl(querystr, fld, fld_len - 1); smart_str_appendc(querystr, '='); switch(Z_TYPE_PP(val)) { -- 2.50.1