[asterisk-commits] cdr/cdr adaptive odbc.c: Refactor concatenate columns name. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 22 06:27:38 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: cdr/cdr_adaptive_odbc.c: Refactor concatenate columns name.
......................................................................


cdr/cdr_adaptive_odbc.c: Refactor concatenate columns name.

The concatenate for columns name to INSERT INTO is always the same. It is
possible to do it on one line.

ASTERISK-24980

Change-Id: Ib8bb53c42535378581d4ef729cc5ebbb22b067ac
---
M cdr/cdr_adaptive_odbc.c
1 file changed, 1 insertion(+), 11 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Mark Michelson: Looks good to me, but someone else must approve
  Matt Jordan: Looks good to me, approved; Verified



diff --git a/cdr/cdr_adaptive_odbc.c b/cdr/cdr_adaptive_odbc.c
index 22f7d79..83877cb 100644
--- a/cdr/cdr_adaptive_odbc.c
+++ b/cdr/cdr_adaptive_odbc.c
@@ -484,7 +484,6 @@
 						}
 					}
 
-					ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 					LENGTHEN_BUF2(strlen(colptr));
 
 					/* Encode value, with escaping */
@@ -520,7 +519,6 @@
 							year += 2000;
 						}
 
-						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(17);
 						ast_str_append(&sql2, 0, "%s{ d '%04d-%02d-%02d' }", first ? "" : ",", year, month, day);
 					}
@@ -537,7 +535,6 @@
 							continue;
 						}
 
-						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(15);
 						ast_str_append(&sql2, 0, "%s{ t '%02d:%02d:%02d' }", first ? "" : ",", hour, minute, second);
 					}
@@ -566,7 +563,6 @@
 							year += 2000;
 						}
 
-						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(26);
 						ast_str_append(&sql2, 0, "%s{ ts '%04d-%02d-%02d %02d:%02d:%02d' }", first ? "" : ",", year, month, day, hour, minute, second);
 					}
@@ -581,7 +577,6 @@
 							continue;
 						}
 
-						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(12);
 						ast_str_append(&sql2, 0, "%s%d", first ? "" : ",", integer);
 					}
@@ -596,7 +591,6 @@
 							continue;
 						}
 
-						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(24);
 						ast_str_append(&sql2, 0, "%s%lld", first ? "" : ",", integer);
 					}
@@ -611,7 +605,6 @@
 							continue;
 						}
 
-						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(6);
 						ast_str_append(&sql2, 0, "%s%d", first ? "" : ",", integer);
 					}
@@ -626,7 +619,6 @@
 							continue;
 						}
 
-						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(4);
 						ast_str_append(&sql2, 0, "%s%d", first ? "" : ",", integer);
 					}
@@ -643,7 +635,6 @@
 						if (integer != 0)
 							integer = 1;
 
-						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(2);
 						ast_str_append(&sql2, 0, "%s%d", first ? "" : ",", integer);
 					}
@@ -676,7 +667,6 @@
 							continue;
 						}
 
-						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(entry->decimals);
 						ast_str_append(&sql2, 0, "%s%*.*lf", first ? "" : ",", entry->decimals, entry->radix, number);
 					}
@@ -710,7 +700,6 @@
 							continue;
 						}
 
-						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(entry->decimals);
 						ast_str_append(&sql2, 0, "%s%lf", first ? "" : ",", number);
 					}
@@ -719,6 +708,7 @@
 					ast_log(LOG_WARNING, "Column type %d (field '%s:%s:%s') is unsupported at this time.\n", entry->type, tableptr->connection, tableptr->table, entry->name);
 					continue;
 				}
+				ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 				first = 0;
 			} else if (entry->filtervalue
 				&& ((!entry->negatefiltervalue && entry->filtervalue[0] != '\0')

-- 
To view, visit https://gerrit.asterisk.org/163
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib8bb53c42535378581d4ef729cc5ebbb22b067ac
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Rodrigo Ramirez Norambuena <decipher.hk at gmail.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-commits mailing list