Commit Graph

8204 Commits

Author SHA1 Message Date
Pekka Enberg
ca7f1002b4 Merge 'Change views to use DBSP circuits' from Glauber Costa
Instead of using static elements, use a dynamically generated DBSP-
circuit to keep views.
The DBSP circuit is generated from the logical plan, which only supports
enough for us to generate the DBSP circuit at the moment.
The state of the view is still kept inside the IncrementalView, instead
of materialized at the operator level. As a consequence, this still
depends on us always populating the view at startup. Fixing this is the
next step.

Closes #2815
2025-08-30 08:44:06 +03:00
Pekka Enberg
e684121469 Merge 'CLI: implement Line output .mode' from Andrey Oskin
This is implementation of #2801, basically repeating of `sqlite` output.
1. I do not want any bike-shedding, so I am totally fine with sqlite
version. For me it was mainly fun trying to work with Rust. On the other
hand, if it will be needed to do it somehow differently, than I am
totally fine with that. Even more fun :-)
2. I do not know where tests for this kind of things are, sorry. If
tests are needed and somebody can point to me to the place where they
can be found, I'll be more than happy to add them as well.
Currently, I can only show how it looks like this way:
```bash
> target/debug/tursodb -m records ../db1
Turso v0.1.4
Enter ".help" for usage hints.
This software is ALPHA, only use for development, testing, and experimentation.
turso> CREATE TABLE test(x INT, some_text TEXT, val DOUBLE);
turso> INSERT INTO test VALUES (100, "very important info", 23.12), (2, NULL, 3.14159265), (98, "yet another very important and long text record", NULL);
turso> SELECT * FROM test;
        x = 100
some_text = very important info
      val = 23.12

        x = 2
some_text = 
      val = 3.14159265

        x = 98
some_text = yet another very important and long text record
      val = 
```

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2835
2025-08-30 08:43:31 +03:00
Pekka Enberg
0c16ca9ce9 Merge 'core/wal: cache file size' from Pere Diaz Bou
Closes #2829
2025-08-30 08:41:58 +03:00
Pekka Enberg
e357909cda Merge 'Propagate decryption error from the callback' from Avinash Sajjanshetty
Reviewed-by: Pedro Muniz (@pedrocarlo)

Closes #2843
2025-08-30 08:40:47 +03:00
Pekka Enberg
352099e8ae Merge 'add sqlite integrity check back' from Pedro Muniz
Closes #2719

Reviewed-by: Avinash Sajjanshetty (@avinassh)

