Skip to content

fix(fts): action-event FTS triggers use UNINDEXED event_id instead of rowid #484

Closed

Description

@Sinity

Problem

schema_ddl_actions.py:73,78 — FTS triggers on action_events DELETE/UPDATE use:

DELETE FROM action_events_fts WHERE event_id = old.event_id;

But event_id is declared UNINDEXED in the FTS5 table (schema_ddl_actions.py:49). Every delete or update of an action event triggers a full content scan of the FTS table.

The messages_fts triggers at schema_ddl_archive.py:271 use the correct pattern:

DELETE FROM messages_fts WHERE rowid = old.rowid;

rowid is implicitly indexed in FTS5 — this is O(1).

Same issue affects session_profiles_fts triggers at schema_ddl_product_profiles.py:73-74.

This is separate from #467 (which is about wrong column names in the triggers' INSERT statements).

Fix

Change all FTS DELETE/UPDATE triggers to reference rowid instead of content column IDs. The FTS INSERT triggers already store the source table's rowid — the DELETE/UPDATE triggers should use it.

Discovered during adversarial audit 2026-04-26.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:storagetype:fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions