limbo/testing
Pekka Enberg 2d3fd01f91 Merge 'Support Create Index' from Preston Thorpe
Closes #1193
```console
│limbo> explain create index idxp on products(price);
│addr  opcode             p1    p2    p3    p4             p5  comment
│----  -----------------  ----  ----  ----  -------------  --  -------
│0     Init               0     39    0                    0   Start at 39
│1     CreateBtree        0     1     2                    0   r[1]=root iDb=0 flags=2
│2     OpenWriteAsync     0     1     0                    0
│3     OpenWriteAwait     0     0     0                    0
│4     NewRowId           0     2     0                    0
│5     String8            0     3     0     index          0   r[3]='index'
│6     String8            0     4     0     idxp           0   r[4]='idxp'
│7     String8            0     5     0     products       0   r[5]='products'
│8     Copy               1     6     1                    0   r[6]=r[1]
│9     String8            0     7     0     CREATE INDEX idxp ON products (price)  0   r[7]='CREATE INDEX idxp ON products (price)'
│10    MakeRecord         3     5     8                    0   r[8]=mkrec(r[3..7])
│11    InsertAsync        0     8     2                    0
│12    InsertAwait        0     0     0                    0
│13    SorterOpen         3     1     0     k(1,B)         0   cursor=3
│14    OpenPseudo         4     9     2                    0   2 columns in r[9]
│15    OpenReadAsync      2     273   0                    0   table=products, root=273
│16    OpenReadAwait      0     0     0                    0
│17    RewindAsync        2     0     0                    0
│18    RewindAwait        2     25    0                    0   Rewind table products
│19      Column           2     2     10                   0   r[10]=products.price
│20      RowId            2     11    0                    0   r[11]=products.rowid
│21      MakeRecord       10    2     12                   0   r[12]=mkrec(r[10..11])
│22      SorterInsert     3     12    0     0              0   key=r[12]
│23    NextAsync          2     0     0                    0
│24    NextAwait          2     19    0                    0
│25    OpenWriteAsync     1     1     0                    0
│26    OpenWriteAwait     0     0     0                    0
│27    SorterSort         3     33    0                    0
│28      SorterData       3     13    4                    0   r[13]=data
│29      SeekEnd          1     0     0                    0
│30      IdxInsertAsync   1     13    0                    0   key=r[13]
│31      IdxInsertAwait   1     0     0                    0
│32    SorterNext         3     28    0                    0
│33    Close              3     0     0                    0
│34    Close              2     0     0                    0
│35    Close              1     0     0                    0
│36    ParseSchema        0     0     0     name = 'idxp' AND type = 'index'  0   name = 'idxp' AND type = 'index'
│37    Close              0     0     0                    0
│38    Halt               0     0     0                    0
│39    Transaction        0     1     0                    0   write=true
│40    Goto               0     1     0                    0
```
This will create the initial index btree and insert whatever relevant
records that need to be inserted, it doesn't handle the case of
inserting new index keys when normal records are created afterwards.
That will prob be added in next PR to keep this one concise.
Limbo will properly use the index in a subsequent query:
![image](https://github.com/user-
attachments/assets/eb41e985-4a70-49a5-8218-62c25e4d16c5)
Creating a unique index on a column that has 2 existing identical rows:
![image](https://github.com/user-
attachments/assets/ea46c720-5235-4451-81f0-25497ed9ee92)

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1199
2025-04-06 19:32:36 +03:00
..
cli_tests Merge 'Support Create Index' from Preston Thorpe 2025-04-06 19:32:36 +03:00
test_files Fix import csv failing when single quote is in string 2025-01-11 13:48:21 +05:30
wal testing: Add test database + WAL file 2024-08-03 12:16:34 +03:00
agg-functions.test add compat tests 2025-03-30 18:58:40 +03:00
all.test core/translate: Add support for default values in INSERT statements 2025-04-04 01:32:13 -03:00
changes.test Created basic tcl tests for changes and total_changes 2025-01-19 20:51:16 -05:00
cmdlineshell.test refactor(testing): move .table tests to shelltests.py 2024-12-18 09:10:37 +02:00
coalesce.test extend TCL tests for COALESCE 2025-02-09 22:01:33 +04:00
compare.test Add Null comparision tests 2025-01-19 00:39:10 +05:30
concat.test Added Concat Opcode 2025-01-21 00:29:23 +05:30
default_value.test core/translate: Add support for default values in INSERT statements 2025-04-04 01:32:13 -03:00
delete.test Add TCL tests for delete 2025-02-06 23:39:12 +05:30
drop_table.test core: Fix Destroy opcode root page handling 2025-03-24 10:54:49 +02:00
gen-database.py testing: update testing with products table and cross join test 2024-07-09 18:08:16 +02:00
glob.test Fix glob 2024-12-30 17:02:31 +05:30
groupby.test Support numeric column references in GROUP BY 2025-02-14 16:57:45 +02:00
insert.test Align MustBeInt logic with sqlite 2025-01-16 00:09:45 +05:30
join.test chore: rollback using rowid(sqlite3 unsupported) 2025-01-14 22:56:49 +08:00
json.test make tests pass 2025-03-30 18:58:38 +03:00
like.test Escape character is ignored in LIKE function #1051 2025-03-01 18:32:09 +01:00
math.test fix tests and return nan as null 2025-03-29 14:46:11 +02:00
offset.test Created TCL tests for select queries with offset 2025-01-26 16:40:30 -05:00
orderby.test select: fix bug with referring to a mixed-case alias 2025-02-14 16:40:58 +02:00
pragma.test Add read implementation of user_version pragma with ReadCookie opcode 2025-02-07 09:23:48 -05:00
scalar-functions-datetime.test strftime compatibility issue solved 2025-01-26 17:01:08 -03:00
scalar-functions-printf.test test fix 2025-02-04 21:02:51 +05:30
scalar-functions.test Add tests for corrected behavior around casting 2025-02-24 11:21:25 -05:00
select.test Merge 'Fix numeric conversion in SELECT -'e'' from Diego Reis 2025-03-27 08:58:57 +02:00
subquery.test Add failing tests for CTE functionality 2025-02-08 14:49:01 +02:00
tester.tcl implement is and is not where constraints 2025-01-31 23:01:49 -05:00
testing.db index scan wip foo doesnt work yet 2024-10-05 18:25:04 +03:00
testing_norowidalias.db Run all tcl tests on 2 separate dbs (1. with rowid aliases 2. without rowid aliases) 2024-12-14 17:13:45 +02:00
testing_small.db implement is and is not where constraints 2025-01-31 23:01:49 -05:00
testing_small.db-wal implement is and is not where constraints 2025-01-31 23:01:49 -05:00
testing_user_version_10.db Add read implementation of user_version pragma with ReadCookie opcode 2025-02-07 09:23:48 -05:00
time.test extensions/time: normalize offset_sec 2025-02-19 21:25:14 +08:00
total-changes.test Created basic tcl tests for changes and total_changes 2025-01-19 20:51:16 -05:00
transactions.test Implement deferred transactions 2025-03-17 10:01:00 -03:00
update.test Remove update limit tests from compat tcl tests 2025-03-30 12:15:25 -04:00
vector.test testing: Add few TCL tests for vector extensions 2025-01-28 14:24:09 +02:00
where.test Fix not evaling constant conditions when no tables in query 2025-02-17 13:10:27 +02:00