Closes #2849
2025-08-30 08:40:21 +03:00
Arkoniak
2c0e3cf593 feat: consistent interrupt event processing (#2801) 2025-08-30 06:57:14 +03:00
Arkoniak
cb602d960d feat: records output (#2801) 2025-08-30 06:57:14 +03:00
Preston Thorpe
c844d91866 Merge 'Remove some code duplication in the CLI' from Preston Thorpe
Just some minor refactoring

Closes #2845
2025-08-29 21:48:53 -04:00
Preston Thorpe
18a9a38c8e Merge ' core/translate: parse_table remove unnecessary clone of table name ' from Pere Diaz Bou
```

Benchmarking Prepare `SELECT first_name, count(1) FROM users GROUP BY first_name HAVING count(1) > 1 ORDER BY cou...: Collecting 100 samples in estimated 5.008
Prepare `SELECT first_name, count(1) FROM users GROUP BY first_name HAVING count(1) > 1 ORDER BY cou...
                        time:   [4.0081 µs 4.0223 µs 4.0364 µs]
                        change: [-2.9298% -2.2538% -1.6786%] (p = 0.00 < 0.05)
                        Performance has improved.
                        ```

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2847
2025-08-29 21:45:58 -04:00
Preston Thorpe
4a0655f2b8 Merge 'Update COMPAT.md to remove CREATE INDEX default disabled' from Preston Thorpe
Closes #2854
2025-08-29 20:58:30 -04:00
PThorpe92
8257496411 Update COMPAT.md to remove CREATE INDEX default disabled 2025-08-29 20:44:09 -04:00
Preston Thorpe
0899711439 Merge 'core/translate: remove unneessary agg clones' from Pere Diaz Bou
```
Prepare `SELECT first_name, count(1) FROM users GROUP BY first_name HAVING count(1) > 1 ORDER BY cou...
                        time:   [3.9978 µs 4.0085 µs 4.0193 µs]
                        change: [-5.0734% -4.6271% -4.1644%] (p = 0.00 < 0.05)
```

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2846
2025-08-29 11:40:53 -04:00
pedrocarlo
bcd70488ae add sqlite integrity check back 2025-08-29 12:25:27 -03:00
Pere Diaz Bou
d72be206f2 core/translate: parse_table remove unnecessary clone of table name 2025-08-29 16:42:46 +02:00
Pere Diaz Bou
167459389b core/translate: remove unneessary agg clones 2025-08-29 16:23:44 +02:00
Preston Thorpe
dc34097581 Merge 'core/vdbe: Micro-optimize "zero_or_null" opcode' from Pekka Enberg
It's a hot instruction for TPC-H, for example, so worth optimizing.
Reduces op_zero_or_null() from 5.6% to 2.4% in CPU flamegraph for TCP-H
Q1.

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2842
2025-08-29 10:23:31 -04:00
Preston Thorpe
eb0f2b7029 Merge 'translate: with_capacity insns' from Pere Diaz Bou
Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2831
2025-08-29 10:23:09 -04:00
PThorpe92
959bc6ba74 Remove unused argument from handle_row fn 2025-08-29 10:18:49 -04:00
PThorpe92
5b73fad5d4 Remove some code duplication in the CLI 2025-08-29 10:15:07 -04:00
Avinash Sajjanshetty
bb591ab7e1 Propagate decryption erorr when reading from WAL 2025-08-29 18:07:38 +05:30
Avinash Sajjanshetty
95d14f5f1f Propagate decryption error from the callback 2025-08-29 18:02:56 +05:30
Pekka Enberg
9fc5947fa6 core/vdbe: Micro-optimize "zero_or_null" opcode
It's a hot instruction for TPC-H, for example, so worth optimizing.
Reduces op_zero_or_null() from 5.6% to 2.4% in CPU flamegraph for TCP-H
Q1.
2025-08-29 14:38:50 +03:00
Pere Diaz Bou
db5e2883ee core/wal: cache wal is initialized 2025-08-29 13:15:09 +02:00
Pekka Enberg
13e62ce435 Merge 'core: Initial pass on synchronous pragma' from Pekka Enberg
This adds support for "OFF" and "FULL" (default) synchronous modes. As
future work, we need to add NORMAL and EXTRA as well because
applications expect them.

Closes #2833
2025-08-29 07:27:12 +03:00
Pekka Enberg
70ae983685 Merge 'perf: avoid constructing PageType in helper methods' from Jussi Saurio
I think the `try_into()` is probably expensive. we can use the fact that
both interior page types are `<=5` to our advantage for a little perf
boost in these hot path function calls
Based on #2836 (just to see aggregate perf difference in benchmarks)

Closes #2837
2025-08-29 07:27:02 +03:00
Pekka Enberg
96778cfb0a Merge 'refactor/perf: remove BTreePageInner' from Jussi Saurio
it wasn't used for anything. no more `page.get().get().id`.
i did this simply to clean up the code (we haven't needed BTreePageInner
in probably at least 8 months or more?), but it also:
- makes practically every tpc-h query faster due to removing indirection
and refcell runtime borrowing every time the btree stack is accessed etc
- makes every SELECT * FROM users bench query faster
- drops the count() benchmark runtime by like half

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2836
2025-08-29 07:26:56 +03:00
Jussi Saurio
ae0ac189fa perf: avoid constructing PageType for helper methods 2025-08-28 22:56:44 +03:00
Jussi Saurio
ce860b7ec9 clippy 2025-08-28 21:48:29 +03:00
Jussi Saurio
9aae3fa859 refactor: remove BTreePageInner
it wasn't used for anything. no more `page.get().get().id`.
2025-08-28 21:44:54 +03:00
Pekka Enberg
3952dbb445 Merge 'Fix sorter column deduplication' from Piotr Rżysko
Previously, the added test case failed because the last result column
was missing - a nonexistent column in the sorter was referenced.

Closes #2824
2025-08-28 18:29:44 +03:00
Pekka Enberg
2ea4354afe Merge 'Improve integrity check' from Nikita Sivukhin
- check free list trunk and pages
- use shared hash map to check for duplicate references for pages
- properly check overflow pages

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

Closes #2816
2025-08-28 16:06:15 +03:00
Pekka Enberg
44ed4d562f core: Initial pass on synchronous pragma
This adds support for "OFF" and "FULL" (default) synchronous modes. As
future work, we need to add NORMAL and EXTRA as well because
applications expect them.
2025-08-28 16:02:41 +03:00
Pekka Enberg
878147b931 Merge 'translate/insert: Improve string format performance' from Pere Diaz Bou
Rust's `fmt!` is slow af for the simplest of cases, let's just create
strings with a known size and skip all the fmt stuff.

Closes #2832
2025-08-28 14:36:09 +03:00
Pekka Enberg
a5322d2ab7 Merge 'core/schema: get_dependent_materialized_views_unnormalized' from Pere Diaz Bou
If we get a table name for in memory structure, it's safe to assume it's
already normalized.

Closes #2830
2025-08-28 14:34:06 +03:00
Pekka Enberg
eba90e1c5e Merge 'core/util: emit literal, cow instead of replace' from Pere Diaz Bou
Closes #2828
2025-08-28 14:33:04 +03:00
Pekka Enberg
44e619be1a Merge 'core/translate: sanize_string fast path improvement' from Pere Diaz Bou
Closes #2827
2025-08-28 14:32:43 +03:00
Pere Diaz Bou
964422375e translate/insert: string fmt perf improvmenets 2025-08-28 13:22:54 +02:00
Pere Diaz Bou
c7230f4ab0 translate: with_capacity insns 2025-08-28 13:13:19 +02:00
Pere Diaz Bou
48e5ad7a55 core/schema: get_dependent_materialized_views_unnormalized
If we get a table name for in memory structure, it's safe to assume it's
already normalized.
2025-08-28 13:11:40 +02:00
Pere Diaz Bou
84c5c4e581 core/util: emit literal, cow instead of replace 2025-08-28 12:59:55 +02:00
Pere Diaz Bou
082f18c073 core/translate: sanize_string fast path improvement 2025-08-28 12:57:28 +02:00
Piotr Rzysko
c383d9f16e Remove outdated comment in order_by.rs
The removed comment no longer matches the current code. The
OrderByRemapping struct and the surrounding comments are sufficient to
explain deduplication and remapping.
2025-08-28 09:49:55 +02:00
Piotr Rzysko
e33c2e0f0b Fix sorter column deduplication
Previously, the added test case failed because the last result column
was missing - a nonexistent column in the sorter was referenced.
2025-08-28 09:49:55 +02:00
Pekka Enberg
b4eba8b456 Merge 'Fix planner alias and table name handling' from
closes: #2817
```
turso> select * from simple_view as "v" where "v"."x" = 1;
┌───┐
│ x │
├───┤
│ 1 │
└───┘
turso> select "s"."x" from simple as "s" where "s"."x" = 1;
┌───┐
│ x │
├───┤
│ 1 │
└───
```

Reviewed-by: Preston Thorpe <preston@turso.tech>
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #2818
2025-08-28 07:39:47 +03:00
Pekka Enberg
591914a63b Merge 'Introduce and propagate IOContext as required' from Avinash Sajjanshetty
I added `IOContext` to `DatbaseStorage` IO trait and this struct will
carry the necessary ctx required for encryption (or checksums.). This
lets us set the encryption at outside and let the IO layer handle it
properly

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2812
2025-08-28 07:38:52 +03:00
Pekka Enberg
20260c9dc0 Merge 'core/io: Switch Unix I/O to use libc::pwrite()' from Pekka Enberg
We use libc elsewhere for fault injection reasons, so let's do this
call-site too.

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

Closes #2811
2025-08-28 07:38:42 +03:00
Pekka Enberg
376dbc9261 Merge 'Update README.md for Go documentation' from Preston Thorpe
Closes #2819
2025-08-28 07:38:20 +03:00
PThorpe92
1526448089 Update README.md for Go documentation 2025-08-27 22:23:19 -04:00
themixednuts
79a9f4743e fix: planner alias and table name 2025-08-27 18:13:03 -05:00
Nikita Sivukhin
1c0efcfbff fix clippy 2025-08-27 23:22:21 +04:00