Skip to content
Snippets Groups Projects
Commit 7752cdfd authored by Georgy Kirichenko's avatar Georgy Kirichenko Committed by Nikita Pettik
Browse files

sql: pass true types of columns to Tarantool

As a main part of introducing strict typing in SQL it is required to
prohibit typeless columns in parser's grammar. Originally, SQLite simply
assigns typeless columns to BLOB affinity. Moreover, due to historical
reasons, all columns were stored with <SCALAR> type in Tarantool core
(except for <INTEGER> when it comes to primary key).  Column type should
be defined on table creation. Allowed data types are: <TEXT>, <VARCHAR>,
<CHAR>, <BLOB>, <INT[EGER]>, <REAL>, <FLOAT>, <NUMERIC>, <DECIMAL>,
<DOUBLE> <DATE> and <DATETIME>. However, still any declared data type is
converted to one of <BLOB>, <TEXT>, <REAL> or <INTEGER> affinities.
While affinity reaches space format, it is (again) converted to
Tarantool's field type. To be more precise, table of conversions:

+----------+----------+------------+
| SQL TYPE | AFFINITY | FIELD TYPE |
+----------+----------+------------+
| FLOAT    | REAL     | NUMBER     |
| REAL     | REAL     | NUMBER     |
| DOUBLE   | REAL     | NUMBER     |
| NUMERIC  | REAL     | NUMBER     |
| DECIMAL  | REAL     | NUMBER     |
| INTEGER  | INTEGER  | INTEGER    |
| TEXT     | TEXT     | STRING     |
| VARCHAR  | TEXT     | STRING     |
| CHAR     | TEXT     | STRING     |
| BLOB     | BLOB     | SCALAR     |
| DATETIME | REAL     | NUMBER     |
| DATE     | REAL     | NUMBER     |
| TIME     | REAL     | NUMBER     |
+----------+----------+------------+

<VARCHAR> and <CHAR> types should be specified with length
(e.g. name VARCHAR(10)), but this length currently is not used when
types are processed. Only purpose is to support ANSI syntax.
The same for <NUMERIC> and <DECIMAL> - it is allowed to specify scale
and precision, but they don't affect the way they are stored in memory.

Note that patch is not self-sufficient: a lot of tests still fail due to
wrong types conversions. Fix for that comes as next two patches.

Closes #3018
Closes #3104
Closes #2494
Closes #3459
parent 2b22b913
No related branches found
No related tags found
No related merge requests found
Showing
with 262 additions and 564 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment