Commit graph

70 commits

Author SHA1 Message Date
Jussi Saurio
ea905d276c
Merge 'Add #[turso_macros::test] to automatically create tests that can run MVCC with minimal code changes' from Pedro Muniz
- added procedural macro that creates Rust tests and with just a flag,
creates a new test that runs the same with MVCC enabled
- migrated almost all tests to use this new macro and added the mvcc
flag to the tests that were not failing
- added a `TempDatabase` builder to facilitate the proc_macro to
generate the correct database options

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

Closes #3991
2025-11-27 21:53:09 +02:00
Pekka Enberg
36d2dfcbad macros: Replace unwrap() with expect() in generate_get_description() 2025-11-22 09:57:44 +02:00
Pekka Enberg
7b1b06a128 macros: Eliminate unwrap() calls in derive_atomic_enum_inner() 2025-11-22 09:57:44 +02:00
Pekka Enberg
bdbcfaa28b macros: Eliminate unwrap() in match_ignore_ascci_case() 2025-11-22 09:57:44 +02:00
pedrocarlo
a3acec58df clippy 2025-11-19 23:42:46 -03:00
pedrocarlo
99f895256d add docs to macro 2025-11-19 23:28:23 -03:00
pedrocarlo
0ffda31549 add init_sql arg to proc macro 2025-11-19 12:08:18 -03:00
pedrocarlo
1e85706d54 pass the fn arg type to the macro closure to avoid errors 2025-11-19 11:49:53 -03:00
pedrocarlo
19bb802f97 create two tests when mvcc flag is passed 2025-11-19 11:49:53 -03:00
pedrocarlo
237ce5b601 enhance proc macro to detect the fn args and the return type with better spans 2025-11-19 11:49:53 -03:00
pedrocarlo
696bf2252c create a basic test proc macro that takes a db path and an mvcc flag 2025-11-19 11:49:53 -03:00
PThorpe92
e09d9eb720
Add VBegin, VRename, VRollback and VCommit opcodes 2025-11-09 11:07:42 -05:00
PThorpe92
a8b257c664
Replace several RwLock<Enum> values with new AtomicEnums 2025-10-22 09:35:26 -04:00
PThorpe92
123a26b7d9
Add AtomicEnum macro macros crate 2025-10-22 09:27:14 -04:00
TcMits
4bb6b02b65 clean PR 2025-09-14 19:03:09 +07:00
TcMits
a658273c63 fmt 2025-09-14 18:59:57 +07:00
TcMits
cab0c7b545 peft tuning 2025-09-14 18:53:53 +07:00
TcMits
17ee979583 fix macro 2025-09-13 16:35:58 +07:00
TcMits
40adf3fcfd Merge branch 'perf-3' into perf-4 2025-09-02 18:47:05 +07:00
TcMits
bc8b848aba docs 2025-09-02 18:43:12 +07:00
TcMits
37f33dc45f add eq/contains/starts_with/ends_with_ignore_ascii_case 2025-08-31 16:18:42 +07:00
TcMits
190e9bcc95 add match_ignore_ascii_case macro 2025-08-31 14:35:03 +07:00
Nikita Sivukhin
c771487933 add remove_file method to the IO 2025-08-21 14:51:02 +04:00
PThorpe92
ec95c3f8fb
Add callback api to proc macros 2025-08-13 21:42:19 -04:00
PThorpe92
e9838daa28
Update macro to use const conn pointer 2025-08-06 16:27:26 -04:00
Piotr Rzysko
61234eeb19 Add ResultCode to best_index result
The `best_index` implementation now returns a ResultCode along with the
IndexInfo. This allows it to signal specific outcomes, such as errors or
constraint violations. This change aligns better with SQLite’s xBestIndex
contract, where cases like missing constraints or invalid combinations of
constraints must not result in a valid plan.
2025-08-04 20:18:44 +02:00
PThorpe92
3be8bb374d Use usize for truncate method in place of u64 2025-07-30 13:48:05 +03:00
PThorpe92
d30157518f Impl truncate method for VFS io module and create plumbing in extension lib 2025-07-30 13:48:05 +03:00
PThorpe92
d7c3256a5a
Update vtab derive macro to pass readonly const to module impl 2025-07-23 16:59:18 -04:00
Jussi Saurio
022f679fab chore: make every CREATE TABLE stmt in entire repo have 1 space after tbl name
`BTreeTable::to_sql` makes us incompatible with SQLite by losing e.g. the original whitespace provided during the CREATE TABLE command.

For now let's fix our tests by regex-replacing every CREATE TABLE in
the entire repo to have exactly 1 space after the table name in the
CREATE TABLE statement.
2025-07-22 11:35:21 +03:00
Nils Koch
828d4f5016 fix clippy errors for rust 1.88.0 (auto fix) 2025-07-12 18:58:41 +03:00
Pekka Enberg
eb0de4066b Rename limbo_ext crate to turso_ext 2025-06-29 12:14:08 +03:00
Pekka Enberg
eec994386b Rename limbo_macros to turso_macros 2025-06-29 12:00:17 +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
PThorpe92
cbd7245677
Update Vtable open method to accept core db connection 2025-05-24 14:49:58 -04:00
Piotr Rzysko
9c1dca72db Introduce VTable
This allows storing table arguments parsed in the VTabModule::create
method.
2025-05-21 08:33:17 +02:00
Piotr Rzysko
ea0ec6a216 Remove VTabModule methods delegating directly to VTabCursor 2025-05-21 08:29:20 +02:00
PThorpe92
e86aec892e
Reorganize macros to separate those needed for extension library for better labeling of PRs 2025-05-16 11:20:14 -04:00
Piotr Rzysko
977b6b331a Fix memory leak caused by unclosed virtual table cursors
The following code reproduces the leak, with memory usage increasing
over time:

```
#[tokio::main]
async fn main() {
    let db = Builder::new_local(":memory:").build().await.unwrap();
    let conn = db.connect().unwrap();

    conn.execute("SELECT load_extension('./target/debug/liblimbo_series');", ())
        .await
        .unwrap();

    loop {
        conn.execute("SELECT * FROM generate_series(1,10,2);", ())
            .await
            .unwrap();
    }
}
```

After switching to the system allocator, the leak becomes detectable
with Valgrind:

```
32,000 bytes in 1,000 blocks are definitely lost in loss record 24 of 24
   at 0x538580F: malloc (vg_replace_malloc.c:446)
   by 0x62E15FA: alloc::alloc::alloc (alloc.rs:99)
   by 0x62E172C: alloc::alloc::Global::alloc_impl (alloc.rs:192)
   by 0x62E1530: allocate (alloc.rs:254)
   by 0x62E1530: alloc::alloc::exchange_malloc (alloc.rs:349)
   by 0x62E0271: new<limbo_series::GenerateSeriesCursor> (boxed.rs:257)
   by 0x62E0271: open_GenerateSeriesVTab (lib.rs:19)
   by 0x425D8FA: limbo_core::VirtualTable::open (lib.rs:732)
   by 0x4285DDA: limbo_core::vdbe::execute::op_vopen (execute.rs:890)
   by 0x42351E8: limbo_core::vdbe::Program::step (mod.rs:396)
   by 0x425C638: limbo_core::Statement::step (lib.rs:610)
   by 0x40DB238: limbo::Statement::execute::{{closure}} (lib.rs:181)
   by 0x40D9EAF: limbo::Connection::execute::{{closure}} (lib.rs:109)
   by 0x40D54A1: example::main::{{closure}} (example.rs:26)
```

Interestingly, when using mimalloc, neither Valgrind nor mimalloc’s
internal statistics report the leak.
2025-05-05 21:26:23 +02:00
PThorpe92
95a2fdc096
Fix array from ptr in bestindex ffi method in proc macro 2025-04-17 14:01:45 -04:00
PThorpe92
853af16946
Implement xBestIndex for virtual table api to improve query planning 2025-04-17 13:53:27 -04:00
pedrocarlo
2181de79de add destroy function to vtab 2025-04-13 17:06:12 -03:00
PThorpe92
57d4aa7216
Reorganize ext library and feature gate vfs to more easily prevent wasm build issues 2025-03-19 10:17:11 -04:00
PThorpe92
6cb9091dc8
Remove unused macro method 2025-03-12 21:52:51 -04:00
PThorpe92
35fc9df275
Rename and combine testing extension crate 2025-03-12 21:52:51 -04:00
PThorpe92
7c4f5d8df8
Add macros for generating FFI functions to support vfs 2025-03-12 21:52:50 -04:00
PThorpe92
04abb200a7
Get name of argument for scalars in extensions to allow for less rigid naming 2025-03-01 14:27:33 -05:00
PThorpe92
0547d397b1
Update extension api for vtable interface 2025-02-17 20:44:45 -05:00
PThorpe92
9c8083231c
Implement create virtual table and VUpdate opcode 2025-02-17 20:44:44 -05:00
PThorpe92
d775b3ea5a
Improve extension API with results, fix paths in proc macros 2025-02-17 20:44:39 -05:00