mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-28 13:11:56 +00:00
Go back to storing JSON in TEXT
This commit is contained in:
parent
bc9e69e160
commit
b8092fbc82
@ -818,9 +818,6 @@ class SQLBaseStore(object):
|
|||||||
|
|
||||||
internal_metadata, js, redacted, rejected_reason = res
|
internal_metadata, js, redacted, rejected_reason = res
|
||||||
|
|
||||||
internal_metadata = self.database_engine.load_unicode(internal_metadata)
|
|
||||||
js = self.database_engine.load_unicode(js)
|
|
||||||
|
|
||||||
start_time = update_counter("select_event", start_time)
|
start_time = update_counter("select_event", start_time)
|
||||||
|
|
||||||
result = self._get_event_from_row_txn(
|
result = self._get_event_from_row_txn(
|
||||||
|
@ -366,9 +366,7 @@ class ApplicationServiceTransactionStore(SQLBaseStore):
|
|||||||
new_txn_id = max(highest_txn_id, last_txn_id) + 1
|
new_txn_id = max(highest_txn_id, last_txn_id) + 1
|
||||||
|
|
||||||
# Insert new txn into txn table
|
# Insert new txn into txn table
|
||||||
event_ids = buffer(
|
event_ids = json.dumps([e.event_id for e in events])
|
||||||
json.dumps([e.event_id for e in events]).encode("utf8")
|
|
||||||
)
|
|
||||||
txn.execute(
|
txn.execute(
|
||||||
"INSERT INTO application_services_txns(as_id, txn_id, event_ids) "
|
"INSERT INTO application_services_txns(as_id, txn_id, event_ids) "
|
||||||
"VALUES(?,?,?)",
|
"VALUES(?,?,?)",
|
||||||
|
@ -39,6 +39,3 @@ class PostgresEngine(object):
|
|||||||
if isinstance(error, self.module.DatabaseError):
|
if isinstance(error, self.module.DatabaseError):
|
||||||
return error.pgcode in ["40001", "40P01"]
|
return error.pgcode in ["40001", "40P01"]
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def load_unicode(self, v):
|
|
||||||
return bytes(v).decode("UTF8")
|
|
||||||
|
@ -37,8 +37,3 @@ class Sqlite3Engine(object):
|
|||||||
|
|
||||||
def is_deadlock(self, error):
|
def is_deadlock(self, error):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def load_unicode(self, v):
|
|
||||||
if isinstance(v, types.UnicodeType):
|
|
||||||
return v
|
|
||||||
return bytes(v).decode("UTF8")
|
|
||||||
|
@ -168,7 +168,7 @@ class EventsStore(SQLBaseStore):
|
|||||||
|
|
||||||
metadata_json = encode_canonical_json(
|
metadata_json = encode_canonical_json(
|
||||||
event.internal_metadata.get_dict()
|
event.internal_metadata.get_dict()
|
||||||
)
|
).decode("UTF-8")
|
||||||
|
|
||||||
# If we have already persisted this event, we don't need to do any
|
# If we have already persisted this event, we don't need to do any
|
||||||
# more processing.
|
# more processing.
|
||||||
@ -184,7 +184,7 @@ class EventsStore(SQLBaseStore):
|
|||||||
)
|
)
|
||||||
txn.execute(
|
txn.execute(
|
||||||
sql,
|
sql,
|
||||||
(buffer(metadata_json), event.event_id,)
|
(metadata_json, event.event_id,)
|
||||||
)
|
)
|
||||||
|
|
||||||
sql = (
|
sql = (
|
||||||
@ -229,14 +229,14 @@ class EventsStore(SQLBaseStore):
|
|||||||
values={
|
values={
|
||||||
"event_id": event.event_id,
|
"event_id": event.event_id,
|
||||||
"room_id": event.room_id,
|
"room_id": event.room_id,
|
||||||
"internal_metadata": buffer(metadata_json),
|
"internal_metadata": metadata_json,
|
||||||
"json": buffer(encode_canonical_json(event_dict)),
|
"json": encode_canonical_json(event_dict).decode("UTF-8"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
content = buffer(encode_canonical_json(
|
content = encode_canonical_json(
|
||||||
event.content
|
event.content
|
||||||
))
|
).decode("UTF-8")
|
||||||
|
|
||||||
vals = {
|
vals = {
|
||||||
"topological_ordering": event.depth,
|
"topological_ordering": event.depth,
|
||||||
@ -261,9 +261,9 @@ class EventsStore(SQLBaseStore):
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
vals["unrecognized_keys"] = buffer(encode_canonical_json(
|
vals["unrecognized_keys"] = encode_canonical_json(
|
||||||
unrec
|
unrec
|
||||||
))
|
).decode("UTF-8")
|
||||||
|
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT INTO events"
|
"INSERT INTO events"
|
||||||
|
@ -35,16 +35,13 @@ class ProfileStore(SQLBaseStore):
|
|||||||
desc="get_profile_displayname",
|
desc="get_profile_displayname",
|
||||||
)
|
)
|
||||||
|
|
||||||
if name:
|
|
||||||
name = self.database_engine.load_unicode(name)
|
|
||||||
|
|
||||||
defer.returnValue(name)
|
defer.returnValue(name)
|
||||||
|
|
||||||
def set_profile_displayname(self, user_localpart, new_displayname):
|
def set_profile_displayname(self, user_localpart, new_displayname):
|
||||||
return self._simple_update_one(
|
return self._simple_update_one(
|
||||||
table="profiles",
|
table="profiles",
|
||||||
keyvalues={"user_id": user_localpart},
|
keyvalues={"user_id": user_localpart},
|
||||||
updatevalues={"displayname": new_displayname.encode("utf8")},
|
updatevalues={"displayname": new_displayname},
|
||||||
desc="set_profile_displayname",
|
desc="set_profile_displayname",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -98,11 +98,6 @@ class RegistrationStore(SQLBaseStore):
|
|||||||
allow_none=True,
|
allow_none=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
if user_info:
|
|
||||||
user_info["password_hash"] = self.database_engine.load_unicode(
|
|
||||||
user_info["password_hash"]
|
|
||||||
)
|
|
||||||
|
|
||||||
defer.returnValue(user_info)
|
defer.returnValue(user_info)
|
||||||
|
|
||||||
@cached()
|
@cached()
|
||||||
|
@ -22,7 +22,7 @@ CREATE TABLE IF NOT EXISTS application_services_state(
|
|||||||
CREATE TABLE IF NOT EXISTS application_services_txns(
|
CREATE TABLE IF NOT EXISTS application_services_txns(
|
||||||
as_id VARCHAR(150) NOT NULL,
|
as_id VARCHAR(150) NOT NULL,
|
||||||
txn_id INTEGER NOT NULL,
|
txn_id INTEGER NOT NULL,
|
||||||
event_ids LONGBLOB NOT NULL,
|
event_ids TEXT NOT NULL,
|
||||||
UNIQUE(as_id, txn_id)
|
UNIQUE(as_id, txn_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ CREATE TABLE IF NOT EXISTS events(
|
|||||||
event_id VARCHAR(150) NOT NULL,
|
event_id VARCHAR(150) NOT NULL,
|
||||||
type VARCHAR(150) NOT NULL,
|
type VARCHAR(150) NOT NULL,
|
||||||
room_id VARCHAR(150) NOT NULL,
|
room_id VARCHAR(150) NOT NULL,
|
||||||
content bytea NOT NULL,
|
content TEXT NOT NULL,
|
||||||
unrecognized_keys bytea,
|
unrecognized_keys TEXT,
|
||||||
processed BOOL NOT NULL,
|
processed BOOL NOT NULL,
|
||||||
outlier BOOL NOT NULL,
|
outlier BOOL NOT NULL,
|
||||||
depth BIGINT DEFAULT 0 NOT NULL,
|
depth BIGINT DEFAULT 0 NOT NULL,
|
||||||
@ -35,8 +35,8 @@ CREATE INDEX events_room_id ON events (room_id);
|
|||||||
CREATE TABLE IF NOT EXISTS event_json(
|
CREATE TABLE IF NOT EXISTS event_json(
|
||||||
event_id VARCHAR(150) NOT NULL,
|
event_id VARCHAR(150) NOT NULL,
|
||||||
room_id VARCHAR(150) NOT NULL,
|
room_id VARCHAR(150) NOT NULL,
|
||||||
internal_metadata bytea NOT NULL,
|
internal_metadata TEXT NOT NULL,
|
||||||
json bytea NOT NULL,
|
json TEXT NOT NULL,
|
||||||
UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS application_services_state(
|
|||||||
CREATE TABLE IF NOT EXISTS application_services_txns(
|
CREATE TABLE IF NOT EXISTS application_services_txns(
|
||||||
as_id VARCHAR(150) NOT NULL,
|
as_id VARCHAR(150) NOT NULL,
|
||||||
txn_id INTEGER NOT NULL,
|
txn_id INTEGER NOT NULL,
|
||||||
event_ids bytea NOT NULL,
|
event_ids TEXT NOT NULL,
|
||||||
UNIQUE(as_id, txn_id)
|
UNIQUE(as_id, txn_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ CREATE TABLE IF NOT EXISTS events(
|
|||||||
event_id VARCHAR(150) NOT NULL,
|
event_id VARCHAR(150) NOT NULL,
|
||||||
type VARCHAR(150) NOT NULL,
|
type VARCHAR(150) NOT NULL,
|
||||||
room_id VARCHAR(150) NOT NULL,
|
room_id VARCHAR(150) NOT NULL,
|
||||||
content bytea NOT NULL,
|
content TEXT NOT NULL,
|
||||||
unrecognized_keys bytea,
|
unrecognized_keys TEXT,
|
||||||
processed BOOL NOT NULL,
|
processed BOOL NOT NULL,
|
||||||
outlier BOOL NOT NULL,
|
outlier BOOL NOT NULL,
|
||||||
depth BIGINT DEFAULT 0 NOT NULL,
|
depth BIGINT DEFAULT 0 NOT NULL,
|
||||||
@ -39,8 +39,8 @@ CREATE INDEX events_order_room ON events (
|
|||||||
CREATE TABLE IF NOT EXISTS event_json(
|
CREATE TABLE IF NOT EXISTS event_json(
|
||||||
event_id VARCHAR(150) NOT NULL,
|
event_id VARCHAR(150) NOT NULL,
|
||||||
room_id VARCHAR(150) NOT NULL,
|
room_id VARCHAR(150) NOT NULL,
|
||||||
internal_metadata bytea NOT NULL,
|
internal_metadata TEXT NOT NULL,
|
||||||
json bytea NOT NULL,
|
json TEXT NOT NULL,
|
||||||
UNIQUE (event_id)
|
UNIQUE (event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user