|
myTinySQL v0.2.0-2-g5000098
A tiny SQL interpreter over fixed-width text files
|
Runs statements against the tables in one data directory. More...
#include <Session.hpp>
Public Member Functions | |
| Session (std::filesystem::path dataDir) | |
| Starts a session. | |
| StatementResult | execute (std::string_view sql) |
| Parses and runs one statement. | |
| std::vector< StatementResult > | executeScript (std::string_view script) |
| Runs every statement of a script, in order. | |
Private Member Functions | |
| StatementResult | run (const SelectStmt &stmt) |
| Runs a SELECT. | |
| StatementResult | run (const InsertStmt &stmt) |
| Runs an INSERT, assigning the next ID when it is left out. | |
| StatementResult | run (const UpdateStmt &stmt) |
| Runs an UPDATE. | |
| StatementResult | run (const DeleteStmt &stmt) |
| Runs a DELETE. | |
| StatementResult | run (const CreateTableStmt &stmt) |
| Runs a CREATE TABLE: adds one SYSTEM_TABLE line per column and an empty data file. | |
| StatementResult | run (const ColumnFormatStmt &stmt) |
| Remembers a column's display width for the rest of the session. | |
| StatementResult | run (const DescribeStmt &stmt) |
| Lists the tables, or one table's columns. | |
| StatementResult | run (const CommentStmt &) |
| Does nothing: comments have no effect. | |
Private Attributes | |
| std::filesystem::path | dataDir_ |
| Where the tables are. | |
| std::map< std::string, std::size_t > | displayWidths_ |
| Upper-case column name to display width. | |
Runs statements against the tables in one data directory.
COLUMN ... FORMAT settings last for the whole session. Every statement reloads the catalogue, so changes to the files are seen at once.
Definition at line 42 of file Session.hpp.
|
explicit |
Starts a session.
| dataDir | The directory holding SYSTEM_TABLE and the data files. |
Definition at line 104 of file Session.cpp.
| StatementResult tinysql::Session::execute | ( | std::string_view | sql | ) |
Parses and runs one statement.
| sql | The text of one statement. |
Definition at line 106 of file Session.cpp.
| std::vector< StatementResult > tinysql::Session::executeScript | ( | std::string_view | script | ) |
Runs every statement of a script, in order.
| script | Statements one per line, or separated by ;. |
Definition at line 123 of file Session.cpp.
|
private |
Remembers a column's display width for the rest of the session.
| stmt | The statement. |
Definition at line 378 of file Session.cpp.
|
private |
Does nothing: comments have no effect.
Definition at line 412 of file Session.cpp.
|
private |
Runs a CREATE TABLE: adds one SYSTEM_TABLE line per column and an empty data file.
| stmt | The statement. |
| SqlError | On an invalid or duplicate name, an ID column that is not the first one, a row too long for SYSTEM_TABLE, or a data file that already exists. |
Definition at line 304 of file Session.cpp.
|
private |
Runs a DELETE.
| stmt | The statement. |
| SqlError | On an unknown column or an attempt to change SYSTEM_TABLE. |
Definition at line 282 of file Session.cpp.
|
private |
Lists the tables, or one table's columns.
| stmt | The statement. |
| SqlError | On an unknown table. |
Definition at line 386 of file Session.cpp.
|
private |
Runs an INSERT, assigning the next ID when it is left out.
| stmt | The statement. |
| SqlError | On a wrong number of values, a duplicate ID, or a value too long for its column. |
Definition at line 218 of file Session.cpp.
|
private |
Runs a SELECT.
| stmt | The statement. |
| SqlError | On an unknown table or column, or a missing data file. |
Definition at line 132 of file Session.cpp.
|
private |
Runs an UPDATE.
| stmt | The statement. |
| SqlError | On an unknown column, an attempt to change the ID or SYSTEM_TABLE, or a value too long for its column. |
Definition at line 249 of file Session.cpp.
|
private |
Where the tables are.
Definition at line 107 of file Session.hpp.
|
private |
Upper-case column name to display width.
Definition at line 108 of file Session.hpp.