Skip to content

SQL REPL PoC in rust without Lua

Dmitry Rodionov requested to merge dkr/picosql into master

Summary

This adds new command picodata sql. Arguments are the same as picodata connect. The idea would be to replace picodata connect with sql repl at some point.

Simple prerequisites for testing with auth:

pico.create_user("Yoda", "12341234")
pico.grant_privilege("Yoda", "execute", "role", "super")

Super grant wont be needed in the future when access control will be tuned properly (access to system spaces, context: !663 (merged)).

Then run target/debug/picodata run in one terminal and target/debug/picodata sql Yoda@localhost:3301 in another one

Features:

  • Usual lib readline goodies, backward/forward search etc. Provided by rustyline
  • Simple file based history (~/.picodata_history by default)
  • Displays result sets in ascii tables. Styling can be customized if needed. Here we're using comfy-table library
  • If you type \e command your $EDITOR will be opened so you can write the query there. Once you close your editor the query will be executed (suggested by @funbringer)

There are a lot of things we can add. Completion, highlighting, more special commands.

Close #363 (closed)

Ensure that

  • New code is covered by tests
  • API is documented
  • Changelog is up to date
  • (if Lua API changed) Lua API version is bumped in luamod.rs
  • (if API docs changed) A follow-up doc issue is created in picodata/docs and linked here
Edited by Dmitry Rodionov

Merge request reports