From 92cac65fc1b66337096805f374dba2ed0d98fa68 Mon Sep 17 00:00:00 2001 From: "mskold@mysql.com" <> Date: Thu, 27 Apr 2006 15:13:21 +0200 Subject: [PATCH] Added verification test of on-line (non-copying) alter table --- mysql-test/r/ndb_alter_table.result | 42 ++++++++++++++++++++++ mysql-test/t/ndb_alter_table.test | 56 +++++++++++++++++++++++++++++ storage/ndb/tools/listTables.cpp | 2 ++ 3 files changed, 100 insertions(+) diff --git a/mysql-test/r/ndb_alter_table.result b/mysql-test/r/ndb_alter_table.result index a0220a0bad8..7c687ff33a1 100644 --- a/mysql-test/r/ndb_alter_table.result +++ b/mysql-test/r/ndb_alter_table.result @@ -286,3 +286,45 @@ unique key tx1 (c002, c003, c004, c005)) engine=ndb; create index tx2 on t1 (c010, c011, c012, c013); drop table t1; +CREATE TABLE t1 ( +auto int(5) unsigned NOT NULL auto_increment, +string char(10), +vstring varchar(10), +bin binary(2), +vbin varbinary(7), +tiny tinyint(4) DEFAULT '0' NOT NULL , +short smallint(6) DEFAULT '1' NOT NULL , +medium mediumint(8) DEFAULT '0' NOT NULL, +long_int int(11) DEFAULT '0' NOT NULL, +longlong bigint(13) DEFAULT '0' NOT NULL, +real_float float(13,1) DEFAULT 0.0 NOT NULL, +real_double double(16,4), +real_decimal decimal(16,4), +utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, +ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, +umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, +ulong int(11) unsigned DEFAULT '0' NOT NULL, +ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, +bits bit(3), +options enum('zero','one','two','three','four') not null, +flags set('zero','one','two','three','four') not null, +date_field date, +year_field year, +time_field time, +date_time datetime, +time_stamp timestamp, +PRIMARY KEY (auto) +) engine=ndb; +CREATE TEMPORARY TABLE ndb_show_tables (id INT, type VARCHAR(20), state VARCHAR(20), logging VARCHAR(20), _database VARCHAR(255), _schema VARCHAR(20), name VARCHAR(255)); +LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; +set @t1_id = (select id from ndb_show_tables where name like '%t1%'); +truncate ndb_show_tables; +alter table t1 change tiny new_tiny tinyint(4) DEFAULT '0' NOT NULL; +create index i1 on t1(medium); +alter table t1 add index i2(long_int); +drop index i1 on t1; +LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; +select 'no_copy' from ndb_show_tables where id = @t1_id and name like '%t1%'; +no_copy +no_copy +DROP TABLE t1, ndb_show_tables; diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test index a12ac20a259..29deea4aa0d 100644 --- a/mysql-test/t/ndb_alter_table.test +++ b/mysql-test/t/ndb_alter_table.test @@ -327,3 +327,59 @@ drop table t1; # End of 4.1 tests +# On-line alter table + + +CREATE TABLE t1 ( + auto int(5) unsigned NOT NULL auto_increment, + string char(10), + vstring varchar(10), + bin binary(2), + vbin varbinary(7), + tiny tinyint(4) DEFAULT '0' NOT NULL , + short smallint(6) DEFAULT '1' NOT NULL , + medium mediumint(8) DEFAULT '0' NOT NULL, + long_int int(11) DEFAULT '0' NOT NULL, + longlong bigint(13) DEFAULT '0' NOT NULL, + real_float float(13,1) DEFAULT 0.0 NOT NULL, + real_double double(16,4), + real_decimal decimal(16,4), + utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, + ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, + umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, + ulong int(11) unsigned DEFAULT '0' NOT NULL, + ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, + bits bit(3), + options enum('zero','one','two','three','four') not null, + flags set('zero','one','two','three','four') not null, + date_field date, + year_field year, + time_field time, + date_time datetime, + time_stamp timestamp, + PRIMARY KEY (auto) +) engine=ndb; + +CREATE TEMPORARY TABLE ndb_show_tables (id INT, type VARCHAR(20), state VARCHAR(20), logging VARCHAR(20), _database VARCHAR(255), _schema VARCHAR(20), name VARCHAR(255)); + +--disable_warnings +--exec $NDB_TOOLS_DIR/ndb_show_tables --p > $MYSQLTEST_VARDIR/master-data/test/tmp.dat +LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; +--enable_warnings + +set @t1_id = (select id from ndb_show_tables where name like '%t1%'); +truncate ndb_show_tables; + +alter table t1 change tiny new_tiny tinyint(4) DEFAULT '0' NOT NULL; +create index i1 on t1(medium); +alter table t1 add index i2(long_int); +drop index i1 on t1; + +--disable_warnings +--exec $NDB_TOOLS_DIR/ndb_show_tables --p > $MYSQLTEST_VARDIR/master-data/test/tmp.dat +LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; +--enable_warnings + +select 'no_copy' from ndb_show_tables where id = @t1_id and name like '%t1%'; + +DROP TABLE t1, ndb_show_tables; diff --git a/storage/ndb/tools/listTables.cpp b/storage/ndb/tools/listTables.cpp index ef51b66bb10..a221156280d 100644 --- a/storage/ndb/tools/listTables.cpp +++ b/storage/ndb/tools/listTables.cpp @@ -188,6 +188,8 @@ list(const char * tabname, ndbout_c("%-5d %-20s %-8s %-7s %s", elt.id, type, state, store, elt.name); } } + if (_parsable) + exit(0); } NDB_STD_OPTS_VARS;