Commit Graph

10673 Commits

Author SHA1 Message Date
Jussi Saurio
f5540e9602 boxed select and selectbody (by gwenn and jussisaurio) 2025-01-05 13:50:32 +02:00
Jussi Saurio
d35eadb22c preallocate capacity for yystack (by krishvishal) 2025-01-05 13:46:30 +02:00
psvri
9340c8f0b1 Change sanitize_string comments to doc string 2025-01-05 17:16:18 +05:30
김선우
038ea16d75 Add TODO comments for deprecation. 2025-01-05 20:26:21 +09:00
김선우
8e110da9c9 Add wrapper classes around native methods that Limbo will provide 2025-01-05 20:21:35 +09:00
psvri
a11f4b2b10 Refactor escape string literal logic to a function 2025-01-05 14:21:11 +05:30
Pekka Enberg
fdbf62d5b3 Merge 'Add support for Java bindings' from Kim Seon Woo
Purpose of this PR

- Add support for Java (as Java has an extensive community)
- Enable Limbo to be provided as a Java library in the future.

Changes

- Added `bindings/java` directory.
- Created `src` package for Java (Gradle) and `rs_src` for Rust JNI
code.
- Implemented basic functionality to gather feedback and proceed with
further development.
  - Some features just printout the result for testing purposes.

Future Work

- Integrate CI to publish the library.
- Enhance error handling mechanisms.
- Implement additional features and functionality.
- Add test code after we decide on which features to provide

Issue

https://github.com/tursodatabase/limbo/issues/615

Closes #613
2025-01-05 10:28:35 +02:00
김선우
370e1ca5c2 Add support Java bindings
This add support for Java bindings in the bindings/java directory.
2025-01-05 10:28:05 +02:00
Pekka Enberg
1c2e074c93 Merge 'Add SQLite installation instructions for Windows to contrib' from dkaluza
Closes #614
2025-01-05 10:04:10 +02:00
Pekka Enberg
8617b1f866 Improve CONTRIBUTING on pull requests
These are not hard rules in the project, but describe what the ideal
pull request looks like.
2025-01-05 10:01:07 +02:00
psvri
2d84956fda Fix quote escape in literals 2025-01-05 01:35:29 +05:30
Daniel Kaluza
75c89ed08e Add SQLite installation instructions for Windows to contrib 2025-01-04 19:10:41 +01:00
Pekka Enberg
9f3e064bcf Merge 'Cleanup emitter some more' from Jussi Saurio
No functional changes, just move almost everything out of `emitter.rs`
into smaller modules with more distinct responsibilities. Also, from
`expr.rs`, move `translate_aggregation` into `aggregation.rs` and
`translate_aggregation_groupby` into `group_by.rs`

Closes #610
2025-01-04 17:48:35 +02:00
Pekka Enberg
81b2e18520 Merge 'Add tests prerequisites to README and CONTRIBUTING' from dkaluza
* add description of workaround for running coverage with Rust 1.83

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

Closes #611
2025-01-04 17:47:25 +02:00
Pekka Enberg
5c52c8b1e9 Merge 'Fix integer overflow output to be same as sqlite3' from Vrishabh
In sqlite3, before arithmetic operation is done, it first checks if the
operation dosent overflow and then does the operation. In case it
overflows it would covert the arguments into floats and then does the
operation as [per code](https://github.com/sqlite/sqlite/blob/ded37f337b
7b2e916657a83732aaec40eb146282/src/vdbe.c#L1875)  . I have done the same
behaviour for limbo.

Closes #612
2025-01-04 17:46:48 +02:00
PThorpe92
ca428b3dda Julianday function and additional tests/comments 2025-01-04 10:42:34 -05:00
PThorpe92
9a635be7b8 Add tests for new modifiers and datetime func 2025-01-04 08:41:05 -05:00
PThorpe92
7c4a780cc2 Add DateTime func and support more modifiers 2025-01-04 08:41:03 -05:00
Daniel Kaluza
4c1e8038b3 Add tests prerequisites to README and CONTRIBUTING 2025-01-04 13:59:47 +01:00
Jussi Saurio
9a8156753e core/translate: break emitter.rs into smaller modules 2025-01-04 14:52:46 +02:00
psvri
18137c932e Fix integer overflow output to be same result as sqlite3 2025-01-04 18:14:09 +05:30
Pekka Enberg
b18abba118 Merge 'Auto-create index in CREATE TABLE when necessary' from Jussi Saurio
Closes #448
Adds support for:
- Automatically creating index on the PRIMARY KEY if the pk is not a
rowid alias
- Parsing the automatically created index into memory, for use in
queries
    * `testing/testing_norowidalias.db` now uses the PK indexes and some
tests were failing -- looks like taking the index into use revealed some
bugs in our codegen :) I fixed those in later commits.
Does not add support for:
- Inserting to the index during writes to the table

Closes #588
2025-01-04 14:10:44 +02:00
Jussi Saurio
1b61749c0f feat/core/translate: create automatic index in CREATE TABLE when necessary 2025-01-04 13:54:44 +02:00
Pekka Enberg
fc60e544af Merge 'Fix arithmetic operations for text values' from Vrishabh
We had not implemented arithmetic operations for text values. This PR
implements this and aligns the behavior with sqlite3 .

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

Closes #605
2025-01-04 13:40:03 +02:00
Pekka Enberg
bae452f6b0 Merge 'sqlite3: Add in-memory support to sqlite3_open()' from Pekka Enberg
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #606
2025-01-04 13:39:58 +02:00
Pekka Enberg
0238eaf95d Merge 'Emitter cleanup part 2' from Jussi Saurio
Changes:
---
Instead of passing around:
    1. `SymbolTable` (for resolving functions dynamically provided by
extensions), and
    2. `precomputed_exprs_to_registers` (for resolving registers
containing results from already-computed expressions),
add `Resolver` struct to `TranslateCtx` that encapsulates both.
This introduces some lifetime annotation spam unfortunately, but maybe
we can also migrate to using references instead of cloning elsewhere as
well, since we generally do a lot of copying of expressions right now
for convenience.
---
Use way less arguments to functions - mainly just passing `program`,
`t_ctx` and `plan` around.

Closes #609
2025-01-04 13:27:38 +02:00
Jussi Saurio
e31317fbb5 emitter.rs: use way less arguments to functions 2025-01-04 12:59:30 +02:00
Jussi Saurio
d2b73e8492 emitter.rs: make t_ctx always be the second argument to any functions 2025-01-04 12:32:50 +02:00
Jussi Saurio
d1f74fa3cb Emitter cleanup part 2: add Resolver 2025-01-04 12:23:19 +02:00
Pekka Enberg
08844b80bb Merge 'Code cleanups to emitter' from Jussi Saurio
I plan to do a series of cleanups to `emitter.rs` which is a chonker
module right now. This first one is just making some variable namings
more consistent and refactoring some metadata fields to function-local
variables

Closes #604
2025-01-04 11:03:52 +02:00
Ziyak Jehangir
4f119f4b95 refactor: simplify database header write logic 2025-01-04 14:31:23 +05:30
Pekka Enberg
276819369c sqlite3: Add in-memory support to sqlite3_open() 2025-01-04 10:58:51 +02:00
Jussi Saurio
23f1858239 translatectx: consistent naming 2025-01-04 10:39:32 +02:00
Jussi Saurio
1a01487872 left join metadata: consistent naming 2025-01-04 10:39:32 +02:00
Jussi Saurio
2f129402e8 sorter data register: consistent naming 2025-01-04 10:39:32 +02:00
Jussi Saurio
0c572cda3c more consistent function naming 2025-01-04 10:39:32 +02:00
Jussi Saurio
9c1d952e3b consistent names for group by regs and labels 2025-01-04 10:39:32 +02:00
Jussi Saurio
28b1754cf4 group_by_emit: add comments to labels and registers 2025-01-04 10:39:32 +02:00
Jussi Saurio
9ccbb69618 remove fields from GroupByMetadata that can be function-local 2025-01-04 10:39:32 +02:00
Pekka Enberg
bd5f081ea8 Merge 'Add support for changes() and total_changes() functions' from Lemon-Peppermint
#525
- Adds the necessary `ScalarFunc` variants to support the `changes()` &
`total_changes()` SQLite function.
- Adds the necessary fields to the `Connection` struct to track changes.
- Modify the `InsertAwait` OpCode behaviour to affect the changes
counter.

Closes #589
2025-01-04 10:14:06 +02:00
Pekka Enberg
b5e95d7b5d Merge 'Remove SQLite headers dependency from compat tests' from dkaluza
* Add SQLITE_FLAGS env variable handling to compatibility tests as
SQLite does not handle `-q` flag
* Fix inconsistent SQLITE_NOTFOUND error code and add SQLITE_CANTOPEN
code
* Improve compatibility tests to display errors instead of hanging
indefinitely

Closes #599
2025-01-04 10:12:28 +02:00
Pekka Enberg
3ddbb4bdea Merge 'Add CSV import support to shell' from Vrishabh
I was trying to get limbo to a position where we can run the benchmark [
clickbench](https://github.com/ClickHouse/ClickBench/blob/main/sqlite/be
nchmark.sh)  and found that `.import` command was not supported in cli.
This PR adds that support for command `.import` which has the same
parameters as sqlite cli.
Do note that not all options from sqlite `.import` is implemented yet in
this PR.

Reviewed-by: Preston Thorpe <preston@unlockedlabs.org>

Closes #598
2025-01-04 10:11:41 +02:00
Pekka Enberg
cc6c8b076a Merge 'docs: fix url to tursodatabase' from Todsaporn Banjerdkit
Closes #601
2025-01-04 10:10:59 +02:00
katopz
14657137eb docs: fix url to tursodatabase 2025-01-04 16:30:32 +09:00
Jussi Saurio
a934ead904 Merge 'Json extract' from Kacper Madej
Implements the `json_extract` function.
In the meantime, the json path has already been implemented by
@petersooley in https://github.com/tursodatabase/limbo/pull/555 which is
a requirement for `json_extract`.
However, this PR takes a different approach and parses the JSON path
using the JSON grammar, because there are a lot of quirks in how a JSON
`key` can look (see the JSON grammar in the Pest file).
The downside is that it allocates more memory than the current
implementation, but might be easier to maintain in the long run.
I included a lot of tests with some quirky behavior of the
`json_extract` (some of them still need some work). I also noticed that
these changed between sqlite versions (had `SQLite 3.43.2` locally and
`3.45` gave different results). Due to this, I'm not sure how much value
there is in trying to be fully compatible with SQLite. Perhaps the
approach taken by @petersooley solves 99% of use-cases?

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

Closes #524
2025-01-03 23:53:29 +02:00
Jussi Saurio
0fefffbbcb Merge 'fix: index seek wrong on SeekOp::LT\SeekOp::GT' from Kould
data does not match predicate when using index, e.g: `select id, age
from users where age > 90 limit 1;` will return data with age  90
the reason is that the current index seek directly uses record for
comparison, but the record of the index itself is longer than the record
of the key (because it contains the primary key), so Gt is invalid.
since only single-column indexes are currently supported:
https://github.com/tursodatabase/limbo/pull/350, only the first value of
the record is currently used for comparison.

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

Closes #593
2025-01-03 23:27:24 +02:00
Elijah Morgan
d51ca2150c Cleanup logging, move html files
General cleanup of cruft, deleted dead code, moved html files to clean
up dir.
2025-01-03 14:38:34 -05:00
psvri
2b879a4f40 Fix arithmetic operations for text values 2025-01-04 00:34:04 +05:30
psvri
18a1055088 Edit help message 2025-01-03 19:40:35 +05:30
Daniel Kaluza
9ab0e90807 Fix compatibility tests not showing errors and hanging indefinitely in case of error 2025-01-03 11:19:21 +01:00