diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /storage | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-adbda400be353e676059e335c3c0aaf99e719475.tar.xz firefox-adbda400be353e676059e335c3c0aaf99e719475.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'storage')
-rw-r--r-- | storage/mozIStorageAsyncConnection.idl | 6 | ||||
-rw-r--r-- | storage/mozStorageConnection.cpp | 39 | ||||
-rw-r--r-- | storage/mozStorageService.cpp | 2 | ||||
-rw-r--r-- | storage/test/unit/test_connection_executeAsync.js | 20 | ||||
-rw-r--r-- | storage/test/unit/test_connection_interrupt.js | 8 | ||||
-rw-r--r-- | storage/test/unit/test_default_journal_size_limit.js | 2 | ||||
-rw-r--r-- | storage/test/unit/test_statement_executeAsync.js | 6 | ||||
-rw-r--r-- | storage/test/unit/test_storage_connection.js | 4 | ||||
-rw-r--r-- | storage/test/unit/test_storage_progresshandler.js | 2 |
9 files changed, 51 insertions, 38 deletions
diff --git a/storage/mozIStorageAsyncConnection.idl b/storage/mozIStorageAsyncConnection.idl index 3105750773..767f5232d0 100644 --- a/storage/mozIStorageAsyncConnection.idl +++ b/storage/mozIStorageAsyncConnection.idl @@ -70,8 +70,12 @@ interface mozIStorageAsyncConnection : nsISupports { * * If you bind more params than this limit, `create{Async}Statement` will * fail with a "too many SQL variables" error. + * It's possible to lower the limit, but it's not possible to set it higher + * than the default value, passing an higher value will silently truncate to + * the default. Lowering the limit is particularly useful for testing code + * that may bind many variables. */ - readonly attribute int32_t variableLimit; + attribute int32_t variableLimit; /** * Returns true if a transaction is active on this connection. diff --git a/storage/mozStorageConnection.cpp b/storage/mozStorageConnection.cpp index e10458a68b..5dd2c9223e 100644 --- a/storage/mozStorageConnection.cpp +++ b/storage/mozStorageConnection.cpp @@ -1155,19 +1155,20 @@ nsresult Connection::initialize(nsIFileURL* aFileURL) { bool hasKey = false; bool hasDirectoryLockId = false; - MOZ_ALWAYS_TRUE(URLParams::Parse( - query, [&hasKey, &hasDirectoryLockId](const nsAString& aName, - const nsAString& aValue) { - if (aName.EqualsLiteral("key")) { - hasKey = true; - return true; - } - if (aName.EqualsLiteral("directoryLockId")) { - hasDirectoryLockId = true; - return true; - } - return true; - })); + MOZ_ALWAYS_TRUE( + URLParams::Parse(query, true, + [&hasKey, &hasDirectoryLockId](const nsAString& aName, + const nsAString& aValue) { + if (aName.EqualsLiteral("key")) { + hasKey = true; + return true; + } + if (aName.EqualsLiteral("directoryLockId")) { + hasDirectoryLockId = true; + return true; + } + return true; + })); bool exclusive = StaticPrefs::storage_sqlite_exclusiveLock_enabled(); @@ -2469,6 +2470,18 @@ Connection::GetVariableLimit(int32_t* _limit) { } NS_IMETHODIMP +Connection::SetVariableLimit(int32_t limit) { + if (!connectionReady()) { + return NS_ERROR_NOT_INITIALIZED; + } + int oldLimit = ::sqlite3_limit(mDBConn, SQLITE_LIMIT_VARIABLE_NUMBER, limit); + if (oldLimit < 0) { + return NS_ERROR_UNEXPECTED; + } + return NS_OK; +} + +NS_IMETHODIMP Connection::BeginTransaction() { if (!connectionReady()) { return NS_ERROR_NOT_INITIALIZED; diff --git a/storage/mozStorageService.cpp b/storage/mozStorageService.cpp index 78aebb5d8d..82a3a7344d 100644 --- a/storage/mozStorageService.cpp +++ b/storage/mozStorageService.cpp @@ -727,7 +727,7 @@ Service::Observe(nsISupports*, const char* aTopic, const char16_t*) { if (!connections[i]->isClosed()) { // getFilename is only the leaf name for the database file, // so it shouldn't contain privacy-sensitive information. - CrashReporter::AnnotateCrashReport( + CrashReporter::RecordAnnotationNSCString( CrashReporter::Annotation::StorageConnectionNotClosed, connections[i]->getFilename()); printf_stderr("Storage connection not closed: %s", diff --git a/storage/test/unit/test_connection_executeAsync.js b/storage/test/unit/test_connection_executeAsync.js index a77299ba3b..49071bbfed 100644 --- a/storage/test/unit/test_connection_executeAsync.js +++ b/storage/test/unit/test_connection_executeAsync.js @@ -49,13 +49,9 @@ add_task(async function test_first_create_and_add() { stmts[1].bindBlobByIndex(3, BLOB, BLOB.length); // asynchronously execute the statements - let execResult = await executeMultipleStatementsAsync( - db, - stmts, - function (aResultSet) { - ok(false, "we only did inserts so we should not have gotten results!"); - } - ); + let execResult = await executeMultipleStatementsAsync(db, stmts, function () { + ok(false, "we only did inserts so we should not have gotten results!"); + }); equal( Ci.mozIStorageStatementCallback.REASON_FINISHED, execResult, @@ -142,13 +138,9 @@ add_task(async function test_last_multiple_bindings_on_statements() { } // Execute asynchronously. - let execResult = await executeMultipleStatementsAsync( - db, - stmts, - function (aResultSet) { - ok(false, "we only did inserts so we should not have gotten results!"); - } - ); + let execResult = await executeMultipleStatementsAsync(db, stmts, function () { + ok(false, "we only did inserts so we should not have gotten results!"); + }); equal( Ci.mozIStorageStatementCallback.REASON_FINISHED, execResult, diff --git a/storage/test/unit/test_connection_interrupt.js b/storage/test/unit/test_connection_interrupt.js index e257e9af82..9849330a0d 100644 --- a/storage/test/unit/test_connection_interrupt.js +++ b/storage/test/unit/test_connection_interrupt.js @@ -41,10 +41,10 @@ add_task( let completePromise = new Promise((resolve, reject) => { let listener = { - handleResult(aResultSet) { + handleResult() { reject(); }, - handleError(aError) { + handleError() { reject(); }, handleCompletion(aReason) { @@ -92,10 +92,10 @@ add_task( let completePromise = new Promise((resolve, reject) => { let listener = { - handleResult(aResultSet) { + handleResult() { reject(); }, - handleError(aError) { + handleError() { reject(); }, handleCompletion(aReason) { diff --git a/storage/test/unit/test_default_journal_size_limit.js b/storage/test/unit/test_default_journal_size_limit.js index f2d28b9aa4..fa03d9654c 100644 --- a/storage/test/unit/test_default_journal_size_limit.js +++ b/storage/test/unit/test_default_journal_size_limit.js @@ -10,7 +10,7 @@ async function check_journal_size(db) { handleResult(resultSet) { resolve(resultSet.getNextRow().getResultByIndex(0)); }, - handleError(error) { + handleError() { reject(); }, handleCompletion() {}, diff --git a/storage/test/unit/test_statement_executeAsync.js b/storage/test/unit/test_statement_executeAsync.js index dab15121a5..ba1a652200 100644 --- a/storage/test/unit/test_statement_executeAsync.js +++ b/storage/test/unit/test_statement_executeAsync.js @@ -463,13 +463,13 @@ function test_partial_listener_works() { var stmt = makeTestStatement("DELETE FROM test WHERE id = ?"); stmt.bindByIndex(0, 0); stmt.executeAsync({ - handleResult(aResultSet) {}, + handleResult() {}, }); stmt.executeAsync({ - handleError(aError) {}, + handleError() {}, }); stmt.executeAsync({ - handleCompletion(aReason) {}, + handleCompletion() {}, }); stmt.finalize(); diff --git a/storage/test/unit/test_storage_connection.js b/storage/test/unit/test_storage_connection.js index e7175a9613..4636e3edbb 100644 --- a/storage/test/unit/test_storage_connection.js +++ b/storage/test/unit/test_storage_connection.js @@ -980,6 +980,10 @@ add_task(async function test_variableLimit() { info("Open connection"); let db = Services.storage.openDatabase(getTestDB()); Assert.equal(db.variableLimit, 32766, "Should return default limit"); + db.variableLimit = 999; + Assert.equal(db.variableLimit, 999, "Should return the set limit"); + db.variableLimit = 33000; + Assert.equal(db.variableLimit, 32766, "Should silently truncate"); await asyncClose(db); }); diff --git a/storage/test/unit/test_storage_progresshandler.js b/storage/test/unit/test_storage_progresshandler.js index e2e01eb2ff..5e2af4a984 100644 --- a/storage/test/unit/test_storage_progresshandler.js +++ b/storage/test/unit/test_storage_progresshandler.js @@ -26,7 +26,7 @@ var testProgressHandler = { calls: 0, abort: false, - onProgress(comm) { + onProgress() { ++this.calls; return this.abort; }, |