diff options
author | Robert Szefner <r.szefner@hydro-partner.pl> | 2017-11-09 22:57:51 +0100 |
---|---|---|
committer | Robert Szefner <robertsz27@interia.pl> | 2018-01-06 08:24:32 +0000 |
commit | f99d2b21b8fc867f0ed21dcbfa47865ad013db97 (patch) | |
tree | 3bc1c7016e03d260744674a47c3fda423580dc21 /src/sql/kernel/qsqlresult.cpp | |
parent | 3ed91da4997cf793742e5bba2adb3dbec9ecd458 (diff) |
QPSQL: Add support for forward-only queries
With this change, it is possible to significantly reduce memory
consumption of applications that fetch large result sets from databases.
The implementation is based on the new functionality called "single-row
mode" that was introduced in PostgreSQL version 9.2:
https://www.postgresql.org/docs/9.2/static/libpq-async.html
It also uses asynchronous commands PQsendQuery(), PQgetResult():
https://www.postgresql.org/docs/9.2/static/libpq-single-row-mode.html
[ChangeLog][QtSql][QPSQL] Added support for forward-only queries (requires
libpq version 9.2 or later)
[Important Behavior Changes] The QPSQL driver now supports forward-only
queries. To use this feature, you must build QPSQL plugin with PostreSQL
client library version 9.2 or later. See the Qt SQL documentation for
more information about QPSQL limitations of forward-only queries
(sql-driver.html).
[Important Behavior Changes] If you build the QPSQL plugin with PostgreSQL
version 9.2 or later, then you must distribute your application with
libpq version 9.2 or later. Otherwise, the QPSQL plugin will fail to load.
Task-number: QTBUG-63714
Change-Id: I15db8c8fd664f2a1f719329f5d113511fa69010c
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/sql/kernel/qsqlresult.cpp')
-rw-r--r-- | src/sql/kernel/qsqlresult.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index f79c1c71cd..cdb1379502 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -565,6 +565,14 @@ bool QSqlResult::isForwardOnly() const \note Calling setForwardOnly after execution of the query will result in unexpected results at best, and crashes at worst. + \note To make sure the forward-only query completed successfully, + the application should check lastError() for an error not only after + executing the query, but also after navigating the query results. + + \warning PostgreSQL: While navigating the query results in forward-only + mode, do not execute any other SQL command on the same database + connection. This will cause the query results to be lost. + \sa isForwardOnly(), fetchNext(), QSqlQuery::setForwardOnly() */ void QSqlResult::setForwardOnly(bool forward) @@ -1002,6 +1010,10 @@ bool QSqlResult::nextResult() \warning The handle can be NULL if the result was not executed yet. + \warning PostgreSQL: in forward-only mode, the handle of QSqlResult can change + after calling fetch(), fetchFirst(), fetchLast(), fetchNext(), fetchPrevious(), + nextResult(). + The handle returned here is database-dependent, you should query the type name of the variant before accessing it. |