summaryrefslogtreecommitdiff
path: root/res/res_odbc.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2015-02-09 02:35:31 +0000
committerMatthew Jordan <mjordan@digium.com>2015-02-09 02:35:31 +0000
commit17247daae6c5054c0880f1858d1f0de46cef85d1 (patch)
tree8d7b3038b69cfaf9fca37c69d381114ed6faf53c /res/res_odbc.c
parent2ebe811d80a2ea494260134315efd37fa4ff6cbb (diff)
res/res_odbc: Remove unneeded queries when determining if a table exists
This patch modifies the ast_odbc_find_table function such that it only performs a lookup of the requested table if the table is not already known. Prior to this patch, a queries would be executed against the database even if the table was already known and cached. Review: https://reviewboard.asterisk.org/r/4405/ ASTERISK-24742 #close Reported by: ibercom patches: patch.diff uploaded by ibercom (License 6599) ........ Merged revisions 431617 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 431618 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431619 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_odbc.c')
-rw-r--r--res/res_odbc.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/res/res_odbc.c b/res/res_odbc.c
index d029c88c0..259467ace 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -461,7 +461,7 @@ struct odbc_cache_tables *ast_odbc_find_table(const char *database, const char *
SQLLEN sqlptr;
SQLHSTMT stmt = NULL;
int res = 0, error = 0, try = 0;
- struct odbc_obj *obj = ast_odbc_request_obj(database, 0);
+ struct odbc_obj *obj;
AST_RWLIST_RDLOCK(&odbc_tables);
AST_RWLIST_TRAVERSE(&odbc_tables, tableptr, list) {
@@ -472,13 +472,10 @@ struct odbc_cache_tables *ast_odbc_find_table(const char *database, const char *
if (tableptr) {
AST_RWLIST_RDLOCK(&tableptr->columns);
AST_RWLIST_UNLOCK(&odbc_tables);
- if (obj) {
- ast_odbc_release_obj(obj);
- }
return tableptr;
}
- if (!obj) {
+ if (!(obj = ast_odbc_request_obj(database, 0))) {
ast_log(LOG_WARNING, "Unable to retrieve database handle for table description '%s@%s'\n", tablename, database);
AST_RWLIST_UNLOCK(&odbc_tables);
return NULL;
@@ -564,9 +561,7 @@ struct odbc_cache_tables *ast_odbc_find_table(const char *database, const char *
destroy_table_cache(tableptr);
tableptr = NULL;
}
- if (obj) {
- ast_odbc_release_obj(obj);
- }
+ ast_odbc_release_obj(obj);
return tableptr;
}