* [PATCH v1 1/1] vinyl: fix invalid tuple in surrogate delete
@ 2019-04-02 10:59 Kirill Shcherbatov
2019-04-02 17:09 ` Vladimir Davydov
0 siblings, 1 reply; 2+ messages in thread
From: Kirill Shcherbatov @ 2019-04-02 10:59 UTC (permalink / raw)
To: tarantool-patches, vdavydov.dev; +Cc: Kirill Shcherbatov
If the map contains non-string keys that cannot be used in the
JSON index, an incorrect tuple is created in
vy_stmt_new_surrogate_delete_raw during the construction of the
surrogate tuple. This occurs because the number of items that
the map contains has already been copied, while such invalid
key-value pairs are not copied.
The poblem is resolved through the creation of dummy nil:nil
pairs in such cases.
---
https://github.com/tarantool/tarantool/tree/kshch/surrogate-delete-raw-fixup
src/box/vy_stmt.c | 3 +++
test/engine/json.result | 22 ++++++++++++++++++++++
test/engine/json.test.lua | 9 +++++++++
3 files changed, 34 insertions(+)
diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c
index 5d1e10f07..add86622b 100644
--- a/src/box/vy_stmt.c
+++ b/src/box/vy_stmt.c
@@ -464,6 +464,8 @@ vy_stmt_new_surrogate_delete_raw(struct tuple_format *format,
if (mp_typeof(*src_pos) != MP_STR) {
mp_next(&src_pos);
mp_next(&src_pos);
+ pos = mp_encode_nil(pos);
+ pos = mp_encode_nil(pos);
continue;
}
token.type = JSON_TOKEN_STR;
@@ -514,6 +516,7 @@ finish:
memcpy(stmt_data, data, bsize);
memcpy(stmt_field_map_begin, field_map_begin, format->field_map_size);
vy_stmt_set_type(stmt, IPROTO_DELETE);
+ mp_tuple_assert(stmt_data, stmt_data + bsize);
out:
region_truncate(region, region_svp);
return stmt;
diff --git a/test/engine/json.result b/test/engine/json.result
index a790cdfbc..09c704963 100644
--- a/test/engine/json.result
+++ b/test/engine/json.result
@@ -683,6 +683,28 @@ town:select()
s:drop()
---
...
+-- Check replace with tuple with map having numeric keys that
+-- cannot be included in JSON index.
+s = box.schema.space.create('withdata', {engine='vinyl'})
+---
+...
+pk = s:create_index('pk', {parts={{1, 'int'}}})
+---
+...
+idx0 = s:create_index('idx0', {parts = {{2, 'str', path = 'name'}, {3, "str"}}})
+---
+...
+s:insert({4, {"d", name='D'}, "test"})
+---
+- [4, {1: 'd', 'name': 'D'}, 'test']
+...
+s:replace({4, {"d1", name='D1'}, "test"})
+---
+- [4, {1: 'd1', 'name': 'D1'}, 'test']
+...
+s:drop()
+---
+...
--
-- gh-1260: Multikey indexes
--
diff --git a/test/engine/json.test.lua b/test/engine/json.test.lua
index f9a7180b1..5c235e1ba 100644
--- a/test/engine/json.test.lua
+++ b/test/engine/json.test.lua
@@ -193,6 +193,15 @@ name:drop()
town:select()
s:drop()
+-- Check replace with tuple with map having numeric keys that
+-- cannot be included in JSON index.
+s = box.schema.space.create('withdata', {engine='vinyl'})
+pk = s:create_index('pk', {parts={{1, 'int'}}})
+idx0 = s:create_index('idx0', {parts = {{2, 'str', path = 'name'}, {3, "str"}}})
+s:insert({4, {"d", name='D'}, "test"})
+s:replace({4, {"d1", name='D1'}, "test"})
+s:drop()
+
--
-- gh-1260: Multikey indexes
--
--
2.21.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-02 17:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-02 10:59 [PATCH v1 1/1] vinyl: fix invalid tuple in surrogate delete Kirill Shcherbatov
2019-04-02 17:09 ` Vladimir Davydov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox