aboutsummaryrefslogtreecommitdiffstats
path: root/cdr
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-12-30 17:53:29 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-12-30 17:53:29 +0000
commit98911b23db49c317137bdaa74e7847cc28b7c1ee (patch)
treebda27109efdb9a043b0d5fcf3baa9aaa858063e5 /cdr
parent4e9d12bf8b3c221298578f24d316a3d1990b7fee (diff)
When the field is blank, don't warn about the field being unable to be coerced, just skip the column.
(closes http://lists.digium.com/pipermail/asterisk-dev/2009-December/041362.html) Reported by Nic Colledge on the -dev list, fixed by me. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@236847 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cdr')
-rw-r--r--cdr/cdr_adaptive_odbc.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/cdr/cdr_adaptive_odbc.c b/cdr/cdr_adaptive_odbc.c
index 606506db9..e39edd213 100644
--- a/cdr/cdr_adaptive_odbc.c
+++ b/cdr/cdr_adaptive_odbc.c
@@ -315,7 +315,7 @@ static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data)
#define LENGTHEN_BUF1(size) \
do { \
/* Lengthen buffer, if necessary */ \
- if (ast_str_strlen(sql) + size + 1 > ast_str_size(sql)) { \
+ if (ast_str_strlen(sql) + size + 1 > ast_str_size(sql)) { \
if (ast_str_make_space(&sql, ((ast_str_size(sql) + size + 1) / 512 + 1) * 512) != 0) { \
ast_log(LOG_ERROR, "Unable to allocate sufficient memory. Insert CDR '%s:%s' failed.\n", tableptr->connection, tableptr->table); \
ast_free(sql); \
@@ -328,7 +328,7 @@ static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data)
#define LENGTHEN_BUF2(size) \
do { \
- if (ast_str_strlen(sql2) + size + 1 > ast_str_size(sql2)) { \
+ if (ast_str_strlen(sql2) + size + 1 > ast_str_size(sql2)) { \
if (ast_str_make_space(&sql2, ((ast_str_size(sql2) + size + 3) / 512 + 1) * 512) != 0) { \
ast_log(LOG_ERROR, "Unable to allocate sufficient memory. Insert CDR '%s:%s' failed.\n", tableptr->connection, tableptr->table); \
ast_free(sql); \
@@ -458,7 +458,9 @@ static int odbc_log(struct ast_cdr *cdr)
ast_str_append(&sql2, 0, "'");
break;
case SQL_TYPE_DATE:
- {
+ if (ast_strlen_zero(colptr)) {
+ continue;
+ } else {
int year = 0, month = 0, day = 0;
if (sscanf(colptr, "%4d-%2d-%2d", &year, &month, &day) != 3 || year <= 0 ||
month <= 0 || month > 12 || day < 0 || day > 31 ||
@@ -481,7 +483,9 @@ static int odbc_log(struct ast_cdr *cdr)
}
break;
case SQL_TYPE_TIME:
- {
+ if (ast_strlen_zero(colptr)) {
+ continue;
+ } else {
int hour = 0, minute = 0, second = 0;
int count = sscanf(colptr, "%2d:%2d:%2d", &hour, &minute, &second);
@@ -497,7 +501,9 @@ static int odbc_log(struct ast_cdr *cdr)
break;
case SQL_TYPE_TIMESTAMP:
case SQL_TIMESTAMP:
- {
+ if (ast_strlen_zero(colptr)) {
+ continue;
+ } else {
int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
int count = sscanf(colptr, "%4d-%2d-%2d %2d:%2d:%2d", &year, &month, &day, &hour, &minute, &second);
@@ -523,7 +529,9 @@ static int odbc_log(struct ast_cdr *cdr)
}
break;
case SQL_INTEGER:
- {
+ if (ast_strlen_zero(colptr)) {
+ continue;
+ } else {
int integer = 0;
if (sscanf(colptr, "%30d", &integer) != 1) {
ast_log(LOG_WARNING, "CDR variable %s is not an integer.\n", entry->name);
@@ -536,7 +544,9 @@ static int odbc_log(struct ast_cdr *cdr)
}
break;
case SQL_BIGINT:
- {
+ if (ast_strlen_zero(colptr)) {
+ continue;
+ } else {
long long integer = 0;
if (sscanf(colptr, "%30lld", &integer) != 1) {
ast_log(LOG_WARNING, "CDR variable %s is not an integer.\n", entry->name);
@@ -549,7 +559,9 @@ static int odbc_log(struct ast_cdr *cdr)
}
break;
case SQL_SMALLINT:
- {
+ if (ast_strlen_zero(colptr)) {
+ continue;
+ } else {
short integer = 0;
if (sscanf(colptr, "%30hd", &integer) != 1) {
ast_log(LOG_WARNING, "CDR variable %s is not an integer.\n", entry->name);
@@ -562,7 +574,9 @@ static int odbc_log(struct ast_cdr *cdr)
}
break;
case SQL_TINYINT:
- {
+ if (ast_strlen_zero(colptr)) {
+ continue;
+ } else {
char integer = 0;
if (sscanf(colptr, "%30hhd", &integer) != 1) {
ast_log(LOG_WARNING, "CDR variable %s is not an integer.\n", entry->name);
@@ -575,7 +589,9 @@ static int odbc_log(struct ast_cdr *cdr)
}
break;
case SQL_BIT:
- {
+ if (ast_strlen_zero(colptr)) {
+ continue;
+ } else {
char integer = 0;
if (sscanf(colptr, "%30hhd", &integer) != 1) {
ast_log(LOG_WARNING, "CDR variable %s is not an integer.\n", entry->name);
@@ -591,7 +607,9 @@ static int odbc_log(struct ast_cdr *cdr)
break;
case SQL_NUMERIC:
case SQL_DECIMAL:
- {
+ if (ast_strlen_zero(colptr)) {
+ continue;
+ } else {
double number = 0.0;
if (sscanf(colptr, "%30lf", &number) != 1) {
ast_log(LOG_WARNING, "CDR variable %s is not an numeric type.\n", entry->name);
@@ -606,7 +624,9 @@ static int odbc_log(struct ast_cdr *cdr)
case SQL_FLOAT:
case SQL_REAL:
case SQL_DOUBLE:
- {
+ if (ast_strlen_zero(colptr)) {
+ continue;
+ } else {
double number = 0.0;
if (sscanf(colptr, "%30lf", &number) != 1) {
ast_log(LOG_WARNING, "CDR variable %s is not an numeric type.\n", entry->name);