Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Yukhin <kyukhin@tarantool.org>
To: v.shpilevoy@tarantool.org
Cc: tarantool-patches@freelists.org, Kirill Yukhin <kyukhin@tarantool.org>
Subject: [tarantool-patches] [PATCH 1/3] Add value field to _schema space
Date: Thu, 29 Mar 2018 09:42:06 +0300	[thread overview]
Message-ID: <96cf96edda40dbc76838d742c32a97409c81bb5f.1522303843.git.kyukhin@tarantool.org> (raw)
In-Reply-To: <cover.1522303843.git.kyukhin@tarantool.org>
In-Reply-To: <cover.1522303843.git.kyukhin@tarantool.org>

_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><N}AkEF-elXq={xia_vI#%;}aApx)dpLU&&k)k>C7
zOqR-&QqKU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
                       {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

  reply	other threads:[~2018-03-29  6:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-29  6:42 [tarantool-patches] [PATCH 0/3] sql: move column's default value to Tarantool's core Kirill Yukhin
2018-03-29  6:42 ` Kirill Yukhin [this message]
2018-03-29  6:42 ` [tarantool-patches] [PATCH 2/3] sql: remove dead find DB functions Kirill Yukhin
2018-03-29  6:42 ` [tarantool-patches] [PATCH 3/3] sql: move default col values to Tarantool's core Kirill Yukhin
2018-03-29 14:00   ` [tarantool-patches] " v.shpilevoy
2018-03-31  3:55     ` Kirill Yukhin
2018-03-31  4:24       ` [tarantool-patches] [PATCH] " Kirill Yukhin
2018-04-03  6:29       ` [tarantool-patches] Re: [PATCH 3/3] " Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=96cf96edda40dbc76838d742c32a97409c81bb5f.1522303843.git.kyukhin@tarantool.org \
    --to=kyukhin@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] [PATCH 1/3] Add value field to _schema space' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox