Backout unneeded changes.

clokep/psycopg3
Patrick Cloke 2023-11-09 14:21:33 -05:00
parent 396fa974a1
commit 626f468155
5 changed files with 4 additions and 36 deletions

View File

@ -58,18 +58,6 @@ class BaseDatabaseEngine(Generic[ConnectionType, CursorType], metaclass=abc.ABCM
"""Do we support the `RETURNING` clause in insert/update/delete?""" """Do we support the `RETURNING` clause in insert/update/delete?"""
... ...
@property
@abc.abstractmethod
def supports_select_distinct_on(self) -> bool:
"""Do we support the `DISTINCT ON` clause in SELECT?"""
...
@property
@abc.abstractmethod
def supports_sequences(self) -> bool:
"""Do we support the `CREATE SEQUENCE` clause?"""
...
@abc.abstractmethod @abc.abstractmethod
def check_database( def check_database(
self, db_conn: ConnectionType, allow_outdated_version: bool = False self, db_conn: ConnectionType, allow_outdated_version: bool = False

View File

@ -189,16 +189,6 @@ class PostgresEngine(
"""Do we support the `RETURNING` clause in insert/update/delete?""" """Do we support the `RETURNING` clause in insert/update/delete?"""
return True return True
@property
def supports_select_distinct_on(self) -> bool:
"""Do we support the `DISTINCT ON` clause in SELECT?"""
return True
@property
def supports_sequences(self) -> bool:
"""Do we support the `CREATE SEQUENCE` clause?"""
return True
def is_connection_closed(self, conn: ConnectionType) -> bool: def is_connection_closed(self, conn: ConnectionType) -> bool:
return bool(conn.closed) return bool(conn.closed)

View File

@ -65,16 +65,6 @@ class Sqlite3Engine(BaseDatabaseEngine[sqlite3.Connection, sqlite3.Cursor]):
"""Do we support the `RETURNING` clause in insert/update/delete?""" """Do we support the `RETURNING` clause in insert/update/delete?"""
return sqlite3.sqlite_version_info >= (3, 35, 0) return sqlite3.sqlite_version_info >= (3, 35, 0)
@property
def supports_select_distinct_on(self) -> bool:
"""Do we support the `DISTINCT ON` clause in SELECT?"""
return False
@property
def supports_sequences(self) -> bool:
"""Do we support the `CREATE SEQUENCE` clause?"""
return False
def check_database( def check_database(
self, db_conn: sqlite3.Connection, allow_outdated_version: bool = False self, db_conn: sqlite3.Connection, allow_outdated_version: bool = False
) -> None: ) -> None:

View File

@ -2,7 +2,7 @@ import logging
from io import StringIO from io import StringIO
from synapse.storage.database import LoggingTransaction from synapse.storage.database import LoggingTransaction
from synapse.storage.engines import BaseDatabaseEngine from synapse.storage.engines import BaseDatabaseEngine, PostgresEngine
from synapse.storage.prepare_database import execute_statements_from_stream from synapse.storage.prepare_database import execute_statements_from_stream
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -18,7 +18,7 @@ This migration updates the user_filters table as follows:
def run_create(cur: LoggingTransaction, database_engine: BaseDatabaseEngine) -> None: def run_create(cur: LoggingTransaction, database_engine: BaseDatabaseEngine) -> None:
if database_engine.supports_select_distinct_on: if isinstance(database_engine, PostgresEngine):
select_clause = """ select_clause = """
SELECT DISTINCT ON (user_id, filter_id) user_id, filter_id, filter_json SELECT DISTINCT ON (user_id, filter_id) user_id, filter_id, filter_json
FROM user_filters FROM user_filters

View File

@ -18,11 +18,11 @@ Adds a postgres SEQUENCE for generating application service transaction IDs.
""" """
from synapse.storage.database import LoggingTransaction from synapse.storage.database import LoggingTransaction
from synapse.storage.engines import BaseDatabaseEngine, PsycopgEngine from synapse.storage.engines import BaseDatabaseEngine, PostgresEngine, PsycopgEngine
def run_create(cur: LoggingTransaction, database_engine: BaseDatabaseEngine) -> None: def run_create(cur: LoggingTransaction, database_engine: BaseDatabaseEngine) -> None:
if database_engine.supports_sequences: if isinstance(database_engine, PostgresEngine):
# If we already have some AS TXNs we want to start from the current # If we already have some AS TXNs we want to start from the current
# maximum value. There are two potential places this is stored - the # maximum value. There are two potential places this is stored - the
# actual TXNs themselves *and* the AS state table. At time of migration # actual TXNs themselves *and* the AS state table. At time of migration