Skip to content
Snippets Groups Projects
Commit b1828dd4 authored by Kirill Shcherbatov's avatar Kirill Shcherbatov Committed by Vladimir Davydov
Browse files

box: fix assert with multikey hybrid index

Tarantool used to assume that offset_slot has an extension
iff field_map_get_offset is called with multikey_idx >= 0.
In fact, when some part of the index contains a multikey index
placeholder, tuple_compare_* routines pass a tuple_hint in
meaning of multikey index for each tuple_field_raw_by_part call,
even for regular key_part that doesn't have array index
placeholder (and, correspondingly, field_map extension).
Thus this assumption is invalid.

This patch uses the fact that field_map slots that have extension
store negative offset to distinguish multikey and normal usage
of the field_map_get_offset routine.

Closes #4234
parent eca5c292
No related branches found
No related tags found
No related merge requests found
...@@ -152,8 +152,8 @@ field_map_get_offset(const uint32_t *field_map, int32_t offset_slot, ...@@ -152,8 +152,8 @@ field_map_get_offset(const uint32_t *field_map, int32_t offset_slot,
int multikey_idx) int multikey_idx)
{ {
uint32_t offset; uint32_t offset;
if (multikey_idx != MULTIKEY_NONE && field_map[offset_slot] > 0) { if (multikey_idx != MULTIKEY_NONE &&
assert((int32_t)field_map[offset_slot] < 0); (int32_t) field_map[offset_slot] < 0) {
/** /**
* The field_map extent has the following * The field_map extent has the following
* structure: [size=N|slot1|slot2|..|slotN] * structure: [size=N|slot1|slot2|..|slotN]
......
...@@ -753,3 +753,27 @@ i2:select() ...@@ -753,3 +753,27 @@ i2:select()
s:drop() s:drop()
--- ---
... ...
--
-- gh-4234: Assert when using indexes containing both multikey
-- and regular key_parts.
--
s = box.schema.space.create('clients', {engine = engine})
---
...
name_idx = s:create_index('name_idx', {parts = {{1, 'string'}}})
---
...
phone_idx = s:create_index('phone_idx', {parts = {{'[2][*]', 'string'}, {3, 'string'}}, unique=false})
---
...
s:insert({"Genadiy", {"911"}, 'b'})
---
- ['Genadiy', ['911'], 'b']
...
s:insert({"Jorge", {"911", "89457609234"}, 'a'})
---
- ['Jorge', ['911', '89457609234'], 'a']
...
s:drop()
---
...
...@@ -194,3 +194,14 @@ s:replace{2, {{2, 3}}} ...@@ -194,3 +194,14 @@ s:replace{2, {{2, 3}}}
i2 = s:create_index('sk', {parts = {{2, 'unsigned', path = '[1][*]'}}}) i2 = s:create_index('sk', {parts = {{2, 'unsigned', path = '[1][*]'}}})
i2:select() i2:select()
s:drop() s:drop()
--
-- gh-4234: Assert when using indexes containing both multikey
-- and regular key_parts.
--
s = box.schema.space.create('clients', {engine = engine})
name_idx = s:create_index('name_idx', {parts = {{1, 'string'}}})
phone_idx = s:create_index('phone_idx', {parts = {{'[2][*]', 'string'}, {3, 'string'}}, unique=false})
s:insert({"Genadiy", {"911"}, 'b'})
s:insert({"Jorge", {"911", "89457609234"}, 'a'})
s:drop()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment