Commit Graph

2162 Commits

Author SHA1 Message Date
krishvishal
a4a1ff2b6d Handle special case -9223372036854775808 and prevent conversion to Real 2025-01-29 15:13:57 +05:30
Pekka Enberg
ad8e05b9a1 Merge 'bindings/java: Implement LimboConnection close() ' from Kim Seon Woo
## Purpose of thie PR
- Implement `close()` method for `LimboConnection` and `JDBC4Connection`
## Changes
- Instead of closing the database when closing connections, close the
connection instead
## References
- https://github.com/tursodatabase/limbo/issues/615

Closes #797
2025-01-27 14:51:04 +02:00
김선우
6252947232 Fix the logic on determining whether connection is closed 2025-01-27 19:49:10 +09:00
김선우
1125e51a59 Add test for close() 2025-01-27 19:19:34 +09:00
김선우
dae15ef0e3 Implement limbo close() 2025-01-27 19:15:02 +09:00
Pekka Enberg
ef6a1be335 Merge 'Enable static linking for 'built-in' extensions' from Preston Thorpe
This PR introduces the ability to build and link with an extension
library, enabling features like `uuid` to not have to be shipped as
independent libraries and loaded at runtime.
To build and link with an extension, you simply add it as a dependency
with the `static` feature, and call register_extension_static. in this
case, we feature flag that with `uuid`
```rust
    #[cfg(feature = "uuid")]
    pub fn register_uuid(&self) -> Result<(), String> {
        let ext_api = Box::new(self.build_limbo_ext());
        if unsafe { !limbo_uuid::register_extension_static(&ext_api).is_ok() } {
            return Err("Failed to register uuid extension".to_string());
        }
        Ok(())
    }
```
So fortunately wasm targets are no longer excluded from extensions, only
loading them at runtime for now

Closes #737
2025-01-27 09:49:48 +02:00
Pekka Enberg
e8600fa2a1 Merge branch 'main' into static 2025-01-27 09:49:34 +02:00
Pekka Enberg
5a1e1f690a Merge 'bindings/java: Log driver loading error' from Pekka Enberg
Reviewed-by: Kim Seon Woo (@seonWKim)

Closes #791
2025-01-27 09:09:03 +02:00
Pekka Enberg
6f93f290e1 bindings/java: Log driver loading error 2025-01-26 21:07:18 +02:00
Pekka Enberg
9b9d5f9b4c Merge 'bindings/go: Rename to Limbo' from Pekka Enberg
...we'll likely call this Turso eventually, but right now, let's keep
the code consistent.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #790
2025-01-26 21:04:43 +02:00
Pekka Enberg
0918fc40d4 bindings/go: Rename to Limbo
...we'll likely call this Turso eventually, but right now, let's keep
the code consistent.
2025-01-26 20:58:10 +02:00
Pekka Enberg
4f1548d27b Merge 'bindings/java: Apply spotless formatting in bindings/java project ' from Kim Seon Woo
## Changes
- Add lint related commands in Makefile
- Apply spotless formatting
## Related
- [Issue](https://github.com/tursodatabase/limbo/issues/615)

Closes #783
2025-01-26 20:48:42 +02:00
Pekka Enberg
089e4e66eb Merge 'Implemented json_valid function' from Harin
Closes #789
2025-01-26 20:48:16 +02:00
Pekka Enberg
76e76ba404 Merge 'core: Remove database header from BTreeCursor' from Pekka Enberg
It's already in the pager so use it from there to reduce the size of the
`BTreeCursor` struct.

Closes #788
2025-01-26 20:48:03 +02:00
Harin
0903b9b019 Implemented JSON valid function 2025-01-26 23:35:47 +05:30
Pekka Enberg
983875c443 core: Remove database header from BTreeCursor
It's already in the pager so use it from there to reduce the size of the
`BTreeCursor` struct.
2025-01-26 16:48:12 +02:00
Pekka Enberg
359576d910 Merge 'core: Kill Rows wrapper struct' from Pekka Enberg
It's just an useless wrapper, kill it.

Closes #786
2025-01-26 16:40:51 +02:00
Pekka Enberg
7967cc5efc core: Kill Rows wrapper struct
It's just an useless wrapper, kill it.
2025-01-26 16:27:19 +02:00
Pekka Enberg
9f3b2dcc92 Merge 'Program state optimizations' from Jussi Saurio
Current micro-optimizations:
- store single data structure for cursors in programstate, not one for
every cursor type
- use vec for cursors instead of btreemap
- use knowledge of cursor amount to pre-allocate cursor vec capacity
- don't use resize in ::new() and ::reset(), instead populate directly
and reset by iterating over each elem (somehow this is faster)
- use bitfield for ended_coroutine instead of hashmap

Closes #782
2025-01-26 16:05:04 +02:00
Jussi Saurio
faa6d0c69d use vec for cursors, not map 2025-01-26 14:04:05 +02:00
Jussi Saurio
cdafc9033e ProgramState::registers - no resize 2025-01-26 13:56:09 +02:00
Jussi Saurio
b687cf66eb use bitfield for ended_coroutine 2025-01-26 13:12:47 +02:00
김선우
2212cc2a09 Apply lints 2025-01-26 20:04:57 +09:00
김선우
8b6e761496 Add lint commands in Makefile 2025-01-26 20:04:30 +09:00
Jussi Saurio
9e32ce6c77 Add Cursor enum and store a single BTreeMap of cursors in ProgramState 2025-01-26 12:57:15 +02:00
Pekka Enberg
609839d79a Merge 'core: Fix Statement::reset()' from Pekka Enberg
The first rule of writing fast programs: don't use dynamic memory
allocation!
Brings `SELECT 1` micro-benchmark back to 70 ns, which is a bit closer
to what we had before.

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

Closes #781
2025-01-26 11:56:44 +02:00
Pekka Enberg
8942c38bda core: Fix Statement::reset()
The first rule of writing fast programs: don't use dynamic memory
allocation!

Brings back some performance for the `SELECT 1` micro-benchmark,
although we're still not where we need to be.
2025-01-26 11:47:28 +02:00
Pekka Enberg
17e7e03423 Revert "cargo: Disable LTO.."
This reverts commit 4943217045 to get 5%
of performance back.

Before:

```
limbo/Execute prepared statement: 'SELECT 1'
                        time:   [111.45 ns 111.52 ns 111.61 ns]
                        thrpt:  [8.9594 Melem/s 8.9667 Melem/s 8.9727 Melem/s]
Found 8 outliers among 100 measurements (8.00%)
  2 (2.00%) low mild
  2 (2.00%) high mild
  4 (4.00%) high severe
```

```
limbo/Execute prepared statement: 'SELECT 1'
                        time:   [106.22 ns 106.48 ns 106.85 ns]
                        thrpt:  [9.3587 Melem/s 9.3911 Melem/s 9.4142 Melem/s]
                 change:
                        time:   [-4.8335% -4.6750% -4.5222%] (p = 0.00 < 0.05)
                        thrpt:  [+4.7364% +4.9043% +5.0790%]
                        Performance has improved.
```
2025-01-26 10:31:35 +02:00
Pekka Enberg
0d0906dce4 Merge 'simulator: implement --load and --watch flags' from Alperen Keleş
The current status of the PR is halfway. The new framing of simulation
runner where `setup_simulation` is separated from `run_simulation`
allows for injecting custom plans easily. The PR is currently missing
the functionality to update the `SimulatorEnv` ad hoc from the plan, as
the environment tables were typically created during the planning phase.
The next steps will be to implement a function `fn
mk_env(InteractionPlan, SimulatorEnv) -> SimulatorEnv`, add `--load`
flag to the CLI for loading a serialized plan file, making a
corresponding environment and running the simulation.
We can optionally combine this with a `--save` option, in which we keep
a seed-vault as part of limbo simulator, corresponding each seed with
its generated plan and save the time to regenerate existing seeds by
just loading them into memory. I am curious to hear thoughts on this?
Would the maintainers be open to adding such a seed-vault? Do you think
the saved time would be worth the complexity of the approach?

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

Closes #720
2025-01-26 08:52:58 +02:00
Pekka Enberg
6c80b1dc78 Merge 'bindings/go: Begin implementation of Go database/sql driver' from Preston Thorpe
This WIP driver uses the [purego](github.com/ebitengine/purego) library,
that supports cross platform `Dlopen`/`Dlsym` and not a whole lot else.
I really didn't want to use CGO, have very little experience with WASM
and I heard nothing but good things about this library. It's very easy
to use and stable especially when you consider the use case here of 3
functions.
![image](https://github.com/user-
attachments/assets/ae28c8f2-1d11-4d25-b999-22af8bd65a92)
NOTE: The WIP state that this PR is in right at this moment, is not able
to run these simple queries. This screengrab was taken from a couple
days ago when I wrote up a quick demo to load the library, call a simple
query and had it println! the result to make sure everything was working
properly.
I am opening this so kind of like the Java bindings, I can incrementally
work on this. I didn't want to submit a massive PR, try to keep them at
~1k lines max. The state of what's in this PR is highly subject and
likely to change.
I will update when they are at a working state where they can be tested
out and make sure they work across platforms.

Closes #776
2025-01-26 08:51:27 +02:00
Pekka Enberg
538b3ef823 Merge 'Implement strftime function' from Pedro Muniz
This PR implements the strftime scalar function. It uses underneath the
hood chrono's strftime function and the already existent modifier logic.
The caveat of using chrono's strftime implementation is that it supports
some additional syntax that is not supported in sqlite, such as
precision modifiers (%.3f). If this is a deal breaker for this function
to be implemented at the moment, I will then write a strftime
implementation from scratch.

Closes #778
2025-01-26 08:47:44 +02:00
Pekka Enberg
ef466cbdf7 Merge 'bindings/java: Add auto formatting for java bindings project ' from Kim Seon Woo
## Purpose of this PR
- Add bindings/java project level formatting style
## Changes
- Add spotless as the formatting tool
- USe Makefile to run lint on CI
## Reference
- [Corresponding PR](https://github.com/tursodatabase/limbo/pull/761)
should be merged first
- [Related Issue](https://github.com/tursodatabase/limbo/issues/615)

Closes #773
2025-01-26 08:47:00 +02:00
PThorpe92
32c985f9a8 Progress on Go bindings, add prepare + query statement 2025-01-25 23:01:46 -05:00
Pedro Muniz
9d858f5cb3 Merge branch 'tursodatabase:main' into feature/strftime 2025-01-25 16:23:32 -03:00
pedrocarlo
a316ab51ac feature: implement strftime function 2025-01-25 16:22:53 -03:00
PThorpe92
4be1f9c3cc Begin work on Go bindings (purego) 2025-01-25 11:37:12 -05:00
Pekka Enberg
aded7d3896 Merge 'Implement Or and And bytecodes' from Diego Reis
I think it is mostly correct, not so sure how to handle `BLOB`. One
thing that caught my attention is that sqlite seems to have a
optimization for trivial cases, saving some bytecodes, for instance:
![image](https://github.com/user-
attachments/assets/78b78a0d-5ab6-4a9e-aeac-fa97f1fc5c25)
I'm looking that right now.

Closes #777
2025-01-25 08:42:03 +02:00
Diego Reis
7902d5f200 Fix Text handling of And bytecode 2025-01-25 03:27:11 -03:00
김선우
7d81c32261 Add spotless support for bindings/java formatting 2025-01-25 15:25:13 +09:00
Pekka Enberg
12dd64a599 Merge 'chore: fix typos' from Sonny
while reading the code, I saw some typos so just fixing them.

Closes #770
2025-01-25 08:13:12 +02:00
Pekka Enberg
3c0d727c01 Merge 'Support returning column names from prepared statement' from Preston Thorpe
Closes #764
Go driver needs support for fetching the column names after `prepare`

Reviewed-by: Sonny (@sonhmai)

Closes #766
2025-01-25 08:12:21 +02:00
Pekka Enberg
27c9d06742 Merge 'Add Nyrkiö change point detection to 'cargo bench' workflow' from Henrik Ingo
This adds a separate push-only.yml workflow. For now pull request API
wasn't integrated yet, so shouldn't run on PRs.
disable cargo color
Fixes https://github.com/nyrkio/nyrkio/issues/304

Closes #762
2025-01-25 08:11:48 +02:00
Pekka Enberg
dde164f06a Merge 'Correct discord link' from Pedro Muniz
One of the discord links in the readme was pointing to a Chinese
discord. Both links are now pointing to Limbo's discord

Reviewed-by: Preston Thorpe (@PThorpe92)
Reviewed-by: Kim Seon Woo (@seonWKim)
Reviewed-by: Sonny (@sonhmai)

Closes #767
2025-01-25 08:11:31 +02:00
Pekka Enberg
d1b1ee2c96 Merge '[bindings/java] Fix failing tests ' from Kim Seon Woo
## The purpose of this PR
- Do not create a new `io` and instead use `io` which is used when
creating `LimboDatabase`.
- Run the loop of `step` function on the rust side(better for
performance as we don't have to switch between java <-> rust)
## Changes
- Java
  - handle invalid cases
  - remove @Disabled annotation from tests
- Rust
  - add loops in the step function
## Reference
- https://github.com/tursodatabase/limbo/issues/615

Closes #761
2025-01-25 08:08:34 +02:00
Diego Reis
e7d95399e3 Add Or bytecode
Take the logical OR of the values in register P1 and P2 and store the answer in register P3. If either P1 or P2 is nonzero (true) then the result is 1 (true) even if the other input is NULL. A NULL and false or two NULLs give a NULL output.
2025-01-25 02:54:14 -03:00
Diego Reis
aff454b5f6 Implement And bytecode
Take the logical AND of the values in registers P1 and P2 and write the result into register P3. If either P1 or P2 is 0 (false) then the result is 0 even if the other input is NULL. A NULL and true or two NULLs give a NULL output.
2025-01-25 02:12:50 -03:00
김선우
f10b41c5b5 Pass io to statement from db 2025-01-24 15:43:44 +09:00
김선우
53586b9d00 Break the loop when step() returns Err 2025-01-24 15:06:10 +09:00
김선우
0481e69217 Handle Err case from connection.io 2025-01-24 14:07:52 +09:00
김선우
36dff168b3 Execute io.run_once when receiving StepResult::IO 2025-01-24 13:52:54 +09:00