Commit Graph

755 Commits

Author SHA1 Message Date
Jussi Saurio
7259751eba Merge 'Support the OFFSET clause for Compound select' from meteorgan
Closes #2376
2025-08-01 10:18:13 +03:00
Jussi Saurio
77666b1eb5 Merge 'Fix parser error for repetition in row values' from Diego Reis
Closes #1948
This PR also adds pretty basic support for [row values in UPDATE stateme
nts](https://sqlite.org/rowvalue.html#row_values_in_update_statements),
but it only accepts expressions like:
```sql
UPDATE t SET (a, b) = (2 + 2, 'joe');
```
While SQLite accepts whole new statements, like:
```sql
UPDATE tab3 
   SET (a,b,c) = (SELECT x,y,z
                    FROM tab4
                   WHERE tab4.w=tab3.d)
 WHERE tab3.e BETWEEN 55 AND 66;
 ```
I noticed we don't explicitly have the concept of row values, maybe
doing some plumbing in that matter could solve it?
If there is a way to implement that with our current infrastructure
(a.k.a skill issue from my side) please comment here.

Closes #2355
2025-08-01 10:17:05 +03:00
meteorgan
6262ff4267 support offset for values 2025-08-01 00:46:46 +08:00
Glauber Costa
9d41fa4489 implement IN patterns for non-conditional SELECT queries
Extracts the core logic of IN from the conditional version, and uses the
conditional metadata to determine the jump. Then Uses the AddImm
operator we just added to force the integer conversion at the end (like
SQLite does).
2025-07-31 08:11:41 -05:00
meteorgan
a0f5554b08 support the OFFSET clause for Compound select 2025-07-31 17:43:54 +08:00
Pekka Enberg
d5c5839ee4 Merge 'Serverless JavaScript driver improvements' from Pekka Enberg
Closes #2349
2025-07-31 10:14:22 +03:00
Diego Reis
31c73f3c9a Add basic support for row values in UPDATE .. SET statements
e.g `.. SET (a, b) = (1, 2)` is equivalent to `.. SET a = 1, b = 2`.

Alongside, to repeated lhs values, `(a, a)`, the last rhs prevail; so
`.. SET (a, a) = (1, 2)` is equivalent to `.. SET a = 2`
2025-07-31 00:08:15 -03:00
PThorpe92
28283e4d1c Fix bench_vfs python script to use fresh db for each run 2025-07-30 19:42:52 -04:00
PThorpe92
efcffd380d Clean up io_uring writev implementation, add iovec and cqe cache 2025-07-30 19:42:52 -04:00
PThorpe92
d189f66328 Add pwritev to wasm/js api 2025-07-30 19:42:48 -04:00
Pekka Enberg
5663dd8c91 testing: Skip in-memory database test for serverless 2025-07-30 21:42:45 +03:00
Jussi Saurio
e128bd477e Merge 'Support VALUES clauses for compound select' from meteorgan
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #2293
2025-07-30 21:34:40 +03:00
Pekka Enberg
6c6d74993c testing/javascript: Clean up after test runs 2025-07-29 16:17:11 +03:00
Pekka Enberg
c39f0e7557 testing/javascript: Add libsql to compatibility test suite 2025-07-29 16:09:49 +03:00
Pekka Enberg
b4dc9bebe0 testing/javascript: Improve error message if TURSO_DATABASE_URL is not set 2025-07-29 16:09:49 +03:00
Pekka Enberg
ee58a0bf32 serverless: Implement Connection.pragma() 2025-07-29 15:00:23 +03:00
Pekka Enberg
cace7abcd2 testing: Add JavaScript compatibility test suite
This is essentially an import of the libSQL test suite.
2025-07-29 14:37:48 +03:00
meteorgan
aa69b279c3 support limit 2025-07-28 00:58:20 +08:00
meteorgan
ea660b947d support VALUES clauses for compound select 2025-07-27 19:13:23 +08:00
Pekka Enberg
6bf6cc28e4 Merge 'Implement the Returning statement for inserts and updates' from Glauber Costa
They are very similar. DELETE is very different, so that one we'll do it
later.

Closes #2276
2025-07-27 09:11:16 +03:00
Glauber Costa
5d8d08d1b6 Implement the Returning statement for inserts and updates
They are very similar. DELETE is very different, so that one we'll
do it later.
2025-07-26 09:01:09 -05:00
Iaroslav Zeigerman
6f63327320 fix overlooked tests 2025-07-26 04:51:44 -07:00
Iaroslav Zeigerman
f13b9105b9 Fix error handling when binding column references while translating the UPDATE statement 2025-07-26 04:51:42 -07:00
Glauber Costa
b5927dcfd5 support doubly qualified identifiers 2025-07-25 14:52:45 -05:00
Glauber Costa
988b16f962 Support ATTACH (read only)
Support for attaching databases. The main difference from SQLite is that
we support an arbitrary number of attached databases, and we are not
bound to just 100ish.

We for now only support read-only databases. We open them as read-only,
but also, to keep things simple, we don't patch any of the insert
machinery to resolve foreign tables.  So if an insert is tried on an
attached database, it will just fail with a "no such table" error - this
is perfect for now.

The code in core/translate/attach.rs is written by Claude, who also
played a key part in the boilerplate for stuff like the .databases
command and extending the pragma database_list, and also aided me in
the test cases.
2025-07-24 19:19:48 -05:00
meteorgan
7ef50e0690 fix page_count pragma 2025-07-24 23:18:26 +08:00
Jussi Saurio
92a10f94d8 Merge 'Bail early for read-only virtual tables' from Preston Thorpe
This PR adds a const associated value on the VTabModule trait,
`READONLY` defaulted to `true`, so we can bail early when a write
operation is done on an invalid vtable.
This prevents extensions from having to implement `insert`,`update`,
`delete` just to return `Error::ReadOnly`, and prevents us from having
to step through `VUpdate` just to error out.

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

Closes #2247
2025-07-24 10:12:07 +03:00
PThorpe92
3358e85889 Update py tests for new error msg 2025-07-23 17:05:46 -04:00
Nikita Sivukhin
fd63128227 adjust behaviour in case when both rowid alias and rowid provided 2025-07-23 15:42:05 +04:00
Jussi Saurio
022f679fab chore: make every CREATE TABLE stmt in entire repo have 1 space after tbl name
`BTreeTable::to_sql` makes us incompatible with SQLite by losing e.g. the original whitespace provided during the CREATE TABLE command.

For now let's fix our tests by regex-replacing every CREATE TABLE in
the entire repo to have exactly 1 space after the table name in the
CREATE TABLE statement.
2025-07-22 11:35:21 +03:00
Pekka Enberg
f83870731d testing/sqlite3: Import ALTER TABLE tests
Imported from SQLite 3.50.2
2025-07-22 11:27:52 +03:00
Jussi Saurio
2095e5dde1 test/tcl: run alter_table.test in all.test 2025-07-22 11:12:02 +03:00
Jussi Saurio
58f98391d0 test/tcl: fix alter table test assertions and require index flag on some tests 2025-07-22 11:11:50 +03:00
Pekka Enberg
830f3c7276 Fix typo in insert.ts 2025-07-22 09:12:30 +03:00
Pekka Enberg
30de02d526 testing: Add test case for duplicate SET in UPDATE
Refs #2117
2025-07-22 09:08:14 +03:00
Jussi Saurio
cff4d7e16d Merge 'BTreeTable::to_sql: wrap special column names in brackets' from Nils Koch
Closes #2055

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

Closes #2126
2025-07-21 00:22:49 +03:00
Nils Koch
ed8600db48 add test for dropping special column names 2025-07-20 21:20:59 +01:00
Nikita Sivukhin
66580f42cf add test 2025-07-20 14:22:49 +04:00
Glauber Costa
6506b3147d implement pragma application_id
Just for completeness, because it is easy.
2025-07-19 20:44:06 -05:00
Pekka Enberg
c2a8a6f178 Merge 'improve handling of double quotes' from Glauber Costa
I ended up hitting #1974 today and wanted to fix it. I worked with
Claude to generate a more comprehensive set of queries that could fail
aside from just the insert query described in the issue. He got most of
them right - lots of cases were indeed failing. The ones that were
gibberish, he told me I was absolutely right for pointing out they were
bad.
But alas. With the test cases generated, we can work on fixing it. The
place where the assertion was hit, all we need to do there is return
true (but we assert that this is indeed a string literal, it shouldn't
be anything else at this point).
There are then just a couple of places where we need to make sure we
handle double quotes correctly. We already tested for single quotes in a
couple of places, but never for double quotes.
There is one funny corner case where you can just select "col" from tbl,
and if there is no column "col" on the table, that is treated as a
string literal. We handle that too.
Fixes #1974

Closes #2152
2025-07-18 20:55:37 +03:00
Glauber Costa
cbdd5c5fc7 improve handling of double quotes
I ended up hitting #1974 today and wanted to fix it. I worked with
Claude to generate a more comprehensive set of queries that could fail
aside from just the insert query described in the issue. He got most of
them right - lots of cases were indeed failing. The ones that were
gibberish, he told me I was absolutely right for pointing out they were
bad.

But alas. With the test cases generated, we can work on fixing it. The
place where the assertion was hit, all we need to do there is return
true (but we assert that this is indeed a string literal, it shouldn't
be anything else at this point).

There are then just a couple of places where we need to make sure we
handle double quotes correctly. We already tested for single quotes in a
couple of places, but never for double quotes.

There is one funny corner case where you can just select "col" from tbl,
and if there is no column "col" on the table, that is treated as a
string literal. We handle that too.

Fixes #1974
2025-07-18 10:39:02 -05:00
Pekka Enberg
02f4bc39b3 Merge 'Reanimate MVCC' from Pekka Enberg
Bit-rot happened. Bring MVCC back from the dead.

Closes #2136
2025-07-18 11:22:49 +03:00
Diego Reis
9ade79b3ad Do not rollback in TxError
Fixes #2153. Not so sure if SQLite doesn't rollback in more cases, we
should definitively check this out.
2025-07-18 01:11:51 -03:00
Pekka Enberg
8e98c33fce Ruff you are an idiot 2025-07-17 21:51:34 +03:00
Pekka Enberg
d11a8063f0 testing: Format mvcc.py to make ruff happy... 2025-07-17 21:39:08 +03:00
Pekka Enberg
458dd815ac testing: Add MVCC test suite 2025-07-17 16:23:31 +03:00
Pekka Enberg
f4e82df00e Merge 'Fix CSV import in the shell' from Jussi Saurio
- Fix not being able to create table while importing
    * The behavior now aligns with SQLite so that if the table already
exists, all the rows are treated as data. If the table doesn't exist,
the first row is treated as the header from which column names for the
new table are populated.
- Insert in batches instead of one at a time
This was a pretty quick vibecoding effort tbh :]
Closes #2079

Closes #2094
2025-07-16 08:26:30 +03:00
Nikita Sivukhin
e15f72da2d add simple test for concat_ws bug 2025-07-16 00:52:14 +04:00
Jussi Saurio
38183d3b3b tcl: add regression test for large text keys 2025-07-15 18:48:06 +03:00
Jussi Saurio
cc47bfba02 CSV import fixes
- Fix not being able to create table while importing
    * The behavior now aligns with SQLite so that if the table already
      exists, all the rows are treated as data. If the table doesn't exist,
      the first row is treated as the header from which column names for the
      new table are populated.
- Insert in batches instead of one at a time
2025-07-15 16:44:11 +03:00