diff options
author | Erik Johnston <erik@matrix.org> | 2015-07-01 11:41:55 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-07-01 17:19:12 +0100 |
commit | 80a61330ee794147b213b1d54f2292a1c9adc002 (patch) | |
tree | e6832467f89a0829cc8a7c76288234b4facb082c /synapse/storage/util | |
parent | Add tables for receipts (diff) | |
download | synapse-80a61330ee794147b213b1d54f2292a1c9adc002.tar.xz |
Add basic storage functions for handling of receipts
Diffstat (limited to 'synapse/storage/util')
-rw-r--r-- | synapse/storage/util/id_generators.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/synapse/storage/util/id_generators.py b/synapse/storage/util/id_generators.py index 89d1643f10..b39006315d 100644 --- a/synapse/storage/util/id_generators.py +++ b/synapse/storage/util/id_generators.py @@ -72,7 +72,10 @@ class StreamIdGenerator(object): with stream_id_gen.get_next_txn(txn) as stream_id: # ... persist event ... """ - def __init__(self): + def __init__(self, table, column): + self.table = table + self.column = column + self._lock = threading.Lock() self._current_max = None @@ -126,7 +129,7 @@ class StreamIdGenerator(object): def _get_or_compute_current_max(self, txn): with self._lock: - txn.execute("SELECT MAX(stream_ordering) FROM events") + txn.execute("SELECT MAX(%s) FROM %s" % (self.column, self.table)) rows = txn.fetchall() val, = rows[0] |