aboutsummaryrefslogtreecommitdiff
path: root/roomserver/storage/sqlite3/event_json_table.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2021-04-26 13:25:57 +0100
committerGitHub <noreply@github.com>2021-04-26 13:25:57 +0100
commit5ce1fe80dea8b8cfca8712e8d584deb995bbddcc (patch)
tree1307a1edf73abf68cebd4601efec1e467dac964c /roomserver/storage/sqlite3/event_json_table.go
parentd6e9b7b307ff0d7541046ec33890d49239c7a6ca (diff)
State storage refactor (#1839)
* Hash-deduplicated state storage (and migrations) for PostgreSQL and SQLite * Refactor droomserver database setup for migrations * Fix conflict statements * Update migration names * Set a boundary for old to new block/snapshot IDs so we don't rewrite them more than once accidentally * Create sequence if not exists * Fix boundary queries * Fix boundary queries * Use Query * Break out queries a bit * More sequence tweaks * Query parameters are not playing the game * Injection escaping may not work for CREATE SEQUENCE after all * Fix snapshot sequence name * Use boundaried IDs in SQLite too * Use IFNULL for SQLite * Use COALESCE in PostgreSQL * Review comments @Kegsay
Diffstat (limited to 'roomserver/storage/sqlite3/event_json_table.go')
-rw-r--r--roomserver/storage/sqlite3/event_json_table.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/roomserver/storage/sqlite3/event_json_table.go b/roomserver/storage/sqlite3/event_json_table.go
index 3cd44b1d..29d54b83 100644
--- a/roomserver/storage/sqlite3/event_json_table.go
+++ b/roomserver/storage/sqlite3/event_json_table.go
@@ -53,14 +53,16 @@ type eventJSONStatements struct {
bulkSelectEventJSONStmt *sql.Stmt
}
-func NewSqliteEventJSONTable(db *sql.DB) (tables.EventJSON, error) {
+func createEventJSONTable(db *sql.DB) error {
+ _, err := db.Exec(eventJSONSchema)
+ return err
+}
+
+func prepareEventJSONTable(db *sql.DB) (tables.EventJSON, error) {
s := &eventJSONStatements{
db: db,
}
- _, err := db.Exec(eventJSONSchema)
- if err != nil {
- return nil, err
- }
+
return s, shared.StatementList{
{&s.insertEventJSONStmt, insertEventJSONSQL},
{&s.bulkSelectEventJSONStmt, bulkSelectEventJSONSQL},