Commit Graph

436 Commits

Author SHA1 Message Date
Pekka Enberg
a820079e8e Turso 0.9.0-pre.1 2026-10-15 12:17:20 +03:00
Pekka Enberg
4de24b0c62 core: Pass connection settings to Database::connect as ConnectOpts
Database had five public ways to open a connection: connect,
connect_with_encryption, connect_with_page_codec, connect_async and
connect_with_encryption_async. Every new connection setting needs more
variants, and the async path doubles them again.

Database::connect and Database::connect_async now take a ConnectOpts
that holds the encryption key and the page codec, and the other three
variants are removed. ConnectOpts has no Default, so every caller goes
through ConnectOpts::new() and a required argument added there later
makes the compiler find every call site.
2026-10-12 10:05:12 +03:00
Pekka Enberg
a7244a67df bindings/java: throw on a null statement pointer in columns instead of panicking
columns() was the one native statement function that unwrapped the pointer
check, so a zero pointer would abort the JVM instead of surfacing a Java
exception like every other entry point does.

Add an InvalidStatementPointer error so statement pointer failures no longer
report themselves as connection pointer failures.
2026-09-28 18:37:07 +03:00
Pekka Enberg
b2cf785055 bindings/java: reject use of a closed connection or statement instead of using freed memory
TursoConnection.close() and TursoStatement.close() freed their native boxes
but kept the stale address in a final pointer field. prepare() on a closed
connection, and step, bind, columns, reset, changes and parameterCount on a
closed statement, all passed the freed pointer to native code, which
dereferenced it.

Zero the pointer on close and treat a zero pointer as the closed state, so
there is one source of truth for whether the native handle exists. Every
native call now checks that first. Close and the native entry points are
synchronized so two threads cannot race a close against a use or free the
box twice. The connection takes its monitor only around the free and the
prepare call, never while holding transactionLock, so the lock order stays
transactionLock then connection for close, commit and rollback.

The native _close functions reject a zero pointer with an exception instead
of passing it to Box::from_raw.

Closing a connection before its statements stays safe because each native
statement holds its own clone of the connection; a test covers that ordering.

Tests: bindings/java TursoConnectionTest and TursoStatementTest
(make -C bindings/java test)
2026-09-28 18:37:07 +03:00
Pekka Enberg
6869716df3 bindings/java: reject connect on a closed TursoDB instead of using freed memory
TursoDB.close() freed the native TursoDB box but kept the stale address in
dbPointer, and connect() never checked whether the database was still open.
Calling connect() after close(), including through
new TursoConnection(url, db), passed the freed pointer to connect0, which
dereferenced it to reach the Arc<Database>.

Zero the pointer on close and treat a zero pointer as the closed state, so
there is one source of truth for whether the native handle exists. connect()
now throws on a closed database, and close() and connect() are synchronized
so two threads cannot race a close against a connect or free the box twice.
The native close0 rejects a zero pointer with an exception instead of
passing it to Box::from_raw.

Closing the database before its connections stays safe because each native
connection holds its own Arc<Database>; a test covers that ordering.

Tests: bindings/java TursoDBTest (make -C bindings/java test)
2026-09-28 17:22:17 +03:00
Pekka Enberg
2829ee1662 Turso 0.8.0 2026-09-28 12:42:08 +03:00
Pekka Enberg
632b58d522 Turso 0.8.0-pre.14 2026-09-28 09:09:16 +03:00
Pekka Enberg
64b8ef5742 Turso 0.8.0-pre.13 2026-09-25 10:54:27 +03:00
Pekka Enberg
e7e77e5957 Turso 0.8.0-pre.12 2026-09-22 17:01:34 +03:00
Nikita Sivukhin
7cc973fbe3 Turso 0.8.0-pre.11 2026-09-11 09:37:12 +01:00
Pekka Enberg
342dfbe267 Turso 0.8.0-pre.10 2026-09-09 09:06:19 +03:00
Mikaël Francoeur
56208cc073 Turso 0.8.0-pre.9 2026-09-08 10:24:02 -04:00
Pekka Enberg
9384daad3b Turso 0.8.0-pre.8 2026-09-04 07:17:43 +03:00
Pekka Enberg
277ddd050b Turso 0.8.0-pre.7 2026-08-21 08:50:47 +03:00
Pekka Enberg
e8aef1923d Turso 0.8.0-pre.6 2026-08-19 10:18:12 +03:00
Pekka Enberg
a3e6627ebc Turso 0.8.0-pre.5 2026-08-19 07:18:14 +03:00
Pekka Enberg
5f6098a0cf repo: renormalize gradlew.bat line endings to lf in the index
Commit 59bfb15f3 added .gitattributes with '*.bat text eol=crlf', but
bindings/java/gradlew.bat and examples/react-native/android/gradlew.bat
were committed with crlf blobs and missed by the renormalize pass. Git
stores text files with lf in the index and only converts to crlf on
checkout, so the stale crlf blobs made these files show up as fully
modified whenever anything renormalized them.

