Sqlite导致锁死的问题

在如下系列中:

1、QSqlQuery q("select count(*) from sometable where name=:name");
   ...
2、QSqlDatabase::database().transaction();
   ....

在1和2之间如果不清除q,是会锁死的,答案在这里:

bool QSqlDatabase::commit ()

Commits a transaction to the database if the driver supports transactions and a transaction() has been started. Returns true if the operation succeeded. Otherwise it returns false.

Note: For some databases, the commit will fail and return false if there is an active query using the database for a SELECT. Make the query inactive before doing the commit.

Call lastError() to get information about errors.

See also QSqlQuery::isActive(), QSqlDriver::hasFeature(), and rollback().

你可能感兴趣的:(Sqlite导致锁死的问题)