Commit graph

521 commits

Author SHA1 Message Date
Jussi Saurio
826ca4d44d chore: remove experimental_indexes feature flags 2025-12-08 13:00:37 +02:00
Jussi Saurio
b45578becc
Merge 'sim: add binary tool that converts plan.sql to rust test file' from Jussi Saurio
Takes something like:
```sql
CREATE TABLE persistent_budiati_0 (proficient_shifu_1 TEXT, magnificent_calladinejones_2 TEXT, relaxed_gonzalez_3 TEXT, amiable_suhuyini_4 REAL, friendly_infoshop_5 INTEGER, sleek_apocalypticism_6 REAL, gleaming_ocalan_7 BLOB, polite_nelson_8 BLOB, gorgeous_secretariat_9 TEXT, fortuitous_stapleton_10 BLOB); -- 0
BEGIN CONCURRENT; -- 1
BEGIN CONCURRENT; -- 0
COMMIT; -- 1
UPDATE persistent_budiati_0 SET relaxed_gonzalez_3 = 'sleek_column', sleek_apocalypticism_6 = 1384203229.4851246, amiable_suhuyini_4 = 9656243128.574707, proficient_shifu_1 = 'sleek_romanska', gorgeous_secretariat_9 = 'sincere_postillon', friendly_infoshop_5 = 5387193238366539038, gleaming_ocalan_7 = X'6B696E645F616C6578697362616B6572', fortuitous_stapleton_10 = X'62726176655F77616C6C616365', magnificent_calladinejones_2 = 'energetic_brankovich' WHERE (TRUE); -- 0
BEGIN CONCURRENT; -- 1
INSERT INTO persistent_budiati_0 VALUES ('favorable_demibold', 'warmhearted_stroud', 'plucky_x', 6964007180.209948, 6676621284135822576, -6298192003.47883, X'66756E6E795F64757267616E', X'676C65616D696E675F68656E647269636B73', 'diligent_gai', X'66756E6E795F636172746F677261706879'), ('devoted_courtney', 'competitive_cast', 'glowing_p', 7100262433.047049, 2475381022967570429, -7589464447.394688, X'70726F66696369656E745F7275636B7573', X'7370656C6C62696E64696E675F6D617274696E64616C65', 'glittering_klien', X'696E646570656E64656E745F6E6573736965'), ('generous_pannekoek', 'diplomatic_summer', 'educated_moai', 8820129780.595894, 3736576277869875810, -7059365485.414469, X'7068696C6F736F70686963616C5F63726577', X'626F756E746966756C5F6D63656C726F79', 'mirthful_ansart', X'726F6D616E7469635F7361746F7572'), ('glowing_stirning', 'vivacious_moore', 'friendly_mumm', 1084189058.2024403, 8659164316642650802, 7455040212.614258, X'636861726D696E675F6C6565736F6E', X'666C657869626C655F6775726E6F77', 'insightful_okeeffe', X'6D6972746866756C5F72616576736B79'), ('brave_lanark', 'hilarious_council', 'zestful_murphy', 843262820.8342457, -5203301182531706236, -414439452.86331177, X'696D6167696E61746976655F61636861727961', X'6B6E6F776C6564676561626C655F636173746F726961646973', 'optimistic_olday', X'696D6167696E61746976655F656765'), ('creative_offenhartz', 'sincere_ickibob', 'diligent_conspiracy', -6137268237.420029, -7609135034138257256, -7895069391.899394, X'656E6368616E74696E675F6C6561677565', X'68617264776F726B696E675F6265616473616761696E73746661736369736D', 'inquisitive_wilderness', X'676F7267656F75735F7765747A656C'); -- 0
DELETE FROM persistent_budiati_0 WHERE (0); -- 0
INSERT INTO persistent_budiati_0 VALUES ('capable_ramus', 'vivid_romanos', 'courageous_swann', -8348839044.12441, -3153793306041765852, 1497972203.2522106, X'676F7267656F75735F73747261756D65', X'676F7267656F75735F646973636F72646961', 'sleek_velli', X'61646570745F6D6172696E'), ('proficient_strasbourg', 'perfect_zileli', 'powerful_bellegarrigue', 3656370453.798256, 488521277608345023, 9272977102.174099, X'6D6F76696E675F646F626273', X'616D6961626C655F7671', 'bountiful_nippon', X'7265736F7572636566756C5F61676E69'); -- 0
COMMIT; -- 1
DELETE FROM persistent_budiati_0 WHERE (persistent_budiati_0.sleek_apocalypticism_6 > 2122130920.1633062); -- 0
BEGIN CONCURRENT; -- 1
COMMIT; -- 1
COMMIT; -- 0
ALTER TABLE persistent_budiati_0 RENAME TO humorous_chien_11; -- 0
BEGIN CONCURRENT; -- 1
BEGIN CONCURRENT; -- 0
COMMIT; -- 0
COMMIT; -- 1
BEGIN CONCURRENT; -- 1
COMMIT; -- 1
ALTER TABLE humorous_chien_11 RENAME COLUMN gleaming_ocalan_7 TO diplomatic_mendelgleeson_12; -- 1
BEGIN CONCURRENT; -- 1
INSERT INTO humorous_chien_11 VALUES ('capable_nevada', 'brave_fc', 'stupendous_leila', 1841016158.456213, 382581885747084851, 241956515.74888992, X'6F75747374616E64696E675F616E68696C61616C', X'70617373696F6E6174655F72616661656C', 'competitive_aversion', X'70726F706974696F75735F7679736F74736B79'), ('glimmering_kerr', 'ambitious_marsden', 'sincere_garine', 4621457902.119736, -7728284413371611806, -5001194349.263405, X'6C696B61626C655F636C61726B65', X'676F7267656F75735F676F776479', 'bountiful_majaras', X'63726561746976655F737068696E78'), ('unique_poets', 'polite_gori', 'imaginative_ocalan', 6720955495.1690235, 5051068995752523160, 2163769134.7309666, X'706F77657266756C5F7374616C696E', X'6C6F76696E675F6162', 'incredible_alakran', X'72656D61726B61626C655F62726F67616E'), ('breathtaking_lucca', 'persistent_rebelaze', 'ambitious_durgan', -1675368104.83671, 8903219744372423748, 6327505289.906071, X'676C697374656E696E675F676172736F6E', X'6B6E6F776C6564676561626C655F63616765', 'glittering_tierra', X'6C696B61626C655F6F6E66726179'), ('friendly_riesel', 'splendid_waas', 'philosophical_hare', 7521721975.525509, -4077583965067530416, 8568449025.795597, X'7A65737466756C5F7075626C697368696E67', X'68696C6172696F75735F64657074', 'wondrous_anarchofeminists', X'636F6E73696465726174655F62616D796568'); -- 1
UPDATE humorous_chien_11 SET relaxed_gonzalez_3 = 'outstanding_lupalupa', fortuitous_stapleton_10 = X'676C6974746572696E675F67656C61626572746F', sleek_apocalypticism_6 = 4749515806.792229, gorgeous_secretariat_9 = 'faithful_marechal', magnificent_calladinejones_2 = 'gleaming_woodwork', amiable_suhuyini_4 = 302359235.4986744, polite_nelson_8 = X'696D6167696E61746976655F736368776172747A' WHERE (humorous_chien_11.amiable_suhuyini_4 < 9508571248.762548 AND NOT 'philosophical_hare' AND + 7521721975.525509); -- 1
BEGIN CONCURRENT; -- 0
INSERT INTO humorous_chien_11 VALUES ('unique_anarchists', 'generous_action', 'passionate_books', 7230399065.725552, -6224798804581125214, -7465265323.767456, X'7068696C6F736F70686963616C5F647261676F6E6F776C', X'746563686E6F6C6F676963616C5F667261736572', 'mirthful_cd', X'7175616C69666965645F636F6E747265706F696E7473'), ('charming_buck', 'knowledgeable_pannekoek', 'gorgeous_follmann', -8155760089.594284, -6882263070642873795, 7925299744.793644, X'616C6C7572696E675F646566656E7365', X'6B696E645F616D6265727261656B656C6C79', 'twinkling_fidel', X'706F6C6974655F62727562616B6572'), ('sleek_sail', 'passionate_shaffer', 'confident_moen', -4950429037.66798, 67877469559160520, -7911354264.616009, X'726573706F6E7369626C655F776F6E67', X'677265676172696F75735F6F636172726F6C6C', 'glimmering_eco', X'7A65737466756C5F686F66666D616E'); -- 0
INSERT INTO humorous_chien_11 VALUES ('diplomatic_olympics', 'upbeat_cast', 'confident_bregman', -694836719.9655838, -7590350502083497714, -4833340319.208008, X'726F7573696E675F636F7272', X'6F75747374616E64696E675F6869617474', 'independent_hatzimichelakis', X'7368696D6D6572696E675F706178746F6E'), ('determined_fiscella', 'perfect_toronto', 'philosophical_nacional', 6766485377.716101, -1864833171741648409, 4673986463.289207, X'7370656C6C62696E64696E675F6869617474', X'73696E636572655F6E656C736F6E', 'mirthful_nosakhere', X'626F756E746966756C5F6265636F6D696E6773'), ('gleaming_city', 'dazzling_oak', 'dazzling_mazer', -7297230853.519529, 4678152103342429971, 5169450552.174406, X'676C697374656E696E675F626C61636B', X'76696272616E745F7368616E6E6F6E', 'agreeable_peasants', X'70617469656E745F6967617269776579'); -- 1
DELETE FROM humorous_chien_11 WHERE (humorous_chien_11.relaxed_gonzalez_3 < 'zestful_murphx'); -- 0
-- begin testing 'TableHasExpectedContent'
    -- ASSUME table humorous_chien_11 exists; -- 0
    SELECT * FROM humorous_chien_11 WHERE TRUE; -- 0
    -- ASSERT table humorous_chien_11 should have the expected content;; -- 0
-- end testing 'TableHasExpectedContent'
```
and produces:
```rust
use std::sync::Arc;

use turso_core::Connection;

use crate::common::TempDatabase;

#[turso_macros::test]
fn test_bugbase_13956202564301292478(tmp_db: TempDatabase) {
    let mut connections: Vec<Arc<Connection>> = Vec::new();
    for _ in 0..2 {
        connections.push(tmp_db.connect_limbo());
    }

    // Connection 0
    let _ = connections[0].execute("CREATE TABLE persistent_budiati_0 (proficient_shifu_1 TEXT, magnificent_calladinejones_2 TEXT, relaxed_gonzalez_3 TEXT, amiable_suhuyini_4 REAL, friendly_infoshop_5 INTEGER, sleek_apocalypticism_6 REAL, gleaming_ocalan_7 BLOB, polite_nelson_8 BLOB, gorgeous_secretariat_9 TEXT, fortuitous_stapleton_10 BLOB);");

    // Connection 1
    let _ = connections[1].execute("BEGIN CONCURRENT;");

    // Connection 0
    let _ = connections[0].execute("BEGIN CONCURRENT;");

    // Connection 1
    let _ = connections[1].execute("COMMIT;");

    // Connection 0
    let _ = connections[0].execute("UPDATE persistent_budiati_0 SET relaxed_gonzalez_3 = 'sleek_column', sleek_apocalypticism_6 = 1384203229.4851246, amiable_suhuyini_4 = 9656243128.574707, proficient_shifu_1 = 'sleek_romanska', gorgeous_secretariat_9 = 'sincere_postillon', friendly_infoshop_5 = 5387193238366539038, gleaming_ocalan_7 = X'6B696E645F616C6578697362616B6572', fortuitous_stapleton_10 = X'62726176655F77616C6C616365', magnificent_calladinejones_2 = 'energetic_brankovich' WHERE (TRUE);");

    // Connection 1
    let _ = connections[1].execute("BEGIN CONCURRENT;");

    // Connection 0
    let _ = connections[0].execute("INSERT INTO persistent_budiati_0 VALUES ('favorable_demibold', 'warmhearted_stroud', 'plucky_x', 6964007180.209948, 6676621284135822576, -6298192003.47883, X'66756E6E795F64757267616E', X'676C65616D696E675F68656E647269636B73', 'diligent_gai', X'66756E6E795F636172746F677261706879'), ('devoted_courtney', 'competitive_cast', 'glowing_p', 7100262433.047049, 2475381022967570429, -7589464447.394688, X'70726F66696369656E745F7275636B7573', X'7370656C6C62696E64696E675F6D617274696E64616C65', 'glittering_klien', X'696E646570656E64656E745F6E6573736965'), ('generous_pannekoek', 'diplomatic_summer', 'educated_moai', 8820129780.595894, 3736576277869875810, -7059365485.414469, X'7068696C6F736F70686963616C5F63726577', X'626F756E746966756C5F6D63656C726F79', 'mirthful_ansart', X'726F6D616E7469635F7361746F7572'), ('glowing_stirning', 'vivacious_moore', 'friendly_mumm', 1084189058.2024403, 8659164316642650802, 7455040212.614258, X'636861726D696E675F6C6565736F6E', X'666C657869626C655F6775726E6F77', 'insightful_okeeffe', X'6D6972746866756C5F72616576736B79'), ('brave_lanark', 'hilarious_council', 'zestful_murphy', 843262820.8342457, -5203301182531706236, -414439452.86331177, X'696D6167696E61746976655F61636861727961', X'6B6E6F776C6564676561626C655F636173746F726961646973', 'optimistic_olday', X'696D6167696E61746976655F656765'), ('creative_offenhartz', 'sincere_ickibob', 'diligent_conspiracy', -6137268237.420029, -7609135034138257256, -7895069391.899394, X'656E6368616E74696E675F6C6561677565', X'68617264776F726B696E675F6265616473616761696E73746661736369736D', 'inquisitive_wilderness', X'676F7267656F75735F7765747A656C');");

    // Connection 0
    let _ = connections[0].execute("DELETE FROM persistent_budiati_0 WHERE (0);");

    // Connection 0
    let _ = connections[0].execute("INSERT INTO persistent_budiati_0 VALUES ('capable_ramus', 'vivid_romanos', 'courageous_swann', -8348839044.12441, -3153793306041765852, 1497972203.2522106, X'676F7267656F75735F73747261756D65', X'676F7267656F75735F646973636F72646961', 'sleek_velli', X'61646570745F6D6172696E'), ('proficient_strasbourg', 'perfect_zileli', 'powerful_bellegarrigue', 3656370453.798256, 488521277608345023, 9272977102.174099, X'6D6F76696E675F646F626273', X'616D6961626C655F7671', 'bountiful_nippon', X'7265736F7572636566756C5F61676E69');");

    // Connection 1
    let _ = connections[1].execute("COMMIT;");

    // Connection 0
    let _ = connections[0].execute("DELETE FROM persistent_budiati_0 WHERE (persistent_budiati_0.sleek_apocalypticism_6 > 2122130920.1633062);");

    // Connection 1
    let _ = connections[1].execute("BEGIN CONCURRENT;");

    // Connection 1
    let _ = connections[1].execute("COMMIT;");

    // Connection 0
    let _ = connections[0].execute("COMMIT;");

    // Connection 0
    let _ = connections[0].execute("ALTER TABLE persistent_budiati_0 RENAME TO humorous_chien_11;");

    // Connection 1
    let _ = connections[1].execute("BEGIN CONCURRENT;");

    // Connection 0
    let _ = connections[0].execute("BEGIN CONCURRENT;");

    // Connection 0
    let _ = connections[0].execute("COMMIT;");

    // Connection 1
    let _ = connections[1].execute("COMMIT;");

    // Connection 1
    let _ = connections[1].execute("BEGIN CONCURRENT;");

    // Connection 1
    let _ = connections[1].execute("COMMIT;");

    // Connection 1
    let _ = connections[1].execute("ALTER TABLE humorous_chien_11 RENAME COLUMN gleaming_ocalan_7 TO diplomatic_mendelgleeson_12;");

    // Connection 1
    let _ = connections[1].execute("BEGIN CONCURRENT;");

    // Connection 1
    let _ = connections[1].execute("INSERT INTO humorous_chien_11 VALUES ('capable_nevada', 'brave_fc', 'stupendous_leila', 1841016158.456213, 382581885747084851, 241956515.74888992, X'6F75747374616E64696E675F616E68696C61616C', X'70617373696F6E6174655F72616661656C', 'competitive_aversion', X'70726F706974696F75735F7679736F74736B79'), ('glimmering_kerr', 'ambitious_marsden', 'sincere_garine', 4621457902.119736, -7728284413371611806, -5001194349.263405, X'6C696B61626C655F636C61726B65', X'676F7267656F75735F676F776479', 'bountiful_majaras', X'63726561746976655F737068696E78'), ('unique_poets', 'polite_gori', 'imaginative_ocalan', 6720955495.1690235, 5051068995752523160, 2163769134.7309666, X'706F77657266756C5F7374616C696E', X'6C6F76696E675F6162', 'incredible_alakran', X'72656D61726B61626C655F62726F67616E'), ('breathtaking_lucca', 'persistent_rebelaze', 'ambitious_durgan', -1675368104.83671, 8903219744372423748, 6327505289.906071, X'676C697374656E696E675F676172736F6E', X'6B6E6F776C6564676561626C655F63616765', 'glittering_tierra', X'6C696B61626C655F6F6E66726179'), ('friendly_riesel', 'splendid_waas', 'philosophical_hare', 7521721975.525509, -4077583965067530416, 8568449025.795597, X'7A65737466756C5F7075626C697368696E67', X'68696C6172696F75735F64657074', 'wondrous_anarchofeminists', X'636F6E73696465726174655F62616D796568');");

    // Connection 1
    let _ = connections[1].execute("UPDATE humorous_chien_11 SET relaxed_gonzalez_3 = 'outstanding_lupalupa', fortuitous_stapleton_10 = X'676C6974746572696E675F67656C61626572746F', sleek_apocalypticism_6 = 4749515806.792229, gorgeous_secretariat_9 = 'faithful_marechal', magnificent_calladinejones_2 = 'gleaming_woodwork', amiable_suhuyini_4 = 302359235.4986744, polite_nelson_8 = X'696D6167696E61746976655F736368776172747A' WHERE (humorous_chien_11.amiable_suhuyini_4 < 9508571248.762548 AND NOT 'philosophical_hare' AND + 7521721975.525509);");

    // Connection 0
    let _ = connections[0].execute("BEGIN CONCURRENT;");

    // Connection 0
    let _ = connections[0].execute("INSERT INTO humorous_chien_11 VALUES ('unique_anarchists', 'generous_action', 'passionate_books', 7230399065.725552, -6224798804581125214, -7465265323.767456, X'7068696C6F736F70686963616C5F647261676F6E6F776C', X'746563686E6F6C6F676963616C5F667261736572', 'mirthful_cd', X'7175616C69666965645F636F6E747265706F696E7473'), ('charming_buck', 'knowledgeable_pannekoek', 'gorgeous_follmann', -8155760089.594284, -6882263070642873795, 7925299744.793644, X'616C6C7572696E675F646566656E7365', X'6B696E645F616D6265727261656B656C6C79', 'twinkling_fidel', X'706F6C6974655F62727562616B6572'), ('sleek_sail', 'passionate_shaffer', 'confident_moen', -4950429037.66798, 67877469559160520, -7911354264.616009, X'726573706F6E7369626C655F776F6E67', X'677265676172696F75735F6F636172726F6C6C', 'glimmering_eco', X'7A65737466756C5F686F66666D616E');");

    // Connection 1
    let _ = connections[1].execute("INSERT INTO humorous_chien_11 VALUES ('diplomatic_olympics', 'upbeat_cast', 'confident_bregman', -694836719.9655838, -7590350502083497714, -4833340319.208008, X'726F7573696E675F636F7272', X'6F75747374616E64696E675F6869617474', 'independent_hatzimichelakis', X'7368696D6D6572696E675F706178746F6E'), ('determined_fiscella', 'perfect_toronto', 'philosophical_nacional', 6766485377.716101, -1864833171741648409, 4673986463.289207, X'7370656C6C62696E64696E675F6869617474', X'73696E636572655F6E656C736F6E', 'mirthful_nosakhere', X'626F756E746966756C5F6265636F6D696E6773'), ('gleaming_city', 'dazzling_oak', 'dazzling_mazer', -7297230853.519529, 4678152103342429971, 5169450552.174406, X'676C697374656E696E675F626C61636B', X'76696272616E745F7368616E6E6F6E', 'agreeable_peasants', X'70617469656E745F6967617269776579');");

    // Connection 0
    let _ = connections[0].execute("DELETE FROM humorous_chien_11 WHERE (humorous_chien_11.relaxed_gonzalez_3 < 'zestful_murphx');");

    // Connection 0
    let _ = connections[0].execute("SELECT * FROM humorous_chien_11 WHERE TRUE;");

}
```
prompt to opus 4.5:
Create a parser that generates a Rust integration test a lá
test_transactions.rs from files like
.bugbase/17016242926153013649/plan.sql
the "-- <integer>" means connection number, so as many connections
should be created as there are distinct suffixes like that at the end of
a line. lines BEGINNING with --
 eg "-- begin testing 'ReadYourUpdatesBack'" can be ignored.
