bool SQLTransaction::runCurrentStatement() { if (!m_currentStatement) return false; m_database->resetAuthorizer(); if (m_currentStatement->execute(m_database.get())) { if (m_database->lastActionChangedDatabase()) { // Flag this transaction as having changed the database for later delegate notification m_modifiedDatabase = true; // Also dirty the size of this database file for calculating quota usage m_database->transactionClient()->didExecuteStatement(database()); } if (m_currentStatement->hasStatementCallback()) { m_nextStep = &SQLTransaction::deliverStatementCallback; LOG(StorageAPI, "Scheduling deliverStatementCallback for transaction %p\n", this); m_database->scheduleTransactionCallback(this); return false; } return true; } if (m_currentStatement->lastExecutionFailedDueToQuota()) { m_nextStep = &SQLTransaction::deliverQuotaIncreaseCallback; LOG(StorageAPI, "Scheduling deliverQuotaIncreaseCallback for transaction %p\n", this); m_database->scheduleTransactionCallback(this); return false; } handleCurrentStatementError(); return false; }
void SQLTransaction::runStatements() { ASSERT(m_lockAcquired); // If there is a series of statements queued up that are all successful and have no associated // SQLStatementCallback objects, then we can burn through the queue do { if (m_shouldRetryCurrentStatement && !m_sqliteTransaction->wasRolledBackBySqlite()) { m_shouldRetryCurrentStatement = false; // FIXME - Another place that needs fixing up after <rdar://problem/5628468> is addressed. // See ::openTransactionAndPreflight() for discussion // Reset the maximum size here, as it was increased to allow us to retry this statement. // m_shouldRetryCurrentStatement is set to true only when a statement exceeds // the quota, which can happen only in a read-write transaction. Therefore, there // is no need to check here if the transaction is read-write. m_database->sqliteDatabase().setMaximumSize(m_database->maximumSize()); } else { // If the current statement has already been run, failed due to quota constraints, and we're not retrying it, // that means it ended in an error. Handle it now if (m_currentStatement && m_currentStatement->lastExecutionFailedDueToQuota()) { handleCurrentStatementError(); break; } // Otherwise, advance to the next statement getNextStatement(); } } while (runCurrentStatement()); // If runCurrentStatement() returned false, that means either there was no current statement to run, // or the current statement requires a callback to complete. In the later case, it also scheduled // the callback or performed any other additional work so we can return if (!m_currentStatement) postflightAndCommit(); }
bool SQLTransaction::runCurrentStatement() { if (!m_currentStatement) { // No more statements to run. So move on to the next state. return false; } m_database->resetAuthorizer(); if (m_hasVersionMismatch) m_currentStatement->setVersionMismatchedError(); if (m_currentStatement->execute(m_database)) { if (m_database->lastActionChangedDatabase()) { // Flag this transaction as having changed the database for later delegate notification m_modifiedDatabase = true; } if (m_currentStatement->hasStatementCallback()) { scheduleCallback(&SQLTransaction::deliverStatementCallback); return false; } // If we get here, then the statement doesn't have a callback to invoke. // We can move on to the next statement. Hence, stay in this state. return true; } if (m_currentStatement->lastExecutionFailedDueToQuota()) { scheduleCallback(&SQLTransaction::deliverQuotaIncreaseCallback); return false; } handleCurrentStatementError(); return false; }