0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2025-05-16 22:32:26 +00:00

87 Commits

Author SHA1 Message Date
2be18a8e0f feature in one commit 2024-07-15 21:08:14 +04:00
bbf49a2199 fix comment 2024-07-15 18:23:52 +04:00
c9b8a07d42 add isInitialized flag to the BlobSpot 2024-07-15 18:22:37 +04:00
1b623c01bb slightly change interface for BlobSpot 2024-07-15 16:56:19 +04:00
4d3432736b add const to the signatures 2024-07-15 12:09:34 +04:00
b7026f528d remove changes from another branch 2024-07-12 17:11:51 +04:00
156cc67ad0 diskann vector binary format 2024-07-12 16:55:34 +04:00
4b21878187 add benchmark scripts ()
* add benchmark scripts

* remove unnecessary srand
2024-07-12 10:04:59 +00:00
be1fca578f feat(vector): add basic functions (vector/vector_extract etc) ()
* add basic functions for working with f32/f64 vectors

* add header file

* fix comment style

* add generic code for working with vectors

* register vector functions

* fix edge cases in vector extract impl

* add static flag for vector (will be used later)

* add basic TCL-based tests

* guard vector functions with SQLITE_OMIT_VECTOR

* adjust build scripts

* delete libsql_vector_idx from this branch

* add one more test

* update bundles

* fix asserts

