From e26bee8ce9d2122c0618d63ad06947edb780b20a Mon Sep 17 00:00:00 2001 From: "a.tolstoy" <a.tolstoy@picodata.io> Date: Fri, 7 Apr 2023 15:37:35 +0300 Subject: [PATCH] align ebnf source with what is actually used to generate svg diagrams --- doc/sql/query.ebnf | 90 ++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 48 deletions(-) diff --git a/doc/sql/query.ebnf b/doc/sql/query.ebnf index 89cfeae930..6ef0e78f34 100644 --- a/doc/sql/query.ebnf +++ b/doc/sql/query.ebnf @@ -1,49 +1,43 @@ -Query ::= Select | Select 'union all' Select | Select ('except' | 'except distinct') Select | Values | Insert -Select ::= 'select' (Column (',' Column)*) 'from' (Table | Select) ('as' Alias)? ( ('inner')? 'join' (Table | Select) ('as' Alias)? 'on' Expression )? ( 'where' Expression )? ( 'group by' GroupBy )? -Column ::= '*' | Table '.' '*' | Expression | Expression 'as' Alias -Expression ::= Expression 'or' Expression - | Expression 'and' Expression - | Expression '*' Expression - | Expression '/' Expression - | Expression '+' Expression - | Expression '-' Expression - | Expression '=' Expression - | Expression '>' Expression - | Expression '>=' Expression - | Expression '<' Expression - | Expression '<=' Expression - | Expression ('<>' | '!=') Expression - | Expression 'is null' - | Expression 'is not null' - | Expression 'between' Expression 'and' Expression - | Reference - | Select - | Value -GroupBy ::= Concat | Cast | Function | Reference -Reference ::= ((Table | '"' Table '"') '.')? (Alias | '"' Alias '"') -Value ::= 'true' - | 'false' - | 'null' +Query ::= EXPLAIN* (SELECT | SELECT 'UNION ALL' SELECT | SELECT ('EXCEPT' | 'EXCEPT DISTINCT') SELECT | INSERT) +EXPLAIN ::= 'SELECT'| 'INSERT' +SELECT ::= 'SELECT' (column (',' column)*) 'FROM' (table (',' table)* | SELECT) ('AS' alias)? ( ('INNER')? 'JOIN' (table | SELECT | VALUES) ('AS' alias)? 'ON' expression )? ( 'WHERE' expression )? ( 'GROUP BY' groupby )? +VALUES ::= 'VALUES' '(' (row (',' row)*) ')' +ROW ::= '(' (value (',' value)*) ')' +COLUMN ::= '*' | table '.' '*' | expression | expression 'AS' alias +EXPRESSION ::= expression 'OR' expression + | expression 'AND' expression + | expression ('* | / | + | -| = | > | >= | < | <= | <> | <= | <> | != | IS NULL | IS NOT NULL') expression + | expression 'BETWEEN' expression 'AND' expression + | reference + | SELECT + | VALUE +GROUPBY ::= concat | cast | function | reference +REFERENCE ::= ((table | '"' table '"') '.')? (alias | '"' alias '"') +VALUE ::= 'TRUE' + | 'FALSE' + | 'NULL' | '?' - | Integer - | Unsigned - | Double - | Decimal - | String - | Row -Cast ::= 'cast' '(' Expression 'as' Type ')' -Type ::= 'any' - | 'bool' - | 'boolean' - | 'decimal' - | 'double' - | 'int' - | 'integer' - | 'number' - | 'scalar' - | 'string' - | 'text' - | 'unsigned' - | 'varchar' ('(' Length ')')? -Insert ::= 'insert into' Table ('(' Reference (',' Reference)* ')')? (Select | Values) -Values ::= 'values' '(' (Value (',' Value)*) ')' (',' '(' (Value (',' Value)*) ')')* + | INTEGER + | UNSIGNED + | DOUBLE + | DECIMAL + | STRING + | ROW +CAST ::= 'CAST' '(' expression 'AS' type ')' +TYPE ::= 'ANY' + | 'BOOL' + | 'BOOLEAN' + | 'DECIMAL' + | 'DOUBLE' + | 'INT' + | 'INTEGER' + | 'NUMBER' + | 'SCALAR' + | 'STRING' + | 'TEXT' + | 'UNSIGNED' + | 'VARCHAR' ('(' length ')')? +INSERT ::= 'INSERT' 'INTO' (table (',' table)*) ('(' reference (',' reference)* ')')? VALUES '(' row ')' + + + -- GitLab