Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.5.2
-
None
-
Qt 4.5.2 open-source, Windows XP SP3, Visual Studio 2005, Oracle 10g
-
1d6be599f5c12e9ce23bbdf081a103aa62618e15 12b032ca7c79955f03f744bdb8f7b0d60e222e40
Description
The symptoms is that for some queries with setForwardOnly(true), QSqlQuery::value() returns the accumulation of all values that have been iterated over, instead of just the current value.
When it happens, it looks like the values parameter to QOCICols::readPiecewise() isn't cleared between rows, and contains data from previous rows, to which the function appends the data from the new row.
To reproduce, the following piece code can be used on any Oracle database :
QSqlDatabase db = QSqlDatabase::addDatabase("QOCI");
db.setDatabaseName("...");
db.setUserName("...");
db.setPassword("...");
db.open();
db.exec("drop table TEST_TABLE");
db.exec("create table TEST_TABLE(COL1 char(10), COL2 char(10), COL3 char(10))");
db.exec("create index INDEX1 on TEST_TABLE (COL1 desc)");
db.exec("create index INDEX2 on TEST_TABLE (COL2 desc)");
db.exec("create index INDEX3 on TEST_TABLE (COL3 desc)");
QSqlQuery q(db);
q.setForwardOnly(true);
q.exec("select COLUMN_EXPRESSION from ALL_IND_EXPRESSIONS where TABLE_NAME='TEST_TABLE'");
while (q.next())
qDebug(q.value(0).toString().toLatin1());
The expected debug output is :
"COL1"
"COL2"
"COL3"
What I get instead is :
"COL1"
"COL1""COL2"
"COL1""COL2""COL3"
If the setForwardOnly(true) line is commented out, the expected output is produced.