Fossil

Check-in [21d9ea4ade]
Login

Check-in [21d9ea4ade]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use temporary triggers, instead of normal schema triggers, to populate the fts index. Fossil disables schema triggers to prevent malicious uses.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | fts5-chat-search
Files: files | file ages | folders
SHA3-256: 21d9ea4adeb3a28c48070da091b9aa09fc42aa954be35e1bc8f9b3df86f91a4b
User & Date: dan 2024-07-01 15:22:06.143
Context
2024-07-01
15:49
Do not filter out the chat-robot messages from /chat search, per feedback. ... (check-in: b5281f4e61 user: stephan tags: fts5-chat-search)
15:22
Use temporary triggers, instead of normal schema triggers, to populate the fts index. Fossil disables schema triggers to prevent malicious uses. ... (check-in: 21d9ea4ade user: dan tags: fts5-chat-search)
11:31
Replace the /chat attach button SVG with the corresponding Unicode 6.0 glyph. Not sure why we didn't do that in the first place, as all of the other buttons use emoji icons. ... (check-in: 74479fb593 user: stephan tags: fts5-chat-search)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/chat.c.
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315











316
317
318
319
320
321
322
  }

  if( !db_table_exists("repository", "chatfts1") ){
    db_multi_exec(
      "CREATE VIRTUAL TABLE repository.chatfts1 USING fts5("
      "    xmsg, content=chat, content_rowid=msgid, tokenize=porter"
      ");"
      "CREATE TRIGGER repository.chat_ai AFTER INSERT ON chat BEGIN "
      "  INSERT INTO chatfts1(rowid, xmsg) VALUES(new.msgid, new.xmsg);"
      "END;"
      "CREATE TRIGGER repository.chat_ad AFTER DELETE ON chat BEGIN "
      "  INSERT INTO chatfts1(chatfts1, rowid, xmsg) "
      "    VALUES('delete', old.msgid, old.xmsg);"
      "END;"
      "INSERT INTO repository.chatfts1(chatfts1) VALUES('rebuild');"
    );
  }











}

/*
** Delete old content from the chat table.
*/
static void chat_purge(void){
   int mxCnt = db_get_int("chat-keep-count",50);







<
<
<
<
<
<
<



>
>
>
>
>
>
>
>
>
>
>







299
300
301
302
303
304
305







306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
  }

  if( !db_table_exists("repository", "chatfts1") ){
    db_multi_exec(
      "CREATE VIRTUAL TABLE repository.chatfts1 USING fts5("
      "    xmsg, content=chat, content_rowid=msgid, tokenize=porter"
      ");"







      "INSERT INTO repository.chatfts1(chatfts1) VALUES('rebuild');"
    );
  }
  db_multi_exec(
    "DROP TRIGGER IF EXISTS chat_ai;"
    "DROP TRIGGER IF EXISTS chat_ad;"
    "CREATE TEMP TRIGGER chat_ai AFTER INSERT ON chat BEGIN "
    "  INSERT INTO chatfts1(rowid, xmsg) VALUES(new.msgid, new.xmsg);"
    "END;"
    "CREATE TEMP TRIGGER chat_ad AFTER DELETE ON chat BEGIN "
    "  INSERT INTO chatfts1(chatfts1, rowid, xmsg) "
    "    VALUES('delete', old.msgid, old.xmsg);"
    "END;"
  );
}

/*
** Delete old content from the chat table.
*/
static void chat_purge(void){
   int mxCnt = db_get_int("chat-keep-count",50);