limbo/testing
Pekka Enberg 3e28541b53 Merge 'Fix null compare operations not giving null' from Vrishabh
In limbo when we do any compare operations like `Eq, gt, lt, gte, lte`
with nulls , we were actually giving the result as true where as sqlite3
gives null. This is because if we had a null, we were incorrectly going
to conditional branch and not increment program by 1. Also the sqlite
generates `ZeroOrNull` op in these cases
(https://github.com/sqlite/sqlite/blob/version-3.45.3/src/expr.c#L4644)
but we were generating a Integer instruction. The below outputs can give
a clearer picture.
This PR aims to fix this.
sqlite3 output
```
SQLite version 3.48.0
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> select 8 = null;

sqlite> select 8 > null;

sqlite> explain select 8 > null;
addr  opcode         p1    p2    p3    p4             p5  comment
----  -------------  ----  ----  ----  -------------  --  -------------
0     Init           0     6     0                    0
1     Integer        1     1     0                    0
2     Gt             3     4     2                    64
3     ZeroOrNull     2     1     3                    0
4     ResultRow      1     1     0                    0
5     Halt           0     0     0                    0
6     Integer        8     2     0                    0
7     Null           0     3     0                    0
8     Goto           0     1     0                    0
sqlite> explain select 8 = null;
addr  opcode         p1    p2    p3    p4             p5  comment
----  -------------  ----  ----  ----  -------------  --  -------------
0     Init           0     6     0                    0
1     Integer        1     1     0                    0
2     Eq             3     4     2                    64
3     ZeroOrNull     2     1     3                    0
4     ResultRow      1     1     0                    0
5     Halt           0     0     0                    0
6     Integer        8     2     0                    0
7     Null           0     3     0                    0
8     Goto           0     1     0                    0
```
Limbo Output
```
Limbo v0.0.12
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database
limbo> select 8 = null;
1
limbo> select 8 > null;
1
limbo> explain select 8 > null;
addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     8     0                    0   Start at 8
1     Integer            8     2     0                    0   r[2]=8
2     Null               0     3     0                    0   r[3]=NULL
3     Integer            1     1     0                    0   r[1]=1
4     Gt                 2     3     6                    0   if r[2]>r[3] goto 6
5     Integer            0     1     0                    0   r[1]=0
6     ResultRow          1     1     0                    0   output=r[1]
7     Halt               0     0     0                    0
8     Transaction        0     0     0                    0
9     Goto               0     1     0                    0
limbo> explain select 8 = null;
addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     8     0                    0   Start at 8
1     Integer            8     2     0                    0   r[2]=8
2     Null               0     3     0                    0   r[3]=NULL
3     Integer            1     1     0                    0   r[1]=1
4     Eq                 2     3     6                    0   if r[2]==r[3] goto 6
5     Integer            0     1     0                    0   r[1]=0
6     ResultRow          1     1     0                    0   output=r[1]
7     Halt               0     0     0                    0
8     Transaction        0     0     0                    0
9     Goto               0     1     0                    0
limbo>
```
Limbo Output with this PR
```
Limbo v0.0.12
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database
limbo> select 8 = null;

limbo> select 8 > null;

limbo> explain select 8 > null;
addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     8     0                    0   Start at 8
1     Integer            8     2     0                    0   r[2]=8
2     Null               0     3     0                    0   r[3]=NULL
3     Integer            1     1     0                    0   r[1]=1
4     Gt                 2     3     6                    0   if r[2]>r[3] goto 6
5     ZeroOrNull         2     1     3                    0   ((r[2]=NULL)|(r[3]=NULL)) ? r[1]=NULL : r[1]=0
6     ResultRow          1     1     0                    0   output=r[1]
7     Halt               0     0     0                    0
8     Transaction        0     0     0                    0
9     Goto               0     1     0                    0
limbo>  explain select 8 = null;
addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     8     0                    0   Start at 8
1     Integer            8     2     0                    0   r[2]=8
2     Null               0     3     0                    0   r[3]=NULL
3     Integer            1     1     0                    0   r[1]=1
4     Eq                 2     3     6                    0   if r[2]==r[3] goto 6
5     ZeroOrNull         2     1     3                    0   ((r[2]=NULL)|(r[3]=NULL)) ? r[1]=NULL : r[1]=0
6     ResultRow          1     1     0                    0   output=r[1]
7     Halt               0     0     0                    0
8     Transaction        0     0     0                    0
9     Goto               0     1     0                    0
```

Closes #733
2025-01-19 09:09:12 +02: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 support TRUE and FALSE in predicates 2024-12-13 22:58:29 +02:00
all.test Add compare tests 2025-01-18 15:51:31 +05:30
cmdlineshell.test refactor(testing): move .table tests to shelltests.py 2024-12-18 09:10:37 +02:00
coalesce.test testing: coalesce.test 2024-07-16 07:20:35 +03:00
compare.test Add Null comparision tests 2025-01-19 00:39:10 +05:30
extensions.py 1. Changes to extension.py 2025-01-19 04:58:05 +05:30
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 Dont assume GROUP BY has aggregates 2024-12-16 00:30:38 +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 Merge branch 'main' into json-error-position 2025-01-13 18:21:37 +02:00
like.test Support like function with escape 2024-12-28 13:55:12 +05:30
math.test Implement ShiftRight 2025-01-15 21:21:51 +05:30
orderby.test test ordering by aggregate not mentioned in select 2024-11-26 17:31:51 +02:00
pragma.test pragma: inital approach to handle pragma statements 2024-12-18 17:26:16 +01:00
scalar-functions-datetime.test Julianday function and additional tests/comments 2025-01-04 10:42:34 -05:00
scalar-functions.test Fix sqlite_version() out of bound 2024-12-27 11:39:33 -03:00
select.test chore: rollback using rowid(sqlite3 unsupported) 2025-01-14 22:56:49 +08:00
shelltests.py Correct CLI comment handling to mimic sqlite behavior 2025-01-17 13:59:34 -05:00
subquery.test feat: subqueries in FROM clause 2024-12-31 14:18:29 +02:00
tester.tcl Add test function with regex 2024-12-27 11:39:02 -03: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
where.test Expr: fix recursive binary operation logic 2025-01-15 14:12:08 +02:00