Bug 1168606 - Removed implicit conversion operator of CachedStatement. r=ttung,asuth

Depends on D44377

Differential Revision: https://phabricator.services.mozilla.com/D44443

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Simon Giesecke 2019-11-05 12:47:28 +00:00
Родитель babd04fe5d
Коммит 1b5b703a49
1 изменённых файлов: 53 добавлений и 56 удалений

Просмотреть файл

@ -4855,9 +4855,7 @@ class DatabaseConnection::CachedStatement final {
#endif
}
// TODO: Remove the implicit operator, and replace it by explicit calls to
// GetUnderlyingStatement.
operator mozIStorageStatement*() const;
explicit operator bool() const;
mozIStorageStatement& operator*() const;
@ -10087,7 +10085,7 @@ nsresult DatabaseConnection::GetFreelistCount(CachedStatement& aCachedStatement,
// Make sure this statement is reset when leaving this function since we're
// not using the normal stack-based protection of CachedStatement.
mozStorageStatementScoper scoper(aCachedStatement);
mozStorageStatementScoper scoper(&*aCachedStatement);
int32_t freelistCount;
rv = aCachedStatement->GetInt32(0, &freelistCount);
@ -10228,11 +10226,9 @@ DatabaseConnection::CachedStatement::~CachedStatement() {
MOZ_COUNT_DTOR(DatabaseConnection::CachedStatement);
}
DatabaseConnection::CachedStatement::operator mozIStorageStatement*() const {
DatabaseConnection::CachedStatement::operator bool() const {
AssertIsOnConnectionThread();
// Note: this might also return nullptr, which is exploited at some call
// sites.
return mStatement;
}
@ -10772,7 +10768,7 @@ nsresult DatabaseConnection::UpdateRefcountFunction::DatabaseUpdateFunction::
}
}
mozStorageStatementScoper updateScoper(mUpdateStatement);
mozStorageStatementScoper updateScoper(&*mUpdateStatement);
rv = mUpdateStatement->BindInt32ByIndex(0, aDelta);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -10808,7 +10804,7 @@ nsresult DatabaseConnection::UpdateRefcountFunction::DatabaseUpdateFunction::
}
}
mozStorageStatementScoper selectScoper(mSelectStatement);
mozStorageStatementScoper selectScoper(&*mSelectStatement);
rv = mSelectStatement->BindInt64ByIndex(0, aId);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -10842,7 +10838,7 @@ nsresult DatabaseConnection::UpdateRefcountFunction::DatabaseUpdateFunction::
}
}
mozStorageStatementScoper insertScoper(mInsertStatement);
mozStorageStatementScoper insertScoper(&*mInsertStatement);
rv = mInsertStatement->BindInt64ByIndex(0, aId);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -18802,12 +18798,12 @@ nsresult DatabaseOperationBase::InsertIndexTableRows(
return rv;
}
rv = info.mPosition.BindToStatement(stmt, kStmtParamNameValue);
rv = info.mPosition.BindToStatement(&*stmt, kStmtParamNameValue);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = info.mLocaleAwarePosition.BindToStatement(stmt,
rv = info.mLocaleAwarePosition.BindToStatement(&*stmt,
kStmtParamNameValueLocale);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -18818,7 +18814,7 @@ nsresult DatabaseOperationBase::InsertIndexTableRows(
return rv;
}
rv = aObjectStoreKey.BindToStatement(stmt, kStmtParamNameObjectDataKey);
rv = aObjectStoreKey.BindToStatement(&*stmt, kStmtParamNameObjectDataKey);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -18905,13 +18901,13 @@ nsresult DatabaseOperationBase::DeleteIndexDataTableRows(
return rv;
}
rv = indexValue.mPosition.BindToStatement(stmt, kStmtParamNameValue);
rv = indexValue.mPosition.BindToStatement(&*stmt, kStmtParamNameValue);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (!indexValue.mUnique) {
rv = aObjectStoreKey.BindToStatement(stmt, kStmtParamNameObjectDataKey);
rv = aObjectStoreKey.BindToStatement(&*stmt, kStmtParamNameObjectDataKey);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -18967,7 +18963,7 @@ nsresult DatabaseOperationBase::DeleteObjectStoreDataTableRowsWithIndexes(
objectStoreKey = aKeyRange.ref().lower();
rv = objectStoreKey.BindToStatement(selectStmt, kStmtParamNameKey);
rv = objectStoreKey.BindToStatement(&*selectStmt, kStmtParamNameKey);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -18988,7 +18984,7 @@ nsresult DatabaseOperationBase::DeleteObjectStoreDataTableRowsWithIndexes(
}
if (aKeyRange.isSome()) {
rv = BindKeyRangeToStatement(aKeyRange.ref(), selectStmt);
rv = BindKeyRangeToStatement(aKeyRange.ref(), &*selectStmt);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -19008,7 +19004,7 @@ nsresult DatabaseOperationBase::DeleteObjectStoreDataTableRowsWithIndexes(
bool hasResult;
while (NS_SUCCEEDED(rv = selectStmt->ExecuteStep(&hasResult)) && hasResult) {
if (!singleRowOnly) {
rv = objectStoreKey.SetFromStatement(selectStmt, 1);
rv = objectStoreKey.SetFromStatement(&*selectStmt, 1);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -19016,7 +19012,7 @@ nsresult DatabaseOperationBase::DeleteObjectStoreDataTableRowsWithIndexes(
indexValues.ClearAndRetainStorage();
}
rv = ReadCompressedIndexDataValues(selectStmt, 0, indexValues);
rv = ReadCompressedIndexDataValues(&*selectStmt, 0, indexValues);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -19046,7 +19042,7 @@ nsresult DatabaseOperationBase::DeleteObjectStoreDataTableRowsWithIndexes(
return rv;
}
rv = objectStoreKey.BindToStatement(deleteStmt, kStmtParamNameKey);
rv = objectStoreKey.BindToStatement(&*deleteStmt, kStmtParamNameKey);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -23529,7 +23525,7 @@ nsresult DeleteIndexOp::RemoveReferencesToIndex(
return rv;
}
rv = aObjectStoreKey.BindToStatement(stmt, kStmtParamNameKey);
rv = aObjectStoreKey.BindToStatement(&*stmt, kStmtParamNameKey);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -23744,7 +23740,7 @@ nsresult DeleteIndexOp::DoDatabaseWork(DatabaseConnection* aConnection) {
while (NS_SUCCEEDED(rv = selectStmt->ExecuteStep(&hasResult)) && hasResult) {
// We always need the index key to delete the index row.
Key indexKey;
rv = indexKey.SetFromStatement(selectStmt, 0);
rv = indexKey.SetFromStatement(&*selectStmt, 0);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -23790,7 +23786,7 @@ nsresult DeleteIndexOp::DoDatabaseWork(DatabaseConnection* aConnection) {
// And the |index_data_values| row if this isn't the only index.
if (!mIsLastIndex) {
lastIndexValues.ClearAndRetainStorage();
rv = ReadCompressedIndexDataValues(selectStmt, 2, lastIndexValues);
rv = ReadCompressedIndexDataValues(&*selectStmt, 2, lastIndexValues);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -23833,13 +23829,13 @@ nsresult DeleteIndexOp::DoDatabaseWork(DatabaseConnection* aConnection) {
return rv;
}
rv = indexKey.BindToStatement(deleteIndexRowStmt, kStmtParamNameValue);
rv = indexKey.BindToStatement(&*deleteIndexRowStmt, kStmtParamNameValue);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (!mUnique) {
rv = lastObjectStoreKey.BindToStatement(deleteIndexRowStmt,
rv = lastObjectStoreKey.BindToStatement(&*deleteIndexRowStmt,
kStmtParamNameObjectDataKey);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -24213,7 +24209,7 @@ nsresult ObjectStoreAddOrPutRequestOp::RemoveOldIndexDataValues(
return rv;
}
rv = mResponse.BindToStatement(indexValuesStmt, kStmtParamNameKey);
rv = mResponse.BindToStatement(&*indexValuesStmt, kStmtParamNameKey);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -24226,7 +24222,8 @@ nsresult ObjectStoreAddOrPutRequestOp::RemoveOldIndexDataValues(
if (hasResult) {
AutoTArray<IndexDataValue, 32> existingIndexValues;
rv = ReadCompressedIndexDataValues(indexValuesStmt, 0, existingIndexValues);
rv = ReadCompressedIndexDataValues(&*indexValuesStmt, 0,
existingIndexValues);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -24472,7 +24469,7 @@ nsresult ObjectStoreAddOrPutRequestOp::DoDatabaseWork(
}
}
key.BindToStatement(stmt, kStmtParamNameKey);
key.BindToStatement(&*stmt, kStmtParamNameKey);
if (mDataOverThreshold) {
// The data we store in the SQLite database is a (signed) 64-bit integer.
@ -24845,7 +24842,7 @@ nsresult ObjectStoreGetRequestOp::DoDatabaseWork(
}
if (mOptionalKeyRange.isSome()) {
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), stmt);
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), &*stmt);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -24859,7 +24856,7 @@ nsresult ObjectStoreGetRequestOp::DoDatabaseWork(
}
rv = GetStructuredCloneReadInfoFromStatement(
stmt, 1, 0, mDatabase->GetFileManager(), cloneInfo);
&*stmt, 1, 0, mDatabase->GetFileManager(), cloneInfo);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -25031,7 +25028,7 @@ nsresult ObjectStoreGetKeyRequestOp::DoDatabaseWork(
}
if (mOptionalKeyRange.isSome()) {
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), stmt);
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), &*stmt);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -25044,7 +25041,7 @@ nsresult ObjectStoreGetKeyRequestOp::DoDatabaseWork(
return NS_ERROR_OUT_OF_MEMORY;
}
rv = key->SetFromStatement(stmt, 0);
rv = key->SetFromStatement(&*stmt, 0);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -25267,7 +25264,7 @@ nsresult ObjectStoreCountRequestOp::DoDatabaseWork(
}
if (mParams.optionalKeyRange().isSome()) {
rv = BindKeyRangeToStatement(mParams.optionalKeyRange().ref(), stmt);
rv = BindKeyRangeToStatement(mParams.optionalKeyRange().ref(), &*stmt);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -25432,7 +25429,7 @@ nsresult IndexGetRequestOp::DoDatabaseWork(DatabaseConnection* aConnection) {
}
if (hasKeyRange) {
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), stmt);
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), &*stmt);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -25446,7 +25443,7 @@ nsresult IndexGetRequestOp::DoDatabaseWork(DatabaseConnection* aConnection) {
}
rv = GetStructuredCloneReadInfoFromStatement(
stmt, 1, 0, mDatabase->GetFileManager(), cloneInfo);
&*stmt, 1, 0, mDatabase->GetFileManager(), cloneInfo);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -25601,7 +25598,7 @@ nsresult IndexGetKeyRequestOp::DoDatabaseWork(DatabaseConnection* aConnection) {
}
if (hasKeyRange) {
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), stmt);
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), &*stmt);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -25614,7 +25611,7 @@ nsresult IndexGetKeyRequestOp::DoDatabaseWork(DatabaseConnection* aConnection) {
return NS_ERROR_OUT_OF_MEMORY;
}
rv = key->SetFromStatement(stmt, 0);
rv = key->SetFromStatement(&*stmt, 0);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -25691,7 +25688,7 @@ nsresult IndexCountRequestOp::DoDatabaseWork(DatabaseConnection* aConnection) {
}
if (hasKeyRange) {
rv = BindKeyRangeToStatement(mParams.optionalKeyRange().ref(), stmt);
rv = BindKeyRangeToStatement(mParams.optionalKeyRange().ref(), &*stmt);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -26163,7 +26160,7 @@ nsresult Cursor::OpenOp::DoObjectStoreDatabaseWork(
}
if (usingKeyRange) {
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), stmt);
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), &*stmt);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -26180,7 +26177,7 @@ nsresult Cursor::OpenOp::DoObjectStoreDatabaseWork(
return NS_OK;
}
rv = PopulateResponseFromStatement(stmt, true);
rv = PopulateResponseFromStatement(&*stmt, true);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -26198,7 +26195,7 @@ nsresult Cursor::OpenOp::DoObjectStoreDatabaseWork(
// TODO: If this is done here, do this in the other Do*DatabaseWork functions
// as well (or move this to DoDatabaseWork).
return PopulateExtraResponses(stmt, mCursor->mMaxExtraCount,
return PopulateExtraResponses(&*stmt, mCursor->mMaxExtraCount,
NS_LITERAL_CSTRING("OpenOp"));
}
@ -26243,7 +26240,7 @@ nsresult Cursor::OpenOp::DoObjectStoreKeyDatabaseWork(
}
if (usingKeyRange) {
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), stmt);
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), &*stmt);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -26260,7 +26257,7 @@ nsresult Cursor::OpenOp::DoObjectStoreKeyDatabaseWork(
return NS_OK;
}
rv = PopulateResponseFromStatement(stmt, true);
rv = PopulateResponseFromStatement(&*stmt, true);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -26358,10 +26355,10 @@ nsresult Cursor::OpenOp::DoIndexDatabaseWork(DatabaseConnection* aConnection) {
if (usingKeyRange) {
if (mCursor->IsLocaleAware()) {
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), stmt,
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), &*stmt,
mCursor->mLocale);
} else {
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), stmt);
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), &*stmt);
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -26379,7 +26376,7 @@ nsresult Cursor::OpenOp::DoIndexDatabaseWork(DatabaseConnection* aConnection) {
return NS_OK;
}
rv = PopulateResponseFromStatement(stmt, true);
rv = PopulateResponseFromStatement(&*stmt, true);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -26393,7 +26390,7 @@ nsresult Cursor::OpenOp::DoIndexDatabaseWork(DatabaseConnection* aConnection) {
// on the parameters of subsequent ContinueOp operations, see also comment in
// ContinueOp::DoDatabaseWork.
return PopulateExtraResponses(stmt, mCursor->mMaxExtraCount,
return PopulateExtraResponses(&*stmt, mCursor->mMaxExtraCount,
NS_LITERAL_CSTRING("OpenOp"));
}
@ -26473,10 +26470,10 @@ nsresult Cursor::OpenOp::DoIndexKeyDatabaseWork(
if (usingKeyRange) {
if (mCursor->IsLocaleAware()) {
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), stmt,
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), &*stmt,
mCursor->mLocale);
} else {
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), stmt);
rv = BindKeyRangeToStatement(mOptionalKeyRange.ref(), &*stmt);
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -26494,7 +26491,7 @@ nsresult Cursor::OpenOp::DoIndexKeyDatabaseWork(
return NS_OK;
}
rv = PopulateResponseFromStatement(stmt, true);
rv = PopulateResponseFromStatement(&*stmt, true);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -26702,7 +26699,7 @@ nsresult Cursor::ContinueOp::DoDatabaseWork(DatabaseConnection* aConnection) {
}
// Bind current key.
rv = currentKey.BindToStatement(stmt, kStmtParamNameCurrentKey);
rv = currentKey.BindToStatement(&*stmt, kStmtParamNameCurrentKey);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -26710,7 +26707,7 @@ nsresult Cursor::ContinueOp::DoDatabaseWork(DatabaseConnection* aConnection) {
// Bind range bound if it is specified.
if (!mCursor->mLocaleAwareRangeBound.IsUnset()) {
rv = mCursor->mLocaleAwareRangeBound.BindToStatement(
stmt, kStmtParamNameRangeBound);
&*stmt, kStmtParamNameRangeBound);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -26722,13 +26719,13 @@ nsresult Cursor::ContinueOp::DoDatabaseWork(DatabaseConnection* aConnection) {
(mCursor->mDirection == IDBCursor::NEXT ||
mCursor->mDirection == IDBCursor::PREV)) {
rv = mCursor->mObjectStorePosition.BindToStatement(
stmt, kStmtParamNameObjectStorePosition);
&*stmt, kStmtParamNameObjectStorePosition);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
} else if (hasContinuePrimaryKey) {
rv = mParams.get_ContinuePrimaryKeyParams().primaryKey().BindToStatement(
stmt, kStmtParamNameObjectStorePosition);
&*stmt, kStmtParamNameObjectStorePosition);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -26753,12 +26750,12 @@ nsresult Cursor::ContinueOp::DoDatabaseWork(DatabaseConnection* aConnection) {
}
}
rv = PopulateResponseFromStatement(stmt, true);
rv = PopulateResponseFromStatement(&*stmt, true);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
return PopulateExtraResponses(stmt, maxExtraCount,
return PopulateExtraResponses(&*stmt, maxExtraCount,
NS_LITERAL_CSTRING("ContinueOp"));
}