Fossil SCM
Use temporary triggers, instead of normal schema triggers, to populate the fts index. Fossil disables schema triggers to prevent malicious uses.
Commit
21d9ea4adeb3a28c48070da091b9aa09fc42aa954be35e1bc8f9b3df86f91a4b
Parent
74479fb5930b844…
1 file changed
+11
-7
+11
-7
| --- src/chat.c | ||
| +++ src/chat.c | ||
| @@ -301,20 +301,24 @@ | ||
| 301 | 301 | if( !db_table_exists("repository", "chatfts1") ){ |
| 302 | 302 | db_multi_exec( |
| 303 | 303 | "CREATE VIRTUAL TABLE repository.chatfts1 USING fts5(" |
| 304 | 304 | " xmsg, content=chat, content_rowid=msgid, tokenize=porter" |
| 305 | 305 | ");" |
| 306 | - "CREATE TRIGGER repository.chat_ai AFTER INSERT ON chat BEGIN " | |
| 307 | - " INSERT INTO chatfts1(rowid, xmsg) VALUES(new.msgid, new.xmsg);" | |
| 308 | - "END;" | |
| 309 | - "CREATE TRIGGER repository.chat_ad AFTER DELETE ON chat BEGIN " | |
| 310 | - " INSERT INTO chatfts1(chatfts1, rowid, xmsg) " | |
| 311 | - " VALUES('delete', old.msgid, old.xmsg);" | |
| 312 | - "END;" | |
| 313 | 306 | "INSERT INTO repository.chatfts1(chatfts1) VALUES('rebuild');" |
| 314 | 307 | ); |
| 315 | 308 | } |
| 309 | + db_multi_exec( | |
| 310 | + "DROP TRIGGER IF EXISTS chat_ai;" | |
| 311 | + "DROP TRIGGER IF EXISTS chat_ad;" | |
| 312 | + "CREATE TEMP TRIGGER chat_ai AFTER INSERT ON chat BEGIN " | |
| 313 | + " INSERT INTO chatfts1(rowid, xmsg) VALUES(new.msgid, new.xmsg);" | |
| 314 | + "END;" | |
| 315 | + "CREATE TEMP TRIGGER chat_ad AFTER DELETE ON chat BEGIN " | |
| 316 | + " INSERT INTO chatfts1(chatfts1, rowid, xmsg) " | |
| 317 | + " VALUES('delete', old.msgid, old.xmsg);" | |
| 318 | + "END;" | |
| 319 | + ); | |
| 316 | 320 | } |
| 317 | 321 | |
| 318 | 322 | /* |
| 319 | 323 | ** Delete old content from the chat table. |
| 320 | 324 | */ |
| 321 | 325 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -301,20 +301,24 @@ | |
| 301 | if( !db_table_exists("repository", "chatfts1") ){ |
| 302 | db_multi_exec( |
| 303 | "CREATE VIRTUAL TABLE repository.chatfts1 USING fts5(" |
| 304 | " xmsg, content=chat, content_rowid=msgid, tokenize=porter" |
| 305 | ");" |
| 306 | "CREATE TRIGGER repository.chat_ai AFTER INSERT ON chat BEGIN " |
| 307 | " INSERT INTO chatfts1(rowid, xmsg) VALUES(new.msgid, new.xmsg);" |
| 308 | "END;" |
| 309 | "CREATE TRIGGER repository.chat_ad AFTER DELETE ON chat BEGIN " |
| 310 | " INSERT INTO chatfts1(chatfts1, rowid, xmsg) " |
| 311 | " VALUES('delete', old.msgid, old.xmsg);" |
| 312 | "END;" |
| 313 | "INSERT INTO repository.chatfts1(chatfts1) VALUES('rebuild');" |
| 314 | ); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | /* |
| 319 | ** Delete old content from the chat table. |
| 320 | */ |
| 321 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -301,20 +301,24 @@ | |
| 301 | if( !db_table_exists("repository", "chatfts1") ){ |
| 302 | db_multi_exec( |
| 303 | "CREATE VIRTUAL TABLE repository.chatfts1 USING fts5(" |
| 304 | " xmsg, content=chat, content_rowid=msgid, tokenize=porter" |
| 305 | ");" |
| 306 | "INSERT INTO repository.chatfts1(chatfts1) VALUES('rebuild');" |
| 307 | ); |
| 308 | } |
| 309 | db_multi_exec( |
| 310 | "DROP TRIGGER IF EXISTS chat_ai;" |
| 311 | "DROP TRIGGER IF EXISTS chat_ad;" |
| 312 | "CREATE TEMP TRIGGER chat_ai AFTER INSERT ON chat BEGIN " |
| 313 | " INSERT INTO chatfts1(rowid, xmsg) VALUES(new.msgid, new.xmsg);" |
| 314 | "END;" |
| 315 | "CREATE TEMP TRIGGER chat_ad AFTER DELETE ON chat BEGIN " |
| 316 | " INSERT INTO chatfts1(chatfts1, rowid, xmsg) " |
| 317 | " VALUES('delete', old.msgid, old.xmsg);" |
| 318 | "END;" |
| 319 | ); |
| 320 | } |
| 321 | |
| 322 | /* |
| 323 | ** Delete old content from the chat table. |
| 324 | */ |
| 325 |