Skip to content
Snippets Groups Projects
Commit c31ebd74 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Fix a sporadic test failure (retrieving duplicate keys).

Duplicate keys are sorted by tuple pointer value.
This led to non-stable test output when retrieving
all duplicates.
Sort results in the test runner to avoid sporadic
errors.
parent d72f22fe
No related branches found
No related tags found
No related merge requests found
......@@ -236,11 +236,11 @@ Found 5 tuples:
[5, 'duplicate one']
select * from t4 where k1='duplicate two'
Found 5 tuples:
[10, 'duplicate two']
[6, 'duplicate two']
[7, 'duplicate two']
[8, 'duplicate two']
[9, 'duplicate two']
[10, 'duplicate two']
select * from t4 where k1='duplicate three'
Found 5 tuples:
[11, 'duplicate three']
......
......@@ -131,9 +131,11 @@ exec sql "insert into t4 values (12, 'duplicate three')"
exec sql "insert into t4 values (13, 'duplicate three')"
exec sql "insert into t4 values (14, 'duplicate three')"
exec sql "insert into t4 values (15, 'duplicate three')"
sql.sort = True
exec sql "select * from t4 where k1='duplicate one'"
exec sql "select * from t4 where k1='duplicate two'"
exec sql "select * from t4 where k1='duplicate three'"
sql.sort = False
exec sql "delete from t4 where k0=1"
exec sql "delete from t4 where k0=2"
exec sql "delete from t4 where k0=3"
......
......@@ -27,6 +27,9 @@ import struct
from tarantool_connection import TarantoolConnection
class BoxConnection(TarantoolConnection):
def __init__(self, host, port):
super(BoxConnection, self).__init__(host, port)
self.sort = False
def recvall(self, length):
res = ""
......@@ -42,6 +45,7 @@ class BoxConnection(TarantoolConnection):
statement = sql.parse("sql", command)
if statement == None:
return "You have an error in your SQL syntax\n"
statement.sort = self.sort
payload = statement.pack()
header = struct.pack("<lll", statement.reqeust_type, len(payload), 0)
......
......@@ -299,6 +299,8 @@ class StatementSelect(StatementPing):
while len(tuples) < tuple_count:
(next_tuple, offset) = unpack_tuple(response, offset)
tuples.append(next_tuple)
if self.sort:
tuples.sort()
if tuple_count == 0:
return "No match"
elif tuple_count == 1:
......
......@@ -26,7 +26,7 @@ import sys
import cStringIO
import errno
class TarantoolConnection:
class TarantoolConnection(object):
def __init__(self, host, port):
self.host = host
self.port = port
......
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