From: Walter Doekes Date: Mon, 10 Feb 2014 16:43:29 +0000 (+0000) Subject: res_config_pgsql: Fix ast_update2_realtime calls. X-Git-Tag: 12.2.0-rc1~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a4d8f7ab580b228a117acd5ac50f9fa2656916a;p=thirdparty%2Fasterisk.git res_config_pgsql: Fix ast_update2_realtime calls. Fix so multiple updates from a single call works (add missing ','). Remove bogus ast_free's that weren't supposed to be there. Moved a few spaces for readability. Review: https://reviewboard.asterisk.org/r/3194/ ........ Merged revisions 407873 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 407874 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@407875 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c index b59dc55213..27494a12fb 100644 --- a/res/res_config_pgsql.c +++ b/res/res_config_pgsql.c @@ -838,8 +838,8 @@ static int update2_pgsql(const char *database, const char *tablename, const stru return -1; } - ast_str_set(&sql, 0, "UPDATE %s SET ", tablename); - ast_str_set(&where, 0, "WHERE"); + ast_str_set(&sql, 0, "UPDATE %s SET", tablename); + ast_str_set(&where, 0, " WHERE"); for (field = lookup_fields; field; field = field->next) { if (!find_column(table, field->name)) { @@ -852,7 +852,6 @@ static int update2_pgsql(const char *database, const char *tablename, const stru if (pgresult) { ast_log(LOG_ERROR, "PostgreSQL RealTime: detected invalid input: '%s'\n", field->value); release_table(table); - ast_free(sql); return -1; } ast_str_append(&where, 0, "%s %s='%s'", first ? "" : " AND", field->name, ast_str_buffer(escapebuf)); @@ -883,15 +882,15 @@ static int update2_pgsql(const char *database, const char *tablename, const stru if (pgresult) { ast_log(LOG_ERROR, "PostgreSQL RealTime: detected invalid input: '%s'\n", field->value); release_table(table); - ast_free(sql); return -1; } ast_str_append(&sql, 0, "%s %s='%s'", first ? "" : ",", field->name, ast_str_buffer(escapebuf)); + first = 0; } release_table(table); - ast_str_append(&sql, 0, " %s", ast_str_buffer(where)); + ast_str_append(&sql, 0, "%s", ast_str_buffer(where)); ast_debug(1, "PostgreSQL RealTime: Update SQL: %s\n", ast_str_buffer(sql));