Commit Graph

134 Commits

Author SHA1 Message Date
pedrocarlo
02c466cb1f start of refactor of repl to use clap 2025-03-30 01:44:58 -03:00
Pere Diaz Bou
d9f5cd870d clippy 2025-03-29 22:04:08 +01:00
Pere Diaz Bou
3317195a53 Reusable ImmutableRecord -> allocation reduction
Improve allocation usage from ImmutableRecords by reusing them.
ImmutableRecord is basically a contigous piece of memory that holds the
current record. If we move to some other record we usually deallocate
the previous one and allocate a new one -- obviously this is wasteful.
With this commit we will reuse the ImmutableRecord to allow payload to
be extended if needed or reused if we can, making it faster to iterate
records basically.
2025-03-29 22:04:08 +01:00
Pere Diaz Bou
ee55116ca6 return row as reference to registers 2025-03-29 22:04:08 +01:00
Pere Diaz Bou
5b7fcd27bd make column reuse blob/text fields 2025-03-29 22:02:49 +01:00
Pere Diaz Bou
bf37fd3314 wip 2025-03-29 22:02:49 +01:00
Pekka Enberg
4ee60348f2 Merge 'Fixes probably all floating point math issues and floating point display issues.' from Ihor Andrianov
Closes #1206
Closes #447
Closes #1117
Issues:
 1. Rust floating point math fucntions are non deterministic.
 2. SQLite have complex floating point display rules.
I changed rust functions to libm for math ops and implemented Display
trait for OwnedValue:Float. A lot of float formatting SQLite probably
inherits from C have to be handcrafted.

Closes #1208
2025-03-29 17:33:53 +02:00
Ihor Andrianov
8b9f34af71 fix tests and return nan as null 2025-03-29 14:46:11 +02:00
Ihor Andrianov
922945e819 all output should go through display 2025-03-29 12:46:06 +02:00
Pekka Enberg
387b68fc06 Merge 'Expose 'Explain' to prepared statement to allow for alternate Writer ' from Preston Thorpe
### The problem:
I often need to copy the output of an `Explain` statement to my
clipboard. Currently this is not possible because it currently will only
write to stdout.
All other limbo output, I am able to run `.output file` in the CLI, then
enter my query and in another tmux pane I simply `cat file | xclip -in
-selection clipboard`.
### The solution:
Expose a `statement.explain()` method that returns the query explanation
as a string. If the user uses something like `execute` instead of
prepare, it will default to `stdout` as expected, but this allows the
user to access the query plan on the prepared statement and do with it
what they please.

Closes #1166
2025-03-28 09:55:58 +02:00
Pere Diaz Bou
9291f60722 Introduce Register struct
OwnedValue has become a powerhouse of madness, mainly because I decided
to do it like that when I first introduced AggContext. I decided it was
enough and I introduced a `Register` struct that contains `OwnedValue`,
`Record` and `Aggregation`, this way we don't use `OwnedValue` for
everything make everyone's life harder.

This is the next step towards making ImmutableRecords the default
because I want to remove unnecessary allocations. Right now we clone
OwnedValues when we generate a record more than needed.
2025-03-27 17:53:02 +01:00
PThorpe92
7b55f7a167 Move explain to statement to allow for alternate writer 2025-03-24 18:48:12 -04:00
Pekka Enberg
63630ff956 Merge 'Enable pretty mode in shell by default' from Pekka Enberg
Fixes #929

Closes #932
2025-03-22 08:20:09 +02:00
Pekka Enberg
7832ae22df Enable pretty mode in shell by default
Fixes #929
2025-03-22 08:10:26 +02:00
Pekka Enberg
95abf0a9b2 Improve CLI color scheme
...let's aim for a green color scheme that is easy on the eyes.
2025-03-21 19:21:25 +02:00
Pedro Muniz
fdddb32ecf Merge branch 'main' into syntax-high 2025-03-13 23:04:07 -03:00
PThorpe92
89a08b7611 Add vfslist command and setup CLI with new db open api 2025-03-12 21:52:51 -04:00
pedrocarlo
e77953ad7f color remainder fix 2025-03-06 15:52:20 -03:00
pedrocarlo
942c65224d changing table colors and adding history hinter 2025-03-06 15:52:20 -03:00
pedrocarlo
e73cad387f adding table colors 2025-03-06 15:52:20 -03:00
pedrocarlo
74ddf40330 add color to headers, see how to make it configurable 2025-03-06 15:52:20 -03:00
pedrocarlo
b123321692 build script for syntax set dump 2025-03-06 15:52:20 -03:00
pedrocarlo
f631706ea4 simple highlighting for prompt 2025-03-06 15:52:20 -03:00
Pekka Enberg
96175cccf7 cli: Add --experimental-mvcc option to enable MVCC 2025-03-06 10:16:42 +02:00
Pere Diaz Bou
8daf7666d1 Make database Sync + Send 2025-03-05 14:07:48 +01:00
pedrocarlo
04d7d8ab87 autocomplete working 2025-03-04 14:43:07 -03:00
m0hossam
37df657b87 Use fold() and write! macro instead of format! 2025-03-03 17:31:49 +02:00
m0hossam
dbe0a64d50 Display blob literals in .dump 2025-03-03 16:43:21 +02:00
Pekka Enberg
936ae307b7 core: Kill value type
We currently have two value types, `Value` and `OwnedValue`. The
original thinking was that `Value` is external type and `OwnedValue` is
internal type. However, this just results in unnecessary transformation
between the types as data crosses the Limbo library boundary.

