0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2025-09-12 04:19:46 +00:00
Commit Graph

22 Commits

Author SHA1 Message Date
Piotr Jastrzębski
f3da77e705 Go bindings: separate query and exec (#1047)
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-03-12 12:40:03 +00:00
Pekka Enberg
9f198679e6 bindings/go: Redirect people to Go SDK repository (#1148)
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
Pekka Enberg
4c96d58a6b bindings/go: Rename WithAutoSync to WithSyncInterval (#1143)
This aligns the API with the other SDKs.
2024-03-06 13:48:10 +00:00
Piotr Jastrzębski
0d483ad479 Go binding: Change default encryption key (#1127)
* 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
Piotr Jastrzębski
213c7dabf5 Go: Add support for bool type (#1114)
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-02-29 15:08:13 +01:00
Piotr Jastrzębski
db894cb68a Refactor Go API (#1111)
* 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
Piotr Jastrzębski
c41e17a998 Encryption in Go SDK (#1099)
* 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
Rafael Zasas
3d36420113 Update libsql.go (#1033)
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
Piotr Jastrzębski
64e5549cec Go Bindings: More tests (#1008)
* 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
Piotr Sarna
cd82068edf libsql_server,bottomless: add encryption support (#928)
* 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
Piotr Jastrzębski
992b450bfb Go bindings: Implement transactions + tests (#1004)
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-02-08 15:39:39 +00:00
Piotr Jastrzębski
1013548213 Go tests2 (#969)
* 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
Piotr Jastrzębski
3c7c2f373c Go bindings support time.Time (#968)
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-30 11:57:01 +01:00
Piotr Jastrzębski
4332bb6c16 Go tests (#962)
* 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
Piotr Jastrzębski
50a4da3423 Go bindings add prepared statement (#961)
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-29 14:27:42 +00:00
Piotr Jastrzębski
8d715223a8 C/Go bindings: Use libsql::Statement in prepare (#960)
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-29 13:21:15 +00:00
Piotr Jastrzębski
6bc489dd1d Go bindings: Add support for transactions and more tests (#944)
* 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
Piotr Jastrzębski
b02947daef Go bindings add positional parameters (#920)
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-25 10:05:40 +00:00
Piotr Jastrzebski
f5160ac03c Go bindings: Improve Connector close
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-24 11:34:44 +01:00
Piotr Jastrzebski
ee964f6aad Go bindings support remote only dbs
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-01-22 12:45:49 +01:00
Lucio Franco
2d50c3ad9c fix go bindings 2023-10-16 10:38:34 -07:00
Lucio Franco
07782b2263 move crates to root 2023-10-16 09:06:25 -07:00