Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.12.2
-
None
Description
Look at the following code execution (PostgreSQL 9.3, Windows 10 and Linux):
QSqlDatabase d = QSqlDatabase::addDatabase("QPSQL"); d.setDatabaseName("postgres"); d.open(); QString sql = "CREATE TEMPORARY TABLE test(field integer);" "INSERT INTO test (field) values (1);" "SELECT * FROM test;"; QSqlQuery q(sql); do { qDebug() << "New result. Size:" << q.size() << "Rows affected:" << q.numRowsAffected(); while (q.next()) { qDebug() << q.record().value(0); } } while (q.nextResult());
5.9.7 output:
New result. Size: 1 Rows affected: 1
QVariant(int, 1)
5.12.2 output:
New result. Size: -1 Rows affected: 0
New result. Size: -1 Rows affected: 1
New result. Size: 1 Rows affected: 1
QVariant(int, 1)
This change has broken a significant number of sql queries in my project. What is it, a bug or a new permanent behavior?
P.S. I understand why it happend.
5.9.7 use PQexec (PQexec silently discards any prior query results that the application didn't eat), but 5.12.2 use PQsendQuery and make all results availible (without any method which return number of results!). It is not bad itself, but imagine that developer work under complicated query with a lot of UPDATE, but at the end need to receive final SELECT. In this case any new UPDATE will change needed query execution processing.
Attachments
Issue Links
- is duplicated by
-
QTBUG-74570 QSqlQuery::exec always return true for wrong queries (PostgreSql)
- Closed