[svn-commits] tilghman: trunk r66920 - in /trunk: ./ funcs/func_odbc.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri Jun 1 14:49:35 MST 2007


Author: tilghman
Date: Fri Jun  1 16:49:34 2007
New Revision: 66920

URL: http://svn.digium.com/view/asterisk?view=rev&rev=66920
Log:
Merged revisions 66919 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r66919 | tilghman | 2007-06-01 16:45:44 -0500 (Fri, 01 Jun 2007) | 2 lines

On some drivers, deallocating the statement handle isn't enough.  We also have to clear the cursor (nice, Oracle)

........

Modified:
    trunk/   (props changed)
    trunk/funcs/func_odbc.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/funcs/func_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_odbc.c?view=diff&rev=66920&r1=66919&r2=66920
==============================================================================
--- trunk/funcs/func_odbc.c (original)
+++ trunk/funcs/func_odbc.c Fri Jun  1 16:49:34 2007
@@ -123,6 +123,7 @@
 	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;
 	}
@@ -225,8 +226,10 @@
 	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);
 
@@ -310,6 +313,7 @@
 	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);
 		pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
@@ -327,6 +331,7 @@
 		} else {
 			ast_log(LOG_WARNING, "Error %d in FETCH [%s]\n", res, sql);
 		}
+		SQLCloseCursor(stmt);
 		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 		ast_odbc_release_obj(obj);
 		pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
@@ -373,6 +378,7 @@
 					if (!tmp) {
 						ast_log(LOG_ERROR, "No space for a new resultset?\n");
 						ast_free(resultset);
+						SQLCloseCursor(stmt);
 						SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 						ast_odbc_release_obj(obj);
 						pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
@@ -451,6 +457,7 @@
 		if (!odbc_store) {
 			ast_log(LOG_ERROR, "Rows retrieved, but unable to store it in the channel.  Results fail.\n");
 			odbc_datastore_free(resultset);
+			SQLCloseCursor(stmt);
 			SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 			ast_odbc_release_obj(obj);
 			return -1;
@@ -458,6 +465,7 @@
 		odbc_store->data = resultset;
 		ast_channel_datastore_add(chan, odbc_store);
 	}
+	SQLCloseCursor(stmt);
 	SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 	ast_odbc_release_obj(obj);
 	return 0;



More information about the svn-commits mailing list