Let's just follow SQLite here and consolidate on a single value type
(where `sqlite3_value` is just an alias for the internal `Mem` type).
The way this will eventually work is that we can have bunch of
pre-allocated `OwnedValue` objects in `ProgramState` and basically
return a reference to them all the way to the application itself, which
extracts the actual value.
2025-02-26 10:57:45 +02:00
Kingsley Yung
67ff5c4ae1 Fix invalid text columns generated by dump
In the INSERT statement generated by dump function, if the type affinity
of the value is TEXT, replace each single quotation mark with two single
quotation marks, and wrap it with single quotation marks.
2025-02-18 23:26:56 +08:00
Pekka Enberg
caa83b347e cli: Rename "raw" output mode to "list"
Change the name of the output mode to match SQLite.
2025-02-17 21:26:15 +02:00
Pekka Enberg
7e173291d5 Merge 'cleanup shell tests and cli' from Clyde K.
Refactored CLI, cleaned up duplicate code.
@PThorpe92

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #941
2025-02-15 11:08:58 +02:00
Glauber Costa
82ceaebe01 Basic dump support
This is a basic support for the very useful .dump command.
It doesn't yet implement any of the dump options sqlite has,
and it doesn't add some of the logic for things like indexes,
since we don't have them.
2025-02-14 15:54:46 -05:00
meteorgan
744df6eedf fix some typo 2025-02-13 23:03:41 +08:00
CK-7vn
5f02521d08 cleanup shell tests and cli 2025-02-13 00:49:12 -05:00
Pekka Enberg
e48c50faf6 Merge 'cli: Fix infinite loop on non-terminated literal' from Ihor Andrianov
Bug: Infinite loop when parsing unclosed string literal
To reproduce:
Run query: `SELECT max(';`
Current behavior:
- Query runner enters an infinite loop when encountering an unclosed
string literal and prints error
Fix:
- Throw error and stop query runner loop
Closes #988

Closes #989
2025-02-12 09:14:35 +02:00
Ihor Andrianov
287c04bde0 remove repeated code 2025-02-12 02:34:13 +02:00
Ihor Andrianov
a5fcbed21a fix infinite loop error 2025-02-12 00:10:56 +02:00
Konstantinos Artopoulos
16ae7cdc35 fix(cli): add newline characters on multiline prompts 2025-02-11 18:20:35 +02:00
wyhaya
351a032cc1 core: Add default column name 2025-02-11 07:03:51 +00:00
Pekka Enberg
cd27068807 Merge 'cli: Add .exit command' from wyhaya
This PR add the `.exit ?<CODE>` command, which will allow limbo to exit
with the specified code (similar to SQLite3 and DuckDB).
```bash
echo '.exit' | cargo run -p limbo ; echo $?
# ...
# 0

echo '.exit 1' | cargo run -p limbo ; echo $?
# ...
# 1
```

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #978
2025-02-11 07:59:59 +02:00
wyhaya
2482c03111 cli: Add .exit command 2025-02-11 03:11:42 +00:00
Konstantinos Artopoulos
839e1ce3e8 fix(cli): handle remaining input on EOF 2025-02-11 00:02:20 +02:00
Tiago Ribeiro
c071e47b03 Update cli to use the new retrieval methods to access Record values. 2025-02-10 00:31:28 -07:00
wyhaya
e9046fef78 cli: Improve pretty mode table 2025-02-09 00:01:07 +08:00
Pekka Enberg
3deac98d40 cli: Make pretty mode pretty like DuckDB
DuckDB is pretty, I want to be pretty!

```
limbo> CREATE TABLE t(x); INSERT INTO t VALUES (1), (2), (3);
limbo> .mode pretty
limbo> SELECT * FROM t;
┌───┐
│ x │
├───┤
│ 1 │
├───┤
│ 2 │
├───┤
│ 3 │
└───┘
```
2025-02-08 11:39:21 +02:00
wyhaya
13062a1479 cli: Add column names in Pretty mode 2025-02-08 15:11:09 +08:00
Pekka Enberg
c210821100 core: Move result row to ProgramState
Move result row to `ProgramState` to mimic what SQLite does where `Vdbe`
struct has a `pResultRow` member. This makes it easier to deal with result
lifetime, but more importantly, eventually lazily parse values at the edges of
the API.
2025-02-06 11:52:26 +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
Jorge López
07970468bd syntactic changes: remove unneeded parentheses 2025-01-18 18:45:05 +01:00