Commit Graph

953 Commits

Author SHA1 Message Date
Pekka Enberg
b2fd509ecc Merge 'Add zeroblob(N) scalar function' from Lauri Virtanen
Relates to issue #144

Closes #352
2024-10-02 10:59:22 +03:00
Lauri Virtanen
f612ead8a3 Add zeroblob(N) scalar function
Relates to issue #144
2024-09-29 23:39:53 +03:00
Pekka Enberg
b8dffbf7f9 Merge 'Maintain pending io_uring ops count for early return on run_once' from Arpit Saxena
Add a `pending_ops` field to `InnerLinuxIO` struct which is incremented
for each operation submitted to the ring and decremented when they are
taken off the completion queue. With this, we can exit from run_once if
there are no pending operations. Otherwise, in that case, it would hang
indefinitely due to call of `ring.submit_and_wait(1)`

Closes #349
2024-09-27 12:22:51 -07:00
Arpit Saxena
b7debabd81 Wrap IoUring to ensure pending_ops is always correctly updated
Adds a struct WrappedIOUring which contains a IoUring and a pending_ops
field. Entry submission and popping from the queue is done through
functions operating on it, which also maintains pending_ops count

NOTE: This is a bit weird/hacky since in get_completion we create a
CompletionQueue and just call its next(). If it were a normal iterator
it would always return the same first item. However it is a queue posing
as an iterator which makes this work.
2024-09-28 00:10:05 +05:30
Arpit Saxena
a7d735d368 Maintain pending io_uring ops count for early return on run_once
Add a `pending_ops` field to `InnerLinuxIO` struct which is incremented
for each operation submitted to the ring and decremented when they are
taken off the completion queue. With this, we can exit from run_once if
there are no pending operations. Otherwise, in that case, it would hang
indefinitely due to call of `ring.submit_and_wait(1)`
2024-09-27 23:32:19 +05:30
Pekka Enberg
34e69731c5 Merge 'Improve Simulator IO by handing RowResult::IO' from Arpit Saxena
This is not related to any open issue (atleast from the ones I saw).
This is related to an issue I saw when running the simulator as it was
calling `io.run_once()` even before submitting any read/write job. This
would lead to it hanging since io_uring's submit_and_wait would keep
waiting for a completion event.
I've tried to improve the simulator's IO handling a bit:
We inject a fault before calling next_row() through which we'll get
pread faults. Also we call io's run_once on getting RowResult::IO. This
is run with a fault probability of 1%. This is less because a fault here
would result us in terminating the entire loop iterating on rows, and
also because realistically we'll expect less faults here.
PS: I think run_once() should not hang either when no operation is
pending in io_uring. Opened #349 for fixing that.

Closes #348
2024-09-26 14:13:49 -07:00
Arpit Saxena
93092fb552 Improve Simulator IO by handing RowResult::IO
We inject fault before calling next_row() through which we'll get pread
faults. Also we call io's run_once on getting RowResult::IO. This is run
with a fault probability of 1%. This is less because a fault here would
result us in terminating the entire loop iterating on rows, and also
because realistically we'll expect less faults here
2024-09-26 20:00:55 +05:30
Pekka Enberg
918578fa94 Merge 'refactor: min max function' from Jean Arhancet
In the current implementation, there is an issue with the `min`/`max`
functions when the input contains both numbers and text. This merge
request fixes the problem.
I have also changed the `minmax` function by splitting it into two
separate functions to be able to add unit tests for both functions, just
like for the other functions

Closes #347
2024-09-26 06:40:30 -07:00
JeanArhancet
7b5d0fcabd refactor: split min/max func 2024-09-25 17:51:49 +02:00
JeanArhancet
222fea9cc8 fix: cmp number/text 2024-09-25 17:39:37 +02:00
Pekka Enberg
ed3608dc1f Merge 'pere mailmap' from Pere Diaz Bou
Closes #345
2024-09-23 09:51:00 -04:00
Pere Diaz Bou
3d2e21675c pere mailmap 2024-09-23 15:29:17 +02:00
Pekka Enberg
bd11dabc15 Merge 'Better support for BLOBs' from Lauri Virtanen
- Limbo command line shell supports e.g. `SELECT x'616263';`
- `EXPLAIN SELECT x'616263';` lists the opcode
Missing:
- Command line shell not entirely compatible with SQLite when blobs have
non-printable characters in the middle (e.g. `SELECT x'610062';`)
- Python bindings not supported (incoming soon)

Closes #343
2024-09-23 09:21:56 -04:00
Lauri Virtanen
0597c048fc Better support for BLOBs
- Limbo command line shell supports e.g. `SELECT x'616263';`
- `EXPLAIN SELECT x'616263';` lists the opcode

Missing:

- Command line shell not entirely compatible with SQLite when blobs have
  non-printable characters in the middle (e.g. `SELECT x'610062';`)
- Python bindings not supported (incoming soon)
2024-09-22 17:55:00 +03:00
Pekka Enberg
f23c668488 Revert part of "Fix source formatting with cargo fmt"
Looks like there's difference in `cargo fmt` across toolchain versions.
Perhaps it's time to add `rust-toolchain.toml` to the project...
2024-09-22 08:58:48 -04:00
Pekka Enberg
5aeb18f474 Fix source formatting with cargo fmt 2024-09-22 08:52:32 -04:00
Pekka Enberg
6985a716f3 Merge 'Add support for hex scalar function' from baishen
Add support for hex scalar function

```
limbo> SELECT hex('abc');
616263

limbo> EXPLAIN SELECT hex('abc');
addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     5     0                    0   Start at 5
1     String8            0     2     0     abc            0   r[2]='abc'
2     Function           0     2     1     hex            0   r[1]=func(r[2])
3     ResultRow          1     1     0                    0   output=r[1]
4     Halt               0     0     0                    0
5     Transaction        0     0     0                    0
6     Goto               0     1     0                    0
```

Related issue #144

