From 9f5962ed25c295501a4e4e57688fb809e01e4271 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Feb 2006 22:42:57 -0800 Subject: [PATCH] The handlerton structures for archive and CSV had not been updated. Nicht so gute. I also fixed CSV to use fast alter table and put in a test in archive in case someone tries to do the same there (hint... it won't work). mysql-test/r/archive.result: New results mysql-test/r/csv.result: New results mysql-test/t/archive.test: Adding test for new fast alter table mysql-test/t/csv.test: Adding test for new fast alter table sql/ha_archive.cc: Updating handlerton to remove warnings. storage/csv/ha_tina.cc: Updating handlerton to remove warnings, and updated CSV to handle fast alter table. storage/csv/ha_tina.h: New method. --- mysql-test/r/archive.result | 55 +++++++++++++++++++++++++++++++++++++ mysql-test/r/csv.result | 55 +++++++++++++++++++++++++++++++++++++ mysql-test/t/archive.test | 28 +++++++++++++++++++ mysql-test/t/csv.test | 26 ++++++++++++++++++ sql/ha_archive.cc | 4 ++- storage/csv/ha_tina.cc | 10 ++++++- storage/csv/ha_tina.h | 2 ++ 7 files changed, 178 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index 201383b06be..26d95a4dc8d 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -12537,4 +12537,59 @@ SELECT c FROM t5 WHERE a IN (32, 23, 5); c NULL posterity +drop table t1; +create table t1 (v varchar(32)); +insert into t1 values ('def'),('abc'),('hij'),('3r4f'); +select * from t1; +v +def +abc +hij +3r4f +alter table t1 change v v2 varchar(32); +select * from t1; +v2 +def +abc +hij +3r4f +alter table t1 change v2 v varchar(64); +select * from t1; +v +def +abc +hij +3r4f +update t1 set v = 'lmn' where v = 'hij'; +select * from t1; +v +def +abc +lmn +3r4f +alter table t1 add i int auto_increment not null primary key first; +select * from t1; +i v +1 def +2 abc +3 lmn +4 3r4f +update t1 set i=5 where i=3; +select * from t1; +i v +1 def +2 abc +5 lmn +4 3r4f +alter table t1 change i i bigint; +select * from t1; +i v +1 def +2 abc +5 lmn +4 3r4f +alter table t1 add unique key (i, v); +select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn'); +i v +4 3r4f drop table t1, t2, t4, t5; diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index 6f58fdfe54a..9e63b82c29d 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -5017,3 +5017,58 @@ insert t1 values (1),(2),(3),(4),(5); truncate table t1; affected rows: 0 drop table t1; +create table t1 (v varchar(32)); +insert into t1 values ('def'),('abc'),('hij'),('3r4f'); +select * from t1; +v +def +abc +hij +3r4f +alter table t1 change v v2 varchar(32); +select * from t1; +v2 +def +abc +hij +3r4f +alter table t1 change v2 v varchar(64); +select * from t1; +v +def +abc +hij +3r4f +update t1 set v = 'lmn' where v = 'hij'; +select * from t1; +v +def +abc +lmn +3r4f +alter table t1 add i int auto_increment not null primary key first; +select * from t1; +i v +1 def +2 abc +3 lmn +4 3r4f +update t1 set i=5 where i=3; +select * from t1; +i v +1 def +2 abc +5 lmn +4 3r4f +alter table t1 change i i bigint; +select * from t1; +i v +1 def +2 abc +5 lmn +4 3r4f +alter table t1 add unique key (i, v); +select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn'); +i v +4 3r4f +drop table t1; diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 185210b8c54..68e3192e8a4 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1456,6 +1456,34 @@ SELECT c FROM t5; SELECT c FROM t5 WHERE a =3; SELECT c FROM t5 WHERE a IN (32, 23, 5); +# Adding this in case someone tries to add fast alter table and doesn't tes +# it. +# Some additional tests for new, faster alter table. Note that most of the +# whole alter table code is being tested all around the test suite already. +# + +drop table t1; +create table t1 (v varchar(32)); +insert into t1 values ('def'),('abc'),('hij'),('3r4f'); +select * from t1; +# Fast alter, no copy performed +alter table t1 change v v2 varchar(32); +select * from t1; +# Fast alter, no copy performed +alter table t1 change v2 v varchar(64); +select * from t1; +update t1 set v = 'lmn' where v = 'hij'; +select * from t1; +# Regular alter table +alter table t1 add i int auto_increment not null primary key first; +select * from t1; +update t1 set i=5 where i=3; +select * from t1; +alter table t1 change i i bigint; +select * from t1; +alter table t1 add unique key (i, v); +select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn'); + # # Cleanup, test is over # diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index 6f0f42f109c..916a2132deb 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1418,3 +1418,29 @@ truncate table t1; -- truncate --disable_info drop table t1; +# +# Some additional tests for new, faster alter table. Note that most of the +# whole alter table code is being tested all around the test suite already. +# + +create table t1 (v varchar(32)); +insert into t1 values ('def'),('abc'),('hij'),('3r4f'); +select * from t1; +# Fast alter, no copy performed +alter table t1 change v v2 varchar(32); +select * from t1; +# Fast alter, no copy performed +alter table t1 change v2 v varchar(64); +select * from t1; +update t1 set v = 'lmn' where v = 'hij'; +select * from t1; +# Regular alter table +alter table t1 add i int auto_increment not null primary key first; +select * from t1; +update t1 set i=5 where i=3; +select * from t1; +alter table t1 change i i bigint; +select * from t1; +alter table t1 add unique key (i, v); +select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn'); +drop table t1; diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc index 366ae08462b..9239f67fced 100644 --- a/sql/ha_archive.cc +++ b/sql/ha_archive.cc @@ -177,7 +177,9 @@ handlerton archive_hton = { NULL, /* Partition flags */ NULL, /* Alter table flags */ NULL, /* Alter interface */ - HTON_NO_FLAGS + HTON_NO_FLAGS, + NULL, /* binlog_func */ + NULL /* binlog_log_query */ }; static handler *archive_create_handler(TABLE_SHARE *table) diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 17c842f43e0..bc228d5c767 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -92,7 +92,9 @@ handlerton tina_hton= { NULL, /* Alter table flags */ NULL, /* Alter Tablespace */ NULL, /* Fill FILES Table */ - HTON_CAN_RECREATE + HTON_CAN_RECREATE, + NULL, /* binlog_func */ + NULL /* binlog_log_query */ }; /***************************************************************************** @@ -1018,6 +1020,12 @@ int ha_tina::create(const char *name, TABLE *table_arg, DBUG_RETURN(0); } +bool ha_tina::check_if_incompatible_data(HA_CREATE_INFO *info, + uint table_changes) +{ + return COMPATIBLE_DATA_YES; +} + mysql_declare_plugin { MYSQL_STORAGE_ENGINE_PLUGIN, diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h index a11d4281389..572d05cb779 100644 --- a/storage/csv/ha_tina.h +++ b/storage/csv/ha_tina.h @@ -122,6 +122,8 @@ public: int extra(enum ha_extra_function operation); int delete_all_rows(void); int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); + bool check_if_incompatible_data(HA_CREATE_INFO *info, + uint table_changes); THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type);