[svn-commits] seanbright: trunk r126274 - /trunk/cdr/cdr_pgsql.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Jun 29 07:06:47 CDT 2008


Author: seanbright
Date: Sun Jun 29 07:06:46 2008
New Revision: 126274

URL: http://svn.digium.com/view/asterisk?view=rev&rev=126274
Log:
Quote column names when inserting CDRs into postgres to avoid conflicts
with reserved words.

(closes issue #12947)
Reported by: panolex

Modified:
    trunk/cdr/cdr_pgsql.c

Modified: trunk/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_pgsql.c?view=diff&rev=126274&r1=126273&r2=126274
==============================================================================
--- trunk/cdr/cdr_pgsql.c (original)
+++ trunk/cdr/cdr_pgsql.c Sun Jun 29 07:06:46 2008
@@ -146,8 +146,8 @@
 			if (!value) {
 				if (cur->notnull && !cur->hasdefault) {
 					/* Field is NOT NULL (but no default), must include it anyway */
-					LENGTHEN_BUF1(strlen(cur->name));
-					lensql += snprintf(sql + lensql, sizesql - lensql, "%s,", cur->name);
+					LENGTHEN_BUF1(strlen(cur->name) + 2);
+					lensql += snprintf(sql + lensql, sizesql - lensql, "\"%s\",", cur->name);
 					LENGTHEN_BUF2(3);
 					strcat(sql2, "'',");
 					lensql2 += 3;
@@ -155,8 +155,8 @@
 				continue;
 			}
 			
-			LENGTHEN_BUF1(strlen(cur->name));
-			lensql += snprintf(sql + lensql, sizesql - lensql, "%s,", cur->name);
+			LENGTHEN_BUF1(strlen(cur->name) + 2);
+			lensql += snprintf(sql + lensql, sizesql - lensql, "\"%s\",", cur->name);
 
 			if (strcmp(cur->name, "start") == 0 || strcmp(cur->name, "calldate") == 0) {
 				if (strncmp(cur->type, "int", 3) == 0) {




More information about the svn-commits mailing list