Closes #342
2024-09-22 08:50:26 -04:00
baishen
5c00c576a5 Add support for hex scalar function 2024-09-22 08:50:08 -04:00
Pekka Enberg
0af1c0ac72 Merge 'Remove unused tcl proc' from Kim Seon Woo
Cleanup(unused tcl procs which I've wrote before)

Closes #341
2024-09-22 08:46:29 -04:00
김선우
06577d56fd Remove unused tcl proc 2024-09-22 08:45:29 -04:00
김선우
910c69aaef Remove unused tcl proc 2024-09-22 08:43:50 -04:00
Pekka Enberg
bd94303377 scripts/merge-pr.py: Manually map Github username to email address
You can get pretty much any old email address out of Github API, so
let's just map the emails manually.
2024-09-22 07:05:08 -04:00
jussisaurio
c738674c5d Merge 'fix: cmp integer/float' from Jean Arhancet
Closes https://github.com/penberg/limbo/issues/339

Reviewed-by: Lauri Virtanen <pere-altea@hotmail.com>

Closes #340
2024-09-21 18:06:04 +03:00
jussisaurio
927d9a67b0 Merge 'Add typeof(X) scalar function' from Lauri Virtanen
See SQLite documentation:
https://www.sqlite.org/lang_corefunc.html#typeof
Relates to issue #144 Scalar function support

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

Closes #310
2024-09-21 18:04:02 +03:00
JeanArhancet
41c1708ee7 fix: cmp integer/float 2024-09-21 16:10:42 +02:00
Lauri Virtanen
67573e12e5 Add typeof(X) scalar function 2024-09-21 15:56:29 +03:00
Pekka Enberg
dc0e6f7fcd Merge 'Add support for parenthesized conditions' from Kim Seon Woo
### Motivation
Add support for WHERE parenthesized conditions
- closes #153

Closes #338
2024-09-21 12:27:18 +03:00
김선우
eb55b7379c Fix failing test 2024-09-21 16:12:10 +09:00
김선우
bbd1eea9ae Add support for parenthesized conditions 2024-09-21 16:03:49 +09:00
Pekka Enberg
d4cc5151fb Merge 'github: Fix stale workflow' from Pekka Enberg
Bump operations per run but more importantly turn "ascending" option so
that we process pull requests with smaller IDs first that are more
likely to be stale.

Closes #337
2024-09-21 08:54:07 +03:00
Pekka Enberg
8380c0740b github: Fix stale workflow
Bump operations per run but more importantly turn "ascending" option so
that we process pull requests with smaller IDs first that are more
likely to be stale.
2024-09-21 08:20:42 +03:00
Pekka Enberg
b67640c437 Merge 'core: constraint check uniqueness' from Pere Diaz Bou
```bash
limbo> insert into products values (1, 'asdf', 432);
Runtime error: UNIQUE constraint failed: products.id (19)
```

Closes #336
2024-09-20 13:27:10 +03:00
Pere Diaz Bou
c8e5673f7a core: constraint check uniqueness 2024-09-20 11:45:55 +02:00
Pekka Enberg
c57e971eb3 Merge 'Add support for sqlite_version() scalar function ' from Kim Seon Woo
### sqlite
<img width="792" alt="image" src="https://github.com/user-
attachments/assets/1a9238db-d948-4583-a808-f9adfec7c534">
### limbo
<img width="809" alt="image" src="https://github.com/user-
attachments/assets/ea3e5f7e-bb3e-450d-be34-59ca00128beb">
### Changes
- Add support for `sqlite_version()` function
- Update function's explain message depending on the number of arguments

Closes #335
2024-09-18 13:50:51 +03:00
김선우
f7304a15a6 Fix clippy 2024-09-18 17:59:11 +09:00
김선우
e9ba458514 Add support for sqlite_version 2024-09-18 17:57:51 +09:00
Pekka Enberg
ac6dd71de6 Update CHANGELOG.md 2024-09-18 09:47:05 +03:00
Pekka Enberg
a8b8c1d2c9 Merge 'Fix clippy ' from Kim Seon Woo
### Changes
- Remove clippy warning messages
- Add `#[allow(clippy...)]` in places where it might be better not to
fix
### TODO
recommended changes by `cargo fmt` on my local and github differs on
`sqlite3/src/lib.rs`. Should check for the reason
=> just upgrade the rust toolchain

Closes #329
2024-09-18 09:46:07 +03:00
Pekka Enberg
e364d10d9a Merge 'Implementation of scalar function glob() and GLOB operator' from RJ Barman
Related to #144
- Separates `glob` and `like` regex caches, since the same pattern would
result in a different regex depending on which rules you apply
- Also fixes the value of `constant_mask` when translating LIKE
expressions now that non-constant pattern values are supported.
Note that LIKE and GLOB are almost entirely the same, the only
difference being the matching rules (so in our case, the regex
construction).

Closes #334
2024-09-18 09:44:51 +03:00
Pekka Enberg
8bc467bca8 Update CHANGELOG.md 2024-09-18 09:44:25 +03:00
Pekka Enberg
35032395e7 Merge 'Make LIKE expressions case-insensitive' from RJ Barman
Per the sqlite docs, LIKE is case-insensitive.
> The LIKE operator does a pattern matching comparison. The operand to
the right of the LIKE operator contains the pattern and the left hand
operand contains the string to match against the pattern. A percent
symbol ("%") in the LIKE pattern matches any sequence of zero or more
characters in the string. An underscore ("_") in the LIKE pattern
matches any single character in the string. **Any other character
matches itself or its lower/upper case equivalent (i.e. case-insensitive
matching)**. Important Note: SQLite only understands upper/lower case
for ASCII characters by default. The LIKE operator is case sensitive by
default for unicode characters that are beyond the ASCII range. For
example, the expression 'a' LIKE 'A' is TRUE but 'æ' LIKE 'Æ' is FALSE.
The ICU extension to SQLite includes an enhanced version of the LIKE
operator that does case folding across all unicode characters.
Note that sqlite does not support case-insensitive comparisons of
unicode characters by default. This PR _does not_ match that behavior
currently. I can change things to not support unicode-case-
insensitivity, but as I understand it, doing so may require disable the
unicode-case feature on the regex crate, and potentially using a
`regex::bytes::Regex`, instead of a `regex::Regex`. (Basically, doing
some stuff that would not match anyone's initial assumptions about how
this would work).

Closes #333
2024-09-18 09:44:00 +03:00
rjhallsted
f6b7a3fba4 Remove duplication of glob and like translation 2024-09-16 16:31:37 -07:00
rjhallsted
338effa0ca Separate glob and like regex caches 2024-09-16 16:22:31 -07:00
rjhallsted
af09f0b7f4 Add testing 2024-09-16 16:18:26 -07:00
rjhallsted
f39dc534a6 add glob execution 2024-09-16 16:12:53 -07:00
rjhallsted
b87b874ed0 WIP commit on glob support 2024-09-16 15:51:32 -07:00
rjhallsted
4aaa0b0989 Make LIKE expressions case-insensitive 2024-09-16 14:43:39 -07:00
김선우
9e2756fabc Nit 2024-09-16 23:07:50 +09:00
김선우
905b34c9a8 Nit 2024-09-16 22:03:53 +09:00
김선우
7f5d9dbb90 Apply fmt 2024-09-16 22:00:36 +09:00