提交 c5281059 authored 作者: Michael Jerris's avatar Michael Jerris

fix Misuse of SQLRowCount, issues with MSSQL (MODAPP-105)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8914 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 a480e196
......@@ -359,18 +359,17 @@ static JSBool odbc_get_data(JSContext * cx, JSObject * obj, uintN argc, jsval *
}
if (odbc_obj->stmt) {
SQLSMALLINT c = 0, x = 0;
SQLLEN m = 0;
SQLSMALLINT nColumns = 0, x = 0;
eval_some_js("~var _oDbC_dB_RoW_DaTa_ = {}", cx, obj, rval);
if (*rval == JS_FALSE) {
return JS_TRUE;
}
SQLNumResultCols(odbc_obj->stmt, &c);
SQLRowCount(odbc_obj->stmt, &m);
if (m > 0) {
for (x = 1; x <= c; x++) {
if ( SQLNumResultCols( odbc_obj->stmt, &nColumns ) != SQL_SUCCESS )
return JS_FALSE;
for (x = 1; x <= nColumns; x++) {
SQLSMALLINT NameLength, DataType, DecimalDigits, Nullable;
SQLULEN ColumnSize;
SQLCHAR name[1024] = "";
......@@ -397,7 +396,7 @@ static JSBool odbc_get_data(JSContext * cx, JSObject * obj, uintN argc, jsval *
JS_GetProperty(cx, obj, "_oDbC_dB_RoW_DaTa_", rval);
return JS_TRUE;
}
}
......
......@@ -196,6 +196,9 @@ static int db_is_up(switch_odbc_handle_t *handle)
SQLCHAR sql[255] = "";
int max_tries = 120;
SQLRETURN rc;
SQLSMALLINT nresultcols;
top:
if (!handle) {
......@@ -219,10 +222,15 @@ static int db_is_up(switch_odbc_handle_t *handle)
result = SQLExecute(stmt);
SQLRowCount(stmt, &m);
ret = (int) m;
if (result < 0 || m < 0) {
SQLRowCount (stmt, &m);
rc = SQLNumResultCols (stmt, &nresultcols);
if (rc != SQL_SUCCESS){
goto error;
}
ret = (int) nresultcols;
/* determine statement type */
if (nresultcols <= 0) {
/* statement is not a select statement */
goto error;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论