limbo/core
Alex Miller 4619890ffc Add basic support for ANALYZE statement.
This permits only `ANALYZE <table_name>` to work, and all other forms
fail with a parse error (as documented in the tests).

On SQLite, ANALYZE generates:

sqlite> CREATE TABLE sqlite_stat1(tbl,idx,stat);
sqlite> CREATE TABLE iiftest(a int, b int, c int);
sqlite> EXPLAIN ANALYZE iiftest;
addr  opcode         p1    p2    p3    p4             p5  comment
----  -------------  ----  ----  ----  -------------  --  -------------
0     Init           0     21    0                    0   Start at 21
1     Null           0     1     0                    0   r[1]=NULL
2     OpenWrite      3     4     0     3              0   root=4 iDb=0; sqlite_stat1
3     Rewind         3     9     0                    0
4       Column         3     0     2                    0   r[2]= cursor 3 column 0
5       Ne             3     8     2     BINARY-8       81  if r[2]!=r[3] goto 8
6       Rowid          3     4     0                    0   r[4]=sqlite_stat1.rowid
7       Delete         3     0     0     sqlite_stat1   2
8     Next           3     4     0                    1
9     OpenWrite      0     4     0     3              0   root=4 iDb=0; sqlite_stat1
10    OpenRead       4     2     0     3              0   root=2 iDb=0; iiftest
11    String8        0     11    0     iiftest        0   r[11]='iiftest'; iiftest
12    Count          4     13    0                    0   r[13]=count()
13    IfNot          13    18    0                    0
14    Null           0     12    0                    0   r[12]=NULL
15    MakeRecord     11    3     9     BBB            0   r[9]=mkrec(r[11..13])
16    NewRowid       0     5     0                    0   r[5]=rowid
17    Insert         0     9     5                    8   intkey=r[5] data=r[9]
18    LoadAnalysis   0     0     0                    0
19    Expire         0     0     0                    0
20    Halt           0     0     0                    0
21    Transaction    0     1     9     0              1   usesStmtJournal=0
22    String8        0     3     0     iiftest        0   r[3]='iiftest'
23    Goto           0     1     0                    0

Turso can now generate:

turso> create table sqlite_stat1(tbl,idx,stat);
turso> create table iiftest(a int, b int, c int);
turso> explain analyze iiftest;
addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     19    0                    0   Start at 19
1     Null               0     1     0                    0   r[1]=NULL
2     OpenWrite          0     2     0                    0   root=2; iDb=0
3     Rewind             0     9     0                    0   Rewind  sqlite_stat1
4       Column           0     0     2                    0   r[2]=sqlite_stat1.tbl
5       Ne               2     3     9                    0   if r[2]!=r[3] goto 9
6       RowId            0     4     0                    0   r[4]=sqlite_stat1.rowid
7       Delete           0     0     0     sqlite_stat1   0
8     Next               0     4     0                    0
9     OpenWrite          1     2     0                    0   root=2; iDb=0
10    OpenRead           2     3     0                    0   =iiftest, root=3, iDb=0
11    String8            0     7     0     iiftest        0   r[7]='iiftest'
12    Count              2     9     0                    0
13    IfNot              9     18    0                    0   if !r[9] goto 18
14    Null               0     8     0                    0   r[8]=NULL
15    MakeRecord         7     3     6                    0   r[6]=mkrec(r[7..9])
16    NewRowid           1     5     0                    0   r[5]=rowid
17    Insert             1     6     5     sqlite_stat1   0   intkey=r[5] data=r[6]
18    Halt               0     0     0                    0
19    String8            0     3     0     iiftest        0   r[3]='iiftest'
20    Goto               0     1     0                    0

Note the missing support for LoadAnalysis and Expire, but there's no
optimizer work done yet to leverage any gathered statistics yet anyway.
2025-08-22 23:18:53 -07:00
..
benches adjust mvcc code to return completions in state machines 2025-08-13 10:24:55 +03:00
ext Remove extension Conn from VirtualTable to survive schema changes 2025-08-06 16:27:26 -04:00
functions Merge 'Add documentation and rename functions' from Mikaël Francoeur 2025-08-16 17:45:33 -04:00
incremental remove unnecessary Box<ast::Select> 2025-08-21 17:20:25 -03:00
io unixio: use Mutex::lock() instead of Mutex::try_lock() 2025-08-22 10:47:50 +03:00
json rename functions 2025-08-15 17:08:53 -04:00
mvcc Merge 'core/mvcc: store txid in conn and reset transaction state on commit ' from Pere Diaz Bou 2025-08-20 16:51:41 +03:00
numeric chore: fix clippy warnings 2025-06-23 19:52:13 +01:00
storage Merge 'wal-api: allow to mix frames insert with SQL execution' from Nikita Sivukhin 2025-08-22 15:41:43 +03:00
time Move time extension to core 2025-06-30 10:01:03 +03:00
translate Add basic support for ANALYZE statement. 2025-08-22 23:18:53 -07:00
vdbe complete parser integration 2025-08-21 15:23:59 -03:00
vector rename functions 2025-08-15 17:08:53 -04:00
assert.rs core: Add Antithesis-aware turso_assert 2025-06-29 11:46:18 +03:00
build.rs implement sqlite_source_id function 2025-01-28 14:55:38 -05:00
Cargo.toml switch to new parser 2025-08-21 15:19:16 -03:00
error.rs complete parser integration 2025-08-21 15:23:59 -03:00
fast_lock.rs chore: fix clippy warnings 2025-06-23 19:52:13 +01:00
function.rs add unlikely to resolve function 2025-08-12 16:42:38 +05:30
info.rs implement sqlite_source_id function 2025-01-28 14:55:38 -05:00
lib.rs Merge 'wal-api: allow to mix frames insert with SQL execution' from Nikita Sivukhin 2025-08-22 15:41:43 +03:00
parameters.rs Consolidate match case in parameters push to handle all anonymous params in one case 2025-05-13 14:42:12 -04:00
pragma.rs switch to new parser 2025-08-21 15:19:16 -03:00
pseudo.rs chore: fix clippy warnings 2025-06-23 19:52:13 +01:00
result.rs Fix transaction read0 shortcut in WAL and track whether we have snapshot 2025-07-30 14:08:33 +03:00
schema.rs fix: incorrect sql statement in parser test 2025-08-21 15:24:01 -03:00
series.rs Replace ConstraintInfo::plan_info with ConstraintInfo::index 2025-08-05 05:48:29 +02:00
state_machine.rs adjust mvcc code to return completions in state machines 2025-08-13 10:24:55 +03:00
types.rs switch to new parser 2025-08-21 15:19:16 -03:00
util.rs complete parser integration 2025-08-21 15:23:59 -03:00
uuid.rs Move UUID extension to core 2025-06-30 09:54:13 +03:00
vtab.rs complete parser integration 2025-08-21 15:23:59 -03:00
vtab_view.rs Implement very basic views using DBSP 2025-08-10 23:34:04 -05:00