[svn-commits] wdoekes: trunk r407876 - in /trunk: ./ res/res_config_pgsql.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Feb 10 10:49:42 CST 2014


Author: wdoekes
Date: Mon Feb 10 10:49:40 2014
New Revision: 407876

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407876
Log:
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
........

Merged revisions 407875 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/res/res_config_pgsql.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/res/res_config_pgsql.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_config_pgsql.c?view=diff&rev=407876&r1=407875&r2=407876
==============================================================================
--- trunk/res/res_config_pgsql.c (original)
+++ trunk/res/res_config_pgsql.c Mon Feb 10 10:49:40 2014
@@ -838,8 +838,8 @@
 		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 @@
 		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 @@
 		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));
 




More information about the svn-commits mailing list