* fix constants (#define-s are universal but const int doesn't recognized by all compilers)

* update bundles

* review fixes

* build bundles

* add comment about linking math library
2024-07-08 08:27:33 +00:00
2402249b5d apply alter column command only to the table ()
* add alter column test

* apply alter column only to the table and ignore indices/triggers/views etc

* fix tests

* update bundle

* add test in rust_suite
2024-07-04 19:48:33 +00:00
b17b6ee0d4 adjust ALTER COLUMN parsing ()
* add basic TCL tests for ALTER COLUMN libsql feature

* propagate length of the new column definition directly from the parser

- this will allow libsql to automatically handle comment and space characters appended to the column definition

* small formatting fixes

* cargo xtask build-bundled

* add test against sqlite3 source in rust_suite

* fix test in rust_suite
2024-07-02 22:02:14 +00:00
355ec0aa16 fix overflow in row counters ()
* replace row read/written with saturating counter

* regenerate bundled sqlite

* fix invalid cast
2024-07-02 09:38:14 +00:00
a0494abd8f use dedicated destroy_wal_manager function to destroy wal as it can be static () 2024-06-27 10:59:55 +00:00
e349a06961 Make libsql-ffi's build more friendly to sandboxed environments. ()
fix: prevent out_path from inheriting the mode of source bindgen.rs
2024-06-18 12:55:36 +00:00
e451079c18 Allow single transaction in schema migration ()
* Return also Program from Connection::run

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

* Extract LibSqlConnection::execute

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

* Use LibSqlConnection::execute in write_proxy

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

* Remove Clone from Program

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

* Remove Arc from Program

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

* Allow a single transaction in schema migration

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

* fix rustc-hash dep issue

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

---------

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
2024-05-28 15:05:45 +00:00
ef446125f7 write queue ()
* introduce connection manager

* remove unused wal methods

* remove lock stealer

* Make use of ConnectionManager in LibsqlConnection

it now takes a W: WalWrap instead of a WalManager. This is because we
want to inject the connection manager at the bottom of the wal wrapping
chain.

* add missing deps

* turn ReplicationLogger into a WrapWal

* update spots to to pass wal wrapper instead of wal manager

* remove dbg

* fmt

* fix sqlite3 rust tests
2024-03-20 22:27:13 +00:00
a2b2b9e00a libsql-sqite3: Fix sqlite3_get_autocommit() export in Wasm () 2024-03-11 14:26:37 +00:00
49db7d57b7 Make sure the C code doesn't segfault ()
* make sure pager is valid

We have had a segfault issue recently because the pager passed down
to the c code was null. That happened because libsql-server had
encryption disabled, while libsql had encryption enabled.

To prevent issues like that in the future, the C code should be checking
if the arguments it needs are valid.

Because this function returned a pointer, we now change it so that it
can return an integer, with the pointer as a return argument.

* update generated code

We have generated code in-tree. We should either remove it, or keep it
in sync. For now, just keeping it in sync.

This patch is just the result of running tests, and seeing what changes.
2024-02-28 20:05:50 +00:00
52d8b8f1c4 Multi-scopes auth & Attach fix ()
* test snapshots

* allow multi-scope auth

* hors-sujet: fix C compile warning

* update jwt and add hashbrown feature

* replace Auth with RequestContext

* extract RequestContext

* fix auth check for multi-scopes

* pass NamespaceName in StmtKind::Attach

* fallback to global auth if key is not set in ns config

* add allow_attach to namespace creation

* return meta store from namespace store

* test attach

* fmt

* review edits
2024-02-26 13:56:20 +00:00
e60a4e33f8 Updated libsql_extensions.md fix broken link ()
Fixed broken link to `wal.h`
2024-02-23 05:15:27 +00:00
112c72bb8e bugfix: RANDOM ROWID should be respected in VACUUM and bulk insert ops ()
* Add regression tests for random rowid bugs

Tests added for:

1. VACUUM does not respect RANDOM ROWID - https://github.com/tursodatabase/libsql/issues/929
2. Bulk insert into a fresh table does not respect RANDOM ROWID - https://github.com/tursodatabase/libsql/issues/1046

In both cases, the table should end up random rowids, but they seem to have sequential ones.

* bugfix: pass `regNextRowid` to `OP_NewRowid` call in `xferOptimization`

The register `regNextRowid` contains the `LIBSQL_RANDOM_ROWID_MARKER` value
which tells the VDBE to use a random value for row ids. The method `xferOptimization`
is used in `VACUUM` and bulk insert routines where data from one table is
inserted in another. Since the data is inserted in a loop, it checks for
max rowid once and then keeps inserting it serially. Hence we pass the marker
in each call, so that random id is generated.
2024-02-19 16:58:50 +00:00
d178de8f07 bugfix: reset modifications of sqlite3_vtab ()
* Remove `libsql_module` field from `sqlite3_vtab`

* remove `libsql_module` struct

Also removed the associated functions `libsql_create_module_v2`, `libsql_create_module` functions'.

The `libsql_module` had a function `xPreparedSql` which is now moved to `sqlite_module`. The `sqlite_module` might get changed in the upstream, so added some padding space for our custom functions

* generate ffi bindings

* Add a github workflow to test crsqlite

* fix crsqlite: remove `pLibsqlModule` references

* Add tests for sqlite-vss extension
2024-02-15 18:18:30 +00:00
b0887d6fa6 fix ci () 2024-02-07 08:54:01 +00:00
a72c066a8e Wal related changes ()
wal extensions
2024-02-06 17:44:23 +00:00
2e04f8febf wal.c: fix the function pointer type ()
* wal.c: fix the function pointer type

A 100% benign error, because the function has the correct signature,
but gets rid of a compiler warning.

* regenerate sqlite3.c amalgamation

* libsql-ffi: regenerate SQLite3MultipleCiphers' sqlite3.c

... not needed later, because an existing patch series switches it
to use the sqlite3.c amalgamation file from bundled/src/,
but let's update it for now.
2024-01-29 11:46:51 +00:00
e1cc9ff829 return number of committed frames on insert_frames () 2024-01-25 16:39:29 +00:00
62f61dbf14 review edits 2024-01-19 12:16:25 +01:00
e83308c5e5 fix sqlite3 rust tests 2024-01-19 09:33:22 +01:00
ea46e792ca introduce wal checkpoint callback 2024-01-19 09:32:34 +01:00
3922cd9bae libsql-sqlite3: add temporary API for leaking database pager
Used for WAL encryption until we migrate that layer to virtual WAL.
2024-01-19 08:22:56 +01:00
87ebafccc3 Merge pull request from tursodatabase/penberg/wasm-autocommit
libsql-sqlite3: Export more API functions in Wasm
2024-01-16 10:39:54 +00:00
12cab8ae52 libsql-sqlite3: Export sqlite3_last_insert_rowid() in Wasm 2024-01-15 12:59:13 +02:00
566434c339 libsql-sqlite3: Export sqlite3_get_autocommit() in Wasm
We need the `sqlite3_get_autocomit()` helper in the TypeScript SDK, for
example. The fact that it's not exported seems to be just an omission so
let's add it.
2024-01-11 11:32:40 +02:00
441b283551 rename getMissingFrame to ignoreFrameIfNewerExist 2024-01-09 16:06:15 +01:00
26789ec455 review edits 2024-01-09 14:25:42 +01:00
f932572382 sqlite3 wal reverse iterator 2024-01-09 12:31:53 +01:00
461f5731b2 Merge pull request from vlcn-io/ci
add a ci task to build cr-sqlite binaries against libsql
2024-01-08 15:48:36 +00:00
450e9053b9 main,pager,pragma: forward-declare custom libsql functions 2024-01-03 13:00:12 +01:00
379b227587 pager,wal: first batch of hooks to integrate encryption
Based on https://gist.github.com/psarna/0dbd95424fb7121bb54bf5f961e1e117
from SQLite3MultipleCiphers, let's try and make libsql flexible enough
to not require patching the amalgamation files at all in order to integrate
with SQLite3Multiple ciphers.

For starters, their codec functions are instead declared as libsql_pager_codec
and libsql_pager_has_codec. The idea for future integration is that
if an appropriate compilation flag is on, we assume that the code will be compiled
with additional symbols that provide all the implementation we need, e.g.
libsql_pager_codec_impl() will just transiently call sqlite3mcPagerCodec().
2024-01-03 13:00:12 +01:00
52bb6cc706 libsql-sqlite3: add hooks for vfs, pragmas and uri
If the following directives are defined:
 - LIBSQL_PRE_VFS_HOOK
 - LIBSQL_EXTRA_PRAGMAS
 - LIBSQL_EXTRA_URI_PARAMS
, a few new symbols need to be compiled in, respectively:
 - libsql_pre_vfs_hook(const char *)
 - libsql_extra_pragma(sqlite3 *, const char *, void *)
 - libsql_handle_extra_uri_params(sqlite3 *, const char *),
   libsql_handle_extra_attach_params(sqlite3 *, const char *,
     const char *, sqlite3_value *, char **)

Those hooks, combined with virtual WAL, should be plenty enough to
integrate SQLite3MultipleCiphers without patching sqlite3.c code.
2024-01-03 13:00:12 +01:00
2f599e2621 libsql-sqlite3: restore sqlite3_filename_* API semantics
Those are really weird internally, and assume that the db path string
you pass as an argument resides in a very specific place in memory,
preceded by 4 zero bytes, and followed by journal and wal names.
The WALv2 rework broke this magic assumption, so we hereby restore it.

As follow-up, we should move this filename management to virtual WAL,
because with virtual WAL implementations you sometimes don't even have
a notion of "WAL file path".
2023-12-22 11:21:03 +01:00
682d42783d fix missing define for cases where we build a loadable rather than static libsql extension 2023-12-21 15:08:39 -05:00
f42bd234c6 pull in latest cr-sqlite changes 2023-12-21 15:05:06 -05:00
5a9c14fc26 libsql-sqlite3: initialize libsqlApi properly
... previously we somehow missed libsql_close_hook
2023-12-20 12:07:01 +01:00
e21cefe907 Merge pull request from vlcn-io/update-libsql
update cr-sqlite to v0.16.2
2023-12-15 17:00:49 +00:00
0e025264b2 fix missing commit frame on local_client inject from snapshot 2023-12-13 13:18:07 +01:00
7a3723663b tweaks to get compiling again after libsql updates 2023-12-12 09:58:03 -05:00
28bb1bc621 update cr-sqlite to v0.16.2 2023-12-12 09:46:49 -05:00
ae9daa8b74 Use NonZeroU32 for frame_no and page_no 2023-12-05 09:20:44 +01:00
4ae365b557 fix review nits 2023-11-30 11:26:49 +01:00