[tarantool-patches] Re: [PATCH 3/6] sql: pass true types of columns to Tarantool

Konstantin Osipov kostja at tarantool.org
Wed Sep 19 05:23:35 MSK 2018


* Nikita Pettik <korablev at tarantool.org> [18/09/18 01:20]:
> From: Georgy Kirichenko <georgy at tarantool.org>
> 
> 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     |
> +----------+----------+------------+

How do you manage to store datetime/date/time values as numbers?
What is your conversion procedure? Are you storing it as unix
timestamp? Note that SQL date begins (AFAIR) at 1900-01-01.

> 
-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov




More information about the Tarantool-patches mailing list