Commit Graph

9589 Commits

Author SHA1 Message Date
Nikita Sivukhin
00114d9674 remove quotes handling from normalization util 2025-09-29 11:00:19 +04:00
Nikita Sivukhin
86a95e813d Merge branch 'main' into quoting-fix-attempt-2 2025-09-29 10:58:51 +04:00
Pekka Enberg
fda1b89540 Merge 'core/storage: Wrap WalFile::{max,min}_frame with AtomicU64' from Pekka Enberg
Closes #3414
2025-09-28 17:42:10 +03:00
Pekka Enberg
d3abeb6281 core/storage: Wrap WalFile::{max,min}_frame with AtomicU64 2025-09-28 16:47:54 +03:00
Pekka Enberg
2da6206c0b Merge 'core/storage: Wrap WalFile::max_frame_read_lock_index with AtomicUsize' from Pekka Enberg
Closes #3411
2025-09-28 14:16:49 +03:00
Pekka Enberg
250ac66c36 github: Increase tpc-h-criterion timeout to 60 minutes 2025-09-28 14:16:18 +03:00
Pekka Enberg
aba596441c core/storage: Wrap WalFile::max_frame_read_lock_index with AtomicUsize 2025-09-28 13:42:32 +03:00
Jussi Saurio
959165eed1 Merge 'core/storage: Mark Page as Send and Sync' from Pekka Enberg
Closes #3399
2025-09-28 08:08:46 +03:00
Jussi Saurio
02ca451c67 Merge 'Correct spelling issue in ForeignKey ast node' from Preston Thorpe
`deref_clause` -> `defer_clause`
(Yes I'm implementing foreign keys)

Closes #3407
2025-09-28 08:08:13 +03:00
Jussi Saurio
2d06375003 Merge 'Move turso.png image to assets directory' from Preston Thorpe
not the first time I deleted this file on accident earlier, it belongs
in `assets`

Closes #3405
2025-09-28 08:07:49 +03:00
Jussi Saurio
618cf2a4e7 Merge 'core/translate: rewrite default column value from identifier to string literal' from Preston Thorpe
closes #3390
closes #3389

Closes #3403
2025-09-28 08:07:11 +03:00
PThorpe92
30f80c2000 Correct spelling issue in ForeignKey ast node 2025-09-27 17:38:45 -04:00
Preston Thorpe
1bacd7ff64 Merge 'core/translate: Persist NOT NULL column constraint to schema table' from Preston Thorpe
closes #3391

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

Closes #3402
2025-09-27 14:34:53 -04:00
PThorpe92
4315a34939 Move png image to assets director 2025-09-27 14:13:45 -04:00
PThorpe92
ace2ac632a Remove semicolon from test 2025-09-27 13:59:51 -04:00
PThorpe92
03046faccb Translate default value Expr::Id to Literal to allow for identifier in col def 2025-09-27 13:56:04 -04:00
PThorpe92
6e3c30623c Fix regression test to not use dot command 2025-09-27 13:17:50 -04:00
PThorpe92
bd17c5d5df Add regression test for alter table with notnull constraint 2025-09-27 13:15:48 -04:00
PThorpe92
b7fc9fef40 Persist NOT NULL column constraint to schema table 2025-09-27 13:12:19 -04:00
Pekka Enberg
2f38d2ef04 Turso 0.2.0-pre.10 2025-09-27 16:52:35 +03:00
Pekka Enberg
9eb6f4b51e Merge 'Sqlean fuzzy string ' from Danawan Bimantoro
Add implementations of string distance and phonetics functions:
fuzzy_damlev
fuzzy_hamming
fuzzy_jarowin
fuzzy_leven
fuzzy_osadist
fuzzy_editdist
fuzzy_soundex
fuzzy_rsoundex
fuzzy_phonetic
fuzzy_caver
fuzzy_translit
This implementation follows sqlean-fuzzy

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

Closes #3262
2025-09-27 16:51:49 +03:00
Pekka Enberg
3d3e39a958 Merge 'Make Sorter Send and Sync' from Pekka Enberg
Closes #3398
2025-09-27 16:51:27 +03:00
Pekka Enberg
d7a0a3db56 Merge 'core/translate: allow creating column called 'rowid'' from Preston Thorpe
closes #3282
includes minor refactor, removing `column_is_rowid_alias`, which is only
checking the public field of the argument Column.

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

Closes #3385
2025-09-27 16:51:09 +03:00
Pekka Enberg
5ff0044961 Merge 'length shall not count when it sees nullc' from Pavan Nambi
fixes #3317

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

Closes #3356
2025-09-27 16:50:50 +03:00
Pekka Enberg
e34a935e0a Merge 'resolve column alias after rewritting column access in the expression in returning insert clause' from Nikita Sivukhin
Fixes https://github.com/tursodatabase/turso/issues/3295

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

Closes #3355
2025-09-27 16:50:42 +03:00
Pekka Enberg
2a8a0729c7 Merge 'core/storage: Wrap WalFile::syncing with AtomicBool' from Pekka Enberg
Closes #3397
2025-09-27 15:18:32 +03:00
Pekka Enberg
ce76aa11b2 core/storage: Mark Page as Send and Sync 2025-09-27 15:16:38 +03:00
Pekka Enberg
7b6fc0f3b6 core/vdbe: Wrap SortedChunk::total_bytes_read with AtomicUsize 2025-09-27 14:35:31 +03:00
Pekka Enberg
61b3f56997 core/vdbe: Wrap SortedChunk::io_state with RwLock 2025-09-27 14:28:55 +03:00
Pekka Enberg
4b189c930a Merge 'Fix materialized views where clause issues' from Glauber Costa
This PR fixes issues on WHERE clauses for Materialized Views.
Ultimately, the problems stem from how we had a positive list of what is
a "complex expression" (needs projection), defaulting everything else to
simple (doesn't need projection). I guess it is fair to call me naive.
It should obviously be the other way. Most expressions need computation
=)

Closes #3396
2025-09-27 14:27:06 +03:00
Pekka Enberg
5f39987ec0 core/vdbe: Wrap SortedChunk::buffer_len with AtomicUsize 2025-09-27 14:23:02 +03:00
Pekka Enberg
b31818f77c core/vdbe: Wrap SortedChunk::buffer with RwLock 2025-09-27 14:23:02 +03:00
Pekka Enberg
8d9d2dad1d core/storage: Wrap WalFile::syncing with AtomicBool 2025-09-27 14:07:26 +03:00
Glauber Costa
3ee97ddf36 Make sure complex expressions in filters go through Project
We had code for this, but the code had a fatal flaw: it tried to detect
a complex operation (an operation that needs projection), and return
false (no need for projection), for the others.

This is the exact opposite of what we should do: we should identify the
*simple* operations, and then return true (needs projection) for the
rest.

CAST is a special beast, since it is not a function, but rather, a
special opcode. Everything else above is the true just the same. But for
CAST, we have to do the extra work to capture it in the logical plan and
pass it down.

Fixes #3372
Fixes #3370
Fixes #3369
2025-09-27 07:21:03 -03:00
Pekka Enberg
9cd869f660 Merge 'Fix various ALTER TABLE bugs' from Jussi Saurio
Closes #3392 , Closes #3395
1. Prevent `ALTER TABLE t DROP COLUMN a` when exists e.g. `CREATE INDEX
ta ON t(a)`
2. Prevent `ALTER TABLE t DROP COLUMN a` when exists e.g. `CREATE INDEX
tba ON t(b) WHERE t.a > 100`
3. Prevent `ALTER TABLE t DROP COLUMN a` when exists e.g. `CREATE VIEW
ta AS SELECT a FROM t`;
and
4. Prevent `ALTER TABLE t RENAME a TO b` when exists e.g. `CREATE VIEW
ta AS SELECT a FROM t`;
Number 4 is incompatible with SQLite because we should be rewriting the
view to include the renamed column. I left that as a FIXME

Closes #3394
2025-09-27 11:10:46 +03:00
Jussi Saurio
283fba2e0d use normalized table name 2025-09-27 09:53:11 +03:00
Jussi Saurio
b43a89e423 Add regression tests for ALTER TABLE stuff 2025-09-27 09:45:15 +03:00
Jussi Saurio
67d320960d ALTER TABLE: prevent dropping/renaming column referenced in VIEW 2025-09-27 09:45:15 +03:00
Jussi Saurio
3137357092 ALTER TABLE: prevent dropping indexed column in VDBE layer 2025-09-27 09:45:15 +03:00
Jussi Saurio
085b92dc4e ALTER TABLE: prevent dropping indexed columns in translate layer 2025-09-27 09:45:15 +03:00
Jussi Saurio
a2d833c073 ALTER TABLE: add comment about things preventing drop column 2025-09-27 09:45:15 +03:00
Pekka Enberg
d796964a1e Merge 'support mixed integer and float expressions in the expr_compiler' from Glauber Costa
Fixes #3373

Closes #3387
2025-09-27 08:22:14 +03:00
Pekka Enberg
e9155610ed Merge 'github: Add 30 minute timeout to all jobs' from Pekka Enberg
We're getting hit by macOS runner concurrency limits whenever some jobs
get stuck (for example, because of a deadlock).

Closes #3377
2025-09-27 08:21:41 +03:00
Pekka Enberg
2f1ac8eb4a Merge 'bench/tpch: remove "cast('yyyy-mm-dd' as datetime)"' from Jussi Saurio
`CAST('yyyy-mm-dd' as datetime)` causes sqlite and tursodb to interpret
the value as just 'yyyy', e.g. '1995-01-01' becomes '1995', causing a
lot of the queries not to return any results, which is not what we want.

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

Closes #3374
2025-09-27 08:21:30 +03:00
Pekka Enberg
65b382b9e1 Merge 'Make MVCC code Send and Sync' from Pekka Enberg
Closes #3361
2025-09-27 08:21:01 +03:00
Pekka Enberg
92291ed736 Merge 'Fix offset variable handling' from Nikita Sivukhin
Before, db generated incorrect plan in case when offset parameter were
introduced as variable:
```
turso> EXPLAIN SELECT * FROM users LIMIT ? OFFSET ?;
addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     16    0                    0   Start at 16
1     Variable           1     1     0                    0   r[1]=parameter(1); OFFSET expr
2     MustBeInt          1     0     0                    0
3     Variable           2     2     0                    0   r[2]=parameter(2); OFFSET expr
4     MustBeInt          2     0     0                    0
5     OffsetLimit        1     3     2                    0   if r[1]>0 then r[3]=r[1]+max(0,r[2]) else r[3]=(-1)
6     OpenRead           0     2     0                    0   table=users, root=2, iDb=0
7     Rewind             0     15    0                    0   Rewind table users
8       Variable         2     2     0                    0   r[2]=parameter(2); OFFSET expr
9       MustBeInt        2     0     0                    0
10      IfPos            2     14    1                    0   r[2]>0 -> r[2]-=1, goto 14
11      Column           0     0     4                    0   r[4]=users.x
12      ResultRow        4     1     0                    0   output=r[4]
13      DecrJumpZero     1     15    0                    0   if (--r[1]==0) goto 15
14    Next               0     8     0                    0
15    Halt               0     0     0                    0
16    Transaction        0     1     1                    0   iDb=0 tx_mode=Read
17    Goto               0     1     0                    0
```

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

Closes #3360
2025-09-27 08:20:54 +03:00
Pekka Enberg
a932ac5450 Merge 'core: recover logical log on Database::connect ' from Pere Diaz Bou
If we open database and logical log is not empty we need to recover from
it. We also make sure a single recover executes concurrently and other
connections just wait for it to finish.
I also changed the fuzz tester to use `restart` instead of calling
`load_logical_log` manually to test this behaviour.

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

Closes #3359
2025-09-27 08:20:41 +03:00
Danawan Bimantoro
a58c6a3c0b Merge branch 'main' into main 2025-09-27 11:05:44 +07:00
Glauber Costa
d28022b491 support mixed integer and float expressions in the expr_compiler
Fixes #3373
2025-09-26 21:11:38 -03:00
Preston Thorpe
5dc30b5a68 Merge 'core/storage: Display page category for rowid integrity check failure' from Pekka Enberg
Let's add more hints to hunt down the reason for #2896.

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

Closes #3378
2025-09-26 19:07:45 -04:00