* [tarantool-patches] [PATCH v1 0/2] sql: default engine pragma @ 2018-06-20 17:06 Kirill Shcherbatov 2018-06-20 17:06 ` [tarantool-patches] [PATCH v1 1/2] sql: introduce pragma sql_default_engine Kirill Shcherbatov ` (3 more replies) 0 siblings, 4 replies; 16+ messages in thread From: Kirill Shcherbatov @ 2018-06-20 17:06 UTC (permalink / raw) To: tarantool-patches; +Cc: v.shpilevoy, Kirill Shcherbatov Introduced a new SQL pragma that allows to set default storage engine. Both 'memtx' and 'vinyl' are supported. Config enum value is stored in user_session represented as uint8_t. Initial 0 value match default MEMTEX storage engine. Adopted basic sql test to launch with multiple engines. Worth to take into account that vinyl transactions don't rollback automatically on failures. This required to modify some tests. Branch: http://github.com/tarantool/tarantool/tree/kshch/gh-2199-engine-sql-specifier Issue: https://github.com/tarantool/tarantool/issues/2199 Kirill Shcherbatov (2): sql: introduce pragma sql_default_engine sql: enable multi-engine tests for SQL src/box/session.cc | 1 + src/box/session.h | 2 + src/box/sql/build.c | 43 +++++++++++++++++++++- src/box/sql/pragma.c | 8 ++++ src/box/sql/pragma.h | 6 +++ src/box/sql/sqliteInt.h | 14 +++++++ test/sql-tap/gh-2367-pragma.test.lua | 14 ++++++- test/sql/check-clear-ephemeral.result | 6 +++ test/sql/check-clear-ephemeral.test.lua | 3 +- test/sql/checks.result | 6 +++ test/sql/checks.test.lua | 2 + test/sql/clear.result | 6 +++ test/sql/clear.test.lua | 2 + test/sql/collation.result | 9 +++++ test/sql/collation.test.lua | 3 ++ test/sql/delete-multiple-idx.result | 6 +++ test/sql/delete-multiple-idx.test.lua | 2 + test/sql/delete.result | 6 +++ test/sql/delete.test.lua | 2 + test/sql/drop-index.result | 6 +++ test/sql/drop-index.test.lua | 2 + test/sql/drop-table.result | 6 +++ test/sql/drop-table.test.lua | 2 + test/sql/engine.cfg | 6 +++ test/sql/engine.result | 42 +++++++++++++++++++++ test/sql/engine.test.lua | 17 +++++++++ test/sql/errinj.result | 9 +++++ test/sql/errinj.test.lua | 3 ++ test/sql/gh-2929-primary-key.result | 9 +++++ test/sql/gh-2929-primary-key.test.lua | 4 ++ test/sql/gh-2981-check-autoinc.result | 9 +++++ test/sql/gh-2981-check-autoinc.test.lua | 4 ++ test/sql/gh-3199-no-mem-leaks.result | 6 +++ test/sql/gh-3199-no-mem-leaks.test.lua | 2 + test/sql/gh2141-delete-trigger-drop-table.result | 6 +++ test/sql/gh2141-delete-trigger-drop-table.test.lua | 2 + test/sql/gh2251-multiple-update.result | 6 +++ test/sql/gh2251-multiple-update.test.lua | 2 + test/sql/gh2483-remote-persistency-check.result | 6 +++ test/sql/gh2483-remote-persistency-check.test.lua | 2 + .../gh2808-inline-unique-persistency-check.result | 6 +++ ...gh2808-inline-unique-persistency-check.test.lua | 2 + test/sql/icu-upper-lower.result | 6 +++ test/sql/icu-upper-lower.test.lua | 2 + test/sql/insert-unique.result | 6 +++ test/sql/insert-unique.test.lua | 2 + test/sql/iproto.result | 12 +++++- test/sql/iproto.test.lua | 6 ++- test/sql/max-on-index.result | 6 +++ test/sql/max-on-index.test.lua | 2 + test/sql/message-func-indexes.result | 6 +++ test/sql/message-func-indexes.test.lua | 2 + test/sql/misc.result | 9 +++++ test/sql/misc.test.lua | 4 ++ test/sql/on-conflict.result | 6 +++ test/sql/on-conflict.test.lua | 2 + test/sql/persistency.result | 6 +++ test/sql/persistency.test.lua | 2 + test/sql/savepoints.result | 6 +++ test/sql/savepoints.test.lua | 2 + test/sql/select-null.result | 6 +++ test/sql/select-null.test.lua | 2 + test/sql/sql-statN-index-drop.result | 6 +++ test/sql/sql-statN-index-drop.test.lua | 2 + test/sql/suite.ini | 1 + test/sql/tokenizer.result | 6 +++ test/sql/tokenizer.test.lua | 2 + test/sql/transition.result | 9 +++++ test/sql/transition.test.lua | 4 ++ test/sql/transitive-transactions.result | 10 +++++ test/sql/transitive-transactions.test.lua | 6 +++ test/sql/triggers.result | 6 +++ test/sql/triggers.test.lua | 2 + test/sql/update-with-nested-select.result | 6 +++ test/sql/update-with-nested-select.test.lua | 2 + test/sql/upgrade.result | 6 +++ test/sql/upgrade.test.lua | 2 + test/sql/view.result | 6 +++ test/sql/view.test.lua | 2 + test/sql/view_delayed_wal.result | 6 +++ test/sql/view_delayed_wal.test.lua | 2 + 81 files changed, 476 insertions(+), 5 deletions(-) create mode 100644 test/sql/engine.cfg create mode 100644 test/sql/engine.result create mode 100644 test/sql/engine.test.lua -- 2.7.4 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] [PATCH v1 1/2] sql: introduce pragma sql_default_engine 2018-06-20 17:06 [tarantool-patches] [PATCH v1 0/2] sql: default engine pragma Kirill Shcherbatov @ 2018-06-20 17:06 ` Kirill Shcherbatov 2018-06-22 20:04 ` [tarantool-patches] " Vladislav Shpilevoy 2018-06-20 17:06 ` [tarantool-patches] [PATCH v1 2/2] sql: enable multi-engine tests for SQL Kirill Shcherbatov ` (2 subsequent siblings) 3 siblings, 1 reply; 16+ messages in thread From: Kirill Shcherbatov @ 2018-06-20 17:06 UTC (permalink / raw) To: tarantool-patches; +Cc: v.shpilevoy, Kirill Shcherbatov Part of #2199. @TarantoolBot document Title: new pragma sql_default_engine Now it is allowed to create vinyl spaces using special pragma setting default engine for SQL requests. Example: \set language sql pragma sql_default_engine='vinyl'; CREATE TABLE t3(a primary key,b,c); --- src/box/session.cc | 1 + src/box/session.h | 2 ++ src/box/sql/build.c | 43 +++++++++++++++++++++++++++++++++++- src/box/sql/pragma.c | 8 +++++++ src/box/sql/pragma.h | 6 +++++ src/box/sql/sqliteInt.h | 14 ++++++++++++ test/sql-tap/gh-2367-pragma.test.lua | 14 +++++++++++- 7 files changed, 86 insertions(+), 2 deletions(-) diff --git a/src/box/session.cc b/src/box/session.cc index e487280..810dd19 100644 --- a/src/box/session.cc +++ b/src/box/session.cc @@ -107,6 +107,7 @@ session_create(enum session_type type) memset(&session->meta, 0, sizeof(session->meta)); session->type = type; session->sql_flags = default_flags; + session->sql_default_engine = 0; /* For on_connect triggers. */ credentials_init(&session->credentials, guest_user->auth_token, diff --git a/src/box/session.h b/src/box/session.h index 515c30a..df1dcbc 100644 --- a/src/box/session.h +++ b/src/box/session.h @@ -92,6 +92,8 @@ union session_meta { struct session { /** Session id. */ uint64_t id; + /** SQL Tarantool Default storage engine. */ + uint8_t sql_default_engine; /** SQL Connection flag for current user session */ uint32_t sql_flags; enum session_type type; diff --git a/src/box/sql/build.c b/src/box/sql/build.c index fff7c19..bcd4d31 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -493,6 +493,43 @@ sqlite3PrimaryKeyIndex(Table * pTab) } /** + * Get default engine name set in current_session. + * @retval engine name string. + */ +static const char * +sql_default_engine_name(void) +{ + switch (current_session()->sql_default_engine) { + case SQL_STORAGE_ENGINE_MEMTX: + return "memtx"; + case SQL_STORAGE_ENGINE_VINYL: + return "vinyl"; + default: + unreachable(); + } +} + +int +sql_default_engine_set(const char *engine_name) +{ + enum sql_storage_engine_t engine = 0; + size_t engine_name_len = strlen(engine_name); + + if (engine_name_len == strlen("memtx") && + sqlite3_stricmp(engine_name, "memtx") == 0) { + engine = SQL_STORAGE_ENGINE_MEMTX; + } else if (engine_name_len == strlen("vinyl") && + sqlite3_stricmp(engine_name, "vinyl") == 0) { + engine = SQL_STORAGE_ENGINE_VINYL; + } else { + diag_set(ClientError, ER_NO_SUCH_ENGINE, engine_name); + return -1; + } + current_session()->sql_default_engine = engine; + return 0; +} + +/** * Create and initialize a new SQL Table object. * All memory except table object itself is allocated on region. * @param parser SQL Parser object. @@ -510,6 +547,9 @@ sql_table_new(Parse *parser, char *name) if (table == NULL) return NULL; + snprintf(table->def->engine_name, sizeof(table->def->engine_name), "%s", + sql_default_engine_name()); + table->iPKey = -1; table->iAutoIncPKey = -1; table->pSchema = db->pSchema; @@ -1602,7 +1642,8 @@ createSpace(Parse * pParse, int iSpaceId, char *zStmt) sqlite3VdbeAddOp4(v, OP_String8, 0, iFirstCol + 2 /* name */ , 0, sqlite3DbStrDup(pParse->db, p->def->name), P4_DYNAMIC); sqlite3VdbeAddOp4(v, OP_String8, 0, iFirstCol + 3 /* engine */ , 0, - "memtx", P4_STATIC); + sqlite3DbStrDup(pParse->db, p->def->engine_name), + P4_DYNAMIC); sqlite3VdbeAddOp2(v, OP_Integer, p->def->field_count, iFirstCol + 4 /* field_count */ ); sqlite3VdbeAddOp4(v, OP_Blob, zOptsSz, iFirstCol + 5, MSGPACK_SUBTYPE, diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c index 5fb29c7..90d1cc1 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -870,6 +870,14 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ } break; } + case PragTyp_DEFAULT_ENGINE: { + if (sql_default_engine_set(zRight) != 0) { + pParse->rc = SQL_TARANTOOL_ERROR; + pParse->nErr++; + goto pragma_out; + } + break; + } /* * PRAGMA busy_timeout * PRAGMA busy_timeout = N * * diff --git a/src/box/sql/pragma.h b/src/box/sql/pragma.h index f966018..6e921d6 100644 --- a/src/box/sql/pragma.h +++ b/src/box/sql/pragma.h @@ -17,6 +17,7 @@ #define PragTyp_STATS 15 #define PragTyp_TABLE_INFO 17 #define PragTyp_PARSER_TRACE 24 +#define PragTyp_DEFAULT_ENGINE 25 /* Property flags associated with various pragma. */ #define PragFlg_NeedSchema 0x01 /* Force schema load before running */ @@ -247,6 +248,11 @@ static const PragmaName aPragmaName[] = { /* ColNames: */ 0, 0, /* iArg: */ SQLITE_ShortColNames}, #endif + { /* zName: */ "sql_default_engine", + /* ePragTyp: */ PragTyp_DEFAULT_ENGINE, + /* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1, + /* ColNames: */ 0, 0, + /* iArg: */ 0}, #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) #if defined(SQLITE_DEBUG) { /* zName: */ "sql_trace", diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h index acda23d..8f5ef39 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -4560,6 +4560,20 @@ void sqlite3VdbeIOTraceSql(Vdbe *); #define sqlite3VdbeIOTraceSql(X) #endif +enum sql_storage_engine_t { + SQL_STORAGE_ENGINE_MEMTX = 0, + SQL_STORAGE_ENGINE_VINYL = 1, +}; + +/** + * Set tarantool backend default engine for SQL interface. + * @param engine_name to set default. + * @retval -1 on error. + * @retval 0 on success. + */ +int +sql_default_engine_set(const char *engine_name); + /* * These routines are available for the mem2.c debugging memory allocator * only. They are used to verify that different "types" of memory diff --git a/test/sql-tap/gh-2367-pragma.test.lua b/test/sql-tap/gh-2367-pragma.test.lua index a41a026..2ee8424 100755 --- a/test/sql-tap/gh-2367-pragma.test.lua +++ b/test/sql-tap/gh-2367-pragma.test.lua @@ -1,7 +1,7 @@ #!/usr/bin/env tarantool test = require("sqltester") -test:plan(1) +test:plan(2) test:do_catchsql_test( "pragma-1.3", @@ -11,4 +11,16 @@ test:do_catchsql_test( 1, "no such pragma: KEK" }) +--- +--- gh-2199: SQL default engine pragma +--- +test:do_catchsql_test( + "pragma-2.1", + [[ + pragma sql_default_engine='creepy'; + ]], { + 1, "Space engine 'creepy' does not exist" +}) + + test:finish_test() -- 2.7.4 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] Re: [PATCH v1 1/2] sql: introduce pragma sql_default_engine 2018-06-20 17:06 ` [tarantool-patches] [PATCH v1 1/2] sql: introduce pragma sql_default_engine Kirill Shcherbatov @ 2018-06-22 20:04 ` Vladislav Shpilevoy 2018-06-26 12:22 ` Kirill Shcherbatov 0 siblings, 1 reply; 16+ messages in thread From: Vladislav Shpilevoy @ 2018-06-22 20:04 UTC (permalink / raw) To: tarantool-patches, Kirill Shcherbatov Thanks for the patch! See 11 comments below. On 20/06/2018 20:06, Kirill Shcherbatov wrote: > Part of #2199. > > @TarantoolBot document > Title: new pragma sql_default_engine > Now it is allowed to create vinyl spaces using special pragma > setting default engine for SQL requests. > Example: > \set language sql > pragma sql_default_engine='vinyl'; > CREATE TABLE t3(a primary key,b,c); > --- > src/box/session.cc | 1 + > src/box/session.h | 2 ++ > src/box/sql/build.c | 43 +++++++++++++++++++++++++++++++++++- > src/box/sql/pragma.c | 8 +++++++ > src/box/sql/pragma.h | 6 +++++ > src/box/sql/sqliteInt.h | 14 ++++++++++++ > test/sql-tap/gh-2367-pragma.test.lua | 14 +++++++++++- > 7 files changed, 86 insertions(+), 2 deletions(-) > > diff --git a/src/box/session.cc b/src/box/session.cc > index e487280..810dd19 100644 > --- a/src/box/session.cc > +++ b/src/box/session.cc > @@ -107,6 +107,7 @@ session_create(enum session_type type) > memset(&session->meta, 0, sizeof(session->meta)); > session->type = type; > session->sql_flags = default_flags; > + session->sql_default_engine = 0; 1. Please, declare engine enums in schema_def.h. If we want to allow different engines for different languages, we need to see this enum from non-sql files. And here please assign not to 0, but explicitly memtx engine enum. You are allowed to assign enum values to int variables. > > /* For on_connect triggers. */ > credentials_init(&session->credentials, guest_user->auth_token, > diff --git a/src/box/sql/build.c b/src/box/sql/build.c > index fff7c19..bcd4d31 100644 > --- a/src/box/sql/build.c > +++ b/src/box/sql/build.c > @@ -493,6 +493,43 @@ sqlite3PrimaryKeyIndex(Table * pTab) > } > > /** > + * Get default engine name set in current_session. > + * @retval engine name string. > + */ > +static const char * > +sql_default_engine_name(void) > +{ > + switch (current_session()->sql_default_engine) { > + case SQL_STORAGE_ENGINE_MEMTX: > + return "memtx"; > + case SQL_STORAGE_ENGINE_VINYL: > + return "vinyl"; > + default: > + unreachable(); > + } > +} 2. Do you really need this function to use in a single place in a single source file? >> +int > +sql_default_engine_set(const char *engine_name) > +{ > + enum sql_storage_engine_t engine = 0; > + size_t engine_name_len = strlen(engine_name); > + > + if (engine_name_len == strlen("memtx") && > + sqlite3_stricmp(engine_name, "memtx") == 0) { 3. Please, do not use sqlite3_ functions when possible. Why can not you use strcasecmp here? 4. You do not need compare lengths. 'engine_name' variable is zero-terminated already. And you use this fact several lines above. 5. Bad indentation. > + engine = SQL_STORAGE_ENGINE_MEMTX; > + } else if (engine_name_len == strlen("vinyl") && > + sqlite3_stricmp(engine_name, "vinyl") == 0) { > + engine = SQL_STORAGE_ENGINE_VINYL; 6. Bad indentation. > + } else { > + diag_set(ClientError, ER_NO_SUCH_ENGINE, engine_name); > + return -1; > + } > + current_session()->sql_default_engine = engine; 7. On language switch it should be reset, if we do not want to affect lua. Maybe we should ask in a big red chat about this default engine for each language unless we will have to set default engine like this when use iproto: c = netbox.connect(uri) c:execute('PRAGMA default_engine = "memtx"') c:eval('box.space.default_engine = "memtx"') ... -- etc for each language. And it breaks our "celebratory interoperability" so much glorified on T+ conf. Maybe it is a good question for Gulutzan. > + return 0; > +} > + > +/** > * Create and initialize a new SQL Table object. > * All memory except table object itself is allocated on region. > * @param parser SQL Parser object> diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h > index acda23d..8f5ef39 100644 > --- a/src/box/sql/sqliteInt.h > +++ b/src/box/sql/sqliteInt.h > @@ -4560,6 +4560,20 @@ void sqlite3VdbeIOTraceSql(Vdbe *); > #define sqlite3VdbeIOTraceSql(X) > #endif > > +enum sql_storage_engine_t { > + SQL_STORAGE_ENGINE_MEMTX = 0, > + SQL_STORAGE_ENGINE_VINYL = 1, > +}; 8. Please, remove '_t'. We do not use it for enums. 9. Please, add a formal comment. I know, it is obvious here, and I have tried to skip them, but Kostja again asked to write the comments. > + > +/** > + * Set tarantool backend default engine for SQL interface. > + * @param engine_name to set default. > + * @retval -1 on error. > + * @retval 0 on success. > + */ > +int > +sql_default_engine_set(const char *engine_name); 10. Please, make this function be static inline in pragma.c. > + > /* > * These routines are available for the mem2.c debugging memory allocator > * only. They are used to verify that different "types" of memory > diff --git a/test/sql-tap/gh-2367-pragma.test.lua b/test/sql-tap/gh-2367-pragma.test.lua > index a41a026..2ee8424 100755 > --- a/test/sql-tap/gh-2367-pragma.test.lua > +++ b/test/sql-tap/gh-2367-pragma.test.lua > @@ -1,7 +1,7 @@ > #!/usr/bin/env tarantool > test = require("sqltester") > > -test:plan(1) > +test:plan(2) > > test:do_catchsql_test( > "pragma-1.3", > @@ -11,4 +11,16 @@ test:do_catchsql_test( > 1, "no such pragma: KEK" > }) > > +--- > +--- gh-2199: SQL default engine pragma > +--- > +test:do_catchsql_test( > + "pragma-2.1", > + [[ > + pragma sql_default_engine='creepy'; > + ]], { > + 1, "Space engine 'creepy' does not exist" > +}) 11. Add a test with correct engines as well. ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] Re: [PATCH v1 1/2] sql: introduce pragma sql_default_engine 2018-06-22 20:04 ` [tarantool-patches] " Vladislav Shpilevoy @ 2018-06-26 12:22 ` Kirill Shcherbatov 2018-06-26 13:34 ` Vladislav Shpilevoy 0 siblings, 1 reply; 16+ messages in thread From: Kirill Shcherbatov @ 2018-06-26 12:22 UTC (permalink / raw) To: tarantool-patches; +Cc: Vladislav Shpilevoy > 1. Please, declare engine enums in schema_def.h. If we want to allow > different engines for different languages, we need to see this enum > from non-sql files. And here please assign not to 0, but explicitly > memtx engine enum. You are allowed to assign enum values to int > variables. +++ b/src/box/schema_def.h @@ -243,6 +243,12 @@ enum schema_object_type { schema_object_type_MAX = 8 }; +/** SQL Storage engine. */ +enum sql_storage_engine_type { + SQL_STORAGE_ENGINE_MEMTX = 0, + SQL_STORAGE_ENGINE_VINYL = 1, +}; > 2. Do you really need this function to use in a single place in a > single source file? Yep. > 3. Please, do not use sqlite3_ functions when possible. Why > can not you use strcasecmp here? > 4. You do not need compare lengths. 'engine_name' variable is > zero-terminated already. And you use this fact several lines above. > 5. Bad indentation. > 6. Bad indentation. +++ b/src/box/sql/pragma.c @@ -235,6 +235,29 @@ printActivePragmas(struct session *user_session) } } +/** + * Set tarantool backend default engine for SQL interface. + * @param engine_name to set default. + * @retval -1 on error. + * @retval 0 on success. + */ +static int +sql_default_engine_set(const char *engine_name) +{ + enum sql_storage_engine_type engine; + if (strcasecmp(engine_name, "memtx") == 0) { + engine = SQL_STORAGE_ENGINE_MEMTX; + } else if (strcasecmp(engine_name, "vinyl") == 0) { + engine = SQL_STORAGE_ENGINE_VINYL; + } else { + diag_set(ClientError, ER_NO_SUCH_ENGINE, engine_name); + return -1; + } + current_session()->sql_default_engine = engine; + return 0; +} > 7. On language switch it should be reset, if we do not want to > affect lua. Don't know, what should I do. > 8. Please, remove '_t'. We do not use it for enums. ok > > 9. Please, add a formal comment. I know, it is obvious here, > and I have tried to skip them, but Kostja again asked to write > the comments. ok. > 10. Please, make this function be static inline in pragma.c. ok. > 11. Add a test with correct engines as well. +test:do_catchsql_test( + "pragma-2.2", + [[ + pragma sql_default_engine='vinyl'; + ]], { + 0 +}) + +test:do_catchsql_test( + "pragma-2.3", + [[ + pragma sql_default_engine='memtx'; + ]], { + 0 +}) ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] Re: [PATCH v1 1/2] sql: introduce pragma sql_default_engine 2018-06-26 12:22 ` Kirill Shcherbatov @ 2018-06-26 13:34 ` Vladislav Shpilevoy 2018-06-26 17:09 ` Kirill Shcherbatov 0 siblings, 1 reply; 16+ messages in thread From: Vladislav Shpilevoy @ 2018-06-26 13:34 UTC (permalink / raw) To: Kirill Shcherbatov, tarantool-patches Hello. Thanks for the fixes! See 5 comments below. On 26/06/2018 15:22, Kirill Shcherbatov wrote: >> 1. Please, declare engine enums in schema_def.h. If we want to allow >> different engines for different languages, we need to see this enum >> from non-sql files. And here please assign not to 0, but explicitly >> memtx engine enum. You are allowed to assign enum values to int >> variables. > +++ b/src/box/schema_def.h > @@ -243,6 +243,12 @@ enum schema_object_type { > schema_object_type_MAX = 8 > }; > +/** SQL Storage engine. */ > +enum sql_storage_engine_type { > + SQL_STORAGE_ENGINE_MEMTX = 0, > + SQL_STORAGE_ENGINE_VINYL = 1, > +}; > > >> 2. Do you really need this function to use in a single place in a >> single source file? > Yep. 1. It was a rhetorical question. Please, remove it in the way described in comment 6. 2. I do not see the new patch version. Please, put it after fixes. > >> 7. On language switch it should be reset, if we do not want to >> affect lua. > Don't know, what should I do. > 3. My fault. I was confused by \set language. Please, do not skip the rest of the comment. I will paste it here for you: > Maybe we should ask in a big red chat about this default engine > for each language unless we will have to set default engine like > this when use iproto: > > c = netbox.connect(uri) > c:execute('PRAGMA default_engine = "memtx"') > c:eval('box.space.default_engine = "memtx"') > ... -- etc for each language. > > And it breaks our "celebratory interoperability" so much > glorified on T+ conf. > > Maybe it is a good question for Gulutzan. Please, do what I said here. > @@ -510,6 +527,9 @@ sql_table_new(Parse *parser, char *name) > if (table == NULL) > return NULL; > > + snprintf(table->def->engine_name, sizeof(table->def->engine_name), "%s", > + sql_default_engine_name()); > + 4. Here strcpy is enough. You do not need any formatting here, and you know, that engine name fits in space_def.engine_name. > +/** > + * Set tarantool backend default engine for SQL interface. > + * @param engine_name to set default. > + * @retval -1 on error. > + * @retval 0 on success. > + */ > +static int > +sql_default_engine_set(const char *engine_name) > +{ > + enum sql_storage_engine_type engine; > + if (strcasecmp(engine_name, "memtx") == 0) { > + engine = SQL_STORAGE_ENGINE_MEMTX; > + } else if (strcasecmp(engine_name, "vinyl") == 0) { > + engine = SQL_STORAGE_ENGINE_VINYL; > + } else { > + diag_set(ClientError, ER_NO_SUCH_ENGINE, engine_name); > + return -1; > + } > + current_session()->sql_default_engine = engine; > + return 0; > +} 5. Please, do not use neither _t nor _type for enums. 6. Why do you need strcasecmp here? I do not think, that we should allow 'MeMtX' or 'Memtx' or something. Only 'memtx' (and 'vinyl'). And in such a case you can declare sql_storage_engine_strs and use STR2ENUM like it is done for other enums visible to user. ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] Re: [PATCH v1 1/2] sql: introduce pragma sql_default_engine 2018-06-26 13:34 ` Vladislav Shpilevoy @ 2018-06-26 17:09 ` Kirill Shcherbatov 2018-06-27 12:32 ` Vladislav Shpilevoy 0 siblings, 1 reply; 16+ messages in thread From: Kirill Shcherbatov @ 2018-06-26 17:09 UTC (permalink / raw) To: tarantool-patches; +Cc: Vladislav Shpilevoy > 1. It was a rhetorical question. Please, remove it in the way > described in comment 6. ok. > 2. I do not see the new patch version. Please, put it after fixes. appended. My fault. I was confused by \set language. > > Please, do not skip the rest of the comment. I will paste it > here for you: > >> Maybe we should ask in a big red chat about this default engine >> for each language unless we will have to set default engine like >> this when use iproto: >> >> c = netbox.connect(uri) >> c:execute('PRAGMA default_engine = "memtx"') >> c:eval('box.space.default_engine = "memtx"') >> ... -- etc for each language. >> >> And it breaks our "celebratory interoperability" so much >> glorified on T+ conf. >> >> Maybe it is a good question for Gulutzan. > > Please, do what I said here. I've discussed this with Kirill. He confirmed to use this setting only in SQL. > 4. Here strcpy is enough. You do not need any formatting here, > and you know, that engine name fits in space_def.engine_name. Ok. > 5. Please, do not use neither _t nor _type for enums. sql_storage_engine > > 6. Why do you need strcasecmp here? I do not think, > that we should allow 'MeMtX' or 'Memtx' or something. Only > 'memtx' (and 'vinyl'). And in such a case you can declare > sql_storage_engine_strs and use STR2ENUM like it is done > for other enums visible to user. Ok. ================================================== Part of #2199. @TarantoolBot document Title: new pragma sql_default_engine Now it is allowed to create vinyl spaces using special pragma setting default engine for SQL requests. This config is stored in user_session() and affect *only* tables been created with SQL. Example: \set language sql pragma sql_default_engine='vinyl'; CREATE TABLE t3(a primary key,b,c); --- src/box/schema_def.h | 7 +++++++ src/box/session.cc | 1 + src/box/session.h | 2 ++ src/box/sql/build.c | 11 ++++++++++- src/box/sql/pragma.c | 28 ++++++++++++++++++++++++++++ src/box/sql/pragma.h | 6 ++++++ src/box/sql/sqliteInt.h | 2 ++ test/sql-tap/gh-2367-pragma.test.lua | 29 ++++++++++++++++++++++++++++- 8 files changed, 84 insertions(+), 2 deletions(-) diff --git a/src/box/schema_def.h b/src/box/schema_def.h index b9a5fa5..e6a7206 100644 --- a/src/box/schema_def.h +++ b/src/box/schema_def.h @@ -243,6 +243,13 @@ enum schema_object_type { schema_object_type_MAX = 8 }; +/** SQL Storage engine. */ +enum sql_storage_engine { + SQL_STORAGE_ENGINE_MEMTX = 0, + SQL_STORAGE_ENGINE_VINYL = 1, + sql_storage_engine_MAX = 2 +}; + enum schema_object_type schema_object_type(const char *name); diff --git a/src/box/session.cc b/src/box/session.cc index e487280..64714cd 100644 --- a/src/box/session.cc +++ b/src/box/session.cc @@ -107,6 +107,7 @@ session_create(enum session_type type) memset(&session->meta, 0, sizeof(session->meta)); session->type = type; session->sql_flags = default_flags; + session->sql_default_engine = SQL_STORAGE_ENGINE_MEMTX; /* For on_connect triggers. */ credentials_init(&session->credentials, guest_user->auth_token, diff --git a/src/box/session.h b/src/box/session.h index 515c30a..df1dcbc 100644 --- a/src/box/session.h +++ b/src/box/session.h @@ -92,6 +92,8 @@ union session_meta { struct session { /** Session id. */ uint64_t id; + /** SQL Tarantool Default storage engine. */ + uint8_t sql_default_engine; /** SQL Connection flag for current user session */ uint32_t sql_flags; enum session_type type; diff --git a/src/box/sql/build.c b/src/box/sql/build.c index 093fea5..5496d29 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -492,6 +492,11 @@ sqlite3PrimaryKeyIndex(Table * pTab) return p; } +const char *sql_storage_engine_strs[] = { + [SQL_STORAGE_ENGINE_MEMTX] = "memtx", + [SQL_STORAGE_ENGINE_VINYL] = "vinyl", +}; + /** * Create and initialize a new SQL Table object. * All memory except table object itself is allocated on region. @@ -510,6 +515,9 @@ sql_table_new(Parse *parser, char *name) if (table == NULL) return NULL; + strcpy(table->def->engine_name, + sql_storage_engine_strs[current_session()->sql_default_engine]); + table->iPKey = -1; table->iAutoIncPKey = -1; table->pSchema = db->pSchema; @@ -1602,7 +1610,8 @@ createSpace(Parse * pParse, int iSpaceId, char *zStmt) sqlite3VdbeAddOp4(v, OP_String8, 0, iFirstCol + 2 /* name */ , 0, sqlite3DbStrDup(pParse->db, p->def->name), P4_DYNAMIC); sqlite3VdbeAddOp4(v, OP_String8, 0, iFirstCol + 3 /* engine */ , 0, - "memtx", P4_STATIC); + sqlite3DbStrDup(pParse->db, p->def->engine_name), + P4_DYNAMIC); sqlite3VdbeAddOp2(v, OP_Integer, p->def->field_count, iFirstCol + 4 /* field_count */ ); sqlite3VdbeAddOp4(v, OP_Blob, zOptsSz, iFirstCol + 5, MSGPACK_SUBTYPE, diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c index be6a01c..7a25db6 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -235,6 +235,26 @@ printActivePragmas(struct session *user_session) } } +/** + * Set tarantool backend default engine for SQL interface. + * @param engine_name to set default. + * @retval -1 on error. + * @retval 0 on success. + */ +static int +sql_default_engine_set(const char *engine_name) +{ + enum sql_storage_engine engine = + STR2ENUM(sql_storage_engine, engine_name); + if (engine == sql_storage_engine_MAX) { + diag_set(ClientError, ER_NO_SUCH_ENGINE, engine_name); + return -1; + } + current_session()->sql_default_engine = engine; + return 0; +} + + /* * Process a pragma statement. * @@ -868,6 +888,14 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ } break; } + case PragTyp_DEFAULT_ENGINE: { + if (sql_default_engine_set(zRight) != 0) { + pParse->rc = SQL_TARANTOOL_ERROR; + pParse->nErr++; + goto pragma_out; + } + break; + } /* * PRAGMA busy_timeout * PRAGMA busy_timeout = N * * diff --git a/src/box/sql/pragma.h b/src/box/sql/pragma.h index 06b7eea..795c98c 100644 --- a/src/box/sql/pragma.h +++ b/src/box/sql/pragma.h @@ -17,6 +17,7 @@ #define PragTyp_STATS 15 #define PragTyp_TABLE_INFO 17 #define PragTyp_PARSER_TRACE 24 +#define PragTyp_DEFAULT_ENGINE 25 /* Property flags associated with various pragma. */ #define PragFlg_NeedSchema 0x01 /* Force schema load before running */ @@ -247,6 +248,11 @@ static const PragmaName aPragmaName[] = { /* ColNames: */ 0, 0, /* iArg: */ SQLITE_ShortColNames}, #endif + { /* zName: */ "sql_default_engine", + /* ePragTyp: */ PragTyp_DEFAULT_ENGINE, + /* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1, + /* ColNames: */ 0, 0, + /* iArg: */ 0}, #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) #if defined(SQLITE_DEBUG) { /* zName: */ "sql_trace", diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h index d6ae5c2..918fe90 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -4804,4 +4804,6 @@ vdbe_emit_halt_if_exists(struct Parse *parser, int space_id, int index_id, const char *name_src, int tarantool_error_code, const char *error_src, bool no_error); +extern const char *sql_storage_engine_strs[]; + #endif /* SQLITEINT_H */ diff --git a/test/sql-tap/gh-2367-pragma.test.lua b/test/sql-tap/gh-2367-pragma.test.lua index a41a026..6d2e73d 100755 --- a/test/sql-tap/gh-2367-pragma.test.lua +++ b/test/sql-tap/gh-2367-pragma.test.lua @@ -1,7 +1,7 @@ #!/usr/bin/env tarantool test = require("sqltester") -test:plan(1) +test:plan(4) test:do_catchsql_test( "pragma-1.3", @@ -11,4 +11,31 @@ test:do_catchsql_test( 1, "no such pragma: KEK" }) +--- +--- gh-2199: SQL default engine pragma +--- +test:do_catchsql_test( + "pragma-2.1", + [[ + pragma sql_default_engine='creepy'; + ]], { + 1, "Space engine 'creepy' does not exist" +}) + +test:do_catchsql_test( + "pragma-2.2", + [[ + pragma sql_default_engine='vinyl'; + ]], { + 0 +}) + +test:do_catchsql_test( + "pragma-2.3", + [[ + pragma sql_default_engine='memtx'; + ]], { + 0 +}) + test:finish_test() -- 2.7.4 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] Re: [PATCH v1 1/2] sql: introduce pragma sql_default_engine 2018-06-26 17:09 ` Kirill Shcherbatov @ 2018-06-27 12:32 ` Vladislav Shpilevoy 2018-06-27 15:59 ` Kirill Shcherbatov 0 siblings, 1 reply; 16+ messages in thread From: Vladislav Shpilevoy @ 2018-06-27 12:32 UTC (permalink / raw) To: Kirill Shcherbatov, tarantool-patches Hello. Thanks for the fixes! > diff --git a/src/box/schema_def.h b/src/box/schema_def.h > index b9a5fa5..e6a7206 100644 > --- a/src/box/schema_def.h > +++ b/src/box/schema_def.h > @@ -243,6 +243,13 @@ enum schema_object_type { > schema_object_type_MAX = 8 > }; > > +/** SQL Storage engine. */ > +enum sql_storage_engine { > + SQL_STORAGE_ENGINE_MEMTX = 0, > + SQL_STORAGE_ENGINE_VINYL = 1, > + sql_storage_engine_MAX = 2 > +}; Please, put _strs here as extern and declare it in schema_def.c like it is done for other enum + _strs pairs (enum + extern strs in a header and declaration in source). > + > enum schema_object_type > schema_object_type(const char *name); > On the branch I got these errors: /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:102:6: error: variable 'trigger_name' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (sqlite3FixSrcList(&fixdb, table) != 0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:156:20: note: uninitialized use occurs here sqlite3DbFree(db, trigger_name); ^~~~~~~~~~~~ /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:102:2: note: remove the 'if' if its condition is always false if (sqlite3FixSrcList(&fixdb, table) != 0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:98:6: error: variable 'trigger_name' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (db->mallocFailed) ^~~~~~~~~~~~~~~~ /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:156:20: note: uninitialized use occurs here sqlite3DbFree(db, trigger_name); ^~~~~~~~~~~~ /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:98:2: note: remove the 'if' if its condition is always false if (db->mallocFailed) ^~~~~~~~~~~~~~~~~~~~~ /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:91:6: error: variable 'trigger_name' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (table == NULL || db->mallocFailed) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:156:20: note: uninitialized use occurs here sqlite3DbFree(db, trigger_name); ^~~~~~~~~~~~ /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:91:2: note: remove the 'if' if its condition is always false if (table == NULL || db->mallocFailed) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:91:6: error: variable 'trigger_name' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized] if (table == NULL || db->mallocFailed) ^~~~~~~~~~~~~ /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:156:20: note: uninitialized use occurs here sqlite3DbFree(db, trigger_name); ^~~~~~~~~~~~ /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:91:6: note: remove the '||' if its condition is always false if (table == NULL || db->mallocFailed) ^~~~~~~~~~~~~~~~ /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/trigger.c:105:2: note: variable 'trigger_name' is declared here char *trigger_name = sqlite3NameFromToken(db, name); ^ 4 errors generated. ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] Re: [PATCH v1 1/2] sql: introduce pragma sql_default_engine 2018-06-27 12:32 ` Vladislav Shpilevoy @ 2018-06-27 15:59 ` Kirill Shcherbatov 0 siblings, 0 replies; 16+ messages in thread From: Kirill Shcherbatov @ 2018-06-27 15:59 UTC (permalink / raw) To: tarantool-patches; +Cc: Vladislav Shpilevoy > Hello. Thanks for the fixes! Thank you for review, > Please, put _strs here as extern and declare it in schema_def.c > like it is done for other enum + _strs pairs (enum + extern strs in > a header and declaration in source). diff --git a/src/box/schema_def.c b/src/box/schema_def.c index 97c074a..cbfad47 100644 --- a/src/box/schema_def.c +++ b/src/box/schema_def.c @@ -30,6 +30,11 @@ */ #include "schema_def.h" +const char *sql_storage_engine_strs[] = { + [SQL_STORAGE_ENGINE_MEMTX] = "memtx", + [SQL_STORAGE_ENGINE_VINYL] = "vinyl", +}; + static const char *object_type_strs[] = { /* [SC_UKNNOWN] = */ "unknown", /* [SC_UNIVERSE] = */ "universe", diff --git a/src/box/schema_def.h b/src/box/schema_def.h index e6a7206..5ab4bb0 100644 --- a/src/box/schema_def.h +++ b/src/box/schema_def.h @@ -250,6 +250,8 @@ enum sql_storage_engine { sql_storage_engine_MAX = 2 }; +extern const char *sql_storage_engine_strs[]; > On the branch I got these errors: This is non-related problem of trigger's branch (that is my HEAD). believe, I've already fixed it there. Rebased. ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] [PATCH v1 2/2] sql: enable multi-engine tests for SQL 2018-06-20 17:06 [tarantool-patches] [PATCH v1 0/2] sql: default engine pragma Kirill Shcherbatov 2018-06-20 17:06 ` [tarantool-patches] [PATCH v1 1/2] sql: introduce pragma sql_default_engine Kirill Shcherbatov @ 2018-06-20 17:06 ` Kirill Shcherbatov 2018-06-22 20:04 ` [tarantool-patches] " Vladislav Shpilevoy 2018-06-26 12:23 ` [tarantool-patches] [PATCH v1 2/3] sql: fix SQL Count for vinyl engine Kirill Shcherbatov 2018-06-28 15:35 ` [tarantool-patches] Re: [PATCH v1 0/2] sql: default engine pragma Vladislav Shpilevoy 3 siblings, 1 reply; 16+ messages in thread From: Kirill Shcherbatov @ 2018-06-20 17:06 UTC (permalink / raw) To: tarantool-patches; +Cc: v.shpilevoy, Kirill Shcherbatov Configured sql tests to set 'pragma sql_engine_default' on start. This allows to test both vinyl and memtx engines for SQL. Resolves #2199. --- test/sql/check-clear-ephemeral.result | 6 ++++ test/sql/check-clear-ephemeral.test.lua | 3 +- test/sql/checks.result | 6 ++++ test/sql/checks.test.lua | 2 ++ test/sql/clear.result | 6 ++++ test/sql/clear.test.lua | 2 ++ test/sql/collation.result | 9 +++++ test/sql/collation.test.lua | 3 ++ test/sql/delete-multiple-idx.result | 6 ++++ test/sql/delete-multiple-idx.test.lua | 2 ++ test/sql/delete.result | 6 ++++ test/sql/delete.test.lua | 2 ++ test/sql/drop-index.result | 6 ++++ test/sql/drop-index.test.lua | 2 ++ test/sql/drop-table.result | 6 ++++ test/sql/drop-table.test.lua | 2 ++ test/sql/engine.cfg | 6 ++++ test/sql/engine.result | 42 ++++++++++++++++++++++ test/sql/engine.test.lua | 17 +++++++++ test/sql/errinj.result | 9 +++++ test/sql/errinj.test.lua | 3 ++ test/sql/gh-2929-primary-key.result | 9 +++++ test/sql/gh-2929-primary-key.test.lua | 4 +++ test/sql/gh-2981-check-autoinc.result | 9 +++++ test/sql/gh-2981-check-autoinc.test.lua | 4 +++ test/sql/gh-3199-no-mem-leaks.result | 6 ++++ test/sql/gh-3199-no-mem-leaks.test.lua | 2 ++ test/sql/gh2141-delete-trigger-drop-table.result | 6 ++++ test/sql/gh2141-delete-trigger-drop-table.test.lua | 2 ++ test/sql/gh2251-multiple-update.result | 6 ++++ test/sql/gh2251-multiple-update.test.lua | 2 ++ test/sql/gh2483-remote-persistency-check.result | 6 ++++ test/sql/gh2483-remote-persistency-check.test.lua | 2 ++ .../gh2808-inline-unique-persistency-check.result | 6 ++++ ...gh2808-inline-unique-persistency-check.test.lua | 2 ++ test/sql/icu-upper-lower.result | 6 ++++ test/sql/icu-upper-lower.test.lua | 2 ++ test/sql/insert-unique.result | 6 ++++ test/sql/insert-unique.test.lua | 2 ++ test/sql/iproto.result | 12 ++++++- test/sql/iproto.test.lua | 6 +++- test/sql/max-on-index.result | 6 ++++ test/sql/max-on-index.test.lua | 2 ++ test/sql/message-func-indexes.result | 6 ++++ test/sql/message-func-indexes.test.lua | 2 ++ test/sql/misc.result | 9 +++++ test/sql/misc.test.lua | 4 +++ test/sql/on-conflict.result | 6 ++++ test/sql/on-conflict.test.lua | 2 ++ test/sql/persistency.result | 6 ++++ test/sql/persistency.test.lua | 2 ++ test/sql/savepoints.result | 6 ++++ test/sql/savepoints.test.lua | 2 ++ test/sql/select-null.result | 6 ++++ test/sql/select-null.test.lua | 2 ++ test/sql/sql-statN-index-drop.result | 6 ++++ test/sql/sql-statN-index-drop.test.lua | 2 ++ test/sql/suite.ini | 1 + test/sql/tokenizer.result | 6 ++++ test/sql/tokenizer.test.lua | 2 ++ test/sql/transition.result | 9 +++++ test/sql/transition.test.lua | 4 +++ test/sql/transitive-transactions.result | 10 ++++++ test/sql/transitive-transactions.test.lua | 6 ++++ test/sql/triggers.result | 6 ++++ test/sql/triggers.test.lua | 2 ++ test/sql/update-with-nested-select.result | 6 ++++ test/sql/update-with-nested-select.test.lua | 2 ++ test/sql/upgrade.result | 6 ++++ test/sql/upgrade.test.lua | 2 ++ test/sql/view.result | 6 ++++ test/sql/view.test.lua | 2 ++ test/sql/view_delayed_wal.result | 6 ++++ test/sql/view_delayed_wal.test.lua | 2 ++ 74 files changed, 390 insertions(+), 3 deletions(-) create mode 100644 test/sql/engine.cfg create mode 100644 test/sql/engine.result create mode 100644 test/sql/engine.test.lua diff --git a/test/sql/check-clear-ephemeral.result b/test/sql/check-clear-ephemeral.result index 156e06a..4ab1fe1 100644 --- a/test/sql/check-clear-ephemeral.result +++ b/test/sql/check-clear-ephemeral.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- box.cfg() -- create space box.sql.execute("CREATE TABLE t1(a,b,c,PRIMARY KEY(b,c));") diff --git a/test/sql/check-clear-ephemeral.test.lua b/test/sql/check-clear-ephemeral.test.lua index 8a5787b..c7ea733 100644 --- a/test/sql/check-clear-ephemeral.test.lua +++ b/test/sql/check-clear-ephemeral.test.lua @@ -1,5 +1,6 @@ test_run = require('test_run').new() - +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- box.cfg() -- create space diff --git a/test/sql/checks.result b/test/sql/checks.result index 21ce210..2a31b01 100644 --- a/test/sql/checks.result +++ b/test/sql/checks.result @@ -8,6 +8,12 @@ test_run:cmd("push filter ".."'\\.lua.*:[0-9]+: ' to '.lua...\"]:<line>: '") --- - true ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- -- gh-3272: Move SQL CHECK into server -- diff --git a/test/sql/checks.test.lua b/test/sql/checks.test.lua index bb76b0c..7ff78fe 100644 --- a/test/sql/checks.test.lua +++ b/test/sql/checks.test.lua @@ -1,6 +1,8 @@ env = require('test_run') test_run = env.new() test_run:cmd("push filter ".."'\\.lua.*:[0-9]+: ' to '.lua...\"]:<line>: '") +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- -- gh-3272: Move SQL CHECK into server diff --git a/test/sql/clear.result b/test/sql/clear.result index d267245..c75e134 100644 --- a/test/sql/clear.result +++ b/test/sql/clear.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- box.cfg() -- create space box.sql.execute("CREATE TABLE zoobar (c1, c2 PRIMARY KEY, c3, c4)") diff --git a/test/sql/clear.test.lua b/test/sql/clear.test.lua index 068a7c1..142cda8 100644 --- a/test/sql/clear.test.lua +++ b/test/sql/clear.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- box.cfg() diff --git a/test/sql/collation.result b/test/sql/collation.result index 3a4f81f..7fec96d 100644 --- a/test/sql/collation.result +++ b/test/sql/collation.result @@ -1,6 +1,15 @@ remote = require('net.box') --- ... +test_run = require('test_run').new() +--- +... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- gh-3010: COLLATE after LIMIT should throw an error -- All of these tests should throw error "near "COLLATE": syntax error" box.sql.execute("SELECT 1 LIMIT 1 COLLATE BINARY;") diff --git a/test/sql/collation.test.lua b/test/sql/collation.test.lua index fe8c1ba..ff2c5b2 100644 --- a/test/sql/collation.test.lua +++ b/test/sql/collation.test.lua @@ -1,4 +1,7 @@ remote = require('net.box') +test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- gh-3010: COLLATE after LIMIT should throw an error diff --git a/test/sql/delete-multiple-idx.result b/test/sql/delete-multiple-idx.result index 000dad2..a163cf1 100644 --- a/test/sql/delete-multiple-idx.result +++ b/test/sql/delete-multiple-idx.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- box.cfg() -- Create space. box.sql.execute("CREATE TABLE t3(id primary key,x,y);"); diff --git a/test/sql/delete-multiple-idx.test.lua b/test/sql/delete-multiple-idx.test.lua index 26c19a0..e187355 100644 --- a/test/sql/delete-multiple-idx.test.lua +++ b/test/sql/delete-multiple-idx.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- box.cfg() diff --git a/test/sql/delete.result b/test/sql/delete.result index b7dc588..c454c60 100644 --- a/test/sql/delete.result +++ b/test/sql/delete.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- box.cfg() -- create space box.sql.execute("CREATE TABLE t1(a, b, PRIMARY KEY(a, b));"); diff --git a/test/sql/delete.test.lua b/test/sql/delete.test.lua index 69d8ff9..2f6b625 100644 --- a/test/sql/delete.test.lua +++ b/test/sql/delete.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- box.cfg() diff --git a/test/sql/drop-index.result b/test/sql/drop-index.result index 9fa8b8b..2aaddac 100644 --- a/test/sql/drop-index.result +++ b/test/sql/drop-index.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- box.cfg() -- create space box.sql.execute("CREATE TABLE zzoobar (c1, c2 PRIMARY KEY, c3, c4)") diff --git a/test/sql/drop-index.test.lua b/test/sql/drop-index.test.lua index d39d33b..8bb51e1 100644 --- a/test/sql/drop-index.test.lua +++ b/test/sql/drop-index.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- box.cfg() diff --git a/test/sql/drop-table.result b/test/sql/drop-table.result index e891764..08f2496 100644 --- a/test/sql/drop-table.result +++ b/test/sql/drop-table.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- box.cfg() -- create space box.sql.execute("CREATE TABLE zzzoobar (c1, c2 PRIMARY KEY, c3, c4)") diff --git a/test/sql/drop-table.test.lua b/test/sql/drop-table.test.lua index a721563..9663074 100644 --- a/test/sql/drop-table.test.lua +++ b/test/sql/drop-table.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- box.cfg() diff --git a/test/sql/engine.cfg b/test/sql/engine.cfg new file mode 100644 index 0000000..0007d8d --- /dev/null +++ b/test/sql/engine.cfg @@ -0,0 +1,6 @@ +{ + "*": { + "memtx": {"engine": "memtx"}, + "vinyl": {"engine": "vinyl"} + } +} diff --git a/test/sql/engine.result b/test/sql/engine.result new file mode 100644 index 0000000..1b31e2f --- /dev/null +++ b/test/sql/engine.result @@ -0,0 +1,42 @@ +env = require('test_run') +--- +... +test_run = env.new() +--- +... +box.sql.execute("pragma sql_default_engine='vinyl'") +--- +... +box.sql.execute("CREATE TABLE t1_vinyl(a primary key,b,c);") +--- +... +box.sql.execute("CREATE TABLE t2_vinyl(a primary key,b,c);") +--- +... +box.sql.execute("pragma sql_default_engine='memtx'") +--- +... +box.sql.execute("CREATE TABLE t3_memtx(a primary key,b,c);") +--- +... +assert(box.space.T1_VINYL.engine == 'vinyl') +--- +- true +... +assert(box.space.T2_VINYL.engine == 'vinyl') +--- +- true +... +assert(box.space.T3_MEMTX.engine == 'memtx') +--- +- true +... +box.sql.execute("DROP TABLE t1_vinyl;") +--- +... +box.sql.execute("DROP TABLE t2_vinyl;") +--- +... +box.sql.execute("DROP TABLE t3_memtx;") +--- +... diff --git a/test/sql/engine.test.lua b/test/sql/engine.test.lua new file mode 100644 index 0000000..2a07c71 --- /dev/null +++ b/test/sql/engine.test.lua @@ -0,0 +1,17 @@ +env = require('test_run') +test_run = env.new() + +box.sql.execute("pragma sql_default_engine='vinyl'") +box.sql.execute("CREATE TABLE t1_vinyl(a primary key,b,c);") +box.sql.execute("CREATE TABLE t2_vinyl(a primary key,b,c);") + +box.sql.execute("pragma sql_default_engine='memtx'") +box.sql.execute("CREATE TABLE t3_memtx(a primary key,b,c);") + +assert(box.space.T1_VINYL.engine == 'vinyl') +assert(box.space.T2_VINYL.engine == 'vinyl') +assert(box.space.T3_MEMTX.engine == 'memtx') + +box.sql.execute("DROP TABLE t1_vinyl;") +box.sql.execute("DROP TABLE t2_vinyl;") +box.sql.execute("DROP TABLE t3_memtx;") diff --git a/test/sql/errinj.result b/test/sql/errinj.result index b004270..8de7497 100644 --- a/test/sql/errinj.result +++ b/test/sql/errinj.result @@ -1,6 +1,15 @@ remote = require('net.box') --- ... +test_run = require('test_run').new() +--- +... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... errinj = box.error.injection --- ... diff --git a/test/sql/errinj.test.lua b/test/sql/errinj.test.lua index f559099..ad33c2b 100644 --- a/test/sql/errinj.test.lua +++ b/test/sql/errinj.test.lua @@ -1,4 +1,7 @@ remote = require('net.box') +test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') errinj = box.error.injection fiber = require('fiber') diff --git a/test/sql/gh-2929-primary-key.result b/test/sql/gh-2929-primary-key.result index 53896fc..c238ed7 100644 --- a/test/sql/gh-2929-primary-key.result +++ b/test/sql/gh-2929-primary-key.result @@ -1,3 +1,12 @@ +test_run = require('test_run').new() +--- +... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- All tables in SQL are now WITHOUT ROW ID, so if user -- tries to create table without a primary key, an appropriate error message -- should be raised. This tests checks it. diff --git a/test/sql/gh-2929-primary-key.test.lua b/test/sql/gh-2929-primary-key.test.lua index 27338a6..0a9395c 100644 --- a/test/sql/gh-2929-primary-key.test.lua +++ b/test/sql/gh-2929-primary-key.test.lua @@ -1,3 +1,7 @@ +test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') + -- All tables in SQL are now WITHOUT ROW ID, so if user -- tries to create table without a primary key, an appropriate error message -- should be raised. This tests checks it. diff --git a/test/sql/gh-2981-check-autoinc.result b/test/sql/gh-2981-check-autoinc.result index aaa0785..b0f55e6 100644 --- a/test/sql/gh-2981-check-autoinc.result +++ b/test/sql/gh-2981-check-autoinc.result @@ -1,3 +1,12 @@ +test_run = require('test_run').new() +--- +... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... box.cfg{} --- ... diff --git a/test/sql/gh-2981-check-autoinc.test.lua b/test/sql/gh-2981-check-autoinc.test.lua index f136505..98a5fb4 100644 --- a/test/sql/gh-2981-check-autoinc.test.lua +++ b/test/sql/gh-2981-check-autoinc.test.lua @@ -1,3 +1,7 @@ +test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') + box.cfg{} box.sql.execute("CREATE TABLE t1 (s1 INTEGER PRIMARY KEY AUTOINCREMENT, s2 INTEGER, CHECK (s1 <> 19));"); diff --git a/test/sql/gh-3199-no-mem-leaks.result b/test/sql/gh-3199-no-mem-leaks.result index 682ca62..9d715e8 100644 --- a/test/sql/gh-3199-no-mem-leaks.result +++ b/test/sql/gh-3199-no-mem-leaks.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... fiber = require('fiber') --- ... diff --git a/test/sql/gh-3199-no-mem-leaks.test.lua b/test/sql/gh-3199-no-mem-leaks.test.lua index d61d474..138166b 100644 --- a/test/sql/gh-3199-no-mem-leaks.test.lua +++ b/test/sql/gh-3199-no-mem-leaks.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') fiber = require('fiber') -- This test checks that no leaks of region memory happens during diff --git a/test/sql/gh2141-delete-trigger-drop-table.result b/test/sql/gh2141-delete-trigger-drop-table.result index ec5a380..d8ba2af 100644 --- a/test/sql/gh2141-delete-trigger-drop-table.result +++ b/test/sql/gh2141-delete-trigger-drop-table.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- create space box.sql.execute("CREATE TABLE t(id PRIMARY KEY)") --- diff --git a/test/sql/gh2141-delete-trigger-drop-table.test.lua b/test/sql/gh2141-delete-trigger-drop-table.test.lua index 87110a4..19d3188 100644 --- a/test/sql/gh2141-delete-trigger-drop-table.test.lua +++ b/test/sql/gh2141-delete-trigger-drop-table.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- create space box.sql.execute("CREATE TABLE t(id PRIMARY KEY)") diff --git a/test/sql/gh2251-multiple-update.result b/test/sql/gh2251-multiple-update.result index 5372cfc..5e137ee 100644 --- a/test/sql/gh2251-multiple-update.result +++ b/test/sql/gh2251-multiple-update.result @@ -2,6 +2,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- box.cfg() box.sql.execute("CREATE TABLE t1(a integer primary key, b UNIQUE, e);") --- diff --git a/test/sql/gh2251-multiple-update.test.lua b/test/sql/gh2251-multiple-update.test.lua index 15795f1..0166a17 100644 --- a/test/sql/gh2251-multiple-update.test.lua +++ b/test/sql/gh2251-multiple-update.test.lua @@ -1,5 +1,7 @@ -- Regression test for #2251 test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- box.cfg() diff --git a/test/sql/gh2483-remote-persistency-check.result b/test/sql/gh2483-remote-persistency-check.result index 5cb6db3..50e65f2 100644 --- a/test/sql/gh2483-remote-persistency-check.result +++ b/test/sql/gh2483-remote-persistency-check.result @@ -5,6 +5,12 @@ env = require('test_run') test_run = env.new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... box.schema.user.grant('guest', 'read,write,execute', 'universe') --- ... diff --git a/test/sql/gh2483-remote-persistency-check.test.lua b/test/sql/gh2483-remote-persistency-check.test.lua index da13e4e..b952f6b 100644 --- a/test/sql/gh2483-remote-persistency-check.test.lua +++ b/test/sql/gh2483-remote-persistency-check.test.lua @@ -1,6 +1,8 @@ -- Regression test for gh-2483 env = require('test_run') test_run = env.new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') box.schema.user.grant('guest', 'read,write,execute', 'universe') diff --git a/test/sql/gh2808-inline-unique-persistency-check.result b/test/sql/gh2808-inline-unique-persistency-check.result index e171f7a..fdd000f 100644 --- a/test/sql/gh2808-inline-unique-persistency-check.result +++ b/test/sql/gh2808-inline-unique-persistency-check.result @@ -5,6 +5,12 @@ env = require('test_run') test_run = env.new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- Create a table and insert a datum box.sql.execute([[CREATE TABLE t1(a PRIMARY KEY, b, UNIQUE(b));]]) --- diff --git a/test/sql/gh2808-inline-unique-persistency-check.test.lua b/test/sql/gh2808-inline-unique-persistency-check.test.lua index 19ae877..eb4e051 100644 --- a/test/sql/gh2808-inline-unique-persistency-check.test.lua +++ b/test/sql/gh2808-inline-unique-persistency-check.test.lua @@ -1,6 +1,8 @@ -- Regression test for gh-2483 env = require('test_run') test_run = env.new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- Create a table and insert a datum box.sql.execute([[CREATE TABLE t1(a PRIMARY KEY, b, UNIQUE(b));]]) diff --git a/test/sql/icu-upper-lower.result b/test/sql/icu-upper-lower.result index 9989ed2..6ca44b9 100644 --- a/test/sql/icu-upper-lower.result +++ b/test/sql/icu-upper-lower.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... test_run:cmd("setopt delimiter ';'") --- - true diff --git a/test/sql/icu-upper-lower.test.lua b/test/sql/icu-upper-lower.test.lua index bb1a518..6629a74 100644 --- a/test/sql/icu-upper-lower.test.lua +++ b/test/sql/icu-upper-lower.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') test_run:cmd("setopt delimiter ';'") diff --git a/test/sql/insert-unique.result b/test/sql/insert-unique.result index 7e564ec..048d628 100644 --- a/test/sql/insert-unique.result +++ b/test/sql/insert-unique.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- box.cfg() -- create space box.sql.execute("CREATE TABLE zoobar (c1, c2 PRIMARY KEY, c3, c4)") diff --git a/test/sql/insert-unique.test.lua b/test/sql/insert-unique.test.lua index dfdaa30..a004c57 100644 --- a/test/sql/insert-unique.test.lua +++ b/test/sql/insert-unique.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- box.cfg() diff --git a/test/sql/iproto.result b/test/sql/iproto.result index 3b7574a..92b7c2e 100644 --- a/test/sql/iproto.result +++ b/test/sql/iproto.result @@ -1,6 +1,15 @@ remote = require('net.box') --- ... +test_run = require('test_run').new() +--- +... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... box.sql.execute('create table test (id primary key, a float, b text)') --- ... @@ -500,7 +509,8 @@ cn:execute('select * from test where id = :1', {1}) - [1, 2, '3'] ... -- gh-2602 obuf_alloc breaks the tuple in different slabs -_ = space:replace{1, 1, string.rep('a', 4 * 1024 * 1024)} +-- 4 * 1024 * 1024 is higher than vinyl max tuple size +if engine ~= 'vinyl' then _ = space:replace{1, 1, string.rep('a', 4 * 1024 * 1024)} end --- ... res = cn:execute('select * from test') diff --git a/test/sql/iproto.test.lua b/test/sql/iproto.test.lua index 159a839..0da6d48 100644 --- a/test/sql/iproto.test.lua +++ b/test/sql/iproto.test.lua @@ -1,4 +1,7 @@ remote = require('net.box') +test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') box.sql.execute('create table test (id primary key, a float, b text)') space = box.space.TEST @@ -175,7 +178,8 @@ cn:execute('select $2, $1, $3', parameters) cn:execute('select * from test where id = :1', {1}) -- gh-2602 obuf_alloc breaks the tuple in different slabs -_ = space:replace{1, 1, string.rep('a', 4 * 1024 * 1024)} +-- 4 * 1024 * 1024 is higher than vinyl max tuple size +if engine ~= 'vinyl' then _ = space:replace{1, 1, string.rep('a', 4 * 1024 * 1024)} end res = cn:execute('select * from test') res.metadata box.sql.execute('drop table test') diff --git a/test/sql/max-on-index.result b/test/sql/max-on-index.result index afd4362..b107633 100644 --- a/test/sql/max-on-index.result +++ b/test/sql/max-on-index.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- box.cfg() -- create space -- scalar affinity diff --git a/test/sql/max-on-index.test.lua b/test/sql/max-on-index.test.lua index 5ce6cd7..b879e38 100644 --- a/test/sql/max-on-index.test.lua +++ b/test/sql/max-on-index.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- box.cfg() diff --git a/test/sql/message-func-indexes.result b/test/sql/message-func-indexes.result index 4bf1cab..37ed4ec 100644 --- a/test/sql/message-func-indexes.result +++ b/test/sql/message-func-indexes.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- Creating tables. box.sql.execute("CREATE TABLE t1(id INTEGER PRIMARY KEY, a INTEGER)") --- diff --git a/test/sql/message-func-indexes.test.lua b/test/sql/message-func-indexes.test.lua index 4597c9b..e0eae76 100644 --- a/test/sql/message-func-indexes.test.lua +++ b/test/sql/message-func-indexes.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- Creating tables. box.sql.execute("CREATE TABLE t1(id INTEGER PRIMARY KEY, a INTEGER)") diff --git a/test/sql/misc.result b/test/sql/misc.result index b1ddb89..93b383a 100644 --- a/test/sql/misc.result +++ b/test/sql/misc.result @@ -1,3 +1,12 @@ +test_run = require('test_run').new() +--- +... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- Forbid multistatement queries. box.sql.execute('select 1;') --- diff --git a/test/sql/misc.test.lua b/test/sql/misc.test.lua index 2c05fcd..1ed0198 100644 --- a/test/sql/misc.test.lua +++ b/test/sql/misc.test.lua @@ -1,3 +1,7 @@ +test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') + -- Forbid multistatement queries. box.sql.execute('select 1;') box.sql.execute('select 1; select 2;') diff --git a/test/sql/on-conflict.result b/test/sql/on-conflict.result index 9e15ec4..c0d0de0 100644 --- a/test/sql/on-conflict.result +++ b/test/sql/on-conflict.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- Create space box.sql.execute("CREATE TABLE t (id INTEGER PRIMARY KEY, v INTEGER UNIQUE ON CONFLICT ABORT)") --- diff --git a/test/sql/on-conflict.test.lua b/test/sql/on-conflict.test.lua index a6aa3d6..b6d92f7 100644 --- a/test/sql/on-conflict.test.lua +++ b/test/sql/on-conflict.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- Create space box.sql.execute("CREATE TABLE t (id INTEGER PRIMARY KEY, v INTEGER UNIQUE ON CONFLICT ABORT)") diff --git a/test/sql/persistency.result b/test/sql/persistency.result index d85d7cc..b3099ce 100644 --- a/test/sql/persistency.result +++ b/test/sql/persistency.result @@ -4,6 +4,12 @@ env = require('test_run') test_run = env.new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- create space box.sql.execute("CREATE TABLE foobar (foo PRIMARY KEY, bar)") --- diff --git a/test/sql/persistency.test.lua b/test/sql/persistency.test.lua index e994a62..417d8c0 100644 --- a/test/sql/persistency.test.lua +++ b/test/sql/persistency.test.lua @@ -1,5 +1,7 @@ env = require('test_run') test_run = env.new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- create space box.sql.execute("CREATE TABLE foobar (foo PRIMARY KEY, bar)") diff --git a/test/sql/savepoints.result b/test/sql/savepoints.result index e32c9b3..8553dd8 100644 --- a/test/sql/savepoints.result +++ b/test/sql/savepoints.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- These tests check that SQL savepoints properly work outside -- transactions as well as inside transactions started in Lua. -- gh-3313 diff --git a/test/sql/savepoints.test.lua b/test/sql/savepoints.test.lua index 2d87b9e..a4ed061 100644 --- a/test/sql/savepoints.test.lua +++ b/test/sql/savepoints.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- These tests check that SQL savepoints properly work outside -- transactions as well as inside transactions started in Lua. diff --git a/test/sql/select-null.result b/test/sql/select-null.result index a229eb9..53bef1b 100644 --- a/test/sql/select-null.result +++ b/test/sql/select-null.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- box.cfg() -- create space box.sql.execute("CREATE TABLE t3(id INT, a, b, PRIMARY KEY(id))") diff --git a/test/sql/select-null.test.lua b/test/sql/select-null.test.lua index a2c1266..3e9cb81 100644 --- a/test/sql/select-null.test.lua +++ b/test/sql/select-null.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- box.cfg() diff --git a/test/sql/sql-statN-index-drop.result b/test/sql/sql-statN-index-drop.result index c7e476f..a751eca 100644 --- a/test/sql/sql-statN-index-drop.result +++ b/test/sql/sql-statN-index-drop.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- Initializing some things. box.sql.execute("CREATE TABLE t1(id PRIMARY KEY, a);") --- diff --git a/test/sql/sql-statN-index-drop.test.lua b/test/sql/sql-statN-index-drop.test.lua index bf4a752..fe7e15b 100644 --- a/test/sql/sql-statN-index-drop.test.lua +++ b/test/sql/sql-statN-index-drop.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- Initializing some things. box.sql.execute("CREATE TABLE t1(id PRIMARY KEY, a);") diff --git a/test/sql/suite.ini b/test/sql/suite.ini index 5f28f23..4504731 100644 --- a/test/sql/suite.ini +++ b/test/sql/suite.ini @@ -3,6 +3,7 @@ core = tarantool description = sql tests script = app.lua use_unix_sockets = True +config = engine.cfg is_parallel = True lua_libs = lua/sql_tokenizer.lua release_disabled = errinj.test.lua view_delayed_wal.test.lua diff --git a/test/sql/tokenizer.result b/test/sql/tokenizer.result index 3868f6b..9e50b87 100644 --- a/test/sql/tokenizer.result +++ b/test/sql/tokenizer.result @@ -4,6 +4,12 @@ env = require('test_run') test_run = env.new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... sql_tokenizer = require('sql_tokenizer') --- ... diff --git a/test/sql/tokenizer.test.lua b/test/sql/tokenizer.test.lua index e368219..7a69d12 100644 --- a/test/sql/tokenizer.test.lua +++ b/test/sql/tokenizer.test.lua @@ -1,5 +1,7 @@ env = require('test_run') test_run = env.new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') sql_tokenizer = require('sql_tokenizer') diff --git a/test/sql/transition.result b/test/sql/transition.result index 7c4a2c8..70fb2db 100644 --- a/test/sql/transition.result +++ b/test/sql/transition.result @@ -1,3 +1,12 @@ +test_run = require('test_run').new() +--- +... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- create space box.sql.execute("CREATE TABLE foobar (foo PRIMARY KEY, bar)") --- diff --git a/test/sql/transition.test.lua b/test/sql/transition.test.lua index 50ee7f5..cae45aa 100644 --- a/test/sql/transition.test.lua +++ b/test/sql/transition.test.lua @@ -1,3 +1,7 @@ +test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') + -- create space box.sql.execute("CREATE TABLE foobar (foo PRIMARY KEY, bar)") diff --git a/test/sql/transitive-transactions.result b/test/sql/transitive-transactions.result index 272a25a..1cced76 100644 --- a/test/sql/transitive-transactions.result +++ b/test/sql/transitive-transactions.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute("pragma sql_default_engine=\'"..engine.."\'") +--- +... test_run:cmd("setopt delimiter ';'") --- - true @@ -104,7 +110,11 @@ box.space.PARENT:select(); --- - - [1, 1] ... +-- vinyl doesn't rollback failed transactions box.sql.execute('PRAGMA defer_foreign_keys = 1;') +if engine == 'vinyl' then + box.rollback() +end fk_defer(); --- ... diff --git a/test/sql/transitive-transactions.test.lua b/test/sql/transitive-transactions.test.lua index 303ecad..743d898 100644 --- a/test/sql/transitive-transactions.test.lua +++ b/test/sql/transitive-transactions.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute("pragma sql_default_engine=\'"..engine.."\'") test_run:cmd("setopt delimiter ';'") -- These tests are aimed at checking transitive transactions @@ -56,6 +58,10 @@ fk_defer(); box.space.CHILD:select(); box.space.PARENT:select(); box.sql.execute('PRAGMA defer_foreign_keys = 1;') +-- vinyl doesn't rollback failed transactions +if engine == 'vinyl' then + box.rollback() +end fk_defer(); box.space.CHILD:select(); box.space.PARENT:select(); diff --git a/test/sql/triggers.result b/test/sql/triggers.result index 090b546..8d307d1 100644 --- a/test/sql/triggers.result +++ b/test/sql/triggers.result @@ -4,6 +4,12 @@ env = require('test_run') test_run = env.new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- get invariant part of the tuple function immutable_part(data) local r = {} for i, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end --- diff --git a/test/sql/triggers.test.lua b/test/sql/triggers.test.lua index 8e3f0c5..41aaba9 100644 --- a/test/sql/triggers.test.lua +++ b/test/sql/triggers.test.lua @@ -1,5 +1,7 @@ env = require('test_run') test_run = env.new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- get invariant part of the tuple function immutable_part(data) local r = {} for i, l in pairs(data) do table.insert(r, {l.name, l.opts}) end return r end diff --git a/test/sql/update-with-nested-select.result b/test/sql/update-with-nested-select.result index 419cebb..51825a2 100644 --- a/test/sql/update-with-nested-select.result +++ b/test/sql/update-with-nested-select.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- box.cfg() -- create space box.sql.execute("CREATE TABLE t1(a integer primary key, b UNIQUE, e);"); diff --git a/test/sql/update-with-nested-select.test.lua b/test/sql/update-with-nested-select.test.lua index 7b90968..f9f9b7a 100644 --- a/test/sql/update-with-nested-select.test.lua +++ b/test/sql/update-with-nested-select.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- box.cfg() diff --git a/test/sql/upgrade.result b/test/sql/upgrade.result index 6f7b115..5e7d851 100644 --- a/test/sql/upgrade.result +++ b/test/sql/upgrade.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... work_dir = 'sql/upgrade/1.10/' --- ... diff --git a/test/sql/upgrade.test.lua b/test/sql/upgrade.test.lua index 1619795..cd4dd3c 100644 --- a/test/sql/upgrade.test.lua +++ b/test/sql/upgrade.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') work_dir = 'sql/upgrade/1.10/' test_run:cmd('create server upgrade with script="sql/upgrade/upgrade.lua", workdir="' .. work_dir .. '"') diff --git a/test/sql/view.result b/test/sql/view.result index b033f19..62fbcee 100644 --- a/test/sql/view.result +++ b/test/sql/view.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... -- Verify that constraints on 'view' option are working. -- box.cfg() -- Create space and view. diff --git a/test/sql/view.test.lua b/test/sql/view.test.lua index 27f449f..1d73133 100644 --- a/test/sql/view.test.lua +++ b/test/sql/view.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- Verify that constraints on 'view' option are working. diff --git a/test/sql/view_delayed_wal.result b/test/sql/view_delayed_wal.result index c65a7e5..eef7fb1 100644 --- a/test/sql/view_delayed_wal.result +++ b/test/sql/view_delayed_wal.result @@ -1,6 +1,12 @@ test_run = require('test_run').new() --- ... +engine = test_run:get_cfg('engine') +--- +... +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') +--- +... fiber = require('fiber') --- ... diff --git a/test/sql/view_delayed_wal.test.lua b/test/sql/view_delayed_wal.test.lua index 8c30fc6..cf0bd38 100644 --- a/test/sql/view_delayed_wal.test.lua +++ b/test/sql/view_delayed_wal.test.lua @@ -1,4 +1,6 @@ test_run = require('test_run').new() +engine = test_run:get_cfg('engine') +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') fiber = require('fiber') -- View reference counters are incremented before firing -- 2.7.4 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] Re: [PATCH v1 2/2] sql: enable multi-engine tests for SQL 2018-06-20 17:06 ` [tarantool-patches] [PATCH v1 2/2] sql: enable multi-engine tests for SQL Kirill Shcherbatov @ 2018-06-22 20:04 ` Vladislav Shpilevoy 2018-06-26 12:22 ` Kirill Shcherbatov 0 siblings, 1 reply; 16+ messages in thread From: Vladislav Shpilevoy @ 2018-06-22 20:04 UTC (permalink / raw) To: Kirill Shcherbatov, tarantool-patches Thanks for the patch! Wow, looks like Vinyl really works on SQL. Did you test sql-tap/ suite? Why is not it in the patch? It could be updated automatically using a short script that adds the engine setting at the beginning of a file. See 2 comments below. On 20/06/2018 20:06, Kirill Shcherbatov wrote: > Configured sql tests to set 'pragma sql_engine_default' on start. > This allows to test both vinyl and memtx engines for SQL. > > Resolves #2199. > --- > test/sql/check-clear-ephemeral.result | 6 ++++ > test/sql/check-clear-ephemeral.test.lua | 3 +- > test/sql/checks.result | 6 ++++ > test/sql/checks.test.lua | 2 ++ > test/sql/clear.result | 6 ++++ > test/sql/clear.test.lua | 2 ++ > test/sql/collation.result | 9 +++++ > test/sql/collation.test.lua | 3 ++ > test/sql/delete-multiple-idx.result | 6 ++++ > test/sql/delete-multiple-idx.test.lua | 2 ++ > test/sql/delete.result | 6 ++++ > test/sql/delete.test.lua | 2 ++ > test/sql/drop-index.result | 6 ++++ > test/sql/drop-index.test.lua | 2 ++ > test/sql/drop-table.result | 6 ++++ > test/sql/drop-table.test.lua | 2 ++ > test/sql/engine.cfg | 6 ++++ > test/sql/engine.result | 42 ++++++++++++++++++++++ > test/sql/engine.test.lua | 17 +++++++++ > test/sql/errinj.result | 9 +++++ > test/sql/errinj.test.lua | 3 ++ > test/sql/gh-2929-primary-key.result | 9 +++++ > test/sql/gh-2929-primary-key.test.lua | 4 +++ > test/sql/gh-2981-check-autoinc.result | 9 +++++ > test/sql/gh-2981-check-autoinc.test.lua | 4 +++ > test/sql/gh-3199-no-mem-leaks.result | 6 ++++ > test/sql/gh-3199-no-mem-leaks.test.lua | 2 ++ > test/sql/gh2141-delete-trigger-drop-table.result | 6 ++++ > test/sql/gh2141-delete-trigger-drop-table.test.lua | 2 ++ > test/sql/gh2251-multiple-update.result | 6 ++++ > test/sql/gh2251-multiple-update.test.lua | 2 ++ > test/sql/gh2483-remote-persistency-check.result | 6 ++++ > test/sql/gh2483-remote-persistency-check.test.lua | 2 ++ > .../gh2808-inline-unique-persistency-check.result | 6 ++++ > ...gh2808-inline-unique-persistency-check.test.lua | 2 ++ > test/sql/icu-upper-lower.result | 6 ++++ > test/sql/icu-upper-lower.test.lua | 2 ++ > test/sql/insert-unique.result | 6 ++++ > test/sql/insert-unique.test.lua | 2 ++ > test/sql/iproto.result | 12 ++++++- > test/sql/iproto.test.lua | 6 +++- > test/sql/max-on-index.result | 6 ++++ > test/sql/max-on-index.test.lua | 2 ++ > test/sql/message-func-indexes.result | 6 ++++ > test/sql/message-func-indexes.test.lua | 2 ++ > test/sql/misc.result | 9 +++++ > test/sql/misc.test.lua | 4 +++ > test/sql/on-conflict.result | 6 ++++ > test/sql/on-conflict.test.lua | 2 ++ > test/sql/persistency.result | 6 ++++ > test/sql/persistency.test.lua | 2 ++ > test/sql/savepoints.result | 6 ++++ > test/sql/savepoints.test.lua | 2 ++ > test/sql/select-null.result | 6 ++++ > test/sql/select-null.test.lua | 2 ++ > test/sql/sql-statN-index-drop.result | 6 ++++ > test/sql/sql-statN-index-drop.test.lua | 2 ++ > test/sql/suite.ini | 1 + > test/sql/tokenizer.result | 6 ++++ > test/sql/tokenizer.test.lua | 2 ++ > test/sql/transition.result | 9 +++++ > test/sql/transition.test.lua | 4 +++ > test/sql/transitive-transactions.result | 10 ++++++ > test/sql/transitive-transactions.test.lua | 6 ++++ > test/sql/triggers.result | 6 ++++ > test/sql/triggers.test.lua | 2 ++ > test/sql/update-with-nested-select.result | 6 ++++ > test/sql/update-with-nested-select.test.lua | 2 ++ > test/sql/upgrade.result | 6 ++++ > test/sql/upgrade.test.lua | 2 ++ > test/sql/view.result | 6 ++++ > test/sql/view.test.lua | 2 ++ > test/sql/view_delayed_wal.result | 6 ++++ > test/sql/view_delayed_wal.test.lua | 2 ++ > 74 files changed, 390 insertions(+), 3 deletions(-) > create mode 100644 test/sql/engine.cfg > create mode 100644 test/sql/engine.result > create mode 100644 test/sql/engine.test.lua > > diff --git a/test/sql/iproto.result b/test/sql/iproto.result > index 3b7574a..92b7c2e 100644 > --- a/test/sql/iproto.result > +++ b/test/sql/iproto.result > @@ -500,7 +509,8 @@ cn:execute('select * from test where id = :1', {1}) > - [1, 2, '3'] > ... > -- gh-2602 obuf_alloc breaks the tuple in different slabs > -_ = space:replace{1, 1, string.rep('a', 4 * 1024 * 1024)} > +-- 4 * 1024 * 1024 is higher than vinyl max tuple size > +if engine ~= 'vinyl' then _ = space:replace{1, 1, string.rep('a', 4 * 1024 * 1024)} end 1. Just increase vinyl_max_tuple_size to the same value. This test should work both for vinyl and memtx. > --- > ... > res = cn:execute('select * from test') > diff --git a/test/sql/transitive-transactions.result b/test/sql/transitive-transactions.result > index 272a25a..1cced76 100644 > --- a/test/sql/transitive-transactions.result > +++ b/test/sql/transitive-transactions.result > @@ -104,7 +110,11 @@ box.space.PARENT:select(); > --- > - - [1, 1] > ... > +-- vinyl doesn't rollback failed transactions > box.sql.execute('PRAGMA defer_foreign_keys = 1;') 2. Vinyl rollbacks failed transactions, but it does not rollback the whole transaction on a non-caught exception. Lets better do rollback always. It is no-op in memtx when no active transactions. > +if engine == 'vinyl' then > + box.rollback() > +end > fk_defer(); > --- > ... ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] Re: [PATCH v1 2/2] sql: enable multi-engine tests for SQL 2018-06-22 20:04 ` [tarantool-patches] " Vladislav Shpilevoy @ 2018-06-26 12:22 ` Kirill Shcherbatov 2018-06-26 13:34 ` Vladislav Shpilevoy 0 siblings, 1 reply; 16+ messages in thread From: Kirill Shcherbatov @ 2018-06-26 12:22 UTC (permalink / raw) To: tarantool-patches; +Cc: Vladislav Shpilevoy > Did you test sql-tap/ suite? Why is not it in the > patch? It could be updated automatically using a > short script that adds the engine setting at the > beginning of a file. Ok, I've change constructor to start SQL-TAP test with all engines. This patch should be merged after than "Vinyl read iterator skips tuples #3477" > 1. Just increase vinyl_max_tuple_size to the same value. This > test should work both for vinyl and memtx. Ok. +-- 4 * 1024 * 1024 is higher than vinyl max tuple size +old_tuple_size = box.cfg.vinyl_max_tuple_size +box.cfg{vinyl_max_tuple_size = 5 * 1024 * 1024} +_ = space:replace{1, 1, string.rep('a', 4 * 1024 * 1024) } +box.cfg{vinyl_max_tuple_size = old_tuple_size} > 2. Vinyl rollbacks failed transactions, but it does not > rollback the whole transaction on a non-caught exception. Ok. +box.rollback() ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] Re: [PATCH v1 2/2] sql: enable multi-engine tests for SQL 2018-06-26 12:22 ` Kirill Shcherbatov @ 2018-06-26 13:34 ` Vladislav Shpilevoy 2018-06-26 17:09 ` Kirill Shcherbatov 0 siblings, 1 reply; 16+ messages in thread From: Vladislav Shpilevoy @ 2018-06-26 13:34 UTC (permalink / raw) To: Kirill Shcherbatov, tarantool-patches Thanks for the fixes! See 2 comments below. On 26/06/2018 15:22, Kirill Shcherbatov wrote: >> Did you test sql-tap/ suite? Why is not it in the >> patch? It could be updated automatically using a >> short script that adds the engine setting at the >> beginning of a file. > Ok, I've change constructor to start SQL-TAP test with all engines. > This patch should be merged after than "Vinyl read iterator skips tuples #3477" > >> 1. Just increase vinyl_max_tuple_size to the same value. This >> test should work both for vinyl and memtx. > Ok. > +-- 4 * 1024 * 1024 is higher than vinyl max tuple size > +old_tuple_size = box.cfg.vinyl_max_tuple_size > +box.cfg{vinyl_max_tuple_size = 5 * 1024 * 1024} 1. Not in the test. See where memtx_max_tuple_size is changed. > +_ = space:replace{1, 1, string.rep('a', 4 * 1024 * 1024) } 2. This line it unnecessary diff. > +box.cfg{vinyl_max_tuple_size = old_tuple_size} > >> 2. Vinyl rollbacks failed transactions, but it does not >> rollback the whole transaction on a non-caught exception. > Ok. > +box.rollback() > ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] Re: [PATCH v1 2/2] sql: enable multi-engine tests for SQL 2018-06-26 13:34 ` Vladislav Shpilevoy @ 2018-06-26 17:09 ` Kirill Shcherbatov 0 siblings, 0 replies; 16+ messages in thread From: Kirill Shcherbatov @ 2018-06-26 17:09 UTC (permalink / raw) To: tarantool-patches; +Cc: Vladislav Shpilevoy > 1. Not in the test. See where memtx_max_tuple_size is changed. --- a/test/sql/app.lua +++ b/test/sql/app.lua @@ -3,7 +3,8 @@ box.cfg{ listen = os.getenv("LISTEN"), pid_file = "tarantool.pid", - memtx_max_tuple_size = 5 * 1024 * 1024 + memtx_max_tuple_size = 5 * 1024 * 1024, + vinyl_max_tuple_size = 5 * 1024 * 1024, } > >> +_ = space:replace{1, 1, string.rep('a', 4 * 1024 * 1024) } > > 2. This line it unnecessary diff. Ok, fixed. ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] [PATCH v1 2/3] sql: fix SQL Count for vinyl engine 2018-06-20 17:06 [tarantool-patches] [PATCH v1 0/2] sql: default engine pragma Kirill Shcherbatov 2018-06-20 17:06 ` [tarantool-patches] [PATCH v1 1/2] sql: introduce pragma sql_default_engine Kirill Shcherbatov 2018-06-20 17:06 ` [tarantool-patches] [PATCH v1 2/2] sql: enable multi-engine tests for SQL Kirill Shcherbatov @ 2018-06-26 12:23 ` Kirill Shcherbatov 2018-06-28 15:35 ` [tarantool-patches] Re: [PATCH v1 0/2] sql: default engine pragma Vladislav Shpilevoy 3 siblings, 0 replies; 16+ messages in thread From: Kirill Shcherbatov @ 2018-06-26 12:23 UTC (permalink / raw) To: tarantool-patches; +Cc: v.shpilevoy, Kirill Shcherbatov As index_size does not match row count for vinyl engine, it was replaced with index_count that working for ITER_ALL in memtx same way. Part of #2199. --- src/box/sql.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/box/sql.c b/src/box/sql.c index 834a437..dc17438 100644 --- a/src/box/sql.c +++ b/src/box/sql.c @@ -355,7 +355,8 @@ int tarantoolSqlite3EphemeralCount(struct BtCursor *pCur, i64 *pnEntry) assert(pCur->curFlags & BTCF_TEphemCursor); struct index *primary_index = space_index(pCur->space, 0 /* PK */); - *pnEntry = index_size(primary_index); + *pnEntry = index_count(primary_index, pCur->iter_type, pCur->key, + pCur->nKey); return SQLITE_OK; } @@ -363,7 +364,8 @@ int tarantoolSqlite3Count(BtCursor *pCur, i64 *pnEntry) { assert(pCur->curFlags & BTCF_TaCursor); - *pnEntry = index_size(pCur->index); + *pnEntry = index_count(pCur->index, pCur->iter_type, pCur->key, + pCur->nKey); return SQLITE_OK; } -- 2.7.4 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] Re: [PATCH v1 0/2] sql: default engine pragma 2018-06-20 17:06 [tarantool-patches] [PATCH v1 0/2] sql: default engine pragma Kirill Shcherbatov ` (2 preceding siblings ...) 2018-06-26 12:23 ` [tarantool-patches] [PATCH v1 2/3] sql: fix SQL Count for vinyl engine Kirill Shcherbatov @ 2018-06-28 15:35 ` Vladislav Shpilevoy 2018-06-28 16:00 ` n.pettik 3 siblings, 1 reply; 16+ messages in thread From: Vladislav Shpilevoy @ 2018-06-28 15:35 UTC (permalink / raw) To: Kirill Shcherbatov, tarantool-patches, Nikita Pettik Thanks for the great patch! Now LGTM. Nikita, please, take a look. On 20/06/2018 20:06, Kirill Shcherbatov wrote: > Introduced a new SQL pragma that allows to set default storage engine. > Both 'memtx' and 'vinyl' are supported. Config enum value is stored in user_session > represented as uint8_t. Initial 0 value match default MEMTEX storage engine. > Adopted basic sql test to launch with multiple engines. > Worth to take into account that vinyl transactions don't rollback automatically > on failures. This required to modify some tests. > > Branch: http://github.com/tarantool/tarantool/tree/kshch/gh-2199-engine-sql-specifier > Issue: https://github.com/tarantool/tarantool/issues/2199 > > Kirill Shcherbatov (2): > sql: introduce pragma sql_default_engine > sql: enable multi-engine tests for SQL > > src/box/session.cc | 1 + > src/box/session.h | 2 + > src/box/sql/build.c | 43 +++++++++++++++++++++- > src/box/sql/pragma.c | 8 ++++ > src/box/sql/pragma.h | 6 +++ > src/box/sql/sqliteInt.h | 14 +++++++ > test/sql-tap/gh-2367-pragma.test.lua | 14 ++++++- > test/sql/check-clear-ephemeral.result | 6 +++ > test/sql/check-clear-ephemeral.test.lua | 3 +- > test/sql/checks.result | 6 +++ > test/sql/checks.test.lua | 2 + > test/sql/clear.result | 6 +++ > test/sql/clear.test.lua | 2 + > test/sql/collation.result | 9 +++++ > test/sql/collation.test.lua | 3 ++ > test/sql/delete-multiple-idx.result | 6 +++ > test/sql/delete-multiple-idx.test.lua | 2 + > test/sql/delete.result | 6 +++ > test/sql/delete.test.lua | 2 + > test/sql/drop-index.result | 6 +++ > test/sql/drop-index.test.lua | 2 + > test/sql/drop-table.result | 6 +++ > test/sql/drop-table.test.lua | 2 + > test/sql/engine.cfg | 6 +++ > test/sql/engine.result | 42 +++++++++++++++++++++ > test/sql/engine.test.lua | 17 +++++++++ > test/sql/errinj.result | 9 +++++ > test/sql/errinj.test.lua | 3 ++ > test/sql/gh-2929-primary-key.result | 9 +++++ > test/sql/gh-2929-primary-key.test.lua | 4 ++ > test/sql/gh-2981-check-autoinc.result | 9 +++++ > test/sql/gh-2981-check-autoinc.test.lua | 4 ++ > test/sql/gh-3199-no-mem-leaks.result | 6 +++ > test/sql/gh-3199-no-mem-leaks.test.lua | 2 + > test/sql/gh2141-delete-trigger-drop-table.result | 6 +++ > test/sql/gh2141-delete-trigger-drop-table.test.lua | 2 + > test/sql/gh2251-multiple-update.result | 6 +++ > test/sql/gh2251-multiple-update.test.lua | 2 + > test/sql/gh2483-remote-persistency-check.result | 6 +++ > test/sql/gh2483-remote-persistency-check.test.lua | 2 + > .../gh2808-inline-unique-persistency-check.result | 6 +++ > ...gh2808-inline-unique-persistency-check.test.lua | 2 + > test/sql/icu-upper-lower.result | 6 +++ > test/sql/icu-upper-lower.test.lua | 2 + > test/sql/insert-unique.result | 6 +++ > test/sql/insert-unique.test.lua | 2 + > test/sql/iproto.result | 12 +++++- > test/sql/iproto.test.lua | 6 ++- > test/sql/max-on-index.result | 6 +++ > test/sql/max-on-index.test.lua | 2 + > test/sql/message-func-indexes.result | 6 +++ > test/sql/message-func-indexes.test.lua | 2 + > test/sql/misc.result | 9 +++++ > test/sql/misc.test.lua | 4 ++ > test/sql/on-conflict.result | 6 +++ > test/sql/on-conflict.test.lua | 2 + > test/sql/persistency.result | 6 +++ > test/sql/persistency.test.lua | 2 + > test/sql/savepoints.result | 6 +++ > test/sql/savepoints.test.lua | 2 + > test/sql/select-null.result | 6 +++ > test/sql/select-null.test.lua | 2 + > test/sql/sql-statN-index-drop.result | 6 +++ > test/sql/sql-statN-index-drop.test.lua | 2 + > test/sql/suite.ini | 1 + > test/sql/tokenizer.result | 6 +++ > test/sql/tokenizer.test.lua | 2 + > test/sql/transition.result | 9 +++++ > test/sql/transition.test.lua | 4 ++ > test/sql/transitive-transactions.result | 10 +++++ > test/sql/transitive-transactions.test.lua | 6 +++ > test/sql/triggers.result | 6 +++ > test/sql/triggers.test.lua | 2 + > test/sql/update-with-nested-select.result | 6 +++ > test/sql/update-with-nested-select.test.lua | 2 + > test/sql/upgrade.result | 6 +++ > test/sql/upgrade.test.lua | 2 + > test/sql/view.result | 6 +++ > test/sql/view.test.lua | 2 + > test/sql/view_delayed_wal.result | 6 +++ > test/sql/view_delayed_wal.test.lua | 2 + > 81 files changed, 476 insertions(+), 5 deletions(-) > create mode 100644 test/sql/engine.cfg > create mode 100644 test/sql/engine.result > create mode 100644 test/sql/engine.test.lua > ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tarantool-patches] Re: [PATCH v1 0/2] sql: default engine pragma 2018-06-28 15:35 ` [tarantool-patches] Re: [PATCH v1 0/2] sql: default engine pragma Vladislav Shpilevoy @ 2018-06-28 16:00 ` n.pettik 0 siblings, 0 replies; 16+ messages in thread From: n.pettik @ 2018-06-28 16:00 UTC (permalink / raw) To: tarantool-patches; +Cc: Kirill Shcherbatov Kirill, could you resend the whole patchset to review fresh version? Thanks. > Thanks for the great patch! Now LGTM. Nikita, please, > take a look. ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2018-06-28 16:00 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-06-20 17:06 [tarantool-patches] [PATCH v1 0/2] sql: default engine pragma Kirill Shcherbatov 2018-06-20 17:06 ` [tarantool-patches] [PATCH v1 1/2] sql: introduce pragma sql_default_engine Kirill Shcherbatov 2018-06-22 20:04 ` [tarantool-patches] " Vladislav Shpilevoy 2018-06-26 12:22 ` Kirill Shcherbatov 2018-06-26 13:34 ` Vladislav Shpilevoy 2018-06-26 17:09 ` Kirill Shcherbatov 2018-06-27 12:32 ` Vladislav Shpilevoy 2018-06-27 15:59 ` Kirill Shcherbatov 2018-06-20 17:06 ` [tarantool-patches] [PATCH v1 2/2] sql: enable multi-engine tests for SQL Kirill Shcherbatov 2018-06-22 20:04 ` [tarantool-patches] " Vladislav Shpilevoy 2018-06-26 12:22 ` Kirill Shcherbatov 2018-06-26 13:34 ` Vladislav Shpilevoy 2018-06-26 17:09 ` Kirill Shcherbatov 2018-06-26 12:23 ` [tarantool-patches] [PATCH v1 2/3] sql: fix SQL Count for vinyl engine Kirill Shcherbatov 2018-06-28 15:35 ` [tarantool-patches] Re: [PATCH v1 0/2] sql: default engine pragma Vladislav Shpilevoy 2018-06-28 16:00 ` n.pettik
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox