mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 04:09:49 +00:00
Create internal db debugger
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
// TODO(indutny): format queries
|
||||
import type { RowType } from '@signalapp/sqlcipher';
|
||||
import SQL, { setLogger as setSqliteLogger } from '@signalapp/sqlcipher';
|
||||
import { randomBytes } from 'crypto';
|
||||
import { mkdirSync, rmSync } from 'node:fs';
|
||||
@@ -477,6 +478,8 @@ export const DataReader: ServerReadableInterface = {
|
||||
finishPageMessages,
|
||||
getKnownDownloads,
|
||||
getKnownConversationAttachments,
|
||||
|
||||
__dangerouslyRunAbitraryReadOnlySqlQuery,
|
||||
};
|
||||
|
||||
export const DataWriter: ServerWritableInterface = {
|
||||
@@ -8717,3 +8720,17 @@ function ensureMessageInsertTriggersAreEnabled(db: WritableDB): void {
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
function __dangerouslyRunAbitraryReadOnlySqlQuery(
|
||||
db: ReadableDB,
|
||||
readOnlySqlQuery: string
|
||||
): ReadonlyArray<RowType<object>> {
|
||||
let results: ReadonlyArray<RowType<object>>;
|
||||
try {
|
||||
db.pragma('query_only = on');
|
||||
results = db.prepare(readOnlySqlQuery).all();
|
||||
} finally {
|
||||
db.pragma('query_only = off');
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user