sql. Make CREATE INDEX work
sql. Introduce TARANTOOL_INDEX. ... and use it instead of direct "_index". sql. Introduce TARANTOOL_SYS_SPACE_NAME for "_space" ... ... also rename TARANTOOL_INDEX -> TARANTOOL_SYS_INDEX_NAME. sql. Implement `DROP INDEX` statement (#2097). * lib/sqlite/src/build.c: Change DropIndex to remove from Tarantool's _index. Remove b-tree cleanup. * Add new test, fix existing to use `DROP INDEX`. sql. Implement `DROP TABLE` SQL statement. * Add new test and fix existing to use `DROP TABLE` statement. * Remove now redundant destroyTable and destroyRootPage to avoid compiler warning. * Fix couple warning about unused var/arg in sqlite/src/build.c. sql: Fix `DROP TABLE` to remove secondary indexes first. Tarantool doesn't allow to remove primary index while secondary exist, so remove secondary indexes first while droppping table. sql: OP_IncMaxid The opcode is specifically tailored for incrementing the max_id - the internal key that track the maximum space id seen so far. sql: Make CREATE TABLE work sql: Use CREATE TABLE in tests, remove hack Also no longer export sql_schema_put. sql: Reject CREATE TABLE lacking WITHOUT ROWID clause sql: Fix CREATE TABLE with implicit indices sql: Several fixes to allow some tests to pass * Treat all CREATE TABLE as if WITHOUT ROWID clause was present. * Schema is loaded from Tarantool into additional SQLite instances (tcltestrunner creates additional database handles, doesn't use one provided by Tarantool.) sql: Implement persistency for SQL schema (gh-2308). src/box/ * alter.cc (opt_set): Support strings with length not limited to def->len. (key_def_new_from_tuple): Make external. (space_def_create_from_tuple): Ditto. (opt_encode): Skip for OPT_STRPTR. (key_opts_default): Use pointer instead of array for SQL, initialize sql_length variable. (space_opts_default): Ditto. (key_opts_reg): Use STRPTR instead of STR to store SQL value. (space_opts_reg): Ditto. * key_def.h (opt_type): add STRPTR. (key_opts): Replace array for storing SQL w/ pointer and its length. (space_opts): Ditto. * schema.cc (schema_init): Use update fields initialization. * sql.c (sql_schema_put): Move function. (tarantoolSqlite3LoadSchema): Move function. Remove rowid mentioning. Iterate over Tarantool `_space` and `_index` initializing SQL data structures. src/lib/sqlite/src/ * prepare.c (sqlite3InitCallback): Detect SQL line length, pass it to sqlite3_prepare. (sqlite3InitCallback): Add sanity check for line length. (sqlite3InitOne): Initialize SQL length. * sqliteInt.h (struct InitData): Add SQL length to field. * vdbe.c (sqlite3VdbeExec): Initialize SQL length in OP_Prepare. sql: Replace key_def w/ index_def after rebase. src/box/ * alter.cc (index_def_new_from_tuple): Make "C" extern. (box_iterator_key_def): Rename to ... (box_iterator_index_def): ... this. * index.h (box_iterator_key_def): Update declaration to ... (box_iterator_key_def): ... this. * key_def.cc (index_opts_reg): Change argument from key_ to index_. * sql.c (tarantoolSqlite3Delete): Update key_def access. (tarantoolSqlite3IdxKeyCompare): Replace key_def w/ index_def. (key_def_new_from_tuple): Update declaration to ... (index_def_new_from_tuple): ... this. (tarantoolSqlite3LoadSchema): Use index_def instead of key_def. sql: Privatize sql string in `index_opts`. src/box/ * alter.cc (opt_set): if SQL passed is non empty - duplicate SQL query sting, set field to NULL otherwise. * key_def.cc (index_opts_destroy): New. Use free () to destroy privatized string. (index_opts_dup): New. Since sql is now privitely owned memory need to use malloc and memcpy in duplication of index_opts. (index_def_dup): Call index_opts duplicator. (index_def_delete): Call index_opts destructor. * key_def.h (struct index_opts): Remove `const` modifier from sql field. sql: Remove explicit `sql_length` field. src/box/ * alter.cc (opt_set): Insead of storing string length into `sql_length` simply use null terminated string. We won't allow UTF-16. * key_def.cc (index_opts_default): Remove `sql_length` initialization. (space_opts_default): Ditto. (index_opts_destroy): Ditto. (index_opts_dup): Use null-terminated string. * key_def.h (index_opts): Remove `sql_length`. (space_opts): Ditto. * schema.cc (schema_init): Remove `sql_length` initialization. * sql.c (tarantoolSqlite3LoadSchema): Remove `iSqlLength` initialization. src/lib/sqlite/src/ * prepare.c (sqlite3InitCallback): Use checks for null-terminated strings. (sqlite3InitOne): Ditto. * sqliteInt.h (struct InitData): Remove `iSqlLength`. * vdbe.c (vdbeExec): Remove `iSqlLength` initialization.
Showing
- src/box/alter.cc 21 additions, 1 deletionsrc/box/alter.cc
- src/box/index.h 0 additions, 1 deletionsrc/box/index.h
- src/box/key_def.cc 31 additions, 1 deletionsrc/box/key_def.cc
- src/box/key_def.h 9 additions, 0 deletionssrc/box/key_def.h
- src/box/schema.cc 2 additions, 1 deletionsrc/box/schema.cc
- src/box/sql.c 366 additions, 103 deletionssrc/box/sql.c
- src/box/sql/build.c 397 additions, 235 deletionssrc/box/sql/build.c
- src/box/sql/prepare.c 12 additions, 3 deletionssrc/box/sql/prepare.c
- src/box/sql/tarantoolInt.h 50 additions, 0 deletionssrc/box/sql/tarantoolInt.h
- src/box/sql/vdbe.c 21 additions, 0 deletionssrc/box/sql/vdbe.c
- test/box/lua/sqlworkaround.lua 0 additions, 34 deletionstest/box/lua/sqlworkaround.lua
- test/box/sql-drop-index.result 43 additions, 0 deletionstest/box/sql-drop-index.result
- test/box/sql-drop-index.test.lua 31 additions, 0 deletionstest/box/sql-drop-index.test.lua
- test/box/sql-drop-table.result 29 additions, 0 deletionstest/box/sql-drop-table.result
- test/box/sql-drop-table.test.lua 25 additions, 0 deletionstest/box/sql-drop-table.test.lua
- test/box/sql-insert-unique.result 6 additions, 30 deletionstest/box/sql-insert-unique.result
- test/box/sql-insert-unique.test.lua 4 additions, 13 deletionstest/box/sql-insert-unique.test.lua
- test/box/sql-transition.result 38 additions, 68 deletionstest/box/sql-transition.result
- test/box/sql-transition.test.lua 24 additions, 29 deletionstest/box/sql-transition.test.lua
- test/box/suite.ini 1 addition, 1 deletiontest/box/suite.ini
Loading
Please register or sign in to comment