Skip to main content

Module shell

Module shell 

Source
Expand description

The shell’s state, and the loop that reads a line and decides what it is.

Invariant: the shell is an adapter. It parses dot commands, formats output and manages files; every statement it runs goes through the public inillucent facade, and it never reaches past it. That is the rule that keeps the shell from becoming a second, slightly different database - which is exactly what happens to a shell that starts “just reading the schema directly”.

Input is accumulated until it is a complete statement. That is the one piece of real logic here and it is not a nicety: a CREATE TRIGGER spans many lines and holds semicolons inside its body, so “ends with a semicolon” is wrong and the engine’s own parser has to be the one that says when a statement is finished.

Structs§

Failure
Why a statement did not produce rows.
Opened
Everything the shell remembers between lines. One open database and the session statements on it belong to.
Shell
One shell session: the databases it can reach, and every setting a dot command can change.

Constants§

CONNECTIONS
How many databases .connection can hold open at once.
MODE_NAMES
Every mode name, for the message above and for .help.

Functions§

drive
Reads input line by line, running statements as they become complete.
mode_named
Returns the mode a .mode argument selects, or a message.
plan_tree
Renders EXPLAIN QUERY PLAN’s four columns as the tree the reference draws.