[asterisk-addons-commits] tilghman: branch 1.6.1 r788 - /branches/1.6.1/cdr/cdr_addon_mysql.c

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Fri Feb 20 16:01:38 CST 2009


Author: tilghman
Date: Fri Feb 20 16:01:38 2009
New Revision: 788

URL: http://svn.digium.com/svn-view/asterisk-addons?view=rev&rev=788
Log:
Only add the column if the value is non-NULL.

Modified:
    branches/1.6.1/cdr/cdr_addon_mysql.c

Modified: branches/1.6.1/cdr/cdr_addon_mysql.c
URL: http://svn.digium.com/svn-view/asterisk-addons/branches/1.6.1/cdr/cdr_addon_mysql.c?view=diff&rev=788&r1=787&r2=788
==============================================================================
--- branches/1.6.1/cdr/cdr_addon_mysql.c (original)
+++ branches/1.6.1/cdr/cdr_addon_mysql.c Fri Feb 20 16:01:38 2009
@@ -252,11 +252,6 @@
 			}
 
 			/* Construct SQL */
-			if (column_count++) {
-				strcat(sql1, ",");
-				strcat(sql2, "','");
-			}
-
 			if (strlen(sql1) + 2 + strlen(entry->name) > sql1size) {
 				char *tmp = ast_realloc(sql1, sql1size * 2);
 				if (!tmp)
@@ -264,7 +259,6 @@
 				sql1size *= 2;
 				sql1 = tmp;
 			}
-			strcat(sql1, entry->name);
 
 			/* Need the type and value to determine if we want the raw value or not */
 			if ((!strcmp(cdrname, "start") ||
@@ -291,6 +285,13 @@
 				sql2 = tmp;
 			}
 			if (value) {
+				if (column_count++) {
+					strcat(sql1, ",");
+					strcat(sql2, "','");
+				}
+
+				strcat(sql1, entry->name);
+
 				/*!\note We're manually escaping here, to ensure that we know exactly
 				 * how much space is used.  Since we only accept ASCII strings at this
 				 * point in time, there is no danger in this simplistic escape method,




More information about the asterisk-addons-commits mailing list