Commit 2ed0f958 authored by Rich Prohaska's avatar Rich Prohaska

#64 get hot text and blob column expansion working

parent c9f8f20b
......@@ -27,7 +27,6 @@ CREATE TABLE t (a TINYBLOB NULL);
ALTER TABLE t CHANGE COLUMN a a TEXT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a BLOB NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TINYBLOB NULL);
ALTER TABLE t CHANGE COLUMN a a TEXT NOT NULL;
......@@ -45,13 +44,11 @@ CREATE TABLE t (a TINYBLOB NOT NULL);
ALTER TABLE t CHANGE COLUMN a a TEXT NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a BLOB NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TINYBLOB NULL);
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TINYBLOB NULL);
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NOT NULL;
......@@ -69,13 +66,11 @@ CREATE TABLE t (a TINYBLOB NOT NULL);
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TINYBLOB NULL);
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TINYBLOB NULL);
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
......@@ -93,7 +88,6 @@ CREATE TABLE t (a TINYBLOB NOT NULL);
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a BLOB NULL);
ALTER TABLE t CHANGE COLUMN a a TINYTEXT NULL;
......@@ -145,7 +139,6 @@ CREATE TABLE t (a BLOB NULL);
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a BLOB NULL);
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NOT NULL;
......@@ -163,13 +156,11 @@ CREATE TABLE t (a BLOB NOT NULL);
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a BLOB NULL);
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a BLOB NULL);
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
......@@ -187,7 +178,6 @@ CREATE TABLE t (a BLOB NOT NULL);
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a MEDIUMBLOB NULL);
ALTER TABLE t CHANGE COLUMN a a TINYTEXT NULL;
......@@ -263,7 +253,6 @@ CREATE TABLE t (a MEDIUMBLOB NULL);
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a MEDIUMBLOB NULL);
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
......@@ -281,7 +270,6 @@ CREATE TABLE t (a MEDIUMBLOB NOT NULL);
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a LONGBLOB NULL);
ALTER TABLE t CHANGE COLUMN a a TINYTEXT NULL;
......
This diff is collapsed.
......@@ -27,7 +27,6 @@ CREATE TABLE t (a TINYTEXT NULL);
ALTER TABLE t CHANGE COLUMN a a BLOB NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a TEXT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TINYTEXT NULL);
ALTER TABLE t CHANGE COLUMN a a BLOB NOT NULL;
......@@ -45,13 +44,11 @@ CREATE TABLE t (a TINYTEXT NOT NULL);
ALTER TABLE t CHANGE COLUMN a a BLOB NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a TEXT NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TINYTEXT NULL);
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TINYTEXT NULL);
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NOT NULL;
......@@ -69,13 +66,11 @@ CREATE TABLE t (a TINYTEXT NOT NULL);
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TINYTEXT NULL);
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TINYTEXT NULL);
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
......@@ -93,7 +88,6 @@ CREATE TABLE t (a TINYTEXT NOT NULL);
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TEXT NULL);
ALTER TABLE t CHANGE COLUMN a a TINYBLOB NULL;
......@@ -145,7 +139,6 @@ CREATE TABLE t (a TEXT NULL);
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TEXT NULL);
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NOT NULL;
......@@ -163,13 +156,11 @@ CREATE TABLE t (a TEXT NOT NULL);
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TEXT NULL);
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a TEXT NULL);
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
......@@ -187,7 +178,6 @@ CREATE TABLE t (a TEXT NOT NULL);
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a MEDIUMTEXT NULL);
ALTER TABLE t CHANGE COLUMN a a TINYBLOB NULL;
......@@ -263,7 +253,6 @@ CREATE TABLE t (a MEDIUMTEXT NULL);
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a MEDIUMTEXT NULL);
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
......@@ -281,7 +270,6 @@ CREATE TABLE t (a MEDIUMTEXT NOT NULL);
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
ERROR 42000: Table 't' uses an extension that doesn't exist in this XYZ version
DROP TABLE t;
CREATE TABLE t (a LONGTEXT NULL);
ALTER TABLE t CHANGE COLUMN a a TINYBLOB NULL;
......
This diff is collapsed.
......@@ -73,7 +73,7 @@ class Field_varchar(Field):
def __init__(self, name, size, is_binary, is_nullible):
Field.__init__(self, name, is_nullible)
assert 0 <= size and size < 64*1024
self.size= size
self.size = size
self.is_binary = is_binary
def get_type(self):
t = "%s(%d)" % (Field_varchar.types[self.is_binary], self.size)
......@@ -96,15 +96,25 @@ class Field_varchar(Field):
return Field_varchar(self.name, new_size, self.is_binary, self.is_nullible)
class Field_blob(Field):
def __init__(self, name, size, is_nullible):
types = [ "TINYBLOB", "BLOB", "MEDIUMBLOB", "LONGBLOB" ]
def __init__(self, name, size, is_nullible, idx):
Field.__init__(self, name, is_nullible)
self.size = size
self.idx = idx
def get_type(self):
return "BLOB(%d)" % (self.size)
t = "%s" % (Field_blob.types[self.idx])
if not self.is_nullible:
t += " NOT NULL"
return t
def get_value(self):
l = random.randint(1, self.size)
s = ''.join(random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits) for x in range(l))
return "'%s'" % (s)
def next_field(self):
self.size += 1
if self.idx < 3:
self.idx += 1
return Field_blob(self.name, self.size, self.is_nullible, self.idx)
def main():
experiments = 1000
......@@ -131,7 +141,7 @@ def main():
print "INSERT INTO ti SELECT * FROM t;"
# transform table schema and contents
for f in [ 0, 2, 3, 5 ]:
for f in [ 0, 2, 3, 5, 6, 7 ]:
fields[f] = fields[f].next_field()
print "ALTER TABLE t CHANGE COLUMN %s %s %s;" % (fields[f].name, fields[f].name, fields[f].get_type())
print "ALTER TABLE ti CHANGE COLUMN %s %s %s;" % (fields[f].name, fields[f].name, fields[f].get_type())
......@@ -157,8 +167,8 @@ def create_fields():
fields.append(create_varchar('d'))
fields.append(create_varchar('e'))
fields.append(create_varchar('f'))
fields.append(Field_blob('g', 100, 0))
fields.append(Field_blob('h', 100, 0))
fields.append(create_blob('g'))
fields.append(create_blob('h'))
fields.append(Field_int_auto_inc('id', 8, 0, 0))
return fields
......@@ -172,6 +182,9 @@ def create_char(name):
def create_varchar(name):
return Field_varchar(name, random.randint(1, 100), random.randint(0,1), random.randint(0,1))
def create_blob(name):
return Field_blob(name, random.randint(1,2), random.randint(0,1), random.randint(0,3))
def create_table(fields):
t = "CREATE TABLE t ("
for f in fields:
......@@ -191,7 +204,7 @@ def insert_row(fields):
return t
def header():
print "# generated from change_all.py"
print "# generated from change_column_all.py"
print "# test random column change on wide tables"
print "--disable_warnings"
print "DROP TABLE IF EXISTS t, ti;"
......
......@@ -18,8 +18,7 @@ def gen_tests(base_types, null_types):
print "--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/"
print "--error ER_UNSUPPORTED_EXTENSION"
print "ALTER TABLE t CHANGE COLUMN a a %sTEXT %s;" % (base_types[to_index], null_types[to_null]);
# if from_null != to_null or from_index > to_index:
if from_null != to_null or from_index != to_index:
if from_null != to_null or from_index > to_index:
print "--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/"
print "--error ER_UNSUPPORTED_EXTENSION"
print "ALTER TABLE t CHANGE COLUMN a a %sBLOB %s;" % (base_types[to_index], null_types[to_null]);
......
......@@ -37,8 +37,6 @@ CREATE TABLE t (a TINYBLOB NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a TEXT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a BLOB NULL;
DROP TABLE t;
CREATE TABLE t (a TINYBLOB NULL);
......@@ -61,16 +59,12 @@ CREATE TABLE t (a TINYBLOB NOT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a TEXT NOT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a BLOB NOT NULL;
DROP TABLE t;
CREATE TABLE t (a TINYBLOB NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NULL;
DROP TABLE t;
CREATE TABLE t (a TINYBLOB NULL);
......@@ -93,16 +87,12 @@ CREATE TABLE t (a TINYBLOB NOT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NOT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NOT NULL;
DROP TABLE t;
CREATE TABLE t (a TINYBLOB NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NULL;
DROP TABLE t;
CREATE TABLE t (a TINYBLOB NULL);
......@@ -125,8 +115,6 @@ CREATE TABLE t (a TINYBLOB NOT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
DROP TABLE t;
CREATE TABLE t (a BLOB NULL);
......@@ -193,8 +181,6 @@ CREATE TABLE t (a BLOB NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NULL;
DROP TABLE t;
CREATE TABLE t (a BLOB NULL);
......@@ -217,16 +203,12 @@ CREATE TABLE t (a BLOB NOT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NOT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NOT NULL;
DROP TABLE t;
CREATE TABLE t (a BLOB NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NULL;
DROP TABLE t;
CREATE TABLE t (a BLOB NULL);
......@@ -249,8 +231,6 @@ CREATE TABLE t (a BLOB NOT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
DROP TABLE t;
CREATE TABLE t (a MEDIUMBLOB NULL);
......@@ -349,8 +329,6 @@ CREATE TABLE t (a MEDIUMBLOB NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NULL;
DROP TABLE t;
CREATE TABLE t (a MEDIUMBLOB NULL);
......@@ -373,8 +351,6 @@ CREATE TABLE t (a MEDIUMBLOB NOT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
DROP TABLE t;
CREATE TABLE t (a LONGBLOB NULL);
......
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())
This diff is collapsed.
......@@ -18,8 +18,7 @@ def gen_tests(base_types, null_types):
print "--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/"
print "--error ER_UNSUPPORTED_EXTENSION"
print "ALTER TABLE t CHANGE COLUMN a a %sBLOB %s;" % (base_types[to_index], null_types[to_null]);
# if from_null != to_null or from_index > to_index
if from_null != to_null or from_index != to_index:
if from_null != to_null or from_index > to_index:
print "--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/"
print "--error ER_UNSUPPORTED_EXTENSION"
print "ALTER TABLE t CHANGE COLUMN a a %sTEXT %s;" % (base_types[to_index], null_types[to_null]);
......
......@@ -37,8 +37,6 @@ CREATE TABLE t (a TINYTEXT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a BLOB NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a TEXT NULL;
DROP TABLE t;
CREATE TABLE t (a TINYTEXT NULL);
......@@ -61,16 +59,12 @@ CREATE TABLE t (a TINYTEXT NOT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a BLOB NOT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a TEXT NOT NULL;
DROP TABLE t;
CREATE TABLE t (a TINYTEXT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NULL;
DROP TABLE t;
CREATE TABLE t (a TINYTEXT NULL);
......@@ -93,16 +87,12 @@ CREATE TABLE t (a TINYTEXT NOT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NOT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NOT NULL;
DROP TABLE t;
CREATE TABLE t (a TINYTEXT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NULL;
DROP TABLE t;
CREATE TABLE t (a TINYTEXT NULL);
......@@ -125,8 +115,6 @@ CREATE TABLE t (a TINYTEXT NOT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
DROP TABLE t;
CREATE TABLE t (a TEXT NULL);
......@@ -193,8 +181,6 @@ CREATE TABLE t (a TEXT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NULL;
DROP TABLE t;
CREATE TABLE t (a TEXT NULL);
......@@ -217,16 +203,12 @@ CREATE TABLE t (a TEXT NOT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMBLOB NOT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a MEDIUMTEXT NOT NULL;
DROP TABLE t;
CREATE TABLE t (a TEXT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NULL;
DROP TABLE t;
CREATE TABLE t (a TEXT NULL);
......@@ -249,8 +231,6 @@ CREATE TABLE t (a TEXT NOT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
DROP TABLE t;
CREATE TABLE t (a MEDIUMTEXT NULL);
......@@ -349,8 +329,6 @@ CREATE TABLE t (a MEDIUMTEXT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NULL;
DROP TABLE t;
CREATE TABLE t (a MEDIUMTEXT NULL);
......@@ -373,8 +351,6 @@ CREATE TABLE t (a MEDIUMTEXT NOT NULL);
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGBLOB NOT NULL;
--replace_regex /MariaDB/XYZ/ /MySQL/XYZ/
--error ER_UNSUPPORTED_EXTENSION
ALTER TABLE t CHANGE COLUMN a a LONGTEXT NOT NULL;
DROP TABLE t;
CREATE TABLE t (a LONGTEXT NULL);
......
This diff is collapsed.
......@@ -665,6 +665,7 @@ public:
int alter_table_expand_varchar_offsets(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
int alter_table_expand_columns(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
int alter_table_expand_one_column(TABLE *altered_table, Alter_inplace_info *ha_alter_info, int expand_field_num);
int alter_table_expand_blobs(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
void print_alter_info(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
int setup_kc_info(TABLE *altered_table, KEY_AND_COL_INFO *kc_info);
int new_row_descriptor(TABLE *table, TABLE *altered_table, Alter_inplace_info *ha_alter_info, uint32_t idx, DBT *row_descriptor);
......
......@@ -115,6 +115,7 @@ public:
compression_changed(false),
expand_varchar_update_needed(false),
expand_fixed_update_needed(false),
expand_blob_update_needed(false),
table_kc_info(NULL),
altered_table_kc_info(NULL) {
}
......@@ -133,6 +134,7 @@ public:
enum toku_compression_method orig_compression_method;
bool expand_varchar_update_needed;
bool expand_fixed_update_needed;
bool expand_blob_update_needed;
Dynamic_array<uint> changed_fields;
KEY_AND_COL_INFO *table_kc_info;
KEY_AND_COL_INFO *altered_table_kc_info;
......@@ -472,12 +474,18 @@ bool ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha
ctx->compression_changed = true;
}
}
if (error == 0 && ctx->expand_varchar_update_needed)
error = alter_table_expand_varchar_offsets(altered_table, ha_alter_info);
// note: only one column expansion is allowed
if (error == 0 && ctx->expand_fixed_update_needed)
error = alter_table_expand_columns(altered_table, ha_alter_info);
if (error == 0 && ctx->expand_varchar_update_needed)
error = alter_table_expand_varchar_offsets(altered_table, ha_alter_info);
if (error == 0 && ctx->expand_blob_update_needed)
error = alter_table_expand_blobs(altered_table, ha_alter_info);
if (error == 0 && ctx->reset_card)
tokudb::set_card_from_status(share->status_block, ctx->alter_txn, table->s, altered_table->s);
......@@ -969,6 +977,60 @@ int ha_tokudb::alter_table_expand_one_column(TABLE *altered_table, Alter_inplace
return error;
}
static void marshall_blob_lengths(tokudb::buffer &b, uint32_t n, TABLE *table, KEY_AND_COL_INFO *kc_info) {
for (uint i = 0; i < n; i++) {
uint blob_field_index = kc_info->blob_fields[i];
assert(blob_field_index < table->s->fields);
uint8_t blob_field_length = table->s->field[blob_field_index]->row_pack_length();
b.append(&blob_field_length, sizeof blob_field_length);
}
}
int ha_tokudb::alter_table_expand_blobs(TABLE *altered_table, Alter_inplace_info *ha_alter_info) {
int error = 0;
tokudb_alter_ctx *ctx = static_cast<tokudb_alter_ctx *>(ha_alter_info->handler_ctx);
uint32_t curr_num_DBs = table->s->keys + test(hidden_primary_key);
for (uint32_t i = 0; i < curr_num_DBs; i++) {
// change to a new descriptor
DBT row_descriptor; memset(&row_descriptor, 0, sizeof row_descriptor);
error = new_row_descriptor(table, altered_table, ha_alter_info, i, &row_descriptor);
if (error)
break;
error = share->key_file[i]->change_descriptor(share->key_file[i], ctx->alter_txn, &row_descriptor, 0);
my_free(row_descriptor.data);
if (error)
break;
// for all trees that have values, make an update blobs message and broadcast it into the tree
if (i == primary_key || (table_share->key_info[i].flags & HA_CLUSTERING)) {
tokudb::buffer b;
uint8_t op = UPDATE_OP_EXPAND_BLOB;
b.append(&op, sizeof op);
b.append_ui<uint32_t>(table->s->null_bytes + ctx->table_kc_info->mcp_info[i].fixed_field_size);
uint32_t var_offset_bytes = ctx->table_kc_info->mcp_info[i].len_of_offsets;
b.append_ui<uint32_t>(var_offset_bytes);
b.append_ui<uint32_t>(var_offset_bytes == 0 ? 0 : ctx->table_kc_info->num_offset_bytes);
// add blobs info
uint32_t num_blobs = ctx->table_kc_info->num_blobs;
b.append_ui<uint32_t>(num_blobs);
marshall_blob_lengths(b, num_blobs, table, ctx->table_kc_info);
marshall_blob_lengths(b, num_blobs, altered_table, ctx->altered_table_kc_info);
// and broadcast it into the tree
DBT expand; memset(&expand, 0, sizeof expand);
expand.data = b.data();
expand.size = b.size();
error = share->key_file[i]->update_broadcast(share->key_file[i], ctx->alter_txn, &expand, DB_IS_RESETTING_OP);
if (error)
break;
}
}
return error;
}
// Return true if two fixed length fields can be changed inplace
static bool change_fixed_length_is_supported(TABLE *table, TABLE *altered_table, Field *old_field, Field *new_field, tokudb_alter_ctx *ctx) {
// no change in size is supported
......@@ -981,6 +1043,22 @@ static bool change_fixed_length_is_supported(TABLE *table, TABLE *altered_table,
return true;
}
static bool change_blob_length_is_supported(TABLE *table, TABLE *altered_table, Field *old_field, Field *new_field, tokudb_alter_ctx *ctx) {
// blob -> longer or equal length blob
if (old_field->binary() && new_field->binary() && old_field->pack_length() <= new_field->pack_length()) {
ctx->expand_blob_update_needed = true;
return true;
}
// text -> longer or equal length text
if (!old_field->binary() && !new_field->binary() &&
old_field->pack_length() <= new_field->pack_length() &&
old_field->charset()->number == new_field->charset()->number) {
ctx->expand_blob_update_needed = true;
return true;
}
return false;
}
// Return true if the MySQL type is an int or unsigned int type
static bool is_int_type(enum_field_types t) {
switch (t) {
......@@ -1017,6 +1095,8 @@ static bool change_field_type_is_supported(Field *old_field, Field *new_field, T
// varchar(X) -> varchar(Y) and varbinary(X) -> varbinary(Y) expansion where X < 256 <= Y
// the ALTER_COLUMN_TYPE handler flag is set for these cases
return change_varchar_length_is_supported(old_field, new_field, table, altered_table, ha_alter_info, ctx);
} else if (old_type == MYSQL_TYPE_BLOB && new_type == MYSQL_TYPE_BLOB) {
return change_blob_length_is_supported(table, altered_table, old_field, new_field, ctx);
} else
return false;
}
......
......@@ -188,19 +188,20 @@ public:
}
// Return a pointer to the data in the buffer
void *data() {
void *data() const {
return m_data;
}
// Return the size of the data in the buffer
size_t size() {
size_t size() const {
return m_size;
}
// Return the size of the underlying memory in the buffer
size_t limit() {
size_t limit() const {
return m_limit;
}
private:
// Maybe reallocate the buffer when it becomes full by doubling its size.
void maybe_realloc(size_t s) {
......
This diff is collapsed.
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