Skip to content

scope ParseSchema by object type to avoid duplicate trigger execution#6326

Open
g0ldyy wants to merge 1 commit intotursodatabase:mainfrom
g0ldyy:fix/view-trigger-parse-schema
Open

scope ParseSchema by object type to avoid duplicate trigger execution#6326
g0ldyy wants to merge 1 commit intotursodatabase:mainfrom
g0ldyy:fix/view-trigger-parse-schema

Conversation

@g0ldyy
Copy link
Copy Markdown

@g0ldyy g0ldyy commented Apr 8, 2026

Summary

  • scope ParseSchema after CREATE VIEW to type = 'view'
  • scope materialized-view schema reload by object type as well
  • prevent same-named triggers from being reparsed and duplicated during view creation
  • add sqltest, integration, and simulator regressions

Reproduction

CREATE TABLE t(x INTEGER);
CREATE TABLE log(v INTEGER);
CREATE TRIGGER dup AFTER INSERT ON t BEGIN
    INSERT INTO log VALUES (NEW.x);
END;
CREATE VIEW dup AS SELECT x FROM t;
INSERT INTO t VALUES (1);
SELECT count(*), group_concat(v, ',') FROM log;

Expected SQLite result:

1|1

Before this patch, Turso returned:

2|1,1

Simulator

This PR extends the deterministic simulator with a targeted memory regression:

  • runner::memory::view_trigger_parse_schema::sim_create_view_does_not_duplicate_same_named_trigger

It verifies the sequence under simulated async I/O and after reopen to ensure the duplicated trigger execution does not persist.

Tests

  • cargo test -q -p core_tester --test integration_tests trigger::test_create_view_does_not_duplicate_same_named_trigger -- --exact --nocapture
  • cargo run -q -p test-runner -- run testing/sqltests/tests/views.sqltest
  • cargo test -q -p limbo_sim runner::memory::view_trigger_parse_schema::sim_create_view_does_not_duplicate_same_named_trigger -- --exact --nocapture

Copy link
Copy Markdown

@turso-bot turso-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review @pereman2

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Fossier: Approved by Maintainer

Approved by @pthorpe92.

@PThorpe92
Copy link
Copy Markdown
Collaborator

/fossier approve

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants