24 std::vector<std::vector<std::string>>
rows;
46 explicit Session(std::filesystem::path dataDir);
57 std::vector<StatementResult>
executeScript(std::string_view script);
The parsed form of every statement, and the functions that build it from text.
Runs statements against the tables in one data directory.
std::filesystem::path dataDir_
Where the tables are.
StatementResult run(const SelectStmt &stmt)
Runs a SELECT.
std::map< std::string, std::size_t > displayWidths_
Upper-case column name to display width.
std::vector< StatementResult > executeScript(std::string_view script)
Runs every statement of a script, in order.
StatementResult execute(std::string_view sql)
Parses and runs one statement.
CREATE TABLE <table> (<column> <type>(<width>)[, ...]): adds a table to SYSTEM_TABLE.
DELETE FROM <table> WHERE <condition>. The WHERE is required, so a table is never emptied by accident...
DESCRIBE lists the tables; DESCRIBE <table> lists that table's columns.
INSERT INTO <table> VALUES (<values>).
The rows produced by a SELECT or DESCRIBE. All per-column vectors have the same length.
std::vector< bool > literal
True for a 'literal' SELECT item.
std::vector< std::size_t > widths
Display width of each column in console output.
std::vector< std::string > headers
Column titles.
std::vector< std::size_t > storageWidths
Width of each column in the data file (0 for a literal).
std::vector< std::vector< std::string > > rows
The values, one inner vector per row.
std::optional< std::size_t > idColumn
Output column holding the row ID, if rows can be edited and deleted by ID.
SELECT <items> FROM <table> [WHERE <condition>].
What running one statement produced: a table, a message, or an error.
std::string sql
The statement as it was run.
std::string tableName
The table the statement worked on, if any.
bool failed
True if the statement failed; message holds the error.
std::string message
E.g. "1 row inserted ...", or the error text.
std::optional< ResultSet > table
The rows, for SELECT and DESCRIBE.
bool silent
True for COLUMN and comments: nothing to show.
UPDATE <table> SET <col> = <value>[, ...] WHERE <condition>. The WHERE is required,...