diff --git a/test/big/tree_variants.result b/test/big/tree_variants.result index 38a773653e26cbd586cefbaa9a6e6c4393e43f06..e72ecc90c2df10bfd01d1b5d8d94192a89f61838 100644 --- a/test/big/tree_variants.result +++ b/test/big/tree_variants.result @@ -62,15 +62,23 @@ space:insert{9, 9, 400, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009} --- - [9, 9, 400, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009] ... +-- In non-unique indexes select output order is undefined, +-- so it's better to additionally sort output to receive same order every time. +function sort_cmp(a, b) return a[1] < b[1] and true or false end +--- +... +function sort(t) table.sort(t, sort_cmp) return t end +--- +... space.index['primary']:get{1} --- - [1, 1, 200, 'Joe', 'Sixpack', 'Drinks', 'Heineken', 'bar', 2001] ... -space.index['i1']:select{2} +sort(space.index['i1']:select{2}) --- - - [2, 2, 200, 'Joe', 'Sixpack', 'Drinks', 'Carlsberg', 'bar', 2002] ... -space.index[2]:select({300}) +sort(space.index[2]:select({300})) --- - - [3, 3, 300, 'Joe', 'Sixpack', 'Drinks', 'Corona Extra', 'bar', 2003] - [4, 4, 300, 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004] @@ -88,15 +96,15 @@ space.index[2]:select({300}) --- - 1 ... -{space.index['i4']:select{'Miller Genuine Draft', 'Drinks'}} +{sort(space.index['i4']:select{'Miller Genuine Draft', 'Drinks'})} --- - - - [5, 5, 300, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005] ... -space.index['i5']:select{2007} +sort(space.index['i5']:select{2007}) --- - - [7, 7, 400, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007] ... -space.index[6]:select{'Miller Genuine Draft', 'Drinks'} +sort(space.index[6]:select{'Miller Genuine Draft', 'Drinks'}) --- - - [5, 5, 300, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005] ... @@ -132,29 +140,29 @@ space:insert{9, 9ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009} --- - [9, 9, 400, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009] ... -space.index['i1']:select{6ULL} +sort(space.index['i1']:select{6ULL}) --- - - [6, 6, 400, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006] ... -space.index['i1']:select{6} +sort(space.index['i1']:select{6}) --- - - [6, 6, 400, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006] ... -space.index['i2']:select(400ULL) +sort(space.index['i2']:select(400ULL)) --- - - [6, 6, 400, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006] - [7, 7, 400, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007] - [8, 8, 400, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008] - [9, 9, 400, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009] ... -space.index['i2']:select(400) +sort(space.index['i2']:select(400)) --- - - [6, 6, 400, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006] - [7, 7, 400, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007] - [8, 8, 400, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008] - [9, 9, 400, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009] ... -space:select{} +sort(space:select{}) --- - - [0, 0, 100, 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000] - [1, 1, 200, 'Joe', 'Sixpack', 'Drinks', 'Heineken', 'bar', 2001] @@ -188,3 +196,9 @@ space:insert{1, 'xxxxxxxxxxx', 2, '', '', '', '', '', 0} space:drop() --- ... +sort = nil +--- +... +sort_cmp = nul +--- +... diff --git a/test/big/tree_variants.test.lua b/test/big/tree_variants.test.lua index 58a946ba6763bdee5b3089771f8954a8606a6877..2508927122e58b8debc7608c38a97d407fcbc775 100644 --- a/test/big/tree_variants.test.lua +++ b/test/big/tree_variants.test.lua @@ -18,15 +18,20 @@ space:insert{7, 7, 400, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007} space:insert{8, 8, 400, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008} space:insert{9, 9, 400, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009} +-- In non-unique indexes select output order is undefined, +-- so it's better to additionally sort output to receive same order every time. +function sort_cmp(a, b) return a[1] < b[1] and true or false end +function sort(t) table.sort(t, sort_cmp) return t end + space.index['primary']:get{1} -space.index['i1']:select{2} -space.index[2]:select({300}) +sort(space.index['i1']:select{2}) +sort(space.index[2]:select({300})) #space.index['i3']:select({'Joe', 'Sixpack'}) #space.index['i3']:select('John') #space.index['i4']:select('A Pipe') -{space.index['i4']:select{'Miller Genuine Draft', 'Drinks'}} -space.index['i5']:select{2007} -space.index[6]:select{'Miller Genuine Draft', 'Drinks'} +{sort(space.index['i4']:select{'Miller Genuine Draft', 'Drinks'})} +sort(space.index['i5']:select{2007}) +sort(space.index[6]:select{'Miller Genuine Draft', 'Drinks'}) space:delete{6} space:delete{7} @@ -38,12 +43,12 @@ space:insert{7, 7ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007} space:insert{8, 8ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008} space:insert{9, 9ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009} -space.index['i1']:select{6ULL} -space.index['i1']:select{6} -space.index['i2']:select(400ULL) -space.index['i2']:select(400) +sort(space.index['i1']:select{6ULL}) +sort(space.index['i1']:select{6}) +sort(space.index['i2']:select(400ULL)) +sort(space.index['i2']:select(400)) -space:select{} +sort(space:select{}) -- Test incorrect keys - supplied key field type does not match index type -- https://bugs.launchpad.net/tarantool/+bug/1072624 @@ -53,3 +58,5 @@ space:insert{1, '', 2, '', '', '', '', '', 0} space:insert{1, 'xxxxxxxxxxx', 2, '', '', '', '', '', 0} space:drop() +sort = nil +sort_cmp = nul