while (running < 5000) {
int result = switch_core_db_step(stmt);
+ const unsigned char *txt;
if (result == SWITCH_CORE_DB_ROW) {
- if ((colcount = switch_core_db_column_count(stmt))) {
- switch_copy_string(resbuf, (char *) switch_core_db_column_text(stmt, 0), len);
- ret = resbuf;
+ if ((colcount = switch_core_db_column_count(stmt)) > 0) {
+ if ((txt = switch_core_db_column_text(stmt, 0))) {
+ switch_copy_string(resbuf, (char *) txt, len);
+ ret = resbuf;
+ } else {
+ goto fail;
+ }
}
break;
} else if (result == SWITCH_CORE_DB_BUSY) {
SWITCH_DECLARE(const unsigned char *) switch_core_db_column_text(switch_core_db_stmt_t *stmt, int iCol)
{
- return sqlite3_column_text(stmt, iCol);
+ const unsigned char *txt = sqlite3_column_text(stmt, iCol);
+
+ if (txt && !strcasecmp((char *)txt, "(null)")) {
+ txt = NULL;
+ }
+
+ return txt;
+
}
SWITCH_DECLARE(const char *) switch_core_db_column_name(switch_core_db_stmt_t *stmt, int N)