0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2025-05-21 23:38:12 +00:00
Commit Graph

47 Commits

Author SHA1 Message Date
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
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
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
f3da77e705 Go bindings: separate query and exec ()
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-03-12 12:40:03 +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
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
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
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
ee964f6aad Go bindings support remote only dbs
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-22 12:45:49 +01:00
0c93c5f11a Merge pull request from Horusiath/libsql-cursor-new-api
Libsql client: introduce async row fetcher
2024-01-17 10:31:45 +00:00
1516bb9e7e drop stray newline 2024-01-16 16:44:39 +01:00
da21747012 treewide: huge un-featurization
The passphrase parameter is now unconditional, we just don't use it
if not applicable.
2024-01-16 16:44:39 +01:00
77a87b4ec1 bindings/c: add stubs for encryption at rest support 2024-01-16 16:44:39 +01:00
ff37062863 c binding: use explicit runtime + replace futures::Mutext with tokio::Mutex 2024-01-16 08:23:08 +01:00
67678167ed changed RowsInner API to make next row method async 2024-01-16 08:23:08 +01:00
f275f24ce2 bindings/c: Implement libsql_open_{file,remote} API
The libsql_open_ext() API does not support auth token. Let's add a
libsql_open_remote() API for establishing connection to remote database,
but also add a libsql_open_file() for what libsql_open_ext() does so
that we can deprecate it in the future.
2023-12-16 14:52:27 +02:00
9a1b686c61 bindings/c: Implement libsql_last_insert_rowid() 2023-11-17 13:00:49 +02:00
a782fdabea bindings/c: Implement libsql_changes() 2023-11-17 13:00:01 +02:00
63b0f8079c sql-experimental: add CI workflow 2023-11-09 16:18:09 -05:00
5dbf5ae8b3 sql-experimental: update example.c to match rust 2023-11-09 16:18:09 -05:00
07782b2263 move crates to root 2023-10-16 09:06:25 -07:00