qsql_odbc: fix SQLGetStmtAtt usage
Failure to initialize the variable can cause spurious non-zero
values.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms715438(v=vs.85).aspx
"..value can either be a SQLULEN value or a null-terminated character
string. If the value is a SQLULEN value, some drivers may only write the
lower 32-bit or 16-bit of a buffer and leave the higher-order
bit unchanged. Therefore, applications should use a buffer of SQLULEN
and initialize the value to 0 before calling this function. Also, the
BufferLength and StringLengthPtr arguments are not used."
Follow-up to 1509316a37
Change-Id: I2e92eb845a2590bea0849c52bde8902adff1b419
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
bb10
parent
4341ae32f4
commit
af35ee291a
|
|
@ -958,9 +958,8 @@ bool QODBCResult::reset (const QString& query)
|
|||
return false;
|
||||
}
|
||||
|
||||
SQLINTEGER bufferLength;
|
||||
SQLULEN isScrollable;
|
||||
r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength);
|
||||
SQLULEN isScrollable = 0;
|
||||
r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, 0);
|
||||
if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
|
||||
QSqlResult::setForwardOnly(isScrollable==SQL_NONSCROLLABLE);
|
||||
|
||||
|
|
@ -1106,7 +1105,7 @@ bool QODBCResult::fetchLast()
|
|||
"Unable to fetch last"), QSqlError::ConnectionError, d));
|
||||
return false;
|
||||
}
|
||||
SQLINTEGER currRow;
|
||||
SQLULEN currRow = 0;
|
||||
r = SQLGetStmtAttr(d->hStmt,
|
||||
SQL_ROW_NUMBER,
|
||||
&currRow,
|
||||
|
|
@ -1592,9 +1591,8 @@ bool QODBCResult::exec()
|
|||
return false;
|
||||
}
|
||||
|
||||
SQLINTEGER bufferLength;
|
||||
SQLULEN isScrollable;
|
||||
r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength);
|
||||
SQLULEN isScrollable = 0;
|
||||
r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, 0);
|
||||
if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
|
||||
QSqlResult::setForwardOnly(isScrollable==SQL_NONSCROLLABLE);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue