penberg / limbo

Limbo is a work-in-progress, in-process OLTP database management system, compatible with SQLite.
MIT License
895 stars 49 forks source link

Implement coalesce && refactor/rename a few things in the labeling system #136

Closed jussisaurio closed 1 month ago

jussisaurio commented 1 month ago

New features:


Jump handling changes:


EXPLAIN outputs:

limbo:

> explain select id, coalesce(age, 100) from users limit 1;
addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     15    0                    0   Start at 15
1     Integer            0     1     0                    0   
2     OpenReadAsync      0     2     0                    0   root=2
3     OpenReadAwait      0     0     0                    0   
4     RewindAsync        0     0     0                    0   
5     RewindAwait        0     13    0                    0   
6       RowId            0     1     0                    0   
7       Column           0     9     2                    0   r[2]= cursor 0 column 9
8       NotNull          2     10    0                    0   r[2] -> 10
9       Integer          2     100   0                    0   
10      ResultRow        1     2     0                    0   output=r[1..3]
11      DecrJumpZero     0     14    0                    0   
12    NextAsync          0     0     0                    0   
13    NextAwait          0     5     0                    0   
14    Halt               0     0     0                    0   
15    Transaction        0     0     0                    0   
16    Goto               0     1     0                    0 

sqlite3:

sqlite> explain select id, coalesce(age, 100) from users limit 1;
addr  opcode         p1    p2    p3    p4             p5  comment      
----  -------------  ----  ----  ----  -------------  --  -------------
0     Init           0     12    0                    0   Start at 12
1     Integer        1     1     0                    0   r[1]=1; LIMIT counter
2     OpenRead       0     2     0     10             0   root=2 iDb=0; users
3     Rewind         0     11    0                    0   
4       Rowid          0     2     0                    0   r[2]=users.rowid
5       Column         0     9     3                    0   r[3]= cursor 0 column 9
6       NotNull        3     8     0                    0   if r[3]!=NULL goto 8
7       Integer        100   3     0                    0   r[3]=100
8       ResultRow      2     2     0                    0   output=r[2..3]
9       DecrJumpZero   1     11    0                    0   if (--r[1])==0 goto 11
10    Next           0     4     0                    1   
11    Halt           0     0     0                    0   
12    Transaction    0     0     2     0              1   usesStmtJournal=0
13    Goto           0     1     0                    0