the end result should be that the parser tool prints out a valid rust
file containing the necessary imports and a test function containing the
statements (modeled after test_transactions.rs tests).
this should be a lightweight script or CLI tool in the simulator
directory where you can give it a sql path and it will produce that
test.

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #4112
2025-12-08 06:20:39 +02:00
Jussi Saurio
299ccdaee4
Merge 'sim: stop ignoring sql execution errors' from Jussi Saurio
Some checks are pending
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on browser@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / sync-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Publish (push) Blocked by required conditions
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust / simulator (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
Reviewed-by: Pedro Muniz (@pedrocarlo)

Closes #4106
2025-12-05 23:04:20 +02:00
Jussi Saurio
f58a839293 sim: add binary tool that converts plan.sql to rust test file
prompt to opus 4.5:

Create a parser that generates a Rust integration test a lá test_transactions.rs
from files like .bugbase/17016242926153013649/plan.sql

the "-- <integer>" means connection number, so as many connections should be created
as there are distinct suffixes like that at the end of a line. lines BEGINNING with --
 eg "-- begin testing 'ReadYourUpdatesBack'" can be ignored.

the end result should be that the parser tool prints out a valid rust file containing
the necessary imports and a test function containing the statements (modeled after
test_transactions.rs tests).

this should be a lightweight script or CLI tool in the simulator directory where you
can give it a sql path and it will produce that test.
2025-12-05 22:40:41 +02:00
Preston Thorpe
231282a5be
Merge 'Simulator Roadmap' from Alperen Keleş
This PR is a working doc on a roadmap for the simulator. @pedrocarlo
@LeMikaelF please take a look.

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #3954
2025-12-05 13:27:57 -05:00
Jussi Saurio
77ad9d87c5 sim: stop ignoring sql execution errors 2025-12-05 13:14:39 +02:00
pedrocarlo
085c108f0d Simulator: after freestanding DML statement, check the table's content 2025-12-03 10:48:46 -03:00
alpaylan
e66405303c add detailed properties, long term simulation and data collection 2025-11-24 12:19:30 -05:00
pedrocarlo
03f38ae72c simulator: only check all tables if we have any tables to check 2025-11-21 01:10:55 -03:00
pedrocarlo
c2be60b007 add pragma to shrinking 2025-11-17 11:45:02 -03:00
pedrocarlo
f09b73c768 remove Span, as interaction ID is enough to determine membership of a property 2025-11-17 11:45:02 -03:00
pedrocarlo
2aab33b714 find_interactions_range only check for interaction id to determine membership 2025-11-17 11:45:02 -03:00
pedrocarlo
4fd0896538 remove extension queries from other types of properties 2025-11-17 11:45:02 -03:00
pedrocarlo
9d439556ca if table changed names, add its previous names to depending tables when shrinking 2025-11-17 11:45:02 -03:00
pedrocarlo
af31e74d9f add depending tables to assertions to delete them if needed in shrinking 2025-11-17 11:45:02 -03:00
pedrocarlo
087d5f59a1 fix execution ticks not ticking enough 2025-11-17 11:45:02 -03:00
pedrocarlo
836d115853 create interaction plan correct in main.rs 2025-11-17 11:45:02 -03:00
pedrocarlo
2c8754985b refactor shrinking to use utilities in the InteractionPlan to iterate over properties, instead of handrolling property iteration 2025-11-17 11:45:02 -03:00
pedrocarlo
a21f7675dd - update interaction stats on demand instead of reading the entire plan
to calculate metrics per generation step 
- simplify generation as we now only store `Interaction`. So now we can 
  funnel most of the logic for interaction generation, metric update,
  and Interaction append in the `PlanGenerator::next`.
2025-11-17 11:45:02 -03:00
pedrocarlo
157a5cf10a - add Interaction Builder to simplify code for building an interaction.
Modify `generation/property.rs` to use the Builder
- add additional metadata to `Interaction` to give more context for
  shrinking and iterating over interactions that originated from the
  same interaction.
- add Iterator like utilities for `InteractionPlan` to facilitate
  iterating over interactions that came from the same property:
2025-11-17 11:45:02 -03:00
pedrocarlo
c088a653e6 move interaction stats to metrics 2025-11-17 11:45:02 -03:00
pedrocarlo
2fe39d40bb add Span and PropertyMetadata structs 2025-11-17 11:45:02 -03:00
pedrocarlo
a4f0f2364d disable Watch Mode until we can properly serialize interaction plan 2025-11-17 11:45:02 -03:00
pedrocarlo
4f143f385a - modify bugbase to not save interaction plan in a plan.json. As we
will track `Interaction` instead of `Interactions` in the Plan, this
  change will impossibilitate the serialization of the InteractionPlan with Serde Json. 
- make --load just load the previous cli args
2025-11-17 11:45:02 -03:00
pedrocarlo
8f50154db2 separate struct defining code from struct generation code. Also move Remaining to a metrics file 2025-11-17 11:44:20 -03:00
alpaylan
f47293c6b0 detail correctness and properties 2025-11-14 18:09:03 -05:00
Mikaël Francoeur
d309e6ddb3
generate self-inserts with nested subqueries 2025-11-14 09:16:17 -05:00
Mikaël Francoeur
23d6080531
make FromClause recursive 2025-11-14 09:16:17 -05:00
Mikaël Francoeur
8ea038c00b
fix join 2025-11-14 09:16:17 -05:00
alpaylan
e2c539066f small updates based on comments 2025-11-13 17:34:35 -05:00
alpaylan
575541c744 small updates based on comments 2025-11-13 16:50:53 -05:00
alpaylan
4aac076400 wip: add simulator roadmap 2025-11-13 14:25:17 -05:00
Pekka Enberg
913b7ac600 core: Disable autovacuum by default
People have discovered various bugs in autovacuum so let's disable it by
default for now.
2025-11-02 12:09:21 +02:00
Pavan-Nambi
cf93360b9c
cleanup
Co-authored-by: Mikaël Francoeur <mikael.francoeur@hotmail.com>

cleanup

Co-authored-by: Mikaël Francoeur <mikael.francoeur@hotmail.com>
2025-10-24 19:35:13 +05:30
Pavan-Nambi
8d0ae362da
Merge branch 'main' of github.com:tursodatabase/turso into avcm 2025-10-24 18:58:30 +05:30
Pavan-Nambi
dbd8b1b01d
change weight and add pragma_weight to querytypes 2025-10-24 18:10:10 +05:30
pedrocarlo
72baf48863 add random generation in simulator IO 2025-10-21 14:10:38 -03:00
Jussi Saurio
b67fabdd62 Fix git directory resolution in simulator to support worktrees
sim cannot be run in a git worktree on main
2025-10-21 14:34:27 +03:00
Bob Peterson
b92f4cb9c4 Make Miri easier to run 2025-10-20 23:48:19 -05:00
Pavan-Nambi
73cabf49f2
fmt sim 2025-10-18 18:46:20 +05:30
Pavan-Nambi
b473a1c3ca
Merge remote-tracking branch 'mikael/sim-pragma' into avcm 2025-10-18 16:41:39 +05:30
Pekka Enberg
9a1bd2112d
Merge 'Run simulator under Miri' from Bob Peterson
This adds support for running the simulator under Miri to detect UB.
There are a few things to note about Miri and its limitations
- It has limited `libc` coverage, so it's not really possible to have
Miri help with `UringIO`/`UringFile` or `UnixIO`/`UnixFile`. That's a
big gap ☹️
- It **can** work for `GenericIO`/`GenericFile`, which only uses `std`
- It can't call external C libraries, so even using `sqlite` is out
(hence adding `--disable-integrity-check` to the simulator for Miri use)
- It runs on nightly, consequently there are a few new lints that don't
exist on turso's pinned version of rustc
Some questions I have about this MR
- I made `GenericFile::{lock_file,unlock_file}` noops so I could use
`GenericIO`. This isn't great, but if/when you update from Rust 1.88.0
to 1.89.0, `std::File::{lock,lock_shared,unlock}` will be stabilized and
available. Should I note that as a TODO or something?
- Previously, the sim runner shelled out to `git` to get stuff like the
current git hash and the repo directory. For Miri, that's out, and so is
`git2`. Unfortunately, `gix` is also out since it has a required
dependency that uses inline assembly, which Miri doesn't like. I wrote a
hacky shim that uses only std to look for `.git` and find the hash that
HEAD is pointing to. It doesn't deal with stuff like packed-refs or the
repo being a secondary one made with `git worktree`. I'm happy to
support that, but wanted to hear from maintainers before doing more
work.
Two UB occurrences I already found:
- `TursoRwLock::read` used `AtomicU64::compare_exchange_weak`, which is
(evidently) [allowed to spuriously fail](https://doc.rust-lang.org/std/s
ync/atomic/struct.AtomicU64.html#method.compare_exchange_weak) in
exchange for perf. Miri forces this behavior, which triggers trivial
read deadlocks even with zero readers/writers. I changed it to
`compare_exchange`, but I'm not an atomics expert.
- Uninitialized read in non-Unix
`core::storage::buffer_pool::arena::alloc`. This is a simple one,
resolved by using `std::alloc::alloc_zeroed` instead of
`std::alloc::alloc`
Moving forward, I'd be interested in potentially getting the tests to
run in Miri, too. `tokio` looks like a good example of a project with
partial coverage that runs it where they can. They have some extra test
config to allow as many as possible to run under Miri, with
appropriately scaled-down parameter values since Miri is super slow

Closes #3720
2025-10-14 09:26:55 +03:00
Jussi Saurio
ebc4ddb2a2
Merge 'Simulator: fix alter table shadowing to modify index column name ' from Pedro Muniz
Forgot to modify the column name referenced in the indexes when
shadowing

Reviewed-by: bit-aloo (@Shourya742)

Closes #3712
2025-10-14 07:25:29 +03:00
Bob Peterson
4d843804b7 Add --disable-integrity-check option to simulator
Miri can't execute sqlite via the FFI, so this needs to be configurable
2025-10-13 14:54:16 -05:00
Bob Peterson
3d4c10df40 Document using Miri to run the simulator 2025-10-13 14:54:16 -05:00
Bob Peterson
ce2f286df0 Replace git shell commands with std shims
gix doesn't work here, since while it's pure Rust, it has a
non-configurable dependency on crates using inline assembly, which Miri
does not support. This commit is a bit of a hack, and only works in
non-bare git repos without e.g packed-refs.
2025-10-13 14:54:16 -05:00
pedrocarlo
45567e6837 fix alter table shadowing to modify index column name on rename and alter 2025-10-13 14:02:26 -03:00
pedrocarlo
bfeccf6543 integrate DropIndex in query generator 2025-10-13 13:56:36 -03:00
pedrocarlo
b2e54d9816 add Drop Index to simulator model 2025-10-13 13:32:16 -03:00
Jussi Saurio
c12c1db275
Merge 'Simulator: persist files in sim memory IO for integrity check' from Pedro Muniz
Some checks are pending
Python / Release (push) Blocked by required conditions
Rust / clippy (push) Waiting to run
Rust / cargo-fmt-check (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Test DB bindings on browser@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Publish (push) Blocked by required conditions
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / simulator (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
If we don't persist the files, rusqlite will open an empty file and
perform integrity check on it.

Reviewed-by: bit-aloo (@Shourya742)

Closes #3676
2025-10-13 14:23:53 +03:00