0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2025-07-06 05:23:32 +00:00

65 Commits

Author SHA1 Message Date
69370ba9d4 Merge branch 'main' into fix/fixup-markdown-documents 2025-03-20 13:56:52 +02:00
d980ce13b9 bindings/c: Add offline to config struct ()
Make it possible to configure offline writes via the normal
`libsql_config` struct too.
2025-03-19 10:22:43 +00:00
a1ca6b1232 bindings/c: Fix libsql_query() error too... 2025-03-11 18:08:19 +02:00
16c44bac0f bindings/c: Fix libsql_query_stmt() error reporting
Let's propagate the error code from the future we block on to the caller
of `libsql_query_stmt()`.
2025-03-11 14:47:11 +02:00
b688913503 bindings/c: Add offline to config struct
Make it possible to configure offline writes via the normal
`libsql_config` struct too.
2025-01-31 09:15:16 +02:00
6a5b840195 chore: fix minor style/grammar issues in markdown files 2025-01-23 12:48:15 +01:00
c00652f264 C bindings include sync into example
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-11-29 10:51:13 +01:00
fa9d76f819 C bindings: Make example show embedded replicas
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-11-29 10:15:18 +01:00
7749b38f46 Remove query parameter from embedded replica url
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-11-28 20:54:55 +01:00
7e6d74fb9f Create SyncedDatabase in libsql_open_sync_with_config if primary url has query param
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-11-25 17:33:52 +01:00
35e9af0acc Add statement reset to libsql_reset_stmt C binding
Without this call to stmt.reset(), the prepared statement is not correctly reset and the same values are read back despite having new bindings.

Fixes 
2024-08-31 22:07:36 +02:00
3853145722 rename function 2024-08-30 16:56:54 +04:00
4192ad285b make libsql_enable_tracing safe to call multiple times 2024-08-30 16:27:43 +04:00
b469ef14b1 add libsql_enable_tracing to the libsql 2024-08-30 15:45:37 +04:00
fb85262418 c: rename sync method to to avoid breaking change 2024-08-09 08:58:57 -04:00
7fe8f96964 c: add replicated data for sync
This adds a new replicated struct that is output during sync for the C
bindings.
2024-08-09 08:58:12 -04:00
7dacca2728 bump rust version, fix warnings 2024-07-31 22:47:53 +02:00
3439af27c6 C bindings: Loading extensions
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-07-29 10:14:49 +02:00
3ab820d57d Add libsql_open_sync_with_config ()
Bindings: Add libsql_open_sync_with_config

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-07-17 12:46:34 +00:00
30623f9d1e React Native support ()
* iOS/Android Support

Add steps for Android

PR comments

* comment size optimization
2024-06-25 17:39:27 +00:00
a9835eeae1 C bindings: add libsql_open_sync_with_webpki and libsql_open_remote_w… ()
C bindings: add libsql_open_sync_with_webpki and libsql_open_remote_with_webpki

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-06-03 18:49:58 +00:00
aadb52ccf4 Define column types ()
Fixes 

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-05-26 15:18:38 +00:00
38dcdb18b7 Add libsql_reset_stmt ()
Fixes 

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-05-26 14:36:54 +00:00
ba96a2d77b Remove in-tree version of go-libsql ()
* Go bindings: build only sql-experimental for CI

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: Run go-libsql tests in CI

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: Remove in-tree version of go-libsql

go-libsql is maintained in https://github.com/tursodatabase/go-libsql

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: Run more tests in CI

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-04-07 09:24:08 +00:00
f7c5bfb7bd Go updates ()
* Go bindings: Improve imports

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: continue Next() after a time.Time

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: remove unused err check

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-04-06 14:43:48 +00:00
f3da77e705 Go bindings: separate query and exec ()
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-03-12 12:40:03 +00:00
9f198679e6 bindings/go: Redirect people to Go SDK repository ()
The Go SDK code lives in two places, but people are supposed to consume
the one in the other repository. Let's add a small hint in this
repository for people to find the right one.
2024-03-06 15:32:45 +00:00
4c96d58a6b bindings/go: Rename WithAutoSync to WithSyncInterval ()
This aligns the API with the other SDKs.
2024-03-06 13:48:10 +00:00
6b13d77519 libsql: Deasyncify some Conn trait methods ()
There's no reason to have `is_autocommit()`, `changes()` or
`last_insert_row()` methods async because they're all fully local and
cannot block. Deasyncify them.
2024-03-05 13:44:53 +00:00
0d483ad479 Go binding: Change default encryption key ()
* Go binding: Change default encryption key

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: Drop sqlite dependency

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-03-04 14:55:16 +00:00
213c7dabf5 Go: Add support for bool type ()
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-02-29 15:08:13 +01:00
db894cb68a Refactor Go API ()
* Go: refactor API

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go: add read your writes test

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-02-29 12:14:42 +00:00
4b2732c5e2 Go: Reset connection when it's returned to a pool ()
* Make all methods of Conn trait async

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* C bindings: Add libsql_reset

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-02-29 10:09:07 +00:00
c41e17a998 Encryption in Go SDK ()
* Go tests: Run less tests in parallel

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: Read your writes

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: encryption

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Don't panic when encryption fails

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: Encryption test

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-02-29 07:55:49 +00:00
2ee5a4726e sys: feature flag pager creator ()
* sys: feature flag pager creator

* fix feature flag pghdr_creator
2024-02-29 00:07:17 +00:00
6a6b5dfc70 chore: remove filesystem clean c bindings ()
* chore: remove filesystem clean c bindings

* add env var in actions file
2024-02-20 20:10:39 +00:00
3d36420113 Update libsql.go ()
Error message for incorrect file type is incorrect.
Files should be imported using `file:` , not `file://` as the error message states.

