Commit Graph

174 Commits

Author SHA1 Message Date
pedrocarlo
4d1ecd2d50 better MalformedHexInteger 2025-04-11 09:44:02 -03:00
Pekka Enberg
17b206297e Merge 'Emit ANSI codes only when tracing is outputting to terminal' from Preston Thorpe
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1289
2025-04-10 20:54:21 +03:00
Jussi Saurio
60a13c129f io/linux: make syscallio the default (io_uring is really slow) 2025-04-10 13:32:26 +03:00
PThorpe92
5643a0abba Dont emit ansi codes when outputting logs to a file 2025-04-09 19:31:35 -04:00
pedrocarlo
94217319a2 Fix Explain to be case insensitive 2025-04-09 14:21:18 -03:00
Pere Diaz Bou
2316d7ebf1 add .timer command with fine grained statistics about limbo
```
Limbo v0.0.19-pre.4
Enter ".help" for usage hints.
limbo> .timer on
limbo> select count(1) from users;
┌───────────┐
│ count (1) │
├───────────┤
│     10000 │
└───────────┘
Command stats:
----------------------------
total: 35 ms (this includes parsing/coloring of cli app)

query execution stats:
----------------------------
Execution: avg=16 us, total=33 us
I/O: avg=123 ns, total=3 us
limbo> select 1;
┌───┐
│ 1 │
├───┤
│ 1 │
└───┘
Command stats:
----------------------------
total: 282 us (this includes parsing/coloring of cli app)

query execution stats:
----------------------------
Execution: avg=2 us, total=4 us
I/O: No samples available
```
2025-04-09 16:31:08 +02:00
PThorpe92
01184ec1d7 Add tracing-appender to log traces to file asyncronously 2025-04-08 19:36:38 -04:00
pedrocarlo
907794cb07 add path completion for .import 2025-04-04 19:04:42 -03:00
pedrocarlo
d5fa37ab66 remove error debug 2025-04-04 17:44:34 -03:00
pedrocarlo
57af9c71ba customize completion candidates for some args 2025-04-04 17:39:09 -03:00
pedrocarlo
fd3335908c basic autocomplete for dot commands 2025-04-04 13:01:57 -03:00
Pere Diaz Bou
70c5cf3970 Merge 'Refactor Cli Repl Commands to use clap' from Pedro Muniz
This PR changes the argument parsing and matching to use Clap instead of
our own handrolled one. This makes it much easier to add new commands
and modify existing ones by using the full power of clap's derive
macros. It also produces nice error and help messages for us. However,
there is a bug in Clap that is not correctly modifying the `display
name` in the help section. So the command would appear as `show` instead
of `.show` in the help messages. This is very minimal, but if this is a
blocker for this PR we can just overwrite the help message in its
entirety. Also using Clap would enable us to use its autocomplete crate
to generate autocompletions for these special repl commands which would
be a huge win when compared to the `sqlite3` cli.
This is the current help message:
```sh

Limbo SQL Shell Help
==============
Welcome to the Limbo SQL Shell! You can execute any standard SQL command here.
In addition to standard SQL commands, the following special commands are available:

Usage: <COMMAND>

Commands:
  exit       Exit this program with return-code CODE
  quit       Quit the shell
  open       Open a database file
  schema     Print this message or the help of the given subcommand(s) Display schema for a table
  output     Set output file (or stdout if empty)
  mode       Set output display mode
  opcodes    Show vdbe opcodes
  cd         Change the current working directory
  show       Display information about settings
  nullvalue  Set the value of NULL to be printed in 'list' mode
  echo       Toggle 'echo' mode to repeat commands before execution
  tables     Display tables
  import     Import data from FILE into TABLE
  load       Loads an extension library
  dump       Dump the current database as a list of SQL statements
  listvfs    List vfs modules available
  help       Print this message or the help of the given subcommand(s)

Usage Examples:
---------------
1. To quit the Limbo SQL Shell:
   .quit

2. To open a database file at path './employees.db':
   .open employees.db

3. To view the schema of a table named 'employees':
   .schema employees

4. To list all tables:
   .tables

5. To list all available SQL opcodes:
   .opcodes

6. To change the current output mode to 'pretty':
   .mode pretty

7. Send output to STDOUT if no file is specified:
   .output

8. To change the current working directory to '/tmp':
   .cd /tmp

9. Show the current values of settings:
   .show

10. To import csv file 'sample.csv' into 'csv_table' table:
   .import --csv sample.csv csv_table

11. To display the database contents as SQL:
   .dump

12. To load an extension library:
   .load /target/debug/liblimbo_regexp

13. To list all available VFS:
   .listvfs

Note:
- All SQL commands must end with a semicolon (;).
- Special commands start with a dot (.) and are not required to end with a semicolon.

```
If we need more information on a specific command, we can leverage CLAP
and do for instance:
```sh
.open -h
```

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

Closes #1110
2025-04-01 11:40:14 +02:00
pedrocarlo
14ed8c8c50 correct vfs command 2025-03-30 03:22:44 -03:00
pedrocarlo
a612ad193c accidently removed an Error string 2025-03-30 03:12:36 -03:00
pedrocarlo
c36dc61c92 adding listvfs to extra helpful message 2025-03-30 02:52:07 -03:00
pedrocarlo
62b866618b docs for cli 2025-03-30 02:41:48 -03:00
pedrocarlo
b7bbafd691 adjusting listvfs command 2025-03-30 01:52:16 -03:00
pedrocarlo
82db51b94f remove debug clap 2025-03-30 01:46:24 -03:00
pedrocarlo
fe25035c7c display name in clap is buggy 2025-03-30 01:46:24 -03:00
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
8c5b631baf nu_ansi_term to facilitate stylizing strings 2025-03-06 21:44:23 -03:00
pedrocarlo
5168afa8b0 highlight candidate 2025-03-06 16:33:23 -03: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
2f38740b27 generated syntax 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
262c4de548 add line number and thread id to tracing logs 2025-03-05 15:36:47 +01:00
Pere Diaz Bou
9a01e32c01 add tracing_subscriber and test_log::test
I don't know when and why we dropped log::* in favor of tracing but when it was done, it made relevant logs not appear any more while debugging so... I added test_log::test which helps by automatically adding info logs from trace package.
2025-03-05 15:36:06 +01: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