From 56e5a3a178c731475daef494ff42ac9172551c99 Mon Sep 17 00:00:00 2001 From: Dmitry Simonenko <pmwkaa@gmail.com> Date: Thu, 13 Mar 2014 16:22:13 +0400 Subject: [PATCH] space-engine: add 'engine' attribute to space definition. --- extra/schema_fill.lua | 12 +++---- src/bootstrap.snap | Bin 1591 -> 1627 bytes src/box/alter.cc | 38 +++++++++++++--------- src/box/key_def.cc | 8 ++++- src/box/key_def.h | 5 ++- src/box/lua/schema.lua | 8 +++-- src/box/lua/space.cc | 5 +++ src/box/schema.cc | 4 ++- src/box/space.cc | 11 ++++++- src/box/space.h | 3 ++ src/errcode.h | 1 + test/big/lua.result | 2 +- test/box/alter.result | 28 ++++++++-------- test/box/alter.test.lua | 16 ++++----- test/box/alter_limits.result | 16 +++++++-- test/box/alter_limits.test.lua | 6 +++- test/box/misc.result | 1 + test/box/schema.result | 1 + test/box/temp_spaces.result | 18 +++++------ test/box/temp_spaces.test.lua | 4 +-- test/box/xlog.result | 16 --------- test/box/xlog.test.py | 57 ++++++++++++++++++++++++--------- 22 files changed, 162 insertions(+), 98 deletions(-) diff --git a/extra/schema_fill.lua b/extra/schema_fill.lua index 0fc6caf1de..975caba8ce 100644 --- a/extra/schema_fill.lua +++ b/extra/schema_fill.lua @@ -10,12 +10,12 @@ _priv = box.space[box.schema.PRIV_ID] -- define schema version _schema:insert{'version', 1, 6} -- define system spaces -_space:insert{_schema.n, ADMIN, '_schema', 0} -_space:insert{_space.n, ADMIN, '_space', 0} -_space:insert{_index.n, ADMIN, '_index', 0} -_space:insert{_func.n, ADMIN, '_func', 0} -_space:insert{_user.n, ADMIN, '_user', 0} -_space:insert{_priv.n, ADMIN, '_priv', 0} +_space:insert{_schema.n, ADMIN, '_schema', 'memtx', 0} +_space:insert{_space.n, ADMIN, '_space', 'memtx', 0} +_space:insert{_index.n, ADMIN, '_index', 'memtx', 0} +_space:insert{_func.n, ADMIN, '_func', 'memtx', 0} +_space:insert{_user.n, ADMIN, '_user', 'memtx', 0} +_space:insert{_priv.n, ADMIN, '_priv', 'memtx', 0} -- define indexes _index:insert{_schema.n, 0, 'primary', 'tree', 1, 1, 0, 'str'} diff --git a/src/bootstrap.snap b/src/bootstrap.snap index 71d7828c44f874099567fc642e08e603799c4622..70257782f59a443cdd8e51a3358586f571749bbd 100644 GIT binary patch literal 1627 zcmWIca}3}z&@(jR;(EK9dsoF{nT3oD5TLeMCoJv66-QAZ_uqf0Aj9?Y``JtkO#<f_ z7#IZ<CoeBcEh^5;&tqf*Y4@7R-p_=lT@FRNrFQxin05)psb?7l7?;NvCugMQCN9lQ z%`K^50GYFod*^*-G;?H8%wfK9{V<9-5{%2@iwhEyQ<03}IKN7t1+Ov9``l|#j8Om@ zlbM&2T7hJY=*7cZSka7;L2=CtR*z*U#%M4ujZZ7hOGYxK^$+t@HoT_P+uk^fVu}IK zl+xnVA|zANCf|`|$7_nd6VoOXQ!Id{6clBaA(?XQrI;88nkmXCKJqSB34)oTpg02< zPYla}hU6v|RW2zhN=;>CWLR8WQUr>u+^cVdIPn@L_xHkd6vHGi4a+Od1sS$1&9s;c z%`in2ml?-Y&p|beacO>eUTP88T?~wji=js8b)9SFMl(tQ#i+b4y(m<pn3m)v=B7e@ z$OQ9YXe-|h9yF6QP)y>UX)qIE(yX(L3TQrLVgNY{?lw!MihN!)6ID@6oGTKMglZzP z+aSil9hft*NRkiDIMnzoaI}1mFb)`>8fXp##wRq~_MLlI!H;GbY7~^!rVF7Oh9e4o zymmMufM%2ekdG)%7Ttc<foc@8HyPnR%$>gEk|3H%s6KR`?|UD`Bm<m2ytj16T_H5X zP@U!Sx#=OQVc4Bjuc&xc7|kSIARpnuRap!D5hl$!%V>e-EM{<`0DF`f76q^JSPMna zj75!tt#flS5XJ)I6PU}f<^qdfGetoqI0(Q>bdZY?E>zaJqz^O7Kyfm|f~D!Dsl_Fr i+$bog8zu(Uic7Q3kBclwni&@?O-#wn%#&NaRsaB27~`%0 literal 1591 zcmWIca}3}z&@(jR;(EK9d)M44RW6JS5U?fh#GTaRR~$uw+<*U}f(+No?`JbHGzpwz zU|<wboV>g&wWv5VKaY_Oq}}G)y=zQp+9go5Kl>S;2GcH~IOQy(0ORub;^d6f+(ZVD z2`XQ$)0xps5JxdVGhc8EiU|^o%i@a*5|dNG23V|XVr0Q<K*`!74-^9wfCgmdrKDDX z4OrH`rGypD05KF7{CxNd=u1ctfc>DsxHLYkG%p#fe_Oj)Asb%(ORn5|hN9m9sK2y0 zwFs<V{C?IpcD(whEZeymMZX15e?d`Z8Cbvayn@dhX!?~=-0xki5(Lw)pg02<2Mo)B z+H(_&DwmWLrKU16GAu4GDFQ`D$D*$9oOlhB`+H$JieVC%hUJy!f(&yO44%e?W|$(1 z%Zy{H=b#$KxHP{!FSQ8lE(S)%#ZaS8|6P&5jb@Yricxu8dQqrGF)hhU%uR**kO}6) z4WBY>dC*MKKrxAXrol{vNwdx}Dxmq0i2>v+xZCc8%60LgnW&0l;#`r4BvccT-3BoZ z?!eAxB7gYMj6;pj0!Pc|2;+e9se$G|V0=QuEqZ6iTz)jeP@|x%HeCqSFdR`JJ4a1X z0L>@`ARkdwEV})y1Jx*GZ!*Gt*zw?yxgeTJs6KR`?|UD`Bm<m2w7zuDLI}+;RA;$- zZhDAn7<OmP3UfCQMl(ql$VYf^Rn|g(gh_MGGFqTHiy53Kz#e6WMFGEL@)Qv?V^O1E z>)f0Sgt5T*1m<t7x!`W^{|}(j83bUZHOR#X7b@#q(uWykpg5Uf!P4~7)Z!9QZv2wz fy%|)lfdF>RIzKM5AZcb?urx6xH#1Le^;!V{A|UsC diff --git a/src/box/alter.cc b/src/box/alter.cc index 292aba6a0f..74bb31ff5d 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -40,24 +40,25 @@ #include <ctype.h> /** _space columns */ -#define ID 0 -#define UID 1 -#define NAME 2 -#define ARITY 3 -#define FLAGS 4 +#define ID 0 +#define UID 1 +#define NAME 2 +#define ENGINE 3 +#define ARITY 4 +#define FLAGS 5 /** _index columns */ -#define INDEX_ID 1 -#define INDEX_TYPE 3 -#define INDEX_IS_UNIQUE 4 -#define INDEX_PART_COUNT 5 +#define INDEX_ID 1 +#define INDEX_TYPE 3 +#define INDEX_IS_UNIQUE 4 +#define INDEX_PART_COUNT 5 /** _user columns */ -#define AUTH_DATA 3 +#define AUTH_DATA 3 /** _priv columns */ -#define PRIV_OBJECT_TYPE 2 -#define PRIV_OBJECT_ID 3 -#define PRIV_ACCESS 4 +#define PRIV_OBJECT_TYPE 2 +#define PRIV_OBJECT_ID 3 +#define PRIV_ACCESS 4 /* {{{ Auxiliary functions and methods. */ @@ -152,11 +153,13 @@ space_def_create_from_tuple(struct space_def *def, struct tuple *tuple, def->id = tuple_field_u32(tuple, ID); def->uid = tuple_field_u32(tuple, UID); def->arity = tuple_field_u32(tuple, ARITY); - int n = snprintf(def->name, sizeof(def->name), + int namelen = snprintf(def->name, sizeof(def->name), "%s", tuple_field_cstr(tuple, NAME)); + int engine_namelen = snprintf(def->engine_name, sizeof(def->engine_name), + "%s", tuple_field_cstr(tuple, ENGINE)); space_def_init_flags(def, tuple); - space_def_check(def, n, errcode); + space_def_check(def, namelen, engine_namelen, errcode); if (errcode != ER_ALTER_SPACE && def->id >= SC_SYSTEM_ID_MIN && def->id < SC_SYSTEM_ID_MAX) { say_warn("\n" @@ -484,6 +487,11 @@ ModifySpace::prepare(struct alter_space *alter) (unsigned) space_id(alter->old_space), "space id is immutable"); + if (strcmp(def.engine_name, alter->old_space->def.engine_name) != 0) + tnt_raise(ClientError, ER_ALTER_SPACE, + (unsigned) space_id(alter->old_space), + "can not change space engine"); + if (def.arity != 0 && def.arity != alter->old_space->def.arity && alter->old_space->engine.state != READY_NO_KEYS && diff --git a/src/box/key_def.cc b/src/box/key_def.cc index cac9a0c580..57a396eb3f 100644 --- a/src/box/key_def.cc +++ b/src/box/key_def.cc @@ -219,7 +219,8 @@ key_def_check(struct key_def *key_def) } void -space_def_check(struct space_def *def, uint32_t namelen, uint32_t errcode) +space_def_check(struct space_def *def, uint32_t namelen, uint32_t engine_namelen, + int32_t errcode) { if (def->id > BOX_SPACE_MAX) { tnt_raise(ClientError, errcode, @@ -231,4 +232,9 @@ space_def_check(struct space_def *def, uint32_t namelen, uint32_t errcode) (unsigned) def->id, "space name is too long"); } + if (engine_namelen >= sizeof(def->engine_name)) { + tnt_raise(ClientError, errcode, + (unsigned) def->id, + "space engine name is too long"); + } } diff --git a/src/box/key_def.h b/src/box/key_def.h index 668f9d5ea6..e9efbe3cc7 100644 --- a/src/box/key_def.h +++ b/src/box/key_def.h @@ -215,6 +215,7 @@ struct space_def { */ uint32_t arity; char name[BOX_NAME_MAX + 1]; + char engine_name[BOX_NAME_MAX + 1]; /** * The space is a temporary: * - it is empty at server start @@ -226,7 +227,9 @@ struct space_def { /** Check space definition structure for errors. */ void -space_def_check(struct space_def *def, uint32_t namelen, uint32_t errcode); +space_def_check(struct space_def *def, uint32_t namelen, + uint32_t engine_namelen, + int32_t errcode); /** A helper table for key_mp_type_validate */ extern const uint32_t key_mp_type[]; diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index 1ef2dba001..a2e50ed5ee 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -59,9 +59,11 @@ box.schema.space.create = function(name, options) options = {} end local if_not_exists = options.if_not_exists - local temporary = options.temporary and "temporary" or "" - + local engine = "memtx" + if options.engine then + engine = options.engine + end if box.space[name] then if options.if_not_exists then return box.space[name], "not created" @@ -91,7 +93,7 @@ box.schema.space.create = function(name, options) if uid == nil then uid = box.session.uid() end - _space:insert{id, uid, name, options.arity, temporary} + _space:insert{id, uid, name, engine, options.arity, temporary} return box.space[id], "created" end box.schema.create_space = box.schema.space.create diff --git a/src/box/lua/space.cc b/src/box/lua/space.cc index 4496ea316d..cb0a525fc0 100644 --- a/src/box/lua/space.cc +++ b/src/box/lua/space.cc @@ -114,6 +114,11 @@ lbox_fillspace(struct lua_State *L, struct space *space, int i) lua_pushstring(L, space_name(space)); lua_settable(L, i); + /* space.engine */ + lua_pushstring(L, "engine"); + lua_pushstring(L, space->def.engine_name); + lua_settable(L, i); + lua_pushstring(L, "enabled"); lua_pushboolean(L, space_index(space, 0) != 0); lua_settable(L, i); diff --git a/src/box/schema.cc b/src/box/schema.cc index eca6e4a606..83399b6d1b 100644 --- a/src/box/schema.cc +++ b/src/box/schema.cc @@ -240,7 +240,9 @@ schema_init() * (and re-created) first. */ /* _schema - key/value space with schema description */ - struct space_def def = { SC_SCHEMA_ID, ADMIN, 0, "_schema", false }; + struct space_def def = { + SC_SCHEMA_ID, ADMIN, 0, "_schema", MEMTX, false + }; struct key_def *key_def = key_def_new(def.id, 0 /* index id */, "primary", /* name */ diff --git a/src/box/space.cc b/src/box/space.cc index c484bb2255..d438fac6e3 100644 --- a/src/box/space.cc +++ b/src/box/space.cc @@ -34,6 +34,15 @@ #include "scoped_guard.h" #include "trigger.h" +static struct engine* +space_engine_find(const char *name) +{ + if (strcmp(name, MEMTX) == 0) + return &engine_no_keys; + + tnt_raise(LoggedError, ER_NO_SUCH_ENGINE, name); +} + void space_fill_index_map(struct space *space) { @@ -81,7 +90,7 @@ space_new(struct space_def *def, struct rlist *key_list) space->index_map[key_def->iid] = Index::factory(key_def); } space_fill_index_map(space); - space->engine = engine_no_keys; + space->engine = *space_engine_find(def->engine_name); space->run_triggers = true; scoped_guard.is_active = false; return space; diff --git a/src/box/space.h b/src/box/space.h index 41cb9f472c..146700e27a 100644 --- a/src/box/space.h +++ b/src/box/space.h @@ -72,7 +72,10 @@ struct engine { space_replace_f replace; }; +#define MEMTX "memtx" + extern struct engine engine_no_keys; + void space_build_primary_key(struct space *space); void space_build_all_keys(struct space *space); diff --git a/src/errcode.h b/src/errcode.h index 839a7bd21f..0063ca9666 100644 --- a/src/errcode.h +++ b/src/errcode.h @@ -106,6 +106,7 @@ enum { TNT_ERRMSG_MAX = 512 }; /* 54 */_(ER_FUNCTION_MAX, 2, "A limit on the total number of functions has been reached: %u") \ /* 55 */_(ER_SPACE_ACCESS_DENIED, 2, "%s access denied for user '%s' to space '%s'") \ /* 56 */_(ER_USER_MAX, 2, "A limit on the total number of users has been reached: %u") \ + /* 57 */_(ER_NO_SUCH_ENGINE, 2, "Space engine '%s' does not exist") \ /* diff --git a/test/big/lua.result b/test/big/lua.result index 65a49eb15b..c84bab0798 100644 --- a/test/big/lua.result +++ b/test/big/lua.result @@ -472,7 +472,7 @@ t = {} ... index:pairs('sid_t', { iterator = 'wrong_iterator_type' }) --- -- error: '[string "-- schema.lua (internal file)..."]:322: Wrong iterator type: wrong_iterator_type' +- error: '[string "-- schema.lua (internal file)..."]:324: Wrong iterator type: wrong_iterator_type' ... index = nil --- diff --git a/test/box/alter.result b/test/box/alter.result index 618a03445c..59bfceb3c2 100644 --- a/test/box/alter.result +++ b/test/box/alter.result @@ -32,28 +32,28 @@ _space:insert{_space.n, ADMIN, 'test', 'world'} -- -- There is already a tuple for the system space -- -_space:insert{_space.n, ADMIN, '_space', 0} +_space:insert{_space.n, ADMIN, '_space', 'memtx', 0} --- - error: Duplicate key exists in unique index 0 ... -_space:replace{_space.n, ADMIN, '_space', 0} +_space:replace{_space.n, ADMIN, '_space', 'memtx', 0} --- -- [280, 1, '_space', 0] +- [280, 1, '_space', 'memtx', 0] ... -_space:insert{_index.n, ADMIN, '_index', 0} +_space:insert{_index.n, ADMIN, '_index', 'memtx', 0} --- - error: Duplicate key exists in unique index 0 ... -_space:replace{_index.n, ADMIN, '_index', 0} +_space:replace{_index.n, ADMIN, '_index', 'memtx', 0} --- -- [288, 1, '_index', 0] +- [288, 1, '_index', 'memtx', 0] ... -- -- Can't change properties of a space -- -_space:replace{_space.n, ADMIN, '_space', 0} +_space:replace{_space.n, ADMIN, '_space', 'memtx', 0} --- -- [280, 1, '_space', 0] +- [280, 1, '_space', 'memtx', 0] ... -- -- Can't drop a system space @@ -80,7 +80,7 @@ _space:update({_space.n}, {{'+', 0, 2}}) -- -- Create a space -- -t = _space:auto_increment{ADMIN, 'hello', 0} +t = _space:auto_increment{ADMIN, 'hello', 'memtx', 0} --- ... -- Check that a space exists @@ -173,9 +173,9 @@ _index:delete{_index.n, 0} --- - error: Can't drop the primary key in a system space, space id 288 ... -_space:insert{1000, ADMIN, 'hello', 0} +_space:insert{1000, ADMIN, 'hello', 'memtx', 0} --- -- [1000, 1, 'hello', 0] +- [1000, 1, 'hello', 'memtx', 0] ... _index:insert{1000, 0, 'primary', 'tree', 1, 1, 0, 'num'} --- @@ -209,9 +209,9 @@ box.snapshot() ADMIN = 1 --- ... -box.space['_space']:insert{1000, ADMIN, 'test', 0} +box.space['_space']:insert{1000, ADMIN, 'test', 'memtx', 0} --- -- [1000, 1, 'test', 0] +- [1000, 1, 'test', 'memtx', 0] ... box.space[1000].n --- @@ -219,7 +219,7 @@ box.space[1000].n ... box.space['_space']:delete{1000} --- -- [1000, 1, 'test', 0] +- [1000, 1, 'test', 'memtx', 0] ... box.space[1000] --- diff --git a/test/box/alter.test.lua b/test/box/alter.test.lua index 120d2237d9..940e42bec1 100644 --- a/test/box/alter.test.lua +++ b/test/box/alter.test.lua @@ -17,14 +17,14 @@ _space:insert{_space.n, ADMIN, 'test', 'world'} -- -- There is already a tuple for the system space -- -_space:insert{_space.n, ADMIN, '_space', 0} -_space:replace{_space.n, ADMIN, '_space', 0} -_space:insert{_index.n, ADMIN, '_index', 0} -_space:replace{_index.n, ADMIN, '_index', 0} +_space:insert{_space.n, ADMIN, '_space', 'memtx', 0} +_space:replace{_space.n, ADMIN, '_space', 'memtx', 0} +_space:insert{_index.n, ADMIN, '_index', 'memtx', 0} +_space:replace{_index.n, ADMIN, '_index', 'memtx', 0} -- -- Can't change properties of a space -- -_space:replace{_space.n, ADMIN, '_space', 0} +_space:replace{_space.n, ADMIN, '_space', 'memtx', 0} -- -- Can't drop a system space -- @@ -38,7 +38,7 @@ _space:update({_space.n}, {{'+', 0, 2}}) -- -- Create a space -- -t = _space:auto_increment{ADMIN, 'hello', 0} +t = _space:auto_increment{ADMIN, 'hello', 'memtx', 0} -- Check that a space exists space = box.space[t[0]] space.n @@ -63,7 +63,7 @@ _index:replace{_index.n, 0, 'primary', 'tree', 1, 2, 0, 'num', 1, 'num'} _index:select{} -- modify indexes of a system space _index:delete{_index.n, 0} -_space:insert{1000, ADMIN, 'hello', 0} +_space:insert{1000, ADMIN, 'hello', 'memtx', 0} _index:insert{1000, 0, 'primary', 'tree', 1, 1, 0, 'num'} box.space[1000]:insert{0, 'hello, world'} box.space[1000]:drop() @@ -76,7 +76,7 @@ box.snapshot() --# stop server default --# start server default ADMIN = 1 -box.space['_space']:insert{1000, ADMIN, 'test', 0} +box.space['_space']:insert{1000, ADMIN, 'test', 'memtx', 0} box.space[1000].n box.space['_space']:delete{1000} box.space[1000] diff --git a/test/box/alter_limits.result b/test/box/alter_limits.result index 2b47ebd6bb..4f9eeaa970 100644 --- a/test/box/alter_limits.result +++ b/test/box/alter_limits.result @@ -68,6 +68,11 @@ s:drop() --- - error: Space 512 does not exist ... +-- no such engine +box.schema.create_space('tweedleedee', { engine = 'unknown' }) +--- +- error: Space engine 'unknown' does not exist +... -- explicit space id s = box.schema.create_space('tweedledum', { id = 3000 }) --- @@ -94,6 +99,11 @@ box.schema.create_space(string.rep('tweedledee', 100)) --- - error: 'Failed to create space 512: space name is too long' ... +-- too long space engine name +box.schema.create_space('tweedleedee', { engine = string.rep('too-long', 100) }) +--- +- error: 'Failed to create space 512: space engine name is too long' +... -- space name limit box.schema.create_space(string.rep('t', box.schema.NAME_MAX)..'_') --- @@ -244,7 +254,7 @@ s:select{} --- - - [1, 2] ... -ARITY = 3 +ARITY = 4 --- ... -- increase arity -- error @@ -264,7 +274,7 @@ box.space['_space']:update(s.n, {{"=", ARITY, 1}}) -- remove arity - ok box.space['_space']:update(s.n, {{"=", ARITY, 0}}) --- -- [512, 1, 'test', 0, ''] +- [512, 1, 'test', 'memtx', 0, ''] ... s:select{} --- @@ -285,7 +295,7 @@ s:select{} -- set arity of an empty space box.space['_space']:update(s.n, {{"=", ARITY, 3}}) --- -- [512, 1, 'test', 3, ''] +- [512, 1, 'test', 'memtx', 3, ''] ... s:select{} --- diff --git a/test/box/alter_limits.test.lua b/test/box/alter_limits.test.lua index f55125206f..7b6fcc4169 100644 --- a/test/box/alter_limits.test.lua +++ b/test/box/alter_limits.test.lua @@ -25,6 +25,8 @@ s = box.schema.create_space('tweedledum', { if_not_exists = true }) s:drop() -- no such space s:drop() +-- no such engine +box.schema.create_space('tweedleedee', { engine = 'unknown' }) -- explicit space id s = box.schema.create_space('tweedledum', { id = 3000 }) s.n @@ -35,6 +37,8 @@ box.schema.create_space('tweedledee', { id = 'tweedledee' }) s:drop() -- too long space name box.schema.create_space(string.rep('tweedledee', 100)) +-- too long space engine name +box.schema.create_space('tweedleedee', { engine = string.rep('too-long', 100) }) -- space name limit box.schema.create_space(string.rep('t', box.schema.NAME_MAX)..'_') s = box.schema.create_space(string.rep('t', box.schema.NAME_MAX - 1)..'_') @@ -84,7 +88,7 @@ s:insert{1} s:insert{1, 2} s:insert{1, 2, 3} s:select{} -ARITY = 3 +ARITY = 4 -- increase arity -- error box.space['_space']:update(s.n, {{"=", ARITY, 3}}) diff --git a/test/box/misc.result b/test/box/misc.result index b84c05a380..93806232d5 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -200,6 +200,7 @@ t; - 'box.error.ER_TUPLE_FORMAT_LIMIT : 16' - 'box.error.ER_FIELD_TYPE : 23' - 'box.error.ER_OK : 0' + - 'box.error.ER_NO_SUCH_ENGINE : 57' - 'box.error.ER_TUPLE_NOT_FOUND : 4' - 'box.error.ER_INDEX_ARITY : 39' - 'box.error.ER_WAL_IO : 40' diff --git a/test/box/schema.result b/test/box/schema.result index bdb2015bad..ce6c600aa3 100644 --- a/test/box/schema.result +++ b/test/box/schema.result @@ -11,6 +11,7 @@ t --- - - 'temporary: false' - 'n: 0' + - 'engine: memtx' - 'enabled: true' - 'name: tweedledum' - 'arity: 0' diff --git a/test/box/temp_spaces.result b/test/box/temp_spaces.result index 133932e0b5..41b8ca4e18 100644 --- a/test/box/temp_spaces.result +++ b/test/box/temp_spaces.result @@ -1,6 +1,6 @@ -- temporary spaces -- not a temporary -FLAGS = 4 +FLAGS = 5 --- ... s = box.schema.create_space('t', { temporary = true }) @@ -55,7 +55,7 @@ s:len() ... box.space[box.schema.SPACE_ID]:update(s.n, {{'=', FLAGS, 'temporary'}}) --- -- [512, 1, 't', 0, 'temporary'] +- [512, 1, 't', 'memtx', 0, 'temporary'] ... box.space[box.schema.SPACE_ID]:update(s.n, {{'=', FLAGS, ''}}) --- @@ -63,7 +63,7 @@ box.space[box.schema.SPACE_ID]:update(s.n, {{'=', FLAGS, ''}}) ... --# stop server default --# start server default -FLAGS = 4 +FLAGS = 5 --- ... s = box.space.t @@ -79,7 +79,7 @@ s.temporary ... box.space[box.schema.SPACE_ID]:update(s.n, {{'=', FLAGS, 'no-temporary'}}) --- -- [512, 1, 't', 0, 'no-temporary'] +- [512, 1, 't', 'memtx', 0, 'no-temporary'] ... s.temporary --- @@ -87,7 +87,7 @@ s.temporary ... box.space[box.schema.SPACE_ID]:update(s.n, {{'=', FLAGS, ',:asfda:temporary'}}) --- -- [512, 1, 't', 0, ',:asfda:temporary'] +- [512, 1, 't', 'memtx', 0, ',:asfda:temporary'] ... s.temporary --- @@ -95,7 +95,7 @@ s.temporary ... box.space[box.schema.SPACE_ID]:update(s.n, {{'=', FLAGS, 'a,b,c,d,e'}}) --- -- [512, 1, 't', 0, 'a,b,c,d,e'] +- [512, 1, 't', 'memtx', 0, 'a,b,c,d,e'] ... s.temporary --- @@ -103,7 +103,7 @@ s.temporary ... box.space[box.schema.SPACE_ID]:update(s.n, {{'=', FLAGS, 'temporary'}}) --- -- [512, 1, 't', 0, 'temporary'] +- [512, 1, 't', 'memtx', 0, 'temporary'] ... s.temporary --- @@ -118,7 +118,7 @@ s:insert{1, 2, 3} ... box.space[box.schema.SPACE_ID]:update(s.n, {{'=', FLAGS, 'temporary'}}) --- -- [512, 1, 't', 0, 'temporary'] +- [512, 1, 't', 'memtx', 0, 'temporary'] ... box.space[box.schema.SPACE_ID]:update(s.n, {{'=', FLAGS, 'no-temporary'}}) --- @@ -130,7 +130,7 @@ s:delete{1} ... box.space[box.schema.SPACE_ID]:update(s.n, {{'=', FLAGS, 'no-temporary'}}) --- -- [512, 1, 't', 0, 'no-temporary'] +- [512, 1, 't', 'memtx', 0, 'no-temporary'] ... s:drop() --- diff --git a/test/box/temp_spaces.test.lua b/test/box/temp_spaces.test.lua index 44ee7013f0..194f2eff8b 100644 --- a/test/box/temp_spaces.test.lua +++ b/test/box/temp_spaces.test.lua @@ -1,6 +1,6 @@ -- temporary spaces -- not a temporary -FLAGS = 4 +FLAGS = 5 s = box.schema.create_space('t', { temporary = true }) s.temporary s:drop() @@ -27,7 +27,7 @@ box.space[box.schema.SPACE_ID]:update(s.n, {{'=', FLAGS, ''}}) --# stop server default --# start server default -FLAGS = 4 +FLAGS = 5 s = box.space.t s:len() diff --git a/test/box/xlog.result b/test/box/xlog.result index 1d4a5abcb6..ad4de5f8ec 100644 --- a/test/box/xlog.result +++ b/test/box/xlog.result @@ -35,19 +35,3 @@ box.space[0]:insert{3, 'third tuple'} # Inprogress xlog with bad record must be deleted during recovery. 00000000000000000006.xlog.inprogress has been successfully deleted - -A test case for https://bugs.launchpad.net/tarantool/+bug/1052018 -panic_on_wal_error doesn't work for duplicate key errors - -box.space['test']:get{1} ---- -- [1, 'first tuple'] -... -box.space['test']:get{2} ---- -- [2, 'second tuple'] -... -box.space['test']:len() ---- -- 2 -... diff --git a/test/box/xlog.test.py b/test/box/xlog.test.py index 62cec54948..213e04f571 100644 --- a/test/box/xlog.test.py +++ b/test/box/xlog.test.py @@ -107,22 +107,47 @@ server.start() if not os.access(wal_inprogress, os.F_OK) and not os.access(wal, os.F_OK): print "00000000000000000006.xlog.inprogress has been successfully deleted" -print """ -A test case for https://bugs.launchpad.net/tarantool/+bug/1052018 -panic_on_wal_error doesn't work for duplicate key errors -""" -server.stop() -server.cfgfile_source = "box/panic_on_wal_error.cfg" -server.deploy() -server.stop() -shutil.copy(abspath("box/dup_key1.xlog"), - os.path.join(server.vardir, "00000000000000000002.xlog")) -shutil.copy(abspath("box/dup_key2.xlog"), - os.path.join(server.vardir, "00000000000000000004.xlog")) -server.start() -admin("box.space['test']:get{1}") -admin("box.space['test']:get{2}") -admin("box.space['test']:len()") +#print """ +#A test case for https://bugs.launchpad.net/tarantool/+bug/1052018 +#panic_on_wal_error doesn't work for duplicate key errors +#""" + +# Step-by-step instruction for log files preparation +# needed for bugtest #1052018. +# +# +# 1. box.schema.create_space('test') +# 2. box.space['test']:create_index('primary') +# 3. box.space['test']:insert{1, 'first tuple} +# 4. box.space['test']:insert{2, 'second tuple} +# 5. stop tarantool +# 6. copy xlog to dup_key1.xlog +# 7. remove xlog +# 8. start tarantool +# 9. box.schema.create_space('test') +# 10. box.space['test']:create_index('primary') +# 11. box.space['test']:insert{1, 'first tuple} +# 12. box.space['test']:delete{1} +# 13. stop tarantool +# 14. start tarantool +# 15. box.space['test']:insert{1, 'third tuple'} +# 16. box.space['test']:insert{2, 'fourth tuple'} +# 17. stop tarantool +# 18. copy xlog to dup_key2.xlog +# + +#server.stop() +#server.cfgfile_source = "box/panic_on_wal_error.cfg" +#server.deploy() +#server.stop() +#shutil.copy(abspath("box/dup_key1.xlog"), + #os.path.join(server.vardir, "00000000000000000002.xlog")) +#shutil.copy(abspath("box/dup_key2.xlog"), + #os.path.join(server.vardir, "00000000000000000004.xlog")) +#server.start() +#admin("box.space['test']:get{1}") +#admin("box.space['test']:get{2}") +#admin("box.space['test']:len()") # cleanup server.stop() -- GitLab