Commit Graph

142 Commits

Author SHA1 Message Date
Nikita Sivukhin
5838efe7dd rename flag to wal_auto_checkpoint_disabled 2025-08-13 15:26:25 +04:00
PThorpe92
c3b536957f Fix max_frame determination and comments in WAL checkpointing 2025-08-12 08:57:35 -04:00
danawan
85ca5e07ee fix clippy in test 2025-08-10 18:31:08 +07:00
danawan
f450524ddb sqlite3 api add bind_text and bind_blob 2025-08-10 18:20:52 +07:00
danawan
ea7cad1188 fix clippy warnings in tests 2025-08-07 20:49:39 +07:00
danawan
0ab0c2e0c7 fix clippy 2025-08-07 20:36:52 +07:00
danawan
eaa614aa51 add basic bind and column functions 2025-08-07 20:20:23 +07:00
Nikita Sivukhin
2e23230e79 extend raw WAL API with few more methods
- try_wal_watermark_read_page - try to read page from the DB with given WAL watermark value
- wal_changed_pages_after - return set of unique pages changed after watermark WAL position
2025-08-04 16:55:50 +04:00
Nikita Sivukhin
0adb40534c hind dangerous methods behind conn_raw_api feature 2025-08-04 12:40:28 +04:00
Pekka Enberg
4aea9372bd Rename liblimbo_sqlite3 to libturso_sqlite3 2025-08-02 11:24:40 +03:00
PThorpe92
3db72cf111 Just forget Full checkpoint mode for now, comment out compat test 2025-07-30 14:08:33 +03:00
PThorpe92
b214c3dfc8 Add diff chkpt modes to sqlite3 api, finish checkpoint logic and add tests 2025-07-30 14:08:33 +03:00
PThorpe92
7643ef97a6 Pass checkpoint mode from sqlite3 c api argument 2025-07-30 14:08:33 +03:00
Pekka Enberg
e2d4cbbe48 Merge 'core: Enforce shared database object per database file' from Pekka Enberg
We need to ensures that there is a single, shared `Database` object per
a database file. We need because it is not safe to have multiple
independent WAL files open because coordination happens at process-level
POSIX file advisory locks.
Fixes #2267

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #2299
2025-07-28 19:34:35 +03:00
Nikita Sivukhin
ff0410a7d3 fix clippy (2) 2025-07-28 17:36:41 +04:00
Nikita Sivukhin
4695719d2b fix C bindings 2025-07-28 17:20:10 +04:00
Pekka Enberg
b2a5a7077c sqlite3: Fix WAL tests by closing connection
Commit ac33ae90 ("core: Enforce single, shared database object per
database file") changes the semantics of the WAL because unless we close
all the connections, the WAL remains open due to `Database` being kept
open in memory. Fix test failures by properly closing the connection
between different test cases.
2025-07-28 13:04:22 +03:00
PThorpe92
fb611390c0 Update test to use realistic expectations for should_checkpoint in cacheflush 2025-07-26 23:03:51 -04:00
Pekka Enberg
648ad3e74d Merge 'sqlite3: Improve SQLite error handling and fix C-string safety' from Ceferino Patino
This PR addresses two related issues in the SQLite3 C API
implementation:
1. Properly sets error codes on the database object when handling SQL
preparation failures
2. Fixes C string handling in sqlite3_errstr_impl to ensure proper null-
termination
Error codes should be correctly set on the database object, making them
accessible to API consumers. Also fixes and issue where C strings
weren't properly null-terminated in error reporting functions, which
causes the issue in #2197 where messages all get pushed onto a single
line. Its possible that this also fixes a buffer overflow, but I'm not
actually sure what the behavior was.

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #2212
2025-07-24 14:40:37 +03:00
Nikita Sivukhin
3c0af3e389 small adjustments 2025-07-23 11:31:00 +04:00
Nikita Sivukhin
16763e1500 implement raw WAL write api 2025-07-23 11:30:59 +04:00
Nikita Sivukhin
d617d1d21e fix raw read frame WAL API 2025-07-22 16:21:04 +04:00
C4 Patino
ae1ad65bd2 fix: issue with c_str not being properly null-terminated 2025-07-22 07:05:54 -05:00
C4 Patino
cb08e4cdc3 fix: error codes being properly set on the db object 2025-07-21 14:29:05 -05:00
Jussi Saurio
a48b6d049a Another post-rebase clippy round with 1.88.0 2025-07-12 19:10:56 +03:00
pedrocarlo
711b1ef114 make all run_once be run under statement or connection so that rollback is called 2025-07-07 11:51:25 -03:00
pedrocarlo
56d87cb916 move disable behavior to connection instead of checkpoint 2025-07-03 12:05:53 -03:00
pedrocarlo
3861584edc add test for wal checkpointing correctly 2025-07-03 12:04:17 -03:00
pedrocarlo
44b8275b26 add test + implement sqlite3_column_int64 for test 2025-07-03 12:04:17 -03:00
pedrocarlo
db005c81a0 add option to disable wal checkpoint 2025-07-03 12:04:17 -03:00
Pekka Enberg
53ba3ff926 Rename limbo_core crate to turso_core 2025-06-29 09:59:17 +03:00
Pekka Enberg
2fc5c0ce5c Switch to runtime flag for enabling indexes
Makes it easier to test the feature:

```
$ cargo run --  --experimental-indexes
Limbo v0.0.22
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database
limbo> CREATE TABLE t(x);
limbo> CREATE INDEX t_idx ON t(x);
limbo> DROP INDEX t_idx;
```
2025-06-26 10:07:28 +03:00
Pekka Enberg
5c35810f78 sqlite3: Make Clippy happy 2025-06-16 11:07:39 +03:00
Pekka Enberg
5b47c9932d sqlite3: Make sqlite3 thread safe with a mutex
Make the sqlite3 object thread-safe with a mutex, like SQLite does.
2025-06-16 11:03:21 +03:00
Pekka Enberg
5fb50245ed sqlite3: Clean up sqlite3_wal_checkpoint() function 2025-06-16 11:02:44 +03:00
Pekka Enberg
50fdf7105d sqlite3: Clean up sqlite3_extended_errcode() function 2025-06-16 11:02:44 +03:00
Pekka Enberg
6901b7bcd6 sqlite3: Clean up sqlite3_errmsg() function 2025-06-16 11:02:44 +03:00
Pekka Enberg
0830578ec5 sqlite3: Clean up sqlite3_errcode() function 2025-06-16 11:02:44 +03:00
Pekka Enberg
5477d0a4f5 sqlite3: Clean up sqlite3_safety_check_sick_or_ok() function
Underscore in parameter or variable name indicates it's not used. Also,
drop useless `crate` qualifier from constants.
2025-06-16 11:02:44 +03:00
Pekka Enberg
0b0f712575 sqlite3: Move sqlite3_safety_check_sick_or_ok() to lib.rs
It's pointless to have a module for just one function...
2025-06-16 11:02:43 +03:00
Pekka Enberg
90c1e3fc06 Switch Connection to use Arc instead of Rc
Connection needs to be Arc so that bindings can wrap it with `Mutex` for
multi-threading.
2025-06-16 10:43:19 +03:00
Jussi Saurio
e59c1ac985 tests/compat: use tempfiles for all empty dbs the tests open 2025-05-29 11:01:37 +03:00
Pekka Enberg
ac97ac36a6 Fix broken build in sqlite3 tests
Thanks for the heads up Pedro!
2025-05-27 18:44:41 +03:00
Pekka Enberg
99926c5f99 sqlite3/tests: Clippy is not happy 2025-05-27 18:16:54 +03:00
Pekka Enberg
edfa7402f0 sqlite3/test: Use tempfile in read frame test case
...make test runs idempotent, as suggested by Jussi.
2025-05-27 16:45:02 +03:00
Pekka Enberg
3250560eb8 sqlite3: Add libsql_wal_get_frame() API 2025-05-27 13:47:40 +03:00
Pekka Enberg
9f5904d4df cargo fmt 2025-05-22 13:02:30 +03:00
Pekka Enberg
7d471889eb sqlite3: Switch to tracing logger
...we now actually see logging from core too.
2025-05-22 12:37:09 +03:00
PThorpe92
45de41626c Adjust sqlite3 compat tests to use temp cloned database so further tests dont break 2025-05-17 16:11:59 -04:00
Pekka Enberg
524a523036 sqlite3: Add libsql_wal_frame_count() API 2025-05-15 11:43:44 +03:00