Index: funcs/func_strings.c =================================================================== --- funcs/func_strings.c (revision 180672) +++ funcs/func_strings.c (working copy) @@ -174,6 +174,17 @@ char *value2; int i; + if (chan) { + const char *value3; + ast_mutex_lock(&chan->lock); + if ((value3 = pbx_builtin_getvar_helper(chan, "~ODBCVALUES~"))) { + value = ast_strdupa(value3); + /* Don't allow the value to interfere with subsequent settings */ + pbx_builtin_setvar_helper(chan, "~ODBCVALUES~", NULL); + } + ast_mutex_unlock(&chan->lock); + } + value2 = ast_strdupa(value); if (!var || !value2) return -1; Index: funcs/func_odbc.c =================================================================== --- funcs/func_odbc.c (revision 180672) +++ funcs/func_odbc.c (working copy) @@ -227,6 +227,9 @@ SQLSMALLINT colcount=0; SQLLEN indicator; + /* Reset, in case of an error */ + pbx_builtin_setvar_helper(chan, "~ODBCVALUES~", NULL); + AST_LIST_LOCK(&queries); AST_LIST_TRAVERSE(&queries, query, list) { if (!strcmp(query->acf->name, cmd)) { @@ -368,6 +371,10 @@ SQLCloseCursor(stmt); SQLFreeHandle(SQL_HANDLE_STMT, stmt); ast_odbc_release_obj(obj); + + /* Pass an unadulterated string to ARRAY, if needed. This is only needed + * in 1.4, because of the misfeature in Set. */ + pbx_builtin_setvar_helper(chan, "~ODBCVALUES~", buf); if (chan) ast_autoservice_stop(chan); if (bogus_chan)