Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 80d6dc9

Browse files
Remove conflicting sqlite tables that are "reserved" (shadow fts4 tables) (#9003)
Remove conflicting sqlite tables that throw sqlite3.OperationalError: object name reserved for internal use: event_search_content when running the twisted unit tests. Fix #8996
1 parent fb0e14e commit 80d6dc9

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

changelog.d/9003.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix 'object name reserved for internal use' errors with recent versions of SQLite.

scripts-dev/make_full_schema.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,23 @@ else
162162
fi
163163

164164
# Delete schema_version, applied_schema_deltas and applied_module_schemas tables
165+
# Also delete any shadow tables from fts4
165166
# This needs to be done after synapse_port_db is run
166167
echo "Dropping unwanted db tables..."
167168
SQL="
168169
DROP TABLE schema_version;
169170
DROP TABLE applied_schema_deltas;
170171
DROP TABLE applied_module_schemas;
172+
DROP TABLE event_search_content;
173+
DROP TABLE event_search_segments;
174+
DROP TABLE event_search_segdir;
175+
DROP TABLE event_search_docsize;
176+
DROP TABLE event_search_stat;
177+
DROP TABLE user_directory_search_content;
178+
DROP TABLE user_directory_search_segments;
179+
DROP TABLE user_directory_search_segdir;
180+
DROP TABLE user_directory_search_docsize;
181+
DROP TABLE user_directory_search_stat;
171182
"
172183
sqlite3 "$SQLITE_DB" <<< "$SQL"
173184
psql $POSTGRES_DB_NAME -U "$POSTGRES_USERNAME" -w <<< "$SQL"

synapse/storage/databases/main/schema/full_schemas/54/full.sql.sqlite

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ CREATE TABLE IF NOT EXISTS "user_threepids" ( user_id TEXT NOT NULL, medium TEXT
6767
CREATE INDEX user_threepids_user_id ON user_threepids(user_id);
6868
CREATE VIRTUAL TABLE event_search USING fts4 ( event_id, room_id, sender, key, value )
6969
/* event_search(event_id,room_id,sender,"key",value) */;
70-
CREATE TABLE IF NOT EXISTS 'event_search_content'(docid INTEGER PRIMARY KEY, 'c0event_id', 'c1room_id', 'c2sender', 'c3key', 'c4value');
71-
CREATE TABLE IF NOT EXISTS 'event_search_segments'(blockid INTEGER PRIMARY KEY, block BLOB);
72-
CREATE TABLE IF NOT EXISTS 'event_search_segdir'(level INTEGER,idx INTEGER,start_block INTEGER,leaves_end_block INTEGER,end_block INTEGER,root BLOB,PRIMARY KEY(level, idx));
73-
CREATE TABLE IF NOT EXISTS 'event_search_docsize'(docid INTEGER PRIMARY KEY, size BLOB);
74-
CREATE TABLE IF NOT EXISTS 'event_search_stat'(id INTEGER PRIMARY KEY, value BLOB);
7570
CREATE TABLE guest_access( event_id TEXT NOT NULL, room_id TEXT NOT NULL, guest_access TEXT NOT NULL, UNIQUE (event_id) );
7671
CREATE TABLE history_visibility( event_id TEXT NOT NULL, room_id TEXT NOT NULL, history_visibility TEXT NOT NULL, UNIQUE (event_id) );
7772
CREATE TABLE room_tags( user_id TEXT NOT NULL, room_id TEXT NOT NULL, tag TEXT NOT NULL, content TEXT NOT NULL, CONSTRAINT room_tag_uniqueness UNIQUE (user_id, room_id, tag) );
@@ -149,11 +144,6 @@ CREATE INDEX device_lists_outbound_last_success_idx ON device_lists_outbound_las
149144
CREATE TABLE user_directory_stream_pos ( Lock CHAR(1) NOT NULL DEFAULT 'X' UNIQUE, stream_id BIGINT, CHECK (Lock='X') );
150145
CREATE VIRTUAL TABLE user_directory_search USING fts4 ( user_id, value )
151146
/* user_directory_search(user_id,value) */;
152-
CREATE TABLE IF NOT EXISTS 'user_directory_search_content'(docid INTEGER PRIMARY KEY, 'c0user_id', 'c1value');
153-
CREATE TABLE IF NOT EXISTS 'user_directory_search_segments'(blockid INTEGER PRIMARY KEY, block BLOB);
154-
CREATE TABLE IF NOT EXISTS 'user_directory_search_segdir'(level INTEGER,idx INTEGER,start_block INTEGER,leaves_end_block INTEGER,end_block INTEGER,root BLOB,PRIMARY KEY(level, idx));
155-
CREATE TABLE IF NOT EXISTS 'user_directory_search_docsize'(docid INTEGER PRIMARY KEY, size BLOB);
156-
CREATE TABLE IF NOT EXISTS 'user_directory_search_stat'(id INTEGER PRIMARY KEY, value BLOB);
157147
CREATE TABLE blocked_rooms ( room_id TEXT NOT NULL, user_id TEXT NOT NULL );
158148
CREATE UNIQUE INDEX blocked_rooms_idx ON blocked_rooms(room_id);
159149
CREATE TABLE IF NOT EXISTS "local_media_repository_url_cache"( url TEXT, response_code INTEGER, etag TEXT, expires_ts BIGINT, og TEXT, media_id TEXT, download_ts BIGINT );

0 commit comments

Comments
 (0)