From fcefbd2ad0a6ce723527daa8acc64e51ef95a2b8 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Tue, 27 Aug 2013 21:37:24 +0400 Subject: [PATCH] Convert big/hash, big/hash_multipart, big/sql to the new datadict and lua console. --- test/big/hash.result | 469 ++++++++++++++++--------------- test/big/hash_multipart.result | 108 ++++--- test/big/hash_multipart.test.lua | 48 ++-- test/big/sql.result | 46 +-- 4 files changed, 362 insertions(+), 309 deletions(-) diff --git a/test/big/hash.result b/test/big/hash.result index 84be8c9a40..6e8ec9ad53 100644 --- a/test/big/hash.result +++ b/test/big/hash.result @@ -9,11 +9,11 @@ dofile('utils.lua') ------------------------------------------------------------------------------- box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') --- -'0: {0, ''tweedledum''}' +0: {0, 'tweedledum'} ... box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') --- -'0: {0, ''primary'', 1752392040, 1, 1, 0, ''num''}' +0: {0, 'primary', 1752392040, 1, 1, 0, 'num'} ... hash = box.space[0] --- @@ -21,19 +21,19 @@ hash = box.space[0] -- Insert valid fields hash:insert(0, 'value1 v1.0', 'value2 v1.0') --- - - 0: {'value1 v1.0', 'value2 v1.0'} +0: {'value1 v1.0', 'value2 v1.0'} ... hash:insert(1, 'value1 v1.0', 'value2 v1.0') --- - - 1: {'value1 v1.0', 'value2 v1.0'} +1: {'value1 v1.0', 'value2 v1.0'} ... hash:insert(2, 'value1 v1.0', 'value2 v1.0') --- - - 2: {'value1 v1.0', 'value2 v1.0'} +2: {'value1 v1.0', 'value2 v1.0'} ... hash:insert(3, 'value1 v1.0', 'value2 v1.0') --- - - 3: {'value1 v1.0', 'value2 v1.0'} +3: {'value1 v1.0', 'value2 v1.0'} ... -- Insert invalid fields hash:insert('invalid key', 'value1 v1.0', 'value2 v1.0') @@ -46,15 +46,15 @@ error: 'Tuple field 0 type does not match one required by operation: expected NU -- Replace valid fields hash:replace(3, 'value1 v1.31', 'value2 1.12') --- - - 3: {'value1 v1.31', 'value2 1.12'} +3: {'value1 v1.31', 'value2 1.12'} ... hash:replace(1, 'value1 v1.32', 'value2 1.72') --- - - 1: {'value1 v1.32', 'value2 1.72'} +1: {'value1 v1.32', 'value2 1.72'} ... hash:replace(2, 'value1 v1.43', 'value2 1.92') --- - - 2: {'value1 v1.43', 'value2 1.92'} +2: {'value1 v1.43', 'value2 1.92'} ... -- Replace invalid fields hash:replace('invalid key', 'value1 v1.0', 'value2 v1.0') @@ -67,19 +67,19 @@ error: 'Tuple field 0 type does not match one required by operation: expected NU -- select by valid keys hash:select(0, 0) --- - - 0: {'value1 v1.0', 'value2 v1.0'} +0: {'value1 v1.0', 'value2 v1.0'} ... hash:select(0, 1) --- - - 1: {'value1 v1.32', 'value2 1.72'} +1: {'value1 v1.32', 'value2 1.72'} ... hash:select(0, 2) --- - - 2: {'value1 v1.43', 'value2 1.92'} +2: {'value1 v1.43', 'value2 1.92'} ... hash:select(0, 3) --- - - 3: {'value1 v1.31', 'value2 1.12'} +3: {'value1 v1.31', 'value2 1.12'} ... hash:select(0, 4) --- @@ -94,7 +94,7 @@ error: 'Supplied key type of part 0 does not match index part type: expected NUM ... hash:select(0, 1, 2) --- -error: 'Invalid key part count (expected [0..1], got 2)' +error: Invalid key part count (expected [0..1], got 2) ... ------------------------------------------------------------------------------- -- 32-bit hash delete fields test @@ -102,19 +102,19 @@ error: 'Invalid key part count (expected [0..1], got 2)' -- delete by valid keys hash:delete(0) --- - - 0: {'value1 v1.0', 'value2 v1.0'} +0: {'value1 v1.0', 'value2 v1.0'} ... hash:delete(1) --- - - 1: {'value1 v1.32', 'value2 1.72'} +1: {'value1 v1.32', 'value2 1.72'} ... hash:delete(2) --- - - 2: {'value1 v1.43', 'value2 1.92'} +2: {'value1 v1.43', 'value2 1.92'} ... hash:delete(3) --- - - 3: {'value1 v1.31', 'value2 1.12'} +3: {'value1 v1.31', 'value2 1.12'} ... hash:delete(4) --- @@ -129,7 +129,10 @@ error: 'Supplied key type of part 0 does not match index part type: expected NUM ... hash:delete(1, 2) --- -error: 'Invalid key part count in an exact match (expected 1, got 2)' +error: Invalid key part count in an exact match (expected 1, got 2) +... +hash:truncate() +--- ... --============================================================================= -- 64-bit hash tests @@ -137,41 +140,48 @@ error: 'Invalid key part count in an exact match (expected 1, got 2)' ------------------------------------------------------------------------------- -- 64-bit hash inset fields tests ------------------------------------------------------------------------------- +box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num64') +--- +0: {0, 'primary', 1752392040, 1, 1, 0, 'num64'} +... +hash = box.space[0] +--- +... -- Insert valid fields -box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0') +hash:insert(0ULL, 'value1 v1.0', 'value2 v1.0') --- - - 0: {'value1 v1.0', 'value2 v1.0'} +0: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0') +hash:insert(1ULL, 'value1 v1.0', 'value2 v1.0') --- - - 1: {'value1 v1.0', 'value2 v1.0'} +1: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0') +hash:insert(2ULL, 'value1 v1.0', 'value2 v1.0') --- - - 2: {'value1 v1.0', 'value2 v1.0'} +2: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0') +hash:insert(3ULL, 'value1 v1.0', 'value2 v1.0') --- - - 3: {'value1 v1.0', 'value2 v1.0'} +3: {'value1 v1.0', 'value2 v1.0'} ... -- Insert invalid fields -box.space[11]:insert(100, 'value1 v1.0', 'value2 v1.0') +hash:insert(100, 'value1 v1.0', 'value2 v1.0') --- error: 'Tuple field 0 type does not match one required by operation: expected NUM64' ... -box.space[11]:insert(101, 'value1 v1.0', 'value2 v1.0') +hash:insert(101, 'value1 v1.0', 'value2 v1.0') --- error: 'Tuple field 0 type does not match one required by operation: expected NUM64' ... -box.space[11]:insert(102, 'value1 v1.0', 'value2 v1.0') +hash:insert(102, 'value1 v1.0', 'value2 v1.0') --- error: 'Tuple field 0 type does not match one required by operation: expected NUM64' ... -box.space[11]:insert(103, 'value1 v1.0', 'value2 v1.0') +hash:insert(103, 'value1 v1.0', 'value2 v1.0') --- error: 'Tuple field 0 type does not match one required by operation: expected NUM64' ... -box.space[11]:insert('invalid key', 'value1 v1.0', 'value2 v1.0') +hash:insert('invalid key', 'value1 v1.0', 'value2 v1.0') --- error: 'Tuple field 0 type does not match one required by operation: expected NUM64' ... @@ -179,32 +189,32 @@ error: 'Tuple field 0 type does not match one required by operation: expected NU -- 64-bit hash replace fields tests ------------------------------------------------------------------------------- -- Replace valid fields -box.space[11]:replace(3ULL, 'value1 v1.31', 'value2 1.12') +hash:replace(3ULL, 'value1 v1.31', 'value2 1.12') --- - - 3: {'value1 v1.31', 'value2 1.12'} +3: {'value1 v1.31', 'value2 1.12'} ... -box.space[11]:replace(1ULL, 'value1 v1.32', 'value2 1.72') +hash:replace(1ULL, 'value1 v1.32', 'value2 1.72') --- - - 1: {'value1 v1.32', 'value2 1.72'} +1: {'value1 v1.32', 'value2 1.72'} ... -box.space[11]:replace(2ULL, 'value1 v1.43', 'value2 1.92') +hash:replace(2ULL, 'value1 v1.43', 'value2 1.92') --- - - 2: {'value1 v1.43', 'value2 1.92'} +2: {'value1 v1.43', 'value2 1.92'} ... -- Replace invalid fields -box.space[11]:replace(3, 'value1 v1.31', 'value2 1.12') +hash:replace(3, 'value1 v1.31', 'value2 1.12') --- error: 'Tuple field 0 type does not match one required by operation: expected NUM64' ... -box.space[11]:replace(1, 'value1 v1.32', 'value2 1.72') +hash:replace(1, 'value1 v1.32', 'value2 1.72') --- error: 'Tuple field 0 type does not match one required by operation: expected NUM64' ... -box.space[11]:replace(2, 'value1 v1.43', 'value2 1.92') +hash:replace(2, 'value1 v1.43', 'value2 1.92') --- error: 'Tuple field 0 type does not match one required by operation: expected NUM64' ... -box.space[11]:replace('invalid key', 'value1 v1.0', 'value2 v1.0') +hash:replace('invalid key', 'value1 v1.0', 'value2 v1.0') --- error: 'Tuple field 0 type does not match one required by operation: expected NUM64' ... @@ -212,133 +222,136 @@ error: 'Tuple field 0 type does not match one required by operation: expected NU -- 64-bit hash select fields test ------------------------------------------------------------------------------- -- select by valid keys -box.space[11]:select(0, 0ULL) +hash:select(0, 0ULL) --- - - 0: {'value1 v1.0', 'value2 v1.0'} +0: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:select(0, 1ULL) +hash:select(0, 1ULL) --- - - 1: {'value1 v1.32', 'value2 1.72'} +1: {'value1 v1.32', 'value2 1.72'} ... -box.space[11]:select(0, 2ULL) +hash:select(0, 2ULL) --- - - 2: {'value1 v1.43', 'value2 1.92'} +2: {'value1 v1.43', 'value2 1.92'} ... -box.space[11]:select(0, 3ULL) +hash:select(0, 3ULL) --- - - 3: {'value1 v1.31', 'value2 1.12'} +3: {'value1 v1.31', 'value2 1.12'} ... -box.space[11]:select(0, 4ULL) +hash:select(0, 4ULL) --- ... -box.space[11]:select(0, 5ULL) +hash:select(0, 5ULL) --- ... -- select by valid NUM keys -box.space[11]:select(0, 0) +hash:select(0, 0) --- - - 0: {'value1 v1.0', 'value2 v1.0'} +0: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:select(0, 1) +hash:select(0, 1) --- - - 1: {'value1 v1.32', 'value2 1.72'} +1: {'value1 v1.32', 'value2 1.72'} ... -box.space[11]:select(0, 2) +hash:select(0, 2) --- - - 2: {'value1 v1.43', 'value2 1.92'} +2: {'value1 v1.43', 'value2 1.92'} ... -box.space[11]:select(0, 3) +hash:select(0, 3) --- - - 3: {'value1 v1.31', 'value2 1.12'} +3: {'value1 v1.31', 'value2 1.12'} ... -box.space[11]:select(0, 4) +hash:select(0, 4) --- ... -box.space[11]:select(0, 5) +hash:select(0, 5) --- ... -- select by invalid keys -box.space[11]:select(0, 'invalid key') +hash:select(0, 'invalid key') --- error: 'Supplied key type of part 0 does not match index part type: expected NUM64' ... -box.space[11]:select(0, '00000001', '00000002') +hash:select(0, '00000001', '00000002') --- -error: 'Invalid key part count (expected [0..1], got 2)' +error: Invalid key part count (expected [0..1], got 2) ... ------------------------------------------------------------------------------- -- 64-bit hash delete fields test ------------------------------------------------------------------------------- -- delete by valid keys -box.space[11]:delete(0ULL) +hash:delete(0ULL) --- - - 0: {'value1 v1.0', 'value2 v1.0'} +0: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:delete(1ULL) +hash:delete(1ULL) --- - - 1: {'value1 v1.32', 'value2 1.72'} +1: {'value1 v1.32', 'value2 1.72'} ... -box.space[11]:delete(2ULL) +hash:delete(2ULL) --- - - 2: {'value1 v1.43', 'value2 1.92'} +2: {'value1 v1.43', 'value2 1.92'} ... -box.space[11]:delete(3ULL) +hash:delete(3ULL) --- - - 3: {'value1 v1.31', 'value2 1.12'} +3: {'value1 v1.31', 'value2 1.12'} ... -box.space[11]:delete(4ULL) +hash:delete(4ULL) --- ... -box.space[11]:delete(5ULL) +hash:delete(5ULL) --- ... -box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0') +hash:insert(0ULL, 'value1 v1.0', 'value2 v1.0') --- - - 0: {'value1 v1.0', 'value2 v1.0'} +0: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0') +hash:insert(1ULL, 'value1 v1.0', 'value2 v1.0') --- - - 1: {'value1 v1.0', 'value2 v1.0'} +1: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0') +hash:insert(2ULL, 'value1 v1.0', 'value2 v1.0') --- - - 2: {'value1 v1.0', 'value2 v1.0'} +2: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0') +hash:insert(3ULL, 'value1 v1.0', 'value2 v1.0') --- - - 3: {'value1 v1.0', 'value2 v1.0'} +3: {'value1 v1.0', 'value2 v1.0'} ... -- delete by valid NUM keys -box.space[11]:delete(0) +hash:delete(0) --- - - 0: {'value1 v1.0', 'value2 v1.0'} +0: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:delete(1) +hash:delete(1) --- - - 1: {'value1 v1.0', 'value2 v1.0'} +1: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:delete(2) +hash:delete(2) --- - - 2: {'value1 v1.0', 'value2 v1.0'} +2: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:delete(3) +hash:delete(3) --- - - 3: {'value1 v1.0', 'value2 v1.0'} +3: {'value1 v1.0', 'value2 v1.0'} ... -box.space[11]:delete(4) +hash:delete(4) --- ... -box.space[11]:delete(5) +hash:delete(5) --- ... -- delete by invalid keys -box.space[11]:delete('invalid key') +hash:delete('invalid key') --- error: 'Supplied key type of part 0 does not match index part type: expected NUM64' ... -box.space[11]:delete('00000001', '00000002') +hash:delete('00000001', '00000002') +--- +error: Invalid key part count in an exact match (expected 1, got 2) +... +hash:truncate() --- -error: 'Invalid key part count in an exact match (expected 1, got 2)' ... --============================================================================= -- String hash tests @@ -346,314 +359,330 @@ error: 'Invalid key part count in an exact match (expected 1, got 2)' ------------------------------------------------------------------------------- -- String hash inset fields tests ------------------------------------------------------------------------------- +box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'str') +--- +0: {0, 'primary', 1752392040, 1, 1, 0, 'str'} +... +hash = box.space[0] +--- +... -- Insert valid fields -box.space[12]:insert('key 0', 'value1 v1.0', 'value2 v1.0') +hash:insert('key 0', 'value1 v1.0', 'value2 v1.0') --- - - 'key 0': {'value1 v1.0', 'value2 v1.0'} +'key 0': {'value1 v1.0', 'value2 v1.0'} ... -box.space[12]:insert('key 1', 'value1 v1.0', 'value2 v1.0') +hash:insert('key 1', 'value1 v1.0', 'value2 v1.0') --- - - 'key 1': {'value1 v1.0', 'value2 v1.0'} +'key 1': {'value1 v1.0', 'value2 v1.0'} ... -box.space[12]:insert('key 2', 'value1 v1.0', 'value2 v1.0') +hash:insert('key 2', 'value1 v1.0', 'value2 v1.0') --- - - 'key 2': {'value1 v1.0', 'value2 v1.0'} +'key 2': {'value1 v1.0', 'value2 v1.0'} ... -box.space[12]:insert('key 3', 'value1 v1.0', 'value2 v1.0') +hash:insert('key 3', 'value1 v1.0', 'value2 v1.0') --- - - 'key 3': {'value1 v1.0', 'value2 v1.0'} +'key 3': {'value1 v1.0', 'value2 v1.0'} ... ------------------------------------------------------------------------------- -- String hash replace fields tests ------------------------------------------------------------------------------- -- Replace valid fields -box.space[12]:replace('key 3', 'value1 v1.31', 'value2 1.12') +hash:replace('key 3', 'value1 v1.31', 'value2 1.12') --- - - 'key 3': {'value1 v1.31', 'value2 1.12'} +'key 3': {'value1 v1.31', 'value2 1.12'} ... -box.space[12]:replace('key 1', 'value1 v1.32', 'value2 1.72') +hash:replace('key 1', 'value1 v1.32', 'value2 1.72') --- - - 'key 1': {'value1 v1.32', 'value2 1.72'} +'key 1': {'value1 v1.32', 'value2 1.72'} ... -box.space[12]:replace('key 2', 'value1 v1.43', 'value2 1.92') +hash:replace('key 2', 'value1 v1.43', 'value2 1.92') --- - - 'key 2': {'value1 v1.43', 'value2 1.92'} +'key 2': {'value1 v1.43', 'value2 1.92'} ... ------------------------------------------------------------------------------- -- String hash select fields test ------------------------------------------------------------------------------- -- select by valid keys -box.space[12]:select(0, 'key 0') +hash:select(0, 'key 0') --- - - 'key 0': {'value1 v1.0', 'value2 v1.0'} +'key 0': {'value1 v1.0', 'value2 v1.0'} ... -box.space[12]:select(0, 'key 1') +hash:select(0, 'key 1') --- - - 'key 1': {'value1 v1.32', 'value2 1.72'} +'key 1': {'value1 v1.32', 'value2 1.72'} ... -box.space[12]:select(0, 'key 2') +hash:select(0, 'key 2') --- - - 'key 2': {'value1 v1.43', 'value2 1.92'} +'key 2': {'value1 v1.43', 'value2 1.92'} ... -box.space[12]:select(0, 'key 3') +hash:select(0, 'key 3') --- - - 'key 3': {'value1 v1.31', 'value2 1.12'} +'key 3': {'value1 v1.31', 'value2 1.12'} ... -box.space[12]:select(0, 'key 4') +hash:select(0, 'key 4') --- ... -box.space[12]:select(0, 'key 5') +hash:select(0, 'key 5') --- ... -- select by invalid keys -box.space[12]:select(0, 'key 1', 'key 2') +hash:select(0, 'key 1', 'key 2') --- -error: 'Invalid key part count (expected [0..1], got 2)' +error: Invalid key part count (expected [0..1], got 2) ... ------------------------------------------------------------------------------- -- String hash delete fields test ------------------------------------------------------------------------------- -- delete by valid keys -box.space[12]:delete('key 0') +hash:delete('key 0') --- - - 'key 0': {'value1 v1.0', 'value2 v1.0'} +'key 0': {'value1 v1.0', 'value2 v1.0'} ... -box.space[12]:delete('key 1') +hash:delete('key 1') --- - - 'key 1': {'value1 v1.32', 'value2 1.72'} +'key 1': {'value1 v1.32', 'value2 1.72'} ... -box.space[12]:delete('key 2') +hash:delete('key 2') --- - - 'key 2': {'value1 v1.43', 'value2 1.92'} +'key 2': {'value1 v1.43', 'value2 1.92'} ... -box.space[12]:delete('key 3') +hash:delete('key 3') --- - - 'key 3': {'value1 v1.31', 'value2 1.12'} +'key 3': {'value1 v1.31', 'value2 1.12'} ... -box.space[12]:delete('key 4') +hash:delete('key 4') --- ... -box.space[12]:delete('key 5') +hash:delete('key 5') --- ... -- delete by invalid keys -box.space[12]:delete('key 1', 'key 2') +hash:delete('key 1', 'key 2') --- -error: 'Invalid key part count in an exact match (expected 1, got 2)' +error: Invalid key part count in an exact match (expected 1, got 2) ... --- clean-up hash:truncate() --- ... -box.space[11]:truncate() +------------------------ +-- hash::replace tests +------------------------ +box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') +--- +0: {0, 'primary', 1752392040, 1, 1, 0, 'num'} +... +box.replace(box.schema.INDEX_ID, 0, 1, 'field1', 'hash', 1, 1, 1, 'num') --- +0: {1, 'field1', 1752392040, 1, 1, 1, 'num'} ... -box.space[12]:truncate() +box.replace(box.schema.INDEX_ID, 0, 2, 'field2', 'hash', 1, 1, 2, 'num') --- +0: {2, 'field2', 1752392040, 1, 1, 2, 'num'} ... ------------------------- --- hash::replace tests ------------------------- -box.space[21]:truncate() +box.replace(box.schema.INDEX_ID, 0, 3, 'field3', 'hash', 1, 1, 3, 'num') +--- +0: {3, 'field3', 1752392040, 1, 1, 3, 'num'} +... +hash = box.space[0] --- ... -box.space[21]:insert(0, 0, 0, 0) +hash:insert(0, 0, 0, 0) --- - - 0: {0, 0, 0} +0: {0, 0, 0} ... -box.space[21]:insert(1, 1, 1, 1) +hash:insert(1, 1, 1, 1) --- - - 1: {1, 1, 1} +1: {1, 1, 1} ... -box.space[21]:insert(2, 2, 2, 2) +hash:insert(2, 2, 2, 2) --- - - 2: {2, 2, 2} +2: {2, 2, 2} ... -- OK -box.replace_if_exists(21, 1, 1, 1, 1) +hash:replace_if_exists(1, 1, 1, 1) --- - - 1: {1, 1, 1} +1: {1, 1, 1} ... -box.replace_if_exists(21, 1, 10, 10, 10) +hash:replace_if_exists(1, 10, 10, 10) --- - - 1: {10, 10, 10} +1: {10, 10, 10} ... -box.replace_if_exists(21, 1, 1, 1, 1) +hash:replace_if_exists(1, 1, 1, 1) --- - - 1: {1, 1, 1} +1: {1, 1, 1} ... -box.space[21]:select(0, 10) +hash:select(0, 10) --- ... -box.space[21]:select(1, 10) +hash:select(1, 10) --- ... -box.space[21]:select(2, 10) +hash:select(2, 10) --- ... -box.space[21]:select(3, 10) +hash:select(3, 10) --- ... -box.space[21]:select(0, 1) +hash:select(0, 1) --- - - 1: {1, 1, 1} +1: {1, 1, 1} ... -box.space[21]:select(1, 1) +hash:select(1, 1) --- - - 1: {1, 1, 1} +1: {1, 1, 1} ... -box.space[21]:select(2, 1) +hash:select(2, 1) --- - - 1: {1, 1, 1} +1: {1, 1, 1} ... -box.space[21]:select(3, 1) +hash:select(3, 1) --- - - 1: {1, 1, 1} +1: {1, 1, 1} ... -- OK -box.space[21]:insert(10, 10, 10, 10) +hash:insert(10, 10, 10, 10) --- - - 10: {10, 10, 10} +10: {10, 10, 10} ... -box.space[21]:delete(10) +hash:delete(10) --- - - 10: {10, 10, 10} +10: {10, 10, 10} ... -box.space[21]:select(0, 10) +hash:select(0, 10) --- ... -box.space[21]:select(1, 10) +hash:select(1, 10) --- ... -box.space[21]:select(2, 10) +hash:select(2, 10) --- ... -box.space[21]:select(3, 10) +hash:select(3, 10) --- ... -- TupleFound (primary key) -box.space[21]:insert(1, 10, 10, 10) +hash:insert(1, 10, 10, 10) --- -error: 'Duplicate key exists in unique index 0' +error: Duplicate key exists in unique index 0 ... -box.space[21]:select(0, 10) +hash:select(0, 10) --- ... -box.space[21]:select(1, 10) +hash:select(1, 10) --- ... -box.space[21]:select(2, 10) +hash:select(2, 10) --- ... -box.space[21]:select(3, 10) +hash:select(3, 10) --- ... -box.space[21]:select(0, 1) +hash:select(0, 1) --- - - 1: {1, 1, 1} +1: {1, 1, 1} ... -- TupleNotFound (primary key) -box.replace_if_exists(21, 10, 10, 10, 10) +hash:replace_if_exists(10, 10, 10, 10) --- -error: 'Tuple doesn''t exist in index 0' +error: Tuple doesn't exist in index 0 ... -box.space[21]:select(0, 10) +hash:select(0, 10) --- ... -box.space[21]:select(1, 10) +hash:select(1, 10) --- ... -box.space[21]:select(2, 10) +hash:select(2, 10) --- ... -box.space[21]:select(3, 10) +hash:select(3, 10) --- ... -- TupleFound (key --1) -box.space[21]:insert(10, 0, 10, 10) +hash:insert(10, 0, 10, 10) --- -error: 'Duplicate key exists in unique index 1' +error: Duplicate key exists in unique index 1 ... -box.space[21]:select(0, 10) +hash:select(0, 10) --- ... -box.space[21]:select(1, 10) +hash:select(1, 10) --- ... -box.space[21]:select(2, 10) +hash:select(2, 10) --- ... -box.space[21]:select(3, 10) +hash:select(3, 10) --- ... -box.space[21]:select(1, 0) +hash:select(1, 0) --- - - 0: {0, 0, 0} +0: {0, 0, 0} ... -- TupleFound (key --1) -box.replace_if_exists(21, 2, 0, 10, 10) +hash:replace_if_exists(2, 0, 10, 10) --- -error: 'Duplicate key exists in unique index 1' +error: Duplicate key exists in unique index 1 ... -box.space[21]:select(0, 10) +hash:select(0, 10) --- ... -box.space[21]:select(1, 10) +hash:select(1, 10) --- ... -box.space[21]:select(2, 10) +hash:select(2, 10) --- ... -box.space[21]:select(3, 10) +hash:select(3, 10) --- ... -box.space[21]:select(1, 0) +hash:select(1, 0) --- - - 0: {0, 0, 0} +0: {0, 0, 0} ... -- TupleFound (key --3) -box.space[21]:insert(10, 10, 10, 0) +hash:insert(10, 10, 10, 0) --- -error: 'Duplicate key exists in unique index 3' +error: Duplicate key exists in unique index 3 ... -box.space[21]:select(0, 10) +hash:select(0, 10) --- ... -box.space[21]:select(1, 10) +hash:select(1, 10) --- ... -box.space[21]:select(2, 10) +hash:select(2, 10) --- ... -box.space[21]:select(3, 10) +hash:select(3, 10) --- ... -box.space[21]:select(3, 0) +hash:select(3, 0) --- - - 0: {0, 0, 0} +0: {0, 0, 0} ... -- TupleFound (key --3) -box.replace_if_exists(21, 2, 10, 10, 0) +hash:replace_if_exists(2, 10, 10, 0) --- -error: 'Duplicate key exists in unique index 3' +error: Duplicate key exists in unique index 3 ... -box.space[21]:select(0, 10) +hash:select(0, 10) --- ... -box.space[21]:select(1, 10) +hash:select(1, 10) --- ... -box.space[21]:select(2, 10) +hash:select(2, 10) --- ... -box.space[21]:select(3, 10) +hash:select(3, 10) --- ... -box.space[21]:select(3, 0) +hash:select(3, 0) --- - - 0: {0, 0, 0} +0: {0, 0, 0} ... -box.space[21]:truncate() +hash:drop() --- ... -- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua diff --git a/test/big/hash_multipart.result b/test/big/hash_multipart.result index cfea570e17..0101db27f5 100644 --- a/test/big/hash_multipart.result +++ b/test/big/hash_multipart.result @@ -1,43 +1,58 @@ dofile('utils.lua') --- ... +box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +--- +0: {0, 'tweedledum'} +... +box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 3, 0, 'num', 1, 'str', 2, 'num') +--- +0: {0, 'primary', 1752392040, 1, 3, 0, 'num', 1, 'str', 2, 'num'} +... +box.insert(box.schema.INDEX_ID, 0, 1, 'unique', 'hash', 1, 2, 2, 'num', 4, 'num') +--- +0: {1, 'unique', 1752392040, 1, 2, 2, 'num', 4, 'num'} +... +hash = box.space[0] +--- +... -- insert rows -box.space[27]:insert(0, 'foo', 0, '', 1) +hash:insert(0, 'foo', 0, '', 1) --- - - 0: {'foo', 0, '', 1} +0: {'foo', 0, '', 1} ... -box.space[27]:insert(0, 'foo', 1, '', 1) +hash:insert(0, 'foo', 1, '', 1) --- - - 0: {'foo', 1, '', 1} +0: {'foo', 1, '', 1} ... -box.space[27]:insert(1, 'foo', 0, '', 2) +hash:insert(1, 'foo', 0, '', 2) --- - - 1: {'foo', 0, '', 2} +1: {'foo', 0, '', 2} ... -box.space[27]:insert(1, 'foo', 1, '', 2) +hash:insert(1, 'foo', 1, '', 2) --- - - 1: {'foo', 1, '', 2} +1: {'foo', 1, '', 2} ... -box.space[27]:insert(0, 'bar', 0, '', 3) +hash:insert(0, 'bar', 0, '', 3) --- - - 0: {'bar', 0, '', 3} +0: {'bar', 0, '', 3} ... -box.space[27]:insert(0, 'bar', 1, '', 3) +hash:insert(0, 'bar', 1, '', 3) --- - - 0: {'bar', 1, '', 3} +0: {'bar', 1, '', 3} ... -box.space[27]:insert(1, 'bar', 0, '', 4) +hash:insert(1, 'bar', 0, '', 4) --- - - 1: {'bar', 0, '', 4} +1: {'bar', 0, '', 4} ... -box.space[27]:insert(1, 'bar', 1, '', 4) +hash:insert(1, 'bar', 1, '', 4) --- - - 1: {'bar', 1, '', 4} +1: {'bar', 1, '', 4} ... -- try to insert a row with a duplicate key -box.space[27]:insert(1, 'bar', 1, '', 5) +hash:insert(1, 'bar', 1, '', 5) --- -error: 'Duplicate key exists in unique index 0' +error: Duplicate key exists in unique index 0 ... -- output all rows -- setopt delimiter ';' @@ -51,66 +66,69 @@ end; --- ... -- setopt delimiter '' -unpack(box.sort(box.select_all(27))) +box.sort(box.select_all(0)) --- - - 0: {'bar', 0, '', 3} - - 0: {'bar', 1, '', 3} - - 0: {'foo', 0, '', 1} - - 0: {'foo', 1, '', 1} - - 1: {'bar', 0, '', 4} - - 1: {'bar', 1, '', 4} - - 1: {'foo', 0, '', 2} - - 1: {'foo', 1, '', 2} +-0: {'bar', 0, '', 3} +-0: {'bar', 1, '', 3} +-0: {'foo', 0, '', 1} +-0: {'foo', 1, '', 1} +-1: {'bar', 0, '', 4} +-1: {'bar', 1, '', 4} +-1: {'foo', 0, '', 2} +-1: {'foo', 1, '', 2} ... -- primary index select -box.space[27]:select(0, 1, 'foo', 0) +hash:select(0, 1, 'foo', 0) --- - - 1: {'foo', 0, '', 2} +1: {'foo', 0, '', 2} ... -box.space[27]:select(0, 1, 'bar', 0) +hash:select(0, 1, 'bar', 0) --- - - 1: {'bar', 0, '', 4} +1: {'bar', 0, '', 4} ... -- primary index select with missing part -box.space[27]:select(0, 1, 'foo') +hash:select(0, 1, 'foo') --- -error: 'Invalid key part count in an exact match (expected 3, got 2)' +error: Invalid key part count in an exact match (expected 3, got 2) ... -- primary index select with extra part -box.space[27]:select(0, 1, 'foo', 0, 0) +hash:select(0, 1, 'foo', 0, 0) --- -error: 'Invalid key part count (expected [0..3], got 4)' +error: Invalid key part count (expected [0..3], got 4) ... -- primary index select with wrong type -box.space[27]:select(0, 1, 'foo', 'baz') +hash:select(0, 1, 'foo', 'baz') --- error: 'Supplied key type of part 2 does not match index part type: expected NUM' ... -- secondary index select -box.space[27]:select(1, 1, 4) +hash:select(1, 1, 4) --- - - 1: {'bar', 1, '', 4} +1: {'bar', 1, '', 4} ... -- secondary index select with no such key -box.space[27]:select(1, 1, 5) +hash:select(1, 1, 5) --- ... -- secondary index select with missing part -box.space[27]:select(1, 1) +hash:select(1, 1) --- -error: 'Invalid key part count in an exact match (expected 2, got 1)' +error: Invalid key part count in an exact match (expected 2, got 1) ... -- secondary index select with wrong type -box.space[27]:select(1, 1, 'baz') +hash:select(1, 1, 'baz') --- error: 'Supplied key type of part 1 does not match index part type: expected NUM' ... -- cleanup -box.space[27]:truncate() +hash:truncate() +--- +... +hash:len() --- +0 ... -box.space[27]:len() +hash:drop() --- - - 0 ... -- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua diff --git a/test/big/hash_multipart.test.lua b/test/big/hash_multipart.test.lua index 610c00f567..f789e7a634 100644 --- a/test/big/hash_multipart.test.lua +++ b/test/big/hash_multipart.test.lua @@ -1,17 +1,22 @@ dofile('utils.lua') +box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 3, 0, 'num', 1, 'str', 2, 'num') +box.insert(box.schema.INDEX_ID, 0, 1, 'unique', 'hash', 1, 2, 2, 'num', 4, 'num') +hash = box.space[0] + -- insert rows -box.space[27]:insert(0, 'foo', 0, '', 1) -box.space[27]:insert(0, 'foo', 1, '', 1) -box.space[27]:insert(1, 'foo', 0, '', 2) -box.space[27]:insert(1, 'foo', 1, '', 2) -box.space[27]:insert(0, 'bar', 0, '', 3) -box.space[27]:insert(0, 'bar', 1, '', 3) -box.space[27]:insert(1, 'bar', 0, '', 4) -box.space[27]:insert(1, 'bar', 1, '', 4) +hash:insert(0, 'foo', 0, '', 1) +hash:insert(0, 'foo', 1, '', 1) +hash:insert(1, 'foo', 0, '', 2) +hash:insert(1, 'foo', 1, '', 2) +hash:insert(0, 'bar', 0, '', 3) +hash:insert(0, 'bar', 1, '', 3) +hash:insert(1, 'bar', 0, '', 4) +hash:insert(1, 'bar', 1, '', 4) -- try to insert a row with a duplicate key -box.space[27]:insert(1, 'bar', 1, '', 5) +hash:insert(1, 'bar', 1, '', 5) -- output all rows @@ -24,29 +29,30 @@ function box.select_all(space) return result end; -- setopt delimiter '' -unpack(box.sort(box.select_all(27))) +box.sort(box.select_all(0)) -- primary index select -box.space[27]:select(0, 1, 'foo', 0) -box.space[27]:select(0, 1, 'bar', 0) +hash:select(0, 1, 'foo', 0) +hash:select(0, 1, 'bar', 0) -- primary index select with missing part -box.space[27]:select(0, 1, 'foo') +hash:select(0, 1, 'foo') -- primary index select with extra part -box.space[27]:select(0, 1, 'foo', 0, 0) +hash:select(0, 1, 'foo', 0, 0) -- primary index select with wrong type -box.space[27]:select(0, 1, 'foo', 'baz') +hash:select(0, 1, 'foo', 'baz') -- secondary index select -box.space[27]:select(1, 1, 4) +hash:select(1, 1, 4) -- secondary index select with no such key -box.space[27]:select(1, 1, 5) +hash:select(1, 1, 5) -- secondary index select with missing part -box.space[27]:select(1, 1) +hash:select(1, 1) -- secondary index select with wrong type -box.space[27]:select(1, 1, 'baz') +hash:select(1, 1, 'baz') -- cleanup -box.space[27]:truncate() -box.space[27]:len() +hash:truncate() +hash:len() +hash:drop() -- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua diff --git a/test/big/sql.result b/test/big/sql.result index dfa6157e65..9812ef58b3 100644 --- a/test/big/sql.result +++ b/test/big/sql.result @@ -1,14 +1,14 @@ box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') --- -'0: {0, ''tweedledum''}' +0: {0, 'tweedledum'} ... box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'str') --- -'0: {0, ''primary'', 1752392040, 1, 1, 0, ''str''}' +0: {0, 'primary', 1752392040, 1, 1, 0, 'str'} ... box.insert(box.schema.INDEX_ID, 0, 1, 'secondary', 'tree', 0, 1, 1, 'str') --- -'0: {1, ''secondary'', 1701147252, 0, 1, 1, ''str''}' +0: {1, 'secondary', 1701147252, 0, 1, 1, 'str'} ... # # A test case for Bug#729758 @@ -84,7 +84,7 @@ box.space[0]:truncate() # box.replace(box.schema.INDEX_ID, 0, 1, 'secondary', 'tree', 1, 2, 1, 'str', 2, 'str') --- -'0: {1, ''secondary'', 1701147252, 1, 2, 1, ''str'', 2, ''str''}' +0: {1, 'secondary', 1701147252, 1, 2, 1, 'str', 2, 'str'} ... insert into t0 values ('key1', 'part1', 'part2') Insert OK, 1 row affected @@ -96,9 +96,9 @@ insert into t0 values ('key3', 'part1', 'part2_b') Insert OK, 1 row affected return { box.space[0]:select(1) } --- -- '830039403: {''part1'', ''part2''}' -- '846816619: {''part1'', ''part2_a''}' -- '863593835: {''part1'', ''part2_b''}' +-830039403: {'part1', 'part2'} +-846816619: {'part1', 'part2_a'} +-863593835: {'part1', 'part2_b'} ... select * from t0 where k0='key1' Found 1 tuple: @@ -153,11 +153,11 @@ box.space[0]:truncate() ... box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num64') --- -'0: {0, ''primary'', 1701147252, 1, 1, 0, ''num64''}' +0: {0, 'primary', 1701147252, 1, 1, 0, 'num64'} ... box.replace(box.schema.INDEX_ID, 0, 1, 'secondary', 'tree', 0, 2, 1, 'str', 2, 'str') --- -'0: {1, ''secondary'', 1701147252, 0, 2, 1, ''str'', 2, ''str''}' +0: {1, 'secondary', 1701147252, 0, 2, 1, 'str', 2, 'str'} ... insert into t0 values ('01234567', 'part1', 'part2') Insert OK, 1 row affected @@ -177,11 +177,11 @@ for k, v in box.space[0]:pairs() do table.insert(l, v) end ... return l --- -- '3978425819141910832: {''part1'', ''part2''}' -- '3978425819141910833: {''part1'', ''part2''}' -- '3978425819141910834: {''part1'', ''part2_a''}' -- '3978425819141910835: {''part1_a'', ''part2''}' -- '3978425819141910836: {''part1_a'', ''part2_a''}' +-3978425819141910832: {'part1', 'part2'} +-3978425819141910833: {'part1', 'part2'} +-3978425819141910834: {'part1', 'part2_a'} +-3978425819141910835: {'part1_a', 'part2'} +-3978425819141910836: {'part1_a', 'part2_a'} ... select * from t0 where k0='01234567' Found 1 tuple: @@ -233,11 +233,11 @@ box.space[0]:truncate() ... box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') --- -'0: {0, ''primary'', 1752392040, 1, 1, 0, ''num''}' +0: {0, 'primary', 1752392040, 1, 1, 0, 'num'} ... box.replace(box.schema.INDEX_ID, 0, 1, 'secondary', 'hash', 1, 1, 1, 'str') --- -'0: {1, ''secondary'', 1752392040, 1, 1, 1, ''str''}' +0: {1, 'secondary', 1752392040, 1, 1, 1, 'str'} ... insert into t0 values (1, 'hello') Insert OK, 1 row affected @@ -273,11 +273,11 @@ box.space[0]:truncate() box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'str') --- -'0: {0, ''primary'', 1752392040, 1, 1, 0, ''str''}' +0: {0, 'primary', 1752392040, 1, 1, 0, 'str'} ... box.replace(box.schema.INDEX_ID, 0, 1, 'secondary', 'tree', 0, 1, 1, 'str') --- -'0: {1, ''secondary'', 1701147252, 0, 1, 1, ''str''}' +0: {1, 'secondary', 1701147252, 0, 1, 1, 'str'} ... insert into t0 values ('Spears', 'Britney') Insert OK, 1 row affected @@ -383,9 +383,9 @@ insert into t0 values(3, 'Creature ') Insert OK, 1 row affected { box.space[0]:select(1) } --- -- '1: {''Aardvark ''}' -- '2: {''Bilimbi''}' -- '3: {''Creature ''}' +-1: {'Aardvark '} +-2: {'Bilimbi'} +-3: {'Creature '} ... box.space[0].index[0].idx:min() --- @@ -397,11 +397,11 @@ error: HASH does not support max() ... box.space[0].index[1].idx:min() --- -'1: {''Aardvark ''}' +1: {'Aardvark '} ... box.space[0].index[1].idx:max() --- -'3: {''Creature ''}' +3: {'Creature '} ... delete from t0 where k0=1 Delete OK, 1 row affected -- GitLab