Commit Graph

6457 Commits

Author SHA1 Message Date
Nikita Sivukhin
60eaa11add hide new methods behind fs feature 2025-07-23 11:51:39 +04:00
Nikita Sivukhin
a85283a84f add trailing comma 2025-07-23 11:31:00 +04:00
Nikita Sivukhin
3c0af3e389 small adjustments 2025-07-23 11:31:00 +04:00
Nikita Sivukhin
2283a04aab add more tests 2025-07-23 11:31:00 +04:00
Nikita Sivukhin
73761a8983 rollback non-commited changes 2025-07-23 11:31:00 +04:00
Nikita Sivukhin
bf2bfbe978 fix clippy 2025-07-23 11:31:00 +04:00
Nikita Sivukhin
16763e1500 implement raw WAL write api 2025-07-23 11:30:59 +04:00
Nikita Sivukhin
bc09ea6e98 make end_write_txn/end_read_txn function non-failing 2025-07-23 11:30:29 +04:00
PThorpe92
cb42102a6e Merge 'silence clippy errors with features disabled' from Glauber Costa
When compiling with features disabled, there are lots of clippy
warnings. This PR silences them.
For the utils file, I am using a bit of a hammer and just allowing
unused stuff in the whole file. Due to the box of utilities nature of
this file, it'll always be the case that things will be unused depending
on the feature-set.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #2236
2025-07-22 21:51:27 -04:00
PThorpe92
a13fc3515e Fix cargo fmt warning 2025-07-22 21:47:15 -04:00
Glauber Costa
a10d8d7f94 silence clippy errors with features disabled
When compiling with features disabled, there are lots of clippy
warnings. This PR silences them.

For the utils file, I am using a bit of a hammer and just allowing
unused stuff in the whole file. Due to the box of utilities nature of
this file, it'll always be the case that things will be unused depending
on the feature-set.
2025-07-22 20:37:45 -05:00
PThorpe92
9c785ea0ea Merge 'make readonly a property of the database' from Glauber Costa
There's no such thing as a read-only connection.
In a normal connection, you can have many attached databases. Some r/o,
some r/w.
To properly fix that, we also need to fix the OpenWrite opcode. Right
now we are passing a name, which is the name of the table. That
parameter is not used anywhere. That is also not what the SQLite opcode
specifies. Same as OpenRead, the p3 register should be the database
index.
With that change, we can - for now - pass the index 0, which is all we
support anyway, and then use that to test if we are r/o.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #2232
2025-07-22 21:12:08 -04:00
PThorpe92
dcd677ab6c Merge 'Safe AtomicUsize wrapper for db_state: add DbState and AtomicDbState' from Levy A.
Makes invalid states impossible, removes magic numbers. Functionally
equivalent.
> [!NOTE]
> ~`DbState` is implemented as a transparent wrapper over `usize` to
avoid undefined behavior with `mem::transmute`~
> Switched to a regular enum, by @Shourya742's suggestion.

Reviewed-by: bit-aloo (@Shourya742)
Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #2174
2025-07-22 19:21:10 -04:00
Levy A.
e6ad88cc18 refactor: constified enum -> regular enum 2025-07-22 17:20:30 -03:00
Levy A.
203239ff30 refactor: safer db_state 2025-07-22 17:20:29 -03:00
Glauber Costa
57a1113460 make readonly a property of the database
There's no such thing as a read-only connection.
In a normal connection, you can have many attached databases. Some
r/o, some r/w.

To properly fix that, we also need to fix the OpenWrite opcode. Right
now we are passing a name, which is the name of the table. That
parameter is not used anywhere. That is also not what the SQLite opcode
specifies. Same as OpenRead, the p3 register should be the database
index.

With that change, we can - for now - pass the index 0, which is all
we support anyway, and then use that to test if we are r/o.
2025-07-22 09:41:32 -05:00
Jussi Saurio
60beeaefd9 Merge 'Add Github workflow for Turso serverless package' from Pekka Enberg
Closes #2226
2025-07-22 16:12:04 +03:00
Jussi Saurio
72b4318fa1 Merge 'fix raw read frame WAL API' from Nikita Sivukhin
This PR fixes `wal_read_frame_raw` API
Before, implementation of raw read API read only page content - which is
not enough as we also need page_no and size_after fields from the
header. This PR fixes that and also make few adjustments in the
signatures.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #2229
2025-07-22 16:10:55 +03:00
Jussi Saurio
fbed082257 Merge 'use default hasher for the sake of determinism' from Nikita Sivukhin
Make `cacheflush` / `commit_dirty_pages` functions deterministic. This
can help to mitigate some simulator non-reproducible seeds + simplify
life a bit.

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

Closes #2228
2025-07-22 16:10:43 +03:00
Nikita Sivukhin
b34d081d35 cargo fmt 2025-07-22 16:23:04 +04:00
Nikita Sivukhin
d617d1d21e fix raw read frame WAL API 2025-07-22 16:21:04 +04:00
Nikita Sivukhin
a730136564 use default hasher for the sake of determinism 2025-07-22 16:18:42 +04:00
Pekka Enberg
710b43d2c4 Add Github workflow for Turso serverless package 2025-07-22 13:38:51 +03:00
Pekka Enberg
68169a7b58 Merge 'Work around CREATE TABLE whitespace issue' from Jussi Saurio
`BTreeTable::to_sql` makes us incompatible with SQLite by losing e.g.
the original whitespace provided during the CREATE TABLE command. For
example:
`CREATE TABLE t            (x)` gets saved as `CREATE TABLE t (x)`.
Sqlite preserves the user-provided whitespace.
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.
I also added a FIXME in the doc comment for `BTreeTable::to_sql`, and
opened https://github.com/tursodatabase/turso/issues/2224

