Index: res/res_odbc.c =================================================================== --- res/res_odbc.c (revision 220289) +++ res/res_odbc.c (working copy) @@ -48,6 +48,7 @@ #include "asterisk/res_odbc.h" #include "asterisk/time.h" #include "asterisk/astobj2.h" +#include "asterisk/app.h" struct odbc_class { @@ -135,6 +136,12 @@ SQLHSTMT stmt = NULL; int res = 0, error = 0, try = 0; struct odbc_obj *obj = ast_odbc_request_obj(database, 0); + char *ptr; + AST_DECLARE_APP_ARGS(tbl, + AST_APP_ARG(catalog); + AST_APP_ARG(schema); + AST_APP_ARG(table); + ); AST_RWLIST_RDLOCK(&odbc_tables); AST_RWLIST_TRAVERSE(&odbc_tables, tableptr, list) { @@ -156,6 +163,25 @@ return NULL; } + if (strchr(tablename, '.')) { + if (!(ptr = ast_strdupa(tablename))) { + AST_RWLIST_UNLOCK(&odbc_tables); + return NULL; + } + + AST_NONSTANDARD_APP_ARGS(tbl, ptr, '.'); + + if (tbl.argc == 2) { + tbl.table = tbl.schema; + tbl.schema = tbl.catalog; + tbl.catalog = NULL; + } + } else { + tbl.catalog = NULL; + tbl.schema = NULL; + tbl.table = ast_strdupa(tablename); + } + /* Table structure not already cached; build it now. */ do { retry: @@ -170,7 +196,11 @@ break; } - res = SQLColumns(stmt, NULL, 0, NULL, 0, (unsigned char *)tablename, SQL_NTS, (unsigned char *)"%", SQL_NTS); + res = SQLColumns(stmt, + (unsigned char *) tbl.catalog, tbl.catalog ? SQL_NTS : 0, + (unsigned char *) tbl.schema, tbl.schema ? SQL_NTS : 0, + (unsigned char *) tbl.table, SQL_NTS, + (unsigned char *)"%", SQL_NTS); if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) { if (try == 0) { try = 1;