Co-authored-by: Piotr Jastrzębski <haaawk@gmail.com>
2024-02-20 14:55:23 +00:00
64e5549cec Go Bindings: More tests ()
* Go Bindings: More tests

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Cleanup disk in Go/C CI

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-02-09 14:48:16 +00:00
cd82068edf libsql_server,bottomless: add encryption support ()
* namespace,replication: add LogFile encryption

Anything that uses our LogFile format can now be encrypted
on-disk.
Tested locally by seeing that `wallog` file contains garbage
and no sensible plaintext strings can be extracted from it.

* test fixups

* libsql-ffi: add libsql_generate_initial_vector and...

... libsql_generate_aes256_key to make them reachable from Rust.

* connection: expose additional encryption symbols

* libsql-server: derive aes256 from user passphrase properly

And by properly, I mean calling back to SQLite3MultipleCiphers' code.

* replication: rename Encryptor to FrameEncryptor

Encryptor sounds a little too generic for this specific use case.

* replication: add snapshot encryption

It uses the same mechanism as wallog encryption, now abstracted
away to libsql-replication crate to be reused.

* replication: add an encryption feature for compilation

* cargo fmt pass

* fix remaining SnapshotFile::open calls in tests

* logger: add an encryption test

* replication: use a single buffer for encryption

Ideally we could even encrypt in place, but WalPage is also
used in snapshots and it's buffered, and that makes it exceptionally
annoying to explain to the borrow checker.

* bottomless: restore with libsql_replication::injector

... instead of the transaction page cache. That gives us free
encryption, since the injector is encryption-aware.

This patch doesn't hook encryption_key parameter yet, it will
come in the next patch.

* bottomless: pass the encryption key in options

For WAL restoration, but also to be able to encrypt data that gets
sent to S3.

* bottomless: inherit encryption key from db config if not specified

* libsql-sys: add db_change_counter()

The helper function calls the underlying C API to extract
4 bytes from offset 24 of the database header and return it.
It's the database change counter, which we can use to compare
two databases and decide which one is newer than the other.

* bottomless: use sqlite API to read database metadata

With encryption enabled, we can no longer just go ahead and read data
from given offsets, we must go through the VFS layer instead.
Fortunately, we can just open a database connection and ask for all
the metadata we need.

* libsql-sys: make db change counter actually read from the db file

* bottomless: treat change counter == 1 as a new database

... which it is, after setting the journal mode. Otherwise we decide
too eagerly that the local database is the source of truth.

* libsql-server: fix a local embedded replica test

rebase conflict with encryption

* bottomless-cli: allow passing the encryption key

* replication: rebase new test to the new api

* snapshots: do not try to decrypt headers

They are not encrypted, so we shouldn't attempt to decrypt the data.

* logger: restore encrypted frames during recovery

Instead of decrypting and encrypting back, we just copy encrypted
frames as is during the recovery process, saves IO.

* compaction: clear unused encryption_key parameter

It wasn't used since for compaction we only need headers,
which are unencrypted.

* replication: switch to FrameBorrowed::new_zeroed

Following MarinPostma's suggestion.

Co-authored-by: Marin Postma <postma.marin@protonmail.com>

* replication: rebase chores, fixing parameters

* libsql-replication: use page_mut() to decrypt data in-place

* rustfmt

* bottomless: use 0 for disabling autocheckpoint

... instead of u32::MAX. Effectively it's similar, but 0 is the correct
choice.

* rustfmt

* libsql-server: make cbc, aes optional for encryption only

* post-rebase fixes

* libsql-replication: suppress warnings when no encryption

* libsql: add encryption support for local databases

* libsql: add bytes dependency for encryption

* libsql-ffi: build libsqlite3mc without debug symbols

Technically it should just depend on cargo build mode,
but that's left for a follow-up.

* bindings: an attempt to compile bindings with releasemode

... partially to save space, but also to make them faster.

---------

Co-authored-by: Marin Postma <postma.marin@protonmail.com>
2024-02-09 14:27:39 +00:00
992b450bfb Go bindings: Implement transactions + tests ()
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-02-08 15:39:39 +00:00
954029e31f libsql: add Builder to construct the db ()
This adds a new `Builder` type that can now be used to construct the
`Database` type. This will scale better as we add more varied options.
This commit also deprecates the old builder types and will produce a
warning that will push users to using the new `Builder` type. This will
then allow us to remove the old deprecated constructors at some point in
the future.
2024-02-06 13:59:11 +00:00
37fb629f50 run clippy () 2024-01-31 08:42:20 +00:00
1013548213 Go tests2 ()
* Go bindings: testConcurrentOnSingleConnection for Embedded

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: TestDataTypesEmbedded

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: TestPingEmbedded

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: check for nil db in tests

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: TestArgumentsEmbedded

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: TestExecAndQueryEmbedded

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: TestPreparedStatementsEmbedded

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-30 15:48:46 +00:00
3c7c2f373c Go bindings support time.Time ()
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-30 11:57:01 +01:00
4332bb6c16 Go tests ()
* Go bindings: TestConcurrentOnSingleConnection

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: TestDataTypes

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: TestPing

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-29 15:24:58 +00:00
50a4da3423 Go bindings add prepared statement ()
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-29 14:27:42 +00:00
8d715223a8 C/Go bindings: Use libsql::Statement in prepare ()
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-29 13:21:15 +00:00
6bc489dd1d Go bindings: Add support for transactions and more tests ()
* Go bindings: Implement transactions

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

* Go bindings: Add more tests for remote db

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>

---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-25 13:44:37 +00:00
b02947daef Go bindings add positional parameters ()
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-25 10:05:40 +00:00
f5160ac03c Go bindings: Improve Connector close
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-24 11:34:44 +01:00