git add --renormalize rewrites the blobs to lf; checkouts still produce
crlf on disk via the eol=crlf attribute.
2026-08-17 12:18:59 +03:00
Pekka Enberg
ce276e4218 Turso 0.8.0-pre.4 2026-08-11 15:55:09 +03:00
Pekka Enberg
ed15b13f8e Turso 0.8.0-pre.3 2026-08-06 15:59:00 +03:00
Pekka Enberg
47b0635417 Turso 0.8.0-pre.2 2026-07-26 11:55:13 +03:00
Nikita Sivukhin
4b8518232c Turso 0.8.0-pre.1 2026-07-21 01:16:04 +04:00
Pekka Enberg
9b10c496db core: add Dialect trait and route schema loading through it
Introduce the Dialect trait as the boundary between the engine and the
SQL dialect a frontend speaks. The engine hardcodes SQLite behavior in
many places; the trait is the seam where a frontend substitutes its own
surface, growing one hook per behavior that moves behind it, with
SqliteDialect in core/dialect/sqlite.rs as the SQLite implementation.

The first hook is schema loading: every path that parses a
sqlite_schema table row back into a table definition now goes through
Dialect::parse_table_sql instead of calling BTreeTable::from_sql
directly. Rows written by internal engine paths (sequence backing
tables, sqlite_sequence) are plain SQLite text with no frontend marker,
so every dialect falls back to SQLite parsing for text it does not
recognize as its own.

The dialect is a mandatory, explicit argument on every database
constructor — open_file, open, open_new, from_uri, and the async and
bypass-registry variants — with no defaulting convenience wrappers:
SQLite-compatible callers state Arc::new(SqliteDialect) at the call
site, so the dialect a database runs under is always visible where it
is opened. It is fixed at open time because the schema is parsed during
open itself; a dialect installed later could never see rows stored by
another frontend. The process-wide database registry rejects an open
whose dialect name differs from the already-open instance, and
engine-initiated secondary opens (ATTACH) propagate the parent
database's dialect instead of assuming SQLite.
2026-07-16 10:36:39 +03:00
Pekka Enberg
e7cb62a8bd Turso 0.7.0 2026-07-13 18:12:11 +03:00
Pekka Enberg
4b18962902 Turso 0.7.0-pre.22 2026-07-13 17:38:12 +03:00
Pekka Enberg
9f13ffbecd Turso 0.7.0-pre.19 2026-07-12 08:39:31 +03:00
Pekka Enberg
11ab464138 Turso 0.7.0-pre.18 2026-07-05 19:30:07 +03:00
Nikita Sivukhin
0fd4fb8b7b Turso 0.7.0-pre.14 2026-06-29 11:58:42 +04:00
Pekka Enberg
5fa8222f39 Turso 0.7.0-pre.13 2026-06-25 17:06:04 +03:00
Pekka Enberg
92e8498d26 Turso 0.7.0-pre.12 2026-06-25 16:40:54 +03:00
Pekka Enberg
2e1a41772b Turso 0.7.0-pre.11 2026-06-25 10:22:15 +03:00
Pekka Enberg
1ebe80ff22 Turso 0.7.0-pre.10 2026-06-18 20:48:10 +03:00
Nikita Sivukhin
93dddea459 Turso 0.7.0-pre.9 2026-06-17 22:27:57 +04:00
Pekka Enberg
bfcf68f992 Turso 0.7.0-pre.8 2026-06-17 10:05:39 +03:00
Pekka Enberg
cdd3c057e7 Turso 0.7.0-pre.7 2026-06-11 19:48:55 +03:00
Pekka Enberg
e9c74edadc Turso 0.7.0-pre.6 2026-06-09 12:34:27 +03:00
Pekka Enberg
1457754cc0 Turso 0.7.0-pre.5 2026-06-02 18:57:06 +03:00
Pekka Enberg
30fa0b830e Turso 0.7.0-pre.4 2026-05-27 07:43:00 +03:00
pedrocarlo
07a3120ac3 migrate callers that were affected by Extendable change 2026-05-25 20:16:27 -03:00
Mikaël Francoeur
4fafcbec91 Turso 0.7.0-pre.3 2026-05-22 14:20:55 -04:00
Pekka Enberg
19aabdac26 Turso 0.7.0-pre.2 2026-05-20 23:02:01 +03:00
Mikaël Francoeur
79912ea6a5 Turso 0.7.0-pre.1 2026-05-15 11:29:15 -04:00
Pekka Enberg
b8501209df Turso 0.6.0 2026-05-14 19:34:35 +03:00
Pekka Enberg
2cabfc414b Turso 0.6.0-pre.31 2026-05-14 15:15:33 +03:00
Pekka Enberg
f3990897da Turso 0.6.0-pre.29 2026-05-08 18:12:05 +03:00
Pekka Enberg
fe8521976f Turso 0.6.0-pre.28 2026-05-06 13:47:56 +03:00
Pekka Enberg
d7b6c530b0 Turso 0.6.0-pre.27 2026-05-04 14:21:44 +03:00
Nikita Sivukhin
1f22934504 Turso 0.6.0-pre.26 2026-05-01 22:24:46 +04:00
Mikaël Francoeur
01ad9e03b9 Turso 0.6.0-pre.25 2026-04-29 23:16:10 -04:00
PThorpe92
8121b08758 Turso 0.6.0-pre.24 2026-04-28 17:59:00 -04:00
Nikita Sivukhin
c54bbe283d Turso 0.6.0-pre.23 2026-04-27 11:34:38 +04:00