TessariDBDocs
  • 0.34.2-betalatest
  • 0.34.1-beta
  • 0.34.0-beta
  • 0.33.4-beta
  • 0.33.3-beta
  • 0.33.2-beta
  • 0.33.1-beta
  • 0.33.0-beta
  • 0.32.0-beta

The prompt

Editing a statement, recalling the last one, the rule that decides whether an answer is a table, and the shorthands that stand for statements.

tessaridb with no script to run gives you a prompt. It is the same prompt whether the store is in this process or in another one, because both paths reach the same renderer:

$ tessaridb --at 127.0.0.1:7654
tessaridb> 

A statement ends at ;, and until then the prompt keeps taking lines — so a long SELECT can be pasted or typed across as many lines as it needs. A ; inside a string or a comment does not end anything.

Editing what you are typing

← →a character
Ctrl-B Ctrl-Fthe same two, without leaving the home row
Home End · Ctrl-A Ctrl-Ethe ends of the line
Ctrl-Wthe word behind the cursor
Ctrl-K Ctrl-Uto the end · to the beginning
Ctrl-Lclear the screen, keeping what you have typed
↑ ↓the statements this session has run
Ctrl-Cthrow away the statement being typed — the session stays
Ctrl-Dleave, on an empty line

The line scrolls sideways rather than wrapping when a statement is wider than the terminal.

History is this session only and is never written to disk. That is a decision rather than a missing feature: DEFINE USER … PASSWORD '…' is a statement like any other, so a history file is a file of credentials, and it would be the one place a password outlives the process that was given it.

The terminal is handed back

Whatever ends the session — .exit, Ctrl-D, an error, a panic — the terminal is put back the way it was found. A program that leaves a terminal in raw mode leaves the shell broken after it, with no echo and no Ctrl-C, and the person it happens to has no obvious way to connect that to the database they just closed.

How an answer is drawn

Records that share one flat set of fields are drawn as an aligned table. Anything else keeps the document form:

tessaridb> SELECT * FROM users;
 id | active | name       | visits
----+--------+------------+--------
 1  | true   | 'ada'      |     12
 2  | false  | 'grace'    |      3
 3  | true   | 'margaret' |   1204
(3 record(s), via scan)
tessaridb> SELECT * FROM notes;
1: { body: 'a note', tags: ['one', 'two'] }
(1 record(s), via scan)

The second is not a table because tags is an array, and a cell holding ['one', 'two'] is a rendering that reads as a value the store does not have. The rule is deliberately agreement, not union: if one record has a field the others lack, the answer stays a document. A union with blanks would make absent and empty look identical, and the rendering is the last place a distinction should be lost.

Numbers are right-aligned; everything else is left-aligned.

You can insist either way:

tessaridb> .mode table
tessaridb> .mode document
tessaridb> .mode auto

A script gets the document form by default, whatever a terminal would have done — piped or run with -e or -f — because that form is TessariQL you can paste back into a statement, and a table is not. It is a default and not a prohibition: .mode is read in a script exactly as it is at a prompt, so a script that wants the table asks for it.

Shorthands

Every one of them runs a statement you could have typed, and prints it beside itself in .help so that using one teaches the language rather than hiding it:

shorthandruns
.nsINFO FOR STORE;
.dbINFO FOR NAMESPACE;
.tablesINFO FOR DATABASE;
.d <table>INFO FOR TABLE <table>;
.usersINFO FOR USERS;
.user <name>INFO FOR USER <name>;
.nodeINFO FOR NODE;

A shorthand saves typing and never reaches anything a statement cannot. It carries the same authority too — .users from a viewer is refused exactly as INFO FOR USERS would be, because it is that statement by the time anything executes.

One that needs a name and is given none is not a shorthand, and neither is one that takes no name and is given one: .d alone and .tables users are both left alone rather than guessed at.

The other dot commands

.helpthe table above, and the editing keys
.modehow records are drawn
.timingprint how long each script took
.exit · .quitleave

.timing reports the round trip when the store is a node, because that is the number that decides whether a query is slow from where you are sitting — not the number the node would report about itself.

A refusal does not end the session

At a prompt, a refusal prints its message and the next statement runs. In a script it stops, and the exit code says so. The two are different on purpose: a person at a prompt has just learned something and is about to try again, and a migration that carries on past a failed statement is a migration nobody can reason about afterwards.

Next