From ce8909be6dfcdf6594f8687c7b165617fb9c2926 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Fri, 8 Sep 2023 13:46:15 +0100 Subject: [PATCH 1/2] Log values at DEBUG level with execute_values Occasionally useful for debugging --- synapse/storage/database.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/synapse/storage/database.py b/synapse/storage/database.py index 55ac313f33b0..6c5fcdcec37d 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -422,10 +422,11 @@ def execute_values( return self._do_execute( # TODO: is it safe for values to be Iterable[Iterable[Any]] here? # https://www.psycopg.org/docs/extras.html?highlight=execute_batch#psycopg2.extras.execute_values says values should be Sequence[Sequence] - lambda the_sql: execute_values( - self.txn, the_sql, values, template=template, fetch=fetch + lambda the_sql, the_values: execute_values( + self.txn, the_sql, the_values, template=template, fetch=fetch ), sql, + values, ) def execute(self, sql: str, parameters: SQLQueryParameters = ()) -> None: From 2d49693f3fdb8363c4e1050db33f3badc34ab7f7 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Fri, 8 Sep 2023 13:50:48 +0100 Subject: [PATCH 2/2] Changelog --- changelog.d/16281.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/16281.misc diff --git a/changelog.d/16281.misc b/changelog.d/16281.misc new file mode 100644 index 000000000000..de48396aff14 --- /dev/null +++ b/changelog.d/16281.misc @@ -0,0 +1 @@ +Include values in SQL debug when using `execute_values` with Postgres.