Commit Graph

9678 Commits

Author SHA1 Message Date
Jussi Saurio
e68c652f8f Add some table ID integrity checks to logical log recovery 2025-09-30 22:27:28 +03:00
Jussi Saurio
64ce33bd5c Move resolution of tableid/rootpage inside MvCursor constructor 2025-09-30 17:04:37 +03:00
Jussi Saurio
7c897d382f Implement MvTableId newtype for better type safety of table ids 2025-09-30 16:54:22 +03:00
Jussi Saurio
0ba4c6c00e use negative table id in mvcc tests 2025-09-30 16:53:12 +03:00
Jussi Saurio
a52dbb7842 Handle table ID / rootpages properly for both checkpointed and non-checkpointed tables
Table ID is an opaque identifier that is only meaningful to the MV store.
Each checkpointed MVCC table corresponds to a single B-tree on the pager,
which naturally has a root page.

We cannot use root page as the MVCC table ID directly because:
- We assign table IDs during MVCC commit, but
- we commit pages to the pager only during checkpoint
which means the root page is not easily knowable ahead of time.

Hence, we:

- store the mapping between table id and btree rootpage
- sqlite_schema rows will have a negative rootpage column if the
  table has not been checkpointed yet.
2025-09-30 16:53:12 +03:00
Jussi Saurio
a1bdad58b6 mvcc: add test to verify that reading both checkpointed and non-checkpointed tables works 2025-09-30 16:53:11 +03:00
Pekka Enberg
9788f6d005 Merge 'core/mvcc: Optimize exclusive transaction check' from Pekka Enberg
The check is in fastpath so switch to an atomic instead.

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

Closes #3458
2025-09-30 16:02:42 +03:00
Jussi Saurio
81e7c26f55 Merge 'Anonymous params fix' from Nikita Sivukhin
This PR auto-assign ids for anonymous variables straight into parser.
Otherwise - it's pretty easy to mess up with traversal order in the core
code and assign ids incorrectly.
For example, before the fix, following code worked incorrectly because
parameter values were assigned first to conflict clause instead of
values:
```rs
let mut stmt = conn.prepare("INSERT INTO test VALUES (?, ?), (?, ?) ON CONFLICT DO UPDATE SET v = ?")?;
stmt.bind_at(1.try_into()?, Value::Integer(1));
stmt.bind_at(2.try_into()?, Value::Integer(20));
stmt.bind_at(3.try_into()?, Value::Integer(3));
stmt.bind_at(4.try_into()?, Value::Integer(40));
stmt.bind_at(5.try_into()?, Value::Integer(66));
```

Closes #3455
2025-09-30 15:48:35 +03:00
Pekka Enberg
3d327ba63c core/mvcc: Optimize exclusive transaction check
The check is in fastpath so switch to an atomic instead.
2025-09-30 15:00:24 +03:00
Nikita Sivukhin
e111226f3b add comment 2025-09-30 15:28:50 +04:00
Nikita Sivukhin
c955487c5f remove unnecessary enum variant 2025-09-30 14:52:59 +04:00
Nikita Sivukhin
8f005b31f4 fix bug in parameters binding 2025-09-30 14:52:30 +04:00
Nikita Sivukhin
003547d83d fix clippy 2025-09-30 14:44:48 +04:00
Nikita Sivukhin
759ffc1770 fix clippy 2025-09-30 14:03:25 +04:00
Nikita Sivukhin
ab92102cd8 remove parameter id assign logic from core 2025-09-30 13:58:59 +04:00
Nikita Sivukhin
30a9b2b860 auto-assign anonymous parameters directly in the Parser
- otherwise it will be easy to mess up with the traversal order
2025-09-30 13:58:59 +04:00
Nikita Sivukhin
264cfdd1c0 add smiple test 2025-09-30 13:58:59 +04:00
Jussi Saurio
35b584f050 Merge 'core: change root_page to i64' from Pere Diaz Bou
Closes #3454
2025-09-30 12:50:23 +03:00
Jussi Saurio
2039120106 Merge 'core/storage: Remove unused import from encryption.rs' from Pekka Enberg
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3451
2025-09-30 12:45:40 +03:00
Pere Diaz Bou
2fff6bb119 core: page id to usize 2025-09-30 11:35:06 +02:00
Pekka Enberg
1b991156f3 Merge 'core/vdbe: Fix BEGIN after BEGIN CONCURRENT check' from Pekka Enberg
We're supposed to error out only when "is_begin" is true.

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

Closes #3450
2025-09-30 11:34:40 +03:00
Pekka Enberg
f8a9bb1158 core/storage: Remove unused import from encryption.rs 2025-09-30 11:13:35 +03:00
Pekka Enberg
9b83fe7abf core/vdbe: Fix BEGIN after BEGIN CONCURRENT check
We're supposed to error out only when "is_begin" is true.
2025-09-30 10:55:13 +03:00
Jussi Saurio
17826dc69b Merge 'small improvement of stress testing tool' from Nikita Sivukhin
Before, it omitted BEGIN/COMMIT/ROLLBACK statements which affects
reproducibility

Closes #3427
2025-09-30 10:41:43 +03:00
Nikita Sivukhin
9d7e28ac43 fix clippy 2025-09-30 11:39:17 +04:00
Jussi Saurio
9681377c51 Merge 'sum() can throw integer overflow' from Duy Dang
close #3311

Closes #3416
2025-09-30 10:38:37 +03:00
Nikita Sivukhin
f3a148b802 keep db file 2025-09-30 11:37:43 +04:00
Jussi Saurio
594bdce999 Merge 'sum should identify if there is num in strings/prefix of strings' from Pavan Nambi
closes #3285
maybe adding seperate func for it is stupid but i kept running into
issues with not closing some random `}` and it got annoying real quick
so i just moved tht into its own func. - and as i am using same logic in
3 places i think it's ok.

Closes #3412
2025-09-30 10:37:17 +03:00
Jussi Saurio
13ca94755e Merge 'correct span in ParseUnexpectedToken' from Lâm Hoàng Phúc
Closes #3447
2025-09-30 10:35:49 +03:00
Jussi Saurio
63906e8f44 Merge 'remove UnterminatedBlockComment error' from Lâm Hoàng Phúc
close #3425

Closes #3446
2025-09-30 10:35:23 +03:00
Jussi Saurio
e6a2e2a9cf Merge 'Remove double-quoted identifier assert' from Diego Reis
Closes #3301
Not every identifier should be double-quoted

Closes #3440
2025-09-30 10:34:49 +03:00
Jussi Saurio
568b0eeff3 Merge 'substr scalar should also work with non-text values' from Diego Reis
Closes #3306
Not only blobs, but numbers are also cast to text

Closes #3439
2025-09-30 10:33:40 +03:00
TcMits
04beead7fe correct span in ParseUnexpectedToken 2025-09-30 12:49:26 +07:00
TcMits
4211460ef3 fmt 2025-09-30 12:28:24 +07:00
TcMits
d3d6a015ec fix issue 3425 2025-09-30 12:25:20 +07:00
Pekka Enberg
2b59863447 Merge 'core/printf: Compatibility tests and fixes for printf()' from Luiz Gustavo
Addition of compatibilty tests for `printf()`.
While doing this I found some differences in the current implementation,
so this fixes those too.

Closes #3438
2025-09-30 07:44:35 +03:00
Pekka Enberg
57d8532dcc Merge 'add manual page about materialized views' from Glauber Costa
Closes #3435
2025-09-30 07:35:48 +03:00
Pekka Enberg
9a08fb9e43 core/translate: Remove useless comment from logical.rs 2025-09-30 07:35:12 +03:00
Pekka Enberg
6053bb6556 Merge 'Fix materialized views with complex expressions' from Glauber Costa
SQLite supports complex expressions in group by columns - because of
course it does...
So we need to make sure that a column is created for this expression if
it doesn't exist already, and compute it, the same way we compute pre-
projections in the filter operator.
Fixes #3363
Fixes #3366
Fixes #3365

Closes #3429
2025-09-30 07:34:51 +03:00
luizgfc
f1811794b9 core/testing: Basic sqlite compatibility tests for printf() 2025-09-30 01:02:12 -03:00
luizgfc
3093371f76 core/printf: Fix printf compatibility with %f, %x and %o substitutions 2025-09-30 01:02:09 -03:00
Diego Reis
8e60d64518 rename limbo -> turso 2025-09-29 22:33:39 -03:00
Diego Reis
90f4d69774 fix(3301): Remove identifier assert assumption
Not every identifier should be double-quoted
2025-09-29 22:33:21 -03:00
Diego Reis
c9421e034d fix(3306): substr scalar should also work with non-text values 2025-09-29 21:42:21 -03:00
luizgfc
5da6ed7499 core/printf: Fix null %s formatting behavior for sqlite compatibility 2025-09-29 21:26:47 -03:00
Glauber Costa
89956039be add manual page about materialized views 2025-09-29 15:49:37 -05:00
Pekka Enberg
75f088740d Merge 'core: Disallow CREATE INDEX when MVCC is enabled' from Pekka Enberg
MVCC does currently not support indexes. Therefore,
- Fail if a database with indexes is opened with MVCC
- Disallow `CREATE INDEX` when MVCC is enabled
Fixes: #3108

Closes #3426
2025-09-29 20:53:16 +03:00
Glauber Costa
2fde976605 Fix materialized views with complex expressions
SQLite supports complex expressions in group by columns - because of
course it does...

So we need to make sure that a column is created for this expression if
it doesn't exist already, and compute it, the same way we compute
pre-projections in the filter operator.

Fixes #3363
Fixes #3366
Fixes #3365
2025-09-29 11:56:21 -05:00
Pere Diaz Bou
af98067ff1 fmt 2025-09-29 18:40:17 +02:00
Pere Diaz Bou
0f631101df core: change page idx type from usize to i64
MVCC is like the annoying younger cousin (I know because I was him) that
needs to be treated differently. MVCC requires us to use root_pages that
might not be allocated yet, and the plan is to use negative root_pages
for that case. Therefore, we need i64 in order to fit this change.
2025-09-29 18:38:43 +02:00