aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-01 21:45:44 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-01 21:45:44 +0000
commit61ac2127ea16944d61a119a90fad8b0d3f80a621 (patch)
treebc8e790ade9eecc380a6bb36b631ea455afaee4f /funcs
parenteaee56a7365f54f30810636e1789f2bd4965d97f (diff)
On some drivers, deallocating the statement handle isn't enough. We also have to clear the cursor (nice, Oracle)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@66919 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_odbc.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index 78d3384b5..bf6ad0ec8 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -82,6 +82,7 @@ static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data)
res = SQLPrepare(stmt, (unsigned char *)sql, SQL_NTS);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
ast_log(LOG_WARNING, "SQL Prepare failed![%s]\n", sql);
+ SQLCloseCursor(stmt);
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
return NULL;
}
@@ -184,8 +185,10 @@ static int acf_odbc_write(struct ast_channel *chan, char *cmd, char *s, const ch
snprintf(varname, sizeof(varname), "%d", (int)rows);
pbx_builtin_setvar_helper(chan, "ODBCROWS", varname);
- if (stmt)
+ if (stmt) {
+ SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+ }
if (obj)
ast_odbc_release_obj(obj);
@@ -255,6 +258,7 @@ static int acf_odbc_read(struct ast_channel *chan, char *cmd, char *s, char *buf
res = SQLNumResultCols(stmt, &colcount);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
ast_log(LOG_WARNING, "SQL Column Count error!\n[%s]\n\n", sql);
+ SQLCloseCursor(stmt);
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
return -1;
@@ -273,6 +277,7 @@ static int acf_odbc_read(struct ast_channel *chan, char *cmd, char *s, char *buf
} else if (option_verbose > 3) {
ast_log(LOG_WARNING, "Error %d in FETCH [%s]\n", res, sql);
}
+ SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
return res1;
@@ -291,6 +296,7 @@ static int acf_odbc_read(struct ast_channel *chan, char *cmd, char *s, char *buf
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
+ SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
return -1;
@@ -316,6 +322,7 @@ static int acf_odbc_read(struct ast_channel *chan, char *cmd, char *s, char *buf
/* Trim trailing comma */
buf[buflen - 1] = '\0';
+ SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
return 0;