mirror of
https://github.com/MariaDB/server.git
synced 2025-01-21 06:22:28 +01:00
git-svn-id: file:///svn/mysql/tests/mysql-test@47723 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
03fbdfbd0b
commit
6ef13917e3
6 changed files with 106210 additions and 75458 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -11,4 +11,5 @@ default: $(T)
|
||||||
change_all.test: change_all.py
|
change_all.test: change_all.py
|
||||||
python change_all.py --experiments=1000 --nrows=10 >change_all_1000_10.test
|
python change_all.py --experiments=1000 --nrows=10 >change_all_1000_10.test
|
||||||
python change_all.py --experiments=1000 --nrows=1 >change_all_1000_1.test
|
python change_all.py --experiments=1000 --nrows=1 >change_all_1000_1.test
|
||||||
|
python change_all.py --experiments=10000 --nrows=1 >change_all_10000_1.test
|
||||||
|
|
||||||
|
|
|
@ -9,52 +9,31 @@ class Field:
|
||||||
self.is_nullible = is_nullible
|
self.is_nullible = is_nullible
|
||||||
|
|
||||||
class Field_int(Field):
|
class Field_int(Field):
|
||||||
|
sizes = [ 1, 2, 3, 4, 8 ]
|
||||||
|
next_size = [ 2, 3, 4, 8, 8 ]
|
||||||
|
types = [ "TINYINT", "SMALLINT", "MEDIUMINT", "INT", "BIGINT" ]
|
||||||
|
int_ranges = [ (0,(1<<8)-1), (0,(1<<16)-1), (0,(1<<24)-1), (0,(1<<32)-1), (0,(1<<64)-1) ]
|
||||||
|
uint_ranges = [ (-(1<<7), (1<<7)-1), (-(1<<15),(1<<15)-1), (-(1<<23),(1<<23)-1), (-(1<<31),(1<<31)-1), (-(1<<63),(1<<63)-1) ]
|
||||||
def __init__(self, name, size, is_unsigned, is_nullible):
|
def __init__(self, name, size, is_unsigned, is_nullible):
|
||||||
Field.__init__(self, name, is_nullible)
|
Field.__init__(self, name, is_nullible)
|
||||||
assert size == 1 or size == 2 or size == 3 or size == 4 or size == 8
|
self.idx = Field_int.sizes.index(size)
|
||||||
self.size = size
|
self.size = size
|
||||||
self.is_unsigned = is_unsigned
|
self.is_unsigned = is_unsigned
|
||||||
if self.size == 1:
|
|
||||||
self.max_value = (1<<7)-1
|
|
||||||
elif self.size == 2:
|
|
||||||
self.max_value = (1<<15)-1
|
|
||||||
elif self.size == 3:
|
|
||||||
self.max_value = (1<<23)-1
|
|
||||||
elif self.size == 4:
|
|
||||||
self.max_value = (1<<31)-1
|
|
||||||
else:
|
|
||||||
self.max_value = (1<<63)-1
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
if self.size == 1:
|
t = Field_int.types[self.idx]
|
||||||
t = "TINYINT"
|
|
||||||
elif self.size == 2:
|
|
||||||
t = "SMALLINT"
|
|
||||||
elif self.size == 3:
|
|
||||||
t = "MEDIUMINT"
|
|
||||||
elif self.size == 4:
|
|
||||||
t = "INT"
|
|
||||||
else:
|
|
||||||
t = "BIGINT"
|
|
||||||
if self.is_unsigned:
|
if self.is_unsigned:
|
||||||
t += " UNSIGNED"
|
t += " UNSIGNED"
|
||||||
if not self.is_nullible:
|
if not self.is_nullible:
|
||||||
t += " NOT NULL"
|
t += " NOT NULL"
|
||||||
return t
|
return t
|
||||||
def get_value(self):
|
def get_value(self):
|
||||||
return random.randint(0, self.max_value)
|
if self.is_unsigned:
|
||||||
|
r = Field_int.uint_ranges[self.idx]
|
||||||
def next_field(self, name):
|
|
||||||
if self.size == 1:
|
|
||||||
new_size = 2
|
|
||||||
elif self.size == 2:
|
|
||||||
new_size = 3
|
|
||||||
elif self.size == 3:
|
|
||||||
new_size = 4
|
|
||||||
elif self.size == 4:
|
|
||||||
new_size = 8
|
|
||||||
else:
|
else:
|
||||||
new_size = 8
|
r = Field_int.int_ranges[self.idx]
|
||||||
return Field_int(name, new_size, self.is_unsigned, self.is_nullible)
|
return random.randint(r[0],r[1])
|
||||||
|
def next_field(self, name):
|
||||||
|
return Field_int(name, Field_int.next_size[self.idx], self.is_unsigned, self.is_nullible)
|
||||||
|
|
||||||
class Field_int_auto_inc(Field_int):
|
class Field_int_auto_inc(Field_int):
|
||||||
def __init__(self, name, size, is_unsigned, is_nullible):
|
def __init__(self, name, size, is_unsigned, is_nullible):
|
||||||
|
@ -68,17 +47,14 @@ class Field_int_auto_inc(Field_int):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
class Field_char(Field):
|
class Field_char(Field):
|
||||||
|
types = [ "CHAR", "BINARY" ]
|
||||||
def __init__(self, name, size, is_binary, is_nullible):
|
def __init__(self, name, size, is_binary, is_nullible):
|
||||||
Field.__init__(self, name, is_nullible)
|
Field.__init__(self, name, is_nullible)
|
||||||
assert 0 <= size and size < 256
|
assert 0 <= size and size < 256
|
||||||
self.size = size
|
self.size = size
|
||||||
self.is_binary = is_binary
|
self.is_binary = is_binary
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
if self.is_binary:
|
t = "%s(%d)" % (Field_char.types[self.is_binary], self.size)
|
||||||
t = "BINARY"
|
|
||||||
else:
|
|
||||||
t = "CHAR"
|
|
||||||
t += "(%d)" % (self.size)
|
|
||||||
if not self.is_nullible:
|
if not self.is_nullible:
|
||||||
t += " NOT NULL"
|
t += " NOT NULL"
|
||||||
return t
|
return t
|
||||||
|
@ -92,17 +68,14 @@ class Field_char(Field):
|
||||||
return "'%s'" % (s)
|
return "'%s'" % (s)
|
||||||
|
|
||||||
class Field_varchar(Field):
|
class Field_varchar(Field):
|
||||||
|
types = [ "VARCHAR", "VARBINARY" ]
|
||||||
def __init__(self, name, size, is_binary, is_nullible):
|
def __init__(self, name, size, is_binary, is_nullible):
|
||||||
Field.__init__(self, name, is_nullible)
|
Field.__init__(self, name, is_nullible)
|
||||||
assert 0 <= size and size < 64*1024
|
assert 0 <= size and size < 64*1024
|
||||||
self.size= size
|
self.size= size
|
||||||
self.is_binary = is_binary
|
self.is_binary = is_binary
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
if self.is_binary:
|
t = "%s(%d)" % (Field_varchar.types[self.is_binary], self.size)
|
||||||
t = "VARBINARY"
|
|
||||||
else:
|
|
||||||
t = "VARCHAR"
|
|
||||||
t += "(%d)" % (self.size)
|
|
||||||
if not self.is_nullible:
|
if not self.is_nullible:
|
||||||
t += " NOT NULL"
|
t += " NOT NULL"
|
||||||
return t;
|
return t;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue