Commit Graph

2099 Commits

Author SHA1 Message Date
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
Jussi Saurio
a26fc1619a Merge 'Fix select X'1'; causes limbo to go in infinite loop' from Krishna Vishal
Closes https://github.com/tursodatabase/limbo/issues/730.
Fixed `blog_literal` function to make it return `TK_ILLEGAL` token which
in turn now causes parser to stop and return `UnrecognizedTokenError`.
Added `TK_ILLEGAL` to `TokenType` Enum.
Behavior now:
```sql
SELECT X'1';  -- Odd number of hex digits -> TK_ILLEGAL -> unrecognized token error

  × unrecognized token at (1, 12)
   ╭────
 1 │ SELECT X'1';
   ·        ▲
   ·        ╰── here
   ╰────

SELECT X'AB'; -- Valid blob -> TK_BLOB -> parses successfully
�
SELECT X'G1'; -- Invalid hex digit -> TK_ILLEGAL -> unrecognized token error

  × unrecognized token at (1, 13)
   ╭────
 1 │ SELECT X'G1';
   ·        ▲
   ·        ╰── here
   ╰────

```

Reviewed-by: Jussi Saurio (@jussisaurio)

Closes #736
2025-01-21 11:32:10 +02:00
Jussi Saurio
5b00e4143e Merge 'Centralize Rust integration and regression tests' from Sonny
## What?
- centralized Rust integration and regression tests
- no new tests added
- no tests removed
- only refactored tests into modules and common utils
## Why?
- @penberg and I have a discussion [here](https://github.com/tursodataba
se/limbo/pull/694#discussion_r1921949665) about centralizing the
integration/ regression tests so that they are not scattered around.
- this is a PR to do that and some refactor of the existing tests to
make the structure easier to navigate + add new tests in the future.

Reviewed-by: Jussi Saurio (@jussisaurio)
Reviewed-by: Preston Thorpe (@PThorpe92)
Reviewed-by: Pere Diaz Bou (@pereman2)

Closes #753
2025-01-21 11:31:05 +02:00
sonhmai
a090fb927a centralize Rust integration and regression tests 2025-01-21 15:41:09 +07:00
Pekka Enberg
c282b23e6b Merge 'Implement Concat opcode' from Harin
This adds the Concat opcode to the VDBE.

Closes #758
2025-01-21 07:45:16 +02:00
Pekka Enberg
db3fa2514c Merge 'add PRAGMA statements in COMPAT doc' from Sonny
What? adding PRAGMA statements in COMPAT doc.
Why?
- each pragma is quite independent of each other.
- make it clear for contribution.
- maybe lower the bar of contributing.

Closes #760
2025-01-21 07:43:26 +02:00
Harin
ab3a15e489 Code refactor 2025-01-21 10:02:19 +05:30
sonhmai
dd436d3fc5 add PRAGMA statements in COMPAT doc 2025-01-21 11:27:22 +07:00
Harin
da53cc3821 Added Concat Opcode 2025-01-21 00:29:23 +05:30
Pekka Enberg
c27427d644 Merge 'translate_condition_expr(): fix cases where 1. we jump on false and 2. either operand is NULL' from Jussi Saurio
Change explanation is in the code comment for `Insn::Eq`:
```
        /// Jump if either of the operands is null. Used for "jump when false" logic.
        /// Eg. "SELECT * FROM users WHERE id = NULL" becomes:
        /// <JUMP TO NEXT ROW IF id != NULL>
        /// Without the jump_if_null flag it would not jump because the logical comparison "id != NULL" is never true.
        /// This flag indicates that if either is null we should still jump.
        jump_if_null: bool,
```
Closes #754
Excerpt from SQLite bytecode documentation for e.g. `Lt`:
> If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or
reg(P3) is NULL then the take the jump. If the SQLITE_JUMPIFNULL bit is
clear then fall through if either operand is NULL.
I didn't want to start putting these flags into a bitmask so I just
added a separate boolean. Probably for sqlite `EXPLAIN` compatibility we
should, IF we want to be exactly compatible (which we aren't anyway atm)

Closes #755
2025-01-20 19:40:08 +02:00
Pekka Enberg
2cea85c13b github: Disable failing Nyrkiö workflow
We can revert this patch once the following issue is fixed:

https://github.com/nyrkio/nyrkio/issues/304
2025-01-20 19:09:17 +02:00
Jussi Saurio
ce15ad7d32 Simplify added tests with foreach 2025-01-20 17:30:04 +02:00
Jussi Saurio
2cd9118be6 Fix jump_if_true to be a bool literal in places where it was used as a register number 2025-01-20 17:13:34 +02:00
Jussi Saurio
f88a4d6ac6 Add jump_if_null to cmp insns to account for either operand being NULL 2025-01-20 16:54:39 +02:00
Pekka Enberg
2e5cccee90 Merge 'Fix parser panic when duplicate column names are given to CREATE TABLE' from Krishna Vishal
Currently, we are using the same `Parser` instance across multiple
queries (9cc9577c91).  But during this
error the parser is not finalized, so parser stack is not reset, thereby
triggering the assertion at https://github.com/tursodatabase/limbo/blob/
15f7928551435458e2991dde3a76ce71e8a32057/vendored/sqlite3-
parser/third_party/lemon/lempar.rs#L663
This PR fixes the panic by calling `sqlite3ParserFinalize()` in the case
of error.
Closes https://github.com/tursodatabase/limbo/issues/742
-----------
`git bisect` FTW

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #752
2025-01-20 16:36:37 +02:00
Krishna Vishal
b43c1544d4 Tokenizer::split() function returns TK_ILLEGAL instead of Error. 2025-01-20 19:37:15 +05:30
Krishna Vishal
04fd5a40d6 Finalize the parser in the case of Error while running queries. This resets the parser stack and prevents triggering the assertion and thereby panic.
Closes https://github.com/tursodatabase/limbo/issues/742
2025-01-20 16:10:35 +05:30
Pekka Enberg
9369f06699 Merge 'Initial support for wal_checkpoint pragma' from Sonny
Wire pragma wal_checkpoint to checkpoint infra
- add basic support for parsing and instruction emitting `pragma
wal_checkpoint;`
- checkpoint opcode for instruction
- checkpoint execution in `virtual machine`
- cli test
Part of #696.
Before
```
limbo> pragma wal_checkpoint;

  × Parse error: Not a valid pragma name
```
After
```
Enter ".help" for usage hints.
limbo> pragma wal_checkpoint;
0|0|0
```
```

Closes #694
2025-01-20 09:57:58 +02:00
Pekka Enberg
bda1e4e6ab Merge 'Add support for json_object function' from Jorge Hermo
Relates to #127.  This PR is still in draft and I have a few left things
to do (tests, improve implementation), just opening it so anyone can
track this work meanwhile.

Closes #664
2025-01-20 09:36:56 +02:00
Pekka Enberg
39ceddc7c1 Merge 'bindings/java: Implement JDBC ResultSet' from Kim Seon Woo
## Purpose of this PR
Associate jdbc's `ResultSet` with the returned values from limbo's step
function.
## Changes
### Rust
- `Java_org_github_tursodatabase_core_LimboStatement_step` now returns
an object of java's `LimboStepResult.java`
### Java
- Added `LimboStepResult.java` in order to distinguish the type of
`StepResult`(which limbo returns) and to encapsulate the interpretation
of limbo's `StepResult`
- Change `JDBC4ResultSet` inheriting `LimboResultSet` to composition.
IMO when using inheritance, it's too burdensome to fit unmatching parts
together.
- Enhance `JDBC4Statement.java`'s `execute` method
  - By looking at the `ResultSet` created after executing the qury, it's
now able to determine the (boolean) result.
## Reference
- https://github.com/tursodatabase/limbo/issues/615

Closes #743
2025-01-20 09:33:33 +02:00
Pekka Enberg
a338a19130 Merge 'Make clippy happy' from Sonny
Closes #751
2025-01-20 09:18:19 +02:00
Pekka Enberg
c25d9a1824 Merge 'Implement Not' from Vrishabh
This PR adds support for Not operator and Opcode.

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

Closes #748
2025-01-20 09:17:45 +02:00
Pekka Enberg
11551e8ae9 Merge 'Improve changes() and total_changes() functions and add tests' from Ben Li
#144
- The previous `changes()` function returns 1 no matter what
- Modified `changes()` and `total_changes()` to be closer to the sqlite
implementation
    - Store local `n_change` counter in the `Program` struct
    - Update `last_change` and `total_changes` values in `Connection`
struct on halt
    - Add `change_cnt_on` flag to `Program` struct that is `true` for
insert and delete (also need later on for update)
- Added TCL tests

Closes #749
2025-01-20 09:16:20 +02:00
Pekka Enberg
02b8fb86b8 github: Fix Nyrkiö action git hash
Github actions complains about the following so let's fix it:

  Error: Unable to resolve action `nyrkio/github-action-benchmark@ec6fe57`, the
  provided ref `ec6fe57` is the shortened version of a commit SHA, which is not
  supported. Please use the full commit SHA
  `ec6fe57d80fd83c83c10c6ef3f53899ce993aebb` instead.
2025-01-20 08:53:16 +02:00
Pekka Enberg
eeffe10f61 Merge 'Add Nyrkiö change point detection to 'cargo bench' workflow' from Henrik Ingo
Closes #750
2025-01-20 08:52:14 +02:00
sonhmai
75f0cf9e20 chore: make clippy happy 2025-01-20 13:29:23 +07:00
Henrik Ingo
ea0b1c3f2a Needs a speicif git sha if not version 2025-01-20 05:17:22 +02:00
Henrik Ingo
b87b80a422 Remove version from github-action-benchmark. For now. 2025-01-20 05:12:32 +02:00
Henrik Ingo
b2936b0cd6 Add Nyrkiö change point detection to 'cargo bench' workflow
This adds a separate push-only.yml workflow. For now pull request
API wasn't integrated yet, so shouldn't run on PRs.
2025-01-20 05:09:10 +02:00
ben594
2ec52d14f1 Update compatibility status 2025-01-19 20:51:16 -05:00
ben594
6c4ee1e905 Update changes on delete
Remove unwrap
2025-01-19 20:51:16 -05:00
ben594
a54222d12b Created basic tcl tests for changes and total_changes 2025-01-19 20:51:16 -05:00
ben594
28ce68091f Modified changes and total_changes scalarfuncs to be more like sqlite
Fmt and clippy

Remove print
2025-01-19 20:51:13 -05:00
sonhmai
e45a807f0e core: allocate 2 registers for checkpoint opcode execution 2025-01-20 08:34:13 +07:00
sonhmai
cb631dafdc feat: wire checkpoint to bytecode execution 2025-01-20 08:34:13 +07:00
sonhmai
6243ffbab4 add dev dependencies for testing wal_checkpoint 2025-01-20 08:34:13 +07:00
sonhmai
66d6291f32 add scaffolding for supporting wal checkpoint 2025-01-20 08:34:13 +07:00
psvri
e616bd5361 Implement Not 2025-01-20 00:21:23 +05:30
김선우
ddfbf11659 Fix test 2025-01-19 22:14:17 +09:00
김선우
e8a62b67d2 Disable failing test 2025-01-19 21:56:50 +09:00
김선우
8f9e70417d Implement executeQuery and executeUpdate 2025-01-19 21:56:50 +09:00
김선우
fb2b5eb11f Add debugging logs 2025-01-19 21:56:50 +09:00
김선우
f8cc08e5ad Remove unused method 2025-01-19 21:56:50 +09:00
김선우
24ead40f88 Change LimboStatement.java to throw exception when the result is null which is the error case 2025-01-19 21:56:50 +09:00
김선우
9c3c6271a3 Remove System.out.println 2025-01-19 21:56:50 +09:00
김선우
10a7b1b035 Disable for now 2025-01-19 21:56:50 +09:00
김선우
5fbce67774 Temporarily remove restrictions of running test for 1 second 2025-01-19 21:56:50 +09:00
김선우
f80823a297 Add LimboStepResult.java constructor 2025-01-19 21:56:50 +09:00
김선우
b80438226b Commit for testing 2025-01-19 21:56:49 +09:00