diff options
author | Andrew Morgan <andrewm@element.io> | 2022-08-04 16:37:10 +0100 |
---|---|---|
committer | Andrew Morgan <andrewm@element.io> | 2022-08-04 16:37:10 +0100 |
commit | efc492ed99438d21dc1163adcd4bd0c105eb3bf5 (patch) | |
tree | 878ddac16e745ca0e56413ce5b48fbdb62d4bd49 /synapse/storage/database.py | |
parent | update the changelog entries (diff) | |
download | synapse-efc492ed99438d21dc1163adcd4bd0c105eb3bf5.tar.xz |
Do not return the number of deleted rows from simple_truncate
Postgres does not support returning this information for a TRUNCATE command.
Diffstat (limited to 'synapse/storage/database.py')
-rw-r--r-- | synapse/storage/database.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/synapse/storage/database.py b/synapse/storage/database.py index 396d09ac4f..9cce458dfc 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -2204,20 +2204,18 @@ class DatabasePool: return txn.rowcount - async def simple_truncate(self, table: str, desc: str) -> int: + async def simple_truncate(self, table: str, desc: str) -> None: """Executes a TRUNCATE query on the given table, deleting all rows. SQLite does not support TRUNCATE, thus a 'DELETE FROM table_name' will - be used instead. + be used instead. This method does not return the number of rows deleted, + as this is not returned by postgres for TRUNCATE commands. Args: table: The name of the table to delete all rows from. desc: description of the transaction, for logging and metrics. - - Returns: - The number of deleted rows. """ - return await self.runInteraction( + await self.runInteraction( desc, self._simple_truncate_txn, table, db_autocommit=True ) @@ -2225,18 +2223,16 @@ class DatabasePool: def _simple_truncate_txn( txn: LoggingTransaction, table: str, - ) -> int: + ) -> None: """Executes a TRUNCATE query on the given table, deleting all rows. SQLite does not support TRUNCATE, thus a 'DELETE FROM table_name' will - be used instead. + be used instead. This method does not return the number of rows deleted, + as this is not returned by postgres for TRUNCATE commands. Args: txn: Transaction object table: The name of the table to delete all rows from. - - Returns: - The number of deleted rows. """ if isinstance(txn.database_engine, PostgresEngine): sql = "TRUNCATE %s" % table @@ -2245,7 +2241,6 @@ class DatabasePool: sql = "DELETE FROM %s" % table txn.execute(sql) - return txn.rowcount def get_cache_dict( self, |