Index: apps/app_addon_sql_mysql.c =================================================================== --- apps/app_addon_sql_mysql.c (revision 915) +++ apps/app_addon_sql_mysql.c (working copy) @@ -38,9 +38,12 @@ #include #include #include +#include #define EXTRA_LOG 0 +int nullasstring = 1; + static char *app = "MYSQL"; static char *synopsis = "Do several mySQLy things"; @@ -85,6 +88,7 @@ AST_MUTEX_DEFINE_STATIC(_mysql_mutex); +#define MYSQL_CONFIG "mysql.conf" #define AST_MYSQL_ID_DUMMY 0 #define AST_MYSQL_ID_CONNID 1 #define AST_MYSQL_ID_RESID 2 @@ -392,7 +396,12 @@ break; } s6 = mysqlrow[j]; - pbx_builtin_setvar_helper(chan, s5, s6 ? s6 : "NULL"); + + if (nullasstring) { + pbx_builtin_setvar_helper(chan, s5, s6 ? s6 : "NULL"); + } else { + pbx_builtin_setvar_helper(chan, s5, s6); + } } ast_debug(5, "ast_MYSQL_fetch: numFields=%d\n", numFields); set_asterisk_int(chan, args.resultvar, 1); // try more rows @@ -496,6 +505,24 @@ static int load_module(void) { struct MYSQLidshead *headp = &_mysql_ids_head; + struct ast_flags config_flags = { 0 }; + struct ast_config *cfg = ast_config_load(MYSQL_CONFIG, config_flags); + const char *temp; + + if (!cfg) { + ast_log(LOG_NOTICE, "MySQL config file %s not found. MySQL will return NULL as 'NULL' string.\n", MYSQL_CONFIG); + } else { + + temp = ast_variable_retrieve(cfg, "general", "nullasstring"); + + if (ast_true(temp)) { + ast_log(LOG_NOTICE, "MySQL will return NULL as 'NULL' string.\n"); + } else { + ast_log(LOG_NOTICE, "MySQL will return NULL as NULL.\n"); + nullasstring = 0; + } + } + AST_LIST_HEAD_INIT(headp); return ast_register_application(app, MYSQL_exec, synopsis, descrip); }