mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-18 09:32:34 +00:00
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
This commit is contained in:
parent
a480e1968d
commit
c5281059b7
@ -359,46 +359,45 @@ static JSBool odbc_get_data(JSContext * cx, JSObject * obj, uintN argc, jsval *
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (odbc_obj->stmt) {
|
if (odbc_obj->stmt) {
|
||||||
SQLSMALLINT c = 0, x = 0;
|
SQLSMALLINT nColumns = 0, x = 0;
|
||||||
SQLLEN m = 0;
|
|
||||||
|
|
||||||
eval_some_js("~var _oDbC_dB_RoW_DaTa_ = {}", cx, obj, rval);
|
eval_some_js("~var _oDbC_dB_RoW_DaTa_ = {}", cx, obj, rval);
|
||||||
if (*rval == JS_FALSE) {
|
if (*rval == JS_FALSE) {
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQLNumResultCols(odbc_obj->stmt, &c);
|
if ( SQLNumResultCols( odbc_obj->stmt, &nColumns ) != SQL_SUCCESS )
|
||||||
SQLRowCount(odbc_obj->stmt, &m);
|
return JS_FALSE;
|
||||||
if (m > 0) {
|
|
||||||
for (x = 1; x <= c; x++) {
|
|
||||||
SQLSMALLINT NameLength, DataType, DecimalDigits, Nullable;
|
|
||||||
SQLULEN ColumnSize;
|
|
||||||
SQLCHAR name[1024] = "";
|
|
||||||
SQLCHAR *data = odbc_obj->colbuf;
|
|
||||||
SQLCHAR *esc = NULL;
|
|
||||||
|
|
||||||
SQLDescribeCol(odbc_obj->stmt, x, name, sizeof(name), &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable);
|
for (x = 1; x <= nColumns; x++) {
|
||||||
SQLGetData(odbc_obj->stmt, x, SQL_C_CHAR, odbc_obj->colbuf, odbc_obj->cblen, NULL);
|
SQLSMALLINT NameLength, DataType, DecimalDigits, Nullable;
|
||||||
|
SQLULEN ColumnSize;
|
||||||
|
SQLCHAR name[1024] = "";
|
||||||
|
SQLCHAR *data = odbc_obj->colbuf;
|
||||||
|
SQLCHAR *esc = NULL;
|
||||||
|
|
||||||
if (strchr((char *) odbc_obj->colbuf, '"')) { /* please don't */
|
SQLDescribeCol(odbc_obj->stmt, x, name, sizeof(name), &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable);
|
||||||
esc = (SQLCHAR *) escape_data((char *) odbc_obj->colbuf, '\\');
|
SQLGetData(odbc_obj->stmt, x, SQL_C_CHAR, odbc_obj->colbuf, odbc_obj->cblen, NULL);
|
||||||
data = esc;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_snprintf((char *) odbc_obj->code, odbc_obj->codelen, "~_oDbC_dB_RoW_DaTa_[\"%s\"] = \"%s\"", name, data);
|
if (strchr((char *) odbc_obj->colbuf, '"')) { /* please don't */
|
||||||
switch_safe_free(esc);
|
esc = (SQLCHAR *) escape_data((char *) odbc_obj->colbuf, '\\');
|
||||||
|
data = esc;
|
||||||
eval_some_js((char *) odbc_obj->code, cx, obj, rval);
|
|
||||||
|
|
||||||
if (*rval == JS_FALSE) {
|
|
||||||
return JS_TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_GetProperty(cx, obj, "_oDbC_dB_RoW_DaTa_", rval);
|
switch_snprintf((char *) odbc_obj->code, odbc_obj->codelen, "~_oDbC_dB_RoW_DaTa_[\"%s\"] = \"%s\"", name, data);
|
||||||
return JS_TRUE;
|
switch_safe_free(esc);
|
||||||
|
|
||||||
|
eval_some_js((char *) odbc_obj->code, cx, obj, rval);
|
||||||
|
|
||||||
|
if (*rval == JS_FALSE) {
|
||||||
|
return JS_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JS_GetProperty(cx, obj, "_oDbC_dB_RoW_DaTa_", rval);
|
||||||
|
return JS_TRUE;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -196,6 +196,9 @@ static int db_is_up(switch_odbc_handle_t *handle)
|
|||||||
SQLCHAR sql[255] = "";
|
SQLCHAR sql[255] = "";
|
||||||
int max_tries = 120;
|
int max_tries = 120;
|
||||||
|
|
||||||
|
SQLRETURN rc;
|
||||||
|
SQLSMALLINT nresultcols;
|
||||||
|
|
||||||
top:
|
top:
|
||||||
|
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
@ -219,10 +222,15 @@ static int db_is_up(switch_odbc_handle_t *handle)
|
|||||||
|
|
||||||
result = SQLExecute(stmt);
|
result = SQLExecute(stmt);
|
||||||
|
|
||||||
SQLRowCount(stmt, &m);
|
SQLRowCount (stmt, &m);
|
||||||
ret = (int) m;
|
rc = SQLNumResultCols (stmt, &nresultcols);
|
||||||
|
if (rc != SQL_SUCCESS){
|
||||||
if (result < 0 || m < 0) {
|
goto error;
|
||||||
|
}
|
||||||
|
ret = (int) nresultcols;
|
||||||
|
/* determine statement type */
|
||||||
|
if (nresultcols <= 0) {
|
||||||
|
/* statement is not a select statement */
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user