1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
import sys
import random
import string
def main():
print "# this test is generated by change_column_blob_data.py"
print "# generate hot blob expansion test cases"
print "source include/have_tokudb.inc;"
print "--disable_warnings"
print "DROP TABLE IF EXISTS t, ti;"
print "--enable_warnings"
print "SET SESSION DEFAULT_STORAGE_ENGINE=\"TokuDB\";"
print "SET SESSION TOKUDB_DISABLE_SLOW_ALTER=1;"
for f in [ "", "f INT DEFAULT 0", "f INT DEFAULT 0 NOT NULL" ]:
for v in [ "", "v VARCHAR(32) DEFAULT ''", "v VARCHAR(32) DEFAULT '' NOT NULL" ]:
for nn in [ "", "NOT NULL" ]:
gen_test(f, v, nn)
return 0
def gen_test(f, v, nn):
blob_types = [ "TINYBLOB", "BLOB", "MEDIUMBLOB", "LONGBLOB" ]
print gen_table(f, v, nn)
for r in range(3):
print insert_row("t")
print "CREATE TABLE ti LIKE t;"
print "ALTER TABLE ti ENGINE=myisam;"
print "INSERT INTO ti SELECT * FROM t;"
for i in range(len(blob_types)):
print "ALTER TABLE t CHANGE COLUMN a a %s %s;" % (blob_types[i], nn)
print "ALTER TABLE ti CHANGE COLUMN a a %s %s;" % (blob_types[i], nn)
for i in range(len(blob_types)):
print "ALTER TABLE t CHANGE COLUMN b b %s %s;" % (blob_types[i], nn)
print "ALTER TABLE ti CHANGE COLUMN b b %s %s;" % (blob_types[i], nn)
# compare tables
print "let $diff_tables = test.t, test.ti;"
print "source include/diff_tables.inc;"
print "DROP TABLE t, ti;"
def gen_table(f, v, nn):
t = "CREATE TABLE t ("
if f != "":
t += "%s, " % (f)
if v != "":
t += "%s, " % (v)
t += "a TINYBLOB %s, b TINYBLOB %s);" % (nn, nn)
return t
def insert_row(t):
t = "INSERT INTO %s (a, b) VALUES (" % (t)
l = random.randint(1, 32)
s = ''.join(random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits) for x in range(l))
t += "'%s'," % (s)
l = random.randint(1, 260)
s = ''.join(random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits) for x in range(l))
t += "'%s');" % (s)
return t
sys.exit(main())
|