Commit Graph

3898 Commits

Author SHA1 Message Date
Pekka Enberg
d67e1b604b Merge 'Added 'likelihood' scalar function' from Sachin Kumar Singh
The `likelihood(X,Y)` function returns argument X unchanged. The value Y
in likelihood(X,Y) must be a floating point constant between 0.0 and
1.0, inclusive.
```
sqlite> explain SELECT likelihood(42, 0.0);
addr  opcode         p1    p2    p3    p4             p5  comment
----  -------------  ----  ----  ----  -------------  --  -------------
0     Init           0     6     0                    0   Start at 6
1     Once           0     3     0                    0
2     Integer        42    2     0                    0   r[2]=42
3     Copy           2     1     0                    0   r[1]=r[2]
4     ResultRow      1     1     0                    0   output=r[1]
5     Halt           0     0     0                    0
6     Goto           0     1     0                    0
```
```
limbo> explain SELECT likelihood(42, 0.0);
addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     4     0                    0   Start at 4
1     Copy               2     1     0                    0   r[1]=r[2]
2     ResultRow          1     1     0                    0   output=r[1]
3     Halt               0     0     0                    0
4     Integer            42    2     0                    0   r[2]=42
5     Goto               0     1     0                    0
```

Closes #1303
2025-04-11 09:34:36 +03:00
Pekka Enberg
13516fd53d Merge 'feat: Add timediff data and time function' from Sachin Kumar Singh
This PR implemets the `timediff(A,B)` function, which returns a string
that describes the amount of time that must be added to B in order to
reach time A. I used sqlite's timediff function for format reference:
https://github.com/sqlite/sqlite/blob/master/src/date.c#L1694
Op-codes seems to be in order:
```
limbo> explain SELECT timediff('12:30:45.123', '12:30:44.987');
addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     6     0                    0   Start at 6
1     String8            0     2     0     12:30:45.123   0   r[2]='12:30:45.123'
2     String8            0     3     0     12:30:44.987   0   r[3]='12:30:44.987'
3     Function           0     2     1     timediff       0   r[1]=func(r[2..3])
4     ResultRow          1     1     0                    0   output=r[1]
5     Halt               0     0     0                    0
6     Goto               0     1     0                    0
```
```
sqlite> explain SELECT timediff('12:30:45.123', '12:30:44.987');
addr  opcode         p1    p2    p3    p4             p5  comment
----  -------------  ----  ----  ----  -------------  --  -------------
0     Init           0     8     0                    0   Start at 8
1     Once           0     5     0                    0
2     String8        0     3     0     12:30:45.123   0   r[3]='12:30:45.123'
3     String8        0     4     0     12:30:44.987   0   r[4]='12:30:44.987'
4     Function       3     3     2     timediff(2)    0   r[2]=func(r[3..4])
5     Copy           2     1     0                    0   r[1]=r[2]
6     ResultRow      1     1     0                    0   output=r[1]
7     Halt           0     0     0                    0
8     Goto           0     1     0                    0
```
My first PR, I just followed the [contributing guides](https://github.co
m/tursodatabase/limbo/blob/main/CONTRIBUTING.md) and started.

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1302
2025-04-11 09:34:04 +03:00
Sachin Singh
23ab387143 handle formatting issues 2025-04-11 09:59:27 +05:30
Pekka Enberg
2f428b7dcc Merge 'Fix overwrite cell with size less than cell size' from Pere Diaz Bou
We cannot simply paste a new payload into a cell with a payload with
less size because we need to track fragmentation + free blocks. Let's
keep it simple by only overwriting if size is the same.
Btw I feel like update is not re-entrant.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1301
2025-04-11 07:17:53 +03:00
Sachin Singh
01fa02364d correctly handle edge cases 2025-04-11 08:34:29 +05:30
Sachin Singh
5ffdd42f12 Additional tests 2025-04-11 06:02:07 +05:30
Sachin Singh
482e93bfd0 feat: add likelihood scalar function 2025-04-11 05:54:23 +05:30
Sachin Singh
05b4b7b9f1 edit compat.md 2025-04-11 04:41:59 +05:30
Sachin Singh
ded308ccfa additional tests 2025-04-11 04:40:09 +05:30
Sachin Singh
b7acfa490c feat: add timediff data and time function 2025-04-11 04:30:57 +05:30
Pere Diaz Bou
745c2b92d0 unnecessary dirty set on overwrite 2025-04-10 22:24:15 +02:00
Pere Diaz Bou
038d78f096 overwrite when payload is equal size as current cell only
Prevoiusly we would overwrite even though size less than cell size. This
was wrong because it didn't update any fragment size or free blocks it
could. To be safe let's just overwrite only if local size is the same
amount.
2025-04-10 22:24:15 +02:00
Pere Diaz Bou
506c1a236c find_free_cell fix use of no_offset writes 2025-04-10 22:24:15 +02:00
Pekka Enberg
17b206297e Merge 'Emit ANSI codes only when tracing is outputting to terminal' from Preston Thorpe
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1289
2025-04-10 20:54:21 +03:00
Pekka Enberg
ef893da6c7 Merge 'core/btree: Add PageContent::new() helper' from Pekka Enberg
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1294
2025-04-10 20:53:41 +03:00
Pekka Enberg
a27126cd05 Merge 'B-Tree code cleanups' from Pekka Enberg
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #1290
2025-04-10 20:53:33 +03:00
Pekka Enberg
1d748de273 Merge 'btree index selection on rightmost pointer in balance_non_root' from Pere Diaz Bou
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1297
2025-04-10 18:39:51 +03:00
Pekka Enberg
712a4caa22 stress: Fix per-thread query generation 2025-04-10 18:39:20 +03:00
Pere Diaz Bou
62d0febdb6 panic on corruption 2025-04-10 16:01:24 +02:00
Pere Diaz Bou
b35d805a81 tracing lock stress 2025-04-10 16:01:24 +02:00
Pere Diaz Bou
8e93471d00 fix cell index selection while balancing
Cell index doesn't move in `move_to` unless we don't need to check next
cell. On the other hand, with rightmost pointer, we advance cell index
by 1 even though where we are moving to was to that page
2025-04-10 16:01:24 +02:00
Pere Diaz Bou
4755acb571 init tracing in stress tool 2025-04-10 16:01:24 +02:00
Pere Diaz Bou
0c4e56ecf9 Merge 'Add support to load log file with stress test' from Pere Diaz Bou
run with: `RUST_BACKTRACE=1 cargo run -p limbo_stress -- -t 1 -l`
and then if you want to repeat same plan: `RUST_BACKTRACE=1 cargo run -p
limbo_stress -- -t 1 -L`

Closes #1296
2025-04-10 16:01:11 +02:00
Pere Diaz Bou
cdcbcafbdd clipppy 2025-04-10 13:46:40 +02:00
Pere Diaz Bou
f795a9e331 Add support to load log file with stress test 2025-04-10 13:41:10 +02:00
Jussi Saurio
579d04f521 Merge 'io/linux: make syscallio the default (io_uring is really slow)' from Jussi Saurio
context: https://github.com/tursodatabase/limbo/issues/1275

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #1295
2025-04-10 13:55:06 +03:00
Jussi Saurio
60a13c129f io/linux: make syscallio the default (io_uring is really slow) 2025-04-10 13:32:26 +03:00
Pekka Enberg
53633e8b6f core/btree: Add PageContent::new() helper 2025-04-10 13:14:38 +03:00
Pekka Enberg
6ffa9cf56a Merge 'Stress improvements' from Pekka Enberg
Closes #1292
2025-04-10 12:18:53 +03:00
Pekka Enberg
277efeb5ee Merge 'VDBE code cleanups' from Pekka Enberg
Closes #1291
2025-04-10 12:10:22 +03:00
Pekka Enberg
3fd378cf9f Fix Antithesis Dockerfile to include JavaScript bindings 2025-04-10 12:08:31 +03:00
Pekka Enberg
441cd637b5 stress: Make database file configurable 2025-04-10 11:59:25 +03:00
Pekka Enberg
c4d983bcfe stress: Log SQL statements to a file 2025-04-10 11:59:25 +03:00
Pekka Enberg
39cee1b146 stress: Increase default number of iterations 2025-04-10 11:59:25 +03:00
Pekka Enberg
f50662205e stress: Fix schema creation 2025-04-10 11:59:25 +03:00
Pekka Enberg
207563208f stress: Add support for INSERT, DELETE, and UPDATE 2025-04-10 11:59:25 +03:00
Pekka Enberg
6aaa105321 stress: Add schema generation support 2025-04-10 11:43:32 +03:00
Pekka Enberg
31f0d174d7 core/vdbe: Move exec_*() funtions to execute.rs 2025-04-10 09:42:03 +03:00
Pekka Enberg
3fd51cdf06 core/vdbe: Move Insn implementation close to struct definition 2025-04-10 09:28:43 +03:00
Pekka Enberg
5906d7971a core/vdbe: Clean up imports 2025-04-10 09:25:15 +03:00
Pekka Enberg
a7fa7f7c62 core/btree: Unify debug() tracing 2025-04-10 08:39:07 +03:00
Pekka Enberg
761c03f7c5 core/btree: Clean up B-Tree offset comments 2025-04-10 08:27:55 +03:00
Pekka Enberg
86a4d3e33b core/btree: Move B-Tree header offsets in a module
The grouping (with a fancy comment) makes the code a bit more readable.
2025-04-10 08:19:08 +03:00
Pekka Enberg
11782cbff8 core/btree: Clean up imports 2025-04-10 07:52:10 +03:00
PThorpe92
5643a0abba Dont emit ansi codes when outputting logs to a file 2025-04-09 19:31:35 -04:00
Pekka Enberg
b6718471ce Merge 'Fix EXPLAIN to be case insensitive' from Pedro Muniz
Closes #1286

Closes #1287
2025-04-09 20:23:09 +03:00
pedrocarlo
94217319a2 Fix Explain to be case insensitive 2025-04-09 14:21:18 -03:00
Pekka Enberg
e21e2b5449 Merge 'core: Fix syscall VFS on Linux' from Pekka Enberg
Fix the syscall VFS on Linux not to use `PlatformIO`, which is just an
alias for `io_uring`.

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1285
2025-04-09 19:38:45 +03:00
Pekka Enberg
2d009083ba core: Fix syscall VFS on Linux
Fix the syscall VFS on Linux not to use `PlatformIO`, which is just an
alias for `io_uring`.
2025-04-09 19:27:58 +03:00
Pekka Enberg
a6e32c95d7 Merge 'Support UPDATE for virtual tables' from Preston Thorpe
closes #1144

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1169
2025-04-09 18:21:10 +03:00