Commit 6894f441 authored by Rich Prohaska's avatar Rich Prohaska

refs #5333 #5334 randomize field expansion tests

git-svn-id: file:///svn/mysql/tests/mysql-test@47709 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6e80699f
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -6,4 +6,9 @@ T = $(patsubst %.py,%.test,$(S)) ...@@ -6,4 +6,9 @@ T = $(patsubst %.py,%.test,$(S))
default: $(T) default: $(T)
%.test: %.py %.test: %.py
python $< >$@ python $< >$@
\ No newline at end of file
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=1 >change_all_1000_1.test
import sys import sys
import random import random
import string import string
import re
class Field: class Field:
def __init__(self, name, is_nullible): def __init__(self, name, is_nullible):
...@@ -134,7 +135,12 @@ class Field_blob(Field): ...@@ -134,7 +135,12 @@ class Field_blob(Field):
def main(): def main():
experiments = 1000 experiments = 1000
nrows = 10 nrows = 10
random.seed(0) seed = 0
for arg in sys.argv[1:]:
match = re.match("--(.*)=(.*)", arg)
if match:
exec("%s = %s" % (match.group(1),match.group(2)))
random.seed(seed)
header() header()
for experiment in range(experiments): for experiment in range(experiments):
# generate a schema # generate a schema
...@@ -145,32 +151,30 @@ def main(): ...@@ -145,32 +151,30 @@ def main():
# insert some rows # insert some rows
for r in range(nrows): for r in range(nrows):
print insert_row(fields) print insert_row(fields) % ('t')
print "CREATE TABLE ti LIKE t;" print "CREATE TABLE ti LIKE t;"
print "ALTER TABLE ti ENGINE=myisam;" print "ALTER TABLE ti ENGINE=myisam;"
print "INSERT INTO ti SELECT * FROM t;" print "INSERT INTO ti SELECT * FROM t;"
# compare tables
print "let $diff_tables = test.t, test.ti;"
print "source include/diff_tables.inc;"
# change fixed column # change fixed column
next_field = fields[0].next_field('') next_field = fields[0].next_field('')
print "ALTER TABLE t CHANGE COLUMN a a %s;" % (next_field.get_type()) print "ALTER TABLE t CHANGE COLUMN a a %s;" % (next_field.get_type())
print "ALTER TABLE ti CHANGE COLUMN a a %s;" % (next_field.get_type()) print "ALTER TABLE ti CHANGE COLUMN a a %s;" % (next_field.get_type())
# add some more rows # add some more rows
new_row = insert_row(fields)
# compare tables print new_row % ('t')
print "let $diff_tables = test.t, test.ti;" print new_row % ('ti')
print "source include/diff_tables.inc;"
# change variable column # change variable column
next_field = fields[3].next_field('') next_field = fields[3].next_field('')
print "ALTER TABLE t CHANGE COLUMN d dd %s;" % (next_field.get_type()) print "ALTER TABLE t CHANGE COLUMN d dd %s;" % (next_field.get_type())
print "ALTER TABLE ti CHANGE COLUMN d dd %s;" % (next_field.get_type()) print "ALTER TABLE ti CHANGE COLUMN d dd %s;" % (next_field.get_type())
# add some more rows # add a row
new_row = insert_row(fields)
print new_row % ('t')
print new_row % ('ti')
# compare tables # compare tables
print "let $diff_tables = test.t, test.ti;" print "let $diff_tables = test.t, test.ti;"
...@@ -213,7 +217,7 @@ def create_table(fields): ...@@ -213,7 +217,7 @@ def create_table(fields):
return t return t
def insert_row(fields): def insert_row(fields):
t = "INSERT INTO t VALUES (" t = "INSERT INTO %s VALUES ("
for i in range(len(fields)): for i in range(len(fields)):
f = fields[i] f = fields[i]
t += "%s" % (f.get_value()) t += "%s" % (f.get_value())
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment