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
Showing
- extra/mkkeywordhash.c 14 additions, 7 deletionsextra/mkkeywordhash.c
- src/box/sql.c 5 additions, 77 deletionssrc/box/sql.c
- src/box/sql/build.c 24 additions, 39 deletionssrc/box/sql/build.c
- src/box/sql/expr.c 61 additions, 76 deletionssrc/box/sql/expr.c
- src/box/sql/parse.y 77 additions, 23 deletionssrc/box/sql/parse.y
- src/box/sql/select.c 1 addition, 160 deletionssrc/box/sql/select.c
- src/box/sql/sqliteInt.h 27 additions, 2 deletionssrc/box/sql/sqliteInt.h
- src/box/sql/tarantoolInt.h 1 addition, 3 deletionssrc/box/sql/tarantoolInt.h
- src/box/sql/vdbe.c 11 additions, 3 deletionssrc/box/sql/vdbe.c
- src/box/sql/vdbemem.c 1 addition, 1 deletionsrc/box/sql/vdbemem.c
- src/box/sql/where.c 4 additions, 5 deletionssrc/box/sql/where.c
- src/box/sql/wherecode.c 5 additions, 2 deletionssrc/box/sql/wherecode.c
- test/box/sql-update-with-nested-select.result 1 addition, 1 deletiontest/box/sql-update-with-nested-select.result
- test/box/sql-update-with-nested-select.test.lua 1 addition, 1 deletiontest/box/sql-update-with-nested-select.test.lua
- test/sql-tap/affinity2.test.lua 0 additions, 135 deletionstest/sql-tap/affinity2.test.lua
- test/sql-tap/aggnested.test.lua 2 additions, 2 deletionstest/sql-tap/aggnested.test.lua
- test/sql-tap/alias.test.lua 1 addition, 1 deletiontest/sql-tap/alias.test.lua
- test/sql-tap/alter.test.lua 12 additions, 12 deletionstest/sql-tap/alter.test.lua
- test/sql-tap/alter2.test.lua 8 additions, 8 deletionstest/sql-tap/alter2.test.lua
- test/sql-tap/analyze1.test.lua 6 additions, 6 deletionstest/sql-tap/analyze1.test.lua
Loading
Please register or sign in to comment