Fossil SCM

Ensure that the TEMP TRIGGERs that keep the chat FTS index up-to-date exist before inserting new entries into the chat table itself.

drh 2025-12-11 13:01 trunk
Commit 614b3f755984bdaa79549ac25282a0934b79e56ebbf5705c30114655b26c6db5
2 files changed +1 +1 -1
--- src/alerts.c
+++ src/alerts.c
@@ -159,10 +159,11 @@
159159
if( db_table_exists("temp","deferred_chat_events")
160160
&& db_table_exists("repository","chat")
161161
){
162162
const char *zChatUser = db_get("chat-timeline-user", 0);
163163
if( zChatUser && zChatUser[0] ){
164
+ chat_create_tables(); /* Make sure TEMP TRIGGERs for FTS exist */
164165
db_multi_exec(
165166
"INSERT INTO chat(mtime,lmtime,xfrom,xmsg)"
166167
" SELECT julianday(), "
167168
" strftime('%%Y-%%m-%%dT%%H:%%M:%%S','now','localtime'),"
168169
" %Q,"
169170
--- src/alerts.c
+++ src/alerts.c
@@ -159,10 +159,11 @@
159 if( db_table_exists("temp","deferred_chat_events")
160 && db_table_exists("repository","chat")
161 ){
162 const char *zChatUser = db_get("chat-timeline-user", 0);
163 if( zChatUser && zChatUser[0] ){
 
164 db_multi_exec(
165 "INSERT INTO chat(mtime,lmtime,xfrom,xmsg)"
166 " SELECT julianday(), "
167 " strftime('%%Y-%%m-%%dT%%H:%%M:%%S','now','localtime'),"
168 " %Q,"
169
--- src/alerts.c
+++ src/alerts.c
@@ -159,10 +159,11 @@
159 if( db_table_exists("temp","deferred_chat_events")
160 && db_table_exists("repository","chat")
161 ){
162 const char *zChatUser = db_get("chat-timeline-user", 0);
163 if( zChatUser && zChatUser[0] ){
164 chat_create_tables(); /* Make sure TEMP TRIGGERs for FTS exist */
165 db_multi_exec(
166 "INSERT INTO chat(mtime,lmtime,xfrom,xmsg)"
167 " SELECT julianday(), "
168 " strftime('%%Y-%%m-%%dT%%H:%%M:%%S','now','localtime'),"
169 " %Q,"
170
+1 -1
--- src/chat.c
+++ src/chat.c
@@ -323,11 +323,11 @@
323323
/*
324324
** Make sure the repository data tables used by chat exist. Create
325325
** them if they do not. Set up TEMP triggers (if needed) to update the
326326
** chatfts1 table as the chat table is updated.
327327
*/
328
-static void chat_create_tables(void){
328
+void chat_create_tables(void){
329329
if( !db_table_exists("repository","chat") ){
330330
db_multi_exec(zChatSchema1/*works-like:""*/);
331331
}else if( !db_table_has_column("repository","chat","lmtime") ){
332332
if( !db_table_has_column("repository","chat","mdel") ){
333333
db_multi_exec("ALTER TABLE chat ADD COLUMN mdel INT");
334334
--- src/chat.c
+++ src/chat.c
@@ -323,11 +323,11 @@
323 /*
324 ** Make sure the repository data tables used by chat exist. Create
325 ** them if they do not. Set up TEMP triggers (if needed) to update the
326 ** chatfts1 table as the chat table is updated.
327 */
328 static void chat_create_tables(void){
329 if( !db_table_exists("repository","chat") ){
330 db_multi_exec(zChatSchema1/*works-like:""*/);
331 }else if( !db_table_has_column("repository","chat","lmtime") ){
332 if( !db_table_has_column("repository","chat","mdel") ){
333 db_multi_exec("ALTER TABLE chat ADD COLUMN mdel INT");
334
--- src/chat.c
+++ src/chat.c
@@ -323,11 +323,11 @@
323 /*
324 ** Make sure the repository data tables used by chat exist. Create
325 ** them if they do not. Set up TEMP triggers (if needed) to update the
326 ** chatfts1 table as the chat table is updated.
327 */
328 void chat_create_tables(void){
329 if( !db_table_exists("repository","chat") ){
330 db_multi_exec(zChatSchema1/*works-like:""*/);
331 }else if( !db_table_has_column("repository","chat","lmtime") ){
332 if( !db_table_has_column("repository","chat","mdel") ){
333 db_multi_exec("ALTER TABLE chat ADD COLUMN mdel INT");
334

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button