Closes #2223
2025-07-22 13:38:20 +03: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
Pekka Enberg
d634a28890 Merge 'Fix issues in alter table tests and fix a small error in BTreeTable::to_sql' from Jussi Saurio
Closes #2186
```git
commit 2095e5dde1 (HEAD -> fix-alter-table, origin/fix-alter-table, main)
Author: Jussi Saurio <jussi.saurio@gmail.com>
Date:   Tue Jul 22 11:12:02 2025 +0300

    test/tcl: run alter_table.test in all.test

commit 58f98391d0
Author: Jussi Saurio <jussi.saurio@gmail.com>
Date:   Tue Jul 22 11:11:50 2025 +0300

    test/tcl: fix alter table test assertions and require index flag on some tests

commit 13d40c6a73
Author: Jussi Saurio <jussi.saurio@gmail.com>
Date:   Tue Jul 22 11:11:08 2025 +0300

    schema: fix extra whitespace in BTreeTable::from_sql
```

Closes #2222
2025-07-22 11:20:48 +03:00
Pekka Enberg
eab71d2ee2 Update README.md 2025-07-22 11:20:01 +03:00
Pekka Enberg
b6d3371d46 Update README.md 2025-07-22 11:12:46 +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
Jussi Saurio
13d40c6a73 schema: fix extra whitespace in BTreeTable::from_sql 2025-07-22 11:11:08 +03:00
Pekka Enberg
0a6f99f3d9 Merge 'Add Rickrolling Turso blog post to contrib' from Avinash Sajjanshetty
Closes #2218
2025-07-22 11:10:31 +03:00
Avinash Sajjanshetty
4e91ed1201 Add Rickrolling Turso blog post to contrib 2025-07-22 13:07:33 +05:30
Pekka Enberg
f10723779d bindings/javascript: Add Drizzle example 2025-07-22 10:35:30 +03:00
Pekka Enberg
f979903633 Merge 'Load static extensions once and store on Database instead of once per connection' from Preston Thorpe
To help make the connection speed faster, we don't need to register
these every time as they are compiled in.

Closes #2213
2025-07-22 09:16:22 +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
Pekka Enberg
afc22da07c Merge 'Fix duplicate SET statement compatibility with SQLite' from Ihor Andrianov
For duplicate SET statements, SQLite uses last one

Closes #2117
2025-07-22 09:02:16 +03:00
Pekka Enberg
b03fe4669a Merge 'wal: write txn fail in case max_frame change midway' from Pere Diaz Bou
A write txn can only start if the current snapshot held by writer is
consistent with the one in shared state

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

Closes #2204
2025-07-22 09:01:44 +03:00
Pekka Enberg
c1ee91f500 Merge 'Add @tursodatabase/serverless package' from Pekka Enberg
This package is for serverless access to the Turso Cloud using SQL over
HTTP protocol. The purpose of this package is to provide the same
interface as `@tursodatabase/turso`, but for serverless environments
that cannot host the database engine.
The package also provides a `@libsql/client` compatibility layer in the
`@tursodatabase/serverless/compat` module for drop-in replacement for
existing clients.

Closes #2209
2025-07-22 08:56:22 +03:00
PThorpe92
a92126961d Remove duplicate case and just send Mutex along with schema for extension registrations 2025-07-21 20:06:14 -04:00
PThorpe92
d514304ac2 Remove unneeded changes 2025-07-21 19:24:24 -04:00
PThorpe92
f7ba8efdbd Switch back to std::mutex because it was an unnecessary change 2025-07-21 19:20:17 -04:00
PThorpe92
5e5b3ce071 Fix leak of extension CTX in cli/app 2025-07-21 19:09:58 -04:00
PThorpe92
411c4f059a Load compile time extensions on the initial db startup instead of once per conn 2025-07-21 19:09:31 -04:00
PThorpe92
5ebd3f7271 Change api of extension api context to support static extensions held on db 2025-07-21 19:08:27 -04:00
Pekka Enberg
7765bafb13 Add @tursodatabase/serverless package
This package is for serverless access to the Turso Cloud using SQL over
HTTP protocol. The purpose of this package is to provide the same
interface as `@tursodatabase/turso`, but for serverless environments
that cannot host the database engine.

The package also provides a `@libsql/client` compatibility layer in the
`@tursodatabase/serverless/compat` module for drop-in replacement for
existing clients.
2025-07-21 22:03:43 +03:00
Pekka Enberg
8f83b150b7 Merge 'Implement pragma database_list' from Glauber Costa
And also the CLI option .databases, which is just manipulating that.
This is one step in the road to attach.

Closes #2195
2025-07-21 17:13:26 +03:00
Glauber Costa
0545049d59 Implement pragma database_list
And also the CLI option .databases, which is just manipulating that.

This is one step in the road to attach.
2025-07-21 08:49:35 -05:00