Commit graph

39 commits

Author SHA1 Message Date
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
PThorpe92
cd83ac6146
Remove error from vcursor trait in extensions 2025-02-06 09:15:39 -05:00
PThorpe92
a8ae957162
Add tests for series extension, finish initial vtable impl 2025-02-06 09:15:39 -05:00
PThorpe92
ad30ccdc0e
Add docs in extension README for vtable modules 2025-02-06 09:15:39 -05:00
PThorpe92
d4c06545e1
Refactor vtable impl and remove Rc Refcell from module 2025-02-06 09:15:39 -05:00
PThorpe92
661c74e338
Apply new planner structure to virtual table impl 2025-02-06 09:15:28 -05:00
Jussi Saurio
f5f77c0bd1
Initial virtual table implementation 2025-02-06 07:51:50 -05:00
PThorpe92
793cdf8bad
Fix memory issues, make extension types more efficient 2025-01-27 22:30:31 -05:00
PThorpe92
f13d035965
Enable wasm to static link extensions 2025-01-21 09:36:49 -05:00
PThorpe92
3d188eba0f
Enable staticly linking with builtin extensions 2025-01-21 09:32:43 -05:00
PThorpe92
bcd3ae2bd7
Add documentation to core/ext and relevant macros 2025-01-18 16:04:28 -05:00
PThorpe92
956320b7d0
Fix scalar API in extensions, add some error handling 2025-01-18 15:19:35 -05:00
PThorpe92
b57308003e
Handle freeing memory in finalize, remove unused free fn 2025-01-17 21:54:25 -05:00
PThorpe92
44374b9e69
Clean up scalar trait remove unnecessary args method 2025-01-17 14:13:57 -05:00
PThorpe92
0c737d88f7
Support aggregate functions in Extensions 2025-01-17 14:13:57 -05:00
PThorpe92
9b7b794e07
Begin sketching out aggregates api 2025-01-17 14:13:42 -05:00
Pekka Enberg
93903555aa Rename limbo_extension crate to limbo_ext 2025-01-16 14:40:52 +02:00
PThorpe92
343ccb3f72
Replace declare_scalar_functions in extension API with proc macro 2025-01-14 11:49:57 -05:00
PThorpe92
f6cd707544
Add clippy CI, fix or ignore warnings where appropriate 2024-12-29 10:25:41 -05:00
Pekka Enberg
37e1f35df8 Fix Cargo.toml in macros crate 2024-12-25 11:54:16 +02:00
vignesh-j-shetty
a43a1d204c renamed macro crate 2024-12-21 13:19:04 +05:30