From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 5CA78295A0 for ; Thu, 29 Mar 2018 02:42:20 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p0IOEAn2TB8D for ; Thu, 29 Mar 2018 02:42:20 -0400 (EDT) Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [94.100.177.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id BCEDE2920D for ; Thu, 29 Mar 2018 02:42:19 -0400 (EDT) From: Kirill Yukhin Subject: [tarantool-patches] [PATCH 1/3] Add value field to _schema space Date: Thu, 29 Mar 2018 09:42:06 +0300 Message-Id: <96cf96edda40dbc76838d742c32a97409c81bb5f.1522303843.git.kyukhin@tarantool.org> In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: v.shpilevoy@tarantool.org Cc: tarantool-patches@freelists.org, Kirill Yukhin _schema represented as key-value storage for various values common for Tarantool, like next id for space creation. SQL requires format to be fully specified for columns being access. Unfortunatelly, _schema is inserted into _space before _space's format is set and since DD triggers are disabled during upgrade, format for _schema tuple in _space stays the same. So, set value nullable field in upgrade, regenerate initial snap, update tests. Also, as far as _schema's tuple in _space is not updated: relax fieldno check in sql.c --- src/box/bootstrap.snap | Bin 1638 -> 1657 bytes src/box/lua/upgrade.lua | 14 ++++++++++++-- src/box/sql.c | 5 ++--- test/box-py/bootstrap.result | 3 ++- test/box/access_misc.result | 3 ++- test/xlog/upgrade.result | 3 ++- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/box/bootstrap.snap b/src/box/bootstrap.snap index cf481f9a708e29f680d074ddf755ef6659cdadd4..783aa88995318726e7a93a403a729210d18a39c9 100644 GIT binary patch literal 1657 zcmV-<28Q`lPC-x#FfK7O3RY!ub7^mGIv_GGFfKGLF*h+SXE-x6Fl97j3Q2BrbYX5| zWjY`>IbkwoGh;X{Ib}6rEi_|fVJ%{1Wi~A^V`MO5IAk?rF*r90RzqxWV{1Afdoem7 zFntON)w&D1%?14c&O{PINTmP(0000ewJ-euP^B*bnn6SkNYEHJ0f0S>Qi)TFUQI%s z7R+K1LD)oM^Z*C#FSwWPm}t>C7 zOqR-&QqKUy0NenteZ=#74Q8&%*_W391!*z&8-^nGnADK~&C+tpho~Edr1p3odNRDM zv!(B=Y`u`zudarHI`7V7Kejpy$Q(j{`s!EbUA+o(PgY$j5t5A*K(n-L?Yqi*l&LzX ze|J73lCj6c0?;fihbYmZ0>-QUC*rJ0Sq<7onr3MUfI!t^=KEQ)BbudUQ6>7a_j6aV zs##k8P3rqlpAAlpsVjXb)TxB?aWy5*raP55%yIbi;S5;zcTR>_W^OK((kd=MTCAkD zWN~suhYA2ofdZ!nnx*A~A7)nGqmb9}2SJHL|64zWD6>c7Fa`oma2@;CG#6<97~AqMz(}?g>?x0zRKvyv1cKPgY+D z+`aF4S6fWQz#FE{u1OJlU-&sSq%){LhUD=bxfiRX0h*=dcvmmpM-diYEQYbM)psh) zA1P*)M~5e82gQpMHOE9wi4%#_h||f8*{-7Kcg=!X&Qb`m@Ftv^* zXqJ{E3Dhhy<;k9`$rzFU-C@+F5(RBBFPf$0zTw5=>hjnZ>Q~R}S5OTQQs=OrFTX-m ze{ubG?u9+vV^V)a_`cu$`azH9CPPM^R2~SLrKQ;~*5vM&oWl+HB!IY~qF zBche^&h1Tc*N34u7M;aFr43CsWhfB+}}0R~4Y$7~)FfWSD4!!V427=~j23}ORE z03av`2Q)yn0GKQ-LyH^(01_wK?6!60k_bZZd=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ha7Y^vl2A0n(3L0E8xL|O(AlgJPA`AD1Dp*u!iVaZ+xmXLDfNwoP z5-O@gMVmI8n=>L>_b;n0)@NsX5#d|Up2z%^t?Xyu$YVB|$97OaLf^}9z#SXCA3Od0 zeK*?pu8I8-0n|Tt&9&J1?WD&D6k7uU-+H1yf86Z9X*MwP;sQqiATS6Chyc|Bm@I2T zFV+AyjGK5Fx+20r^o_mIH~Pv253pN{QKuGZFVhs#*0*FB0by&fHFzM!F50Ksn8J6k3g0s9y3)N9W6qSCA|h$3~gU)$%r^Nr&jSMzAhMQxNo zA155((@dqaReqgO>9G7dqtam+FSDsQR#RhBZamXb~e!4oT@U{)Y}cj?p{PERKofHxPkB4_!j^Cx}narG|`Ip z?VDZvKik&Tx$cbK4rp3Lo){Va-}yrUkKyQ%bAQd{bqz*piMCE;kba40;qA3~*E{Kj=~82}9x$c-qDqWjfY`U0hOZ z4nVnvT`LqH4@U?0Ta5N!oFW^fXN?1pTkxqOKUo$)Qkc)LBx{;xIj5m|cxX+XFxRc< zbwTYi@DzF7q%zH;8T}Cq7IBg2Cp?J?SM7&nziI7U6)>wALgIhU54CWu6!m6b3(#7P k&cB;FNloBtT%ms(>pViJVcFJ^Gx&N^Pm;nd2h|X*?Mu=RQ2+n{ diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua index a514d12..7c8f38b 100644 --- a/src/box/lua/upgrade.lua +++ b/src/box/lua/upgrade.lua @@ -479,10 +479,11 @@ local function upgrade_to_1_8_4() {name='nlt', type='string'}, {name='ndlt', type='string'}, {name='sample', type='scalar'}} + local MAP = setmap({}) log.info("create space _sql_stat1") _space:insert{box.schema.SQL_STAT1_ID, ADMIN, '_sql_stat1', 'memtx', 0, - setmap({}), stat1_ft} + MAP, stat1_ft} log.info("create index primary on _sql_stat1") _index:insert{box.schema.SQL_STAT1_ID, 0, 'primary', 'tree', @@ -490,12 +491,21 @@ local function upgrade_to_1_8_4() log.info("create space _sql_stat4") _space:insert{box.schema.SQL_STAT4_ID, ADMIN, '_sql_stat4', 'memtx', 0, - setmap({}), stat4_ft} + MAP, stat4_ft} log.info("create index primary on _sql_stat4") _index:insert{box.schema.SQL_STAT4_ID, 0, 'primary', 'tree', {unique = true}, {{0, 'string'}, {1, 'string'}, {5, 'scalar'}}} + + -- Nullability wasn't skipable. This was fixed in 1-7. + -- Now, abscent field means NULL, so we can safely set second + -- field in format, marking it nullable. + log.info("Add nullable value field to space _schema") + local format = {} + format[1] = {type='string', name='key'} + format[2] = {type='any', name='value', is_nullable=true} + box.space._schema:format(format) end -------------------------------------------------------------------------------- diff --git a/src/box/sql.c b/src/box/sql.c index a13f2f8..6d8ef9a 100644 --- a/src/box/sql.c +++ b/src/box/sql.c @@ -220,9 +220,8 @@ tarantoolSqlite3TupleColumnFast(BtCursor *pCur, u32 fieldno, u32 *field_size) assert(c != NULL); assert(c->tuple_last != NULL); struct tuple_format *format = tuple_format(c->tuple_last); - assert(format->exact_field_count == 0 - || fieldno < format->exact_field_count); - if (format->fields[fieldno].offset_slot == TUPLE_OFFSET_SLOT_NIL) + if (fieldno < format->field_count + || format->fields[fieldno].offset_slot == TUPLE_OFFSET_SLOT_NIL) return NULL; const char *field = tuple_field(c->tuple_last, fieldno); const char *end = field; diff --git a/test/box-py/bootstrap.result b/test/box-py/bootstrap.result index f310326..e6c01fe 100644 --- a/test/box-py/bootstrap.result +++ b/test/box-py/bootstrap.result @@ -13,7 +13,8 @@ box.space._cluster:select{} ... box.space._space:select{} --- -- - [272, 1, '_schema', 'memtx', 0, {}, [{'type': 'string', 'name': 'key'}]] +- - [272, 1, '_schema', 'memtx', 0, {}, [{'type': 'string', 'name': 'key'}, {'type': 'any', + 'name': 'value', 'is_nullable': true}]] - [276, 1, '_collation', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, { 'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'}, {'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, { diff --git a/test/box/access_misc.result b/test/box/access_misc.result index 1bbc8a3..9b3c5c0 100644 --- a/test/box/access_misc.result +++ b/test/box/access_misc.result @@ -732,7 +732,8 @@ box.space._user:select() ... box.space._space:select() --- -- - [272, 1, '_schema', 'memtx', 0, {}, [{'type': 'string', 'name': 'key'}]] +- - [272, 1, '_schema', 'memtx', 0, {}, [{'type': 'string', 'name': 'key'}, {'type': 'any', + 'name': 'value', 'is_nullable': true}]] - [276, 1, '_collation', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, { 'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'}, {'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, { diff --git a/test/xlog/upgrade.result b/test/xlog/upgrade.result index 710ca40..5a6bd05 100644 --- a/test/xlog/upgrade.result +++ b/test/xlog/upgrade.result @@ -40,7 +40,8 @@ box.space._schema:select() ... box.space._space:select() --- -- - [272, 1, '_schema', 'memtx', 0, {}, [{'type': 'string', 'name': 'key'}]] +- - [272, 1, '_schema', 'memtx', 0, {}, [{'type': 'string', 'name': 'key'}, {'type': 'any', + 'name': 'value', 'is_nullable': true}]] - [276, 1, '_collation', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, { 'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'}, {'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, { -- 2.11.0