Commit 1c06de1f authored by Mattias Jonsson's avatar Mattias Jonsson

manual merge of Bug#20129 into 5.1-bugteam

parents 2ace7dc9 f50c4207
...@@ -484,6 +484,7 @@ c1 ...@@ -484,6 +484,7 @@ c1
handler t1 close; handler t1 close;
read the result from the other connection read the result from the other connection
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
proceed with the normal connection proceed with the normal connection
drop table t1; drop table t1;
...@@ -698,6 +699,7 @@ handler a2 read a first; ...@@ -698,6 +699,7 @@ handler a2 read a first;
a a
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
handler a1 close; handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER ERROR 42S02: Unknown table 'a1' in HANDLER
......
...@@ -166,6 +166,7 @@ level id parent_id ...@@ -166,6 +166,7 @@ level id parent_id
1 1007 101 1 1007 101
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
show keys from t1; show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
...@@ -190,6 +191,7 @@ create table t1 (a int) engine=innodb; ...@@ -190,6 +191,7 @@ create table t1 (a int) engine=innodb;
insert into t1 values (1), (2); insert into t1 values (1), (2);
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
delete from t1 where a = 1; delete from t1 where a = 1;
select * from t1; select * from t1;
...@@ -738,6 +740,7 @@ world 2 ...@@ -738,6 +740,7 @@ world 2
hello 1 hello 1
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
show keys from t1; show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
...@@ -3109,6 +3112,7 @@ BEGIN; ...@@ -3109,6 +3112,7 @@ BEGIN;
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB; CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
......
...@@ -577,6 +577,7 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -577,6 +577,7 @@ id select_type table type possible_keys key key_len ref rows Extra
INSERT INTO t2 SELECT * FROM t1; INSERT INTO t2 SELECT * FROM t1;
OPTIMIZE TABLE t2; OPTIMIZE TABLE t2;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t2 optimize note Table does not support optimize, doing recreate + analyze instead
test.t2 optimize status OK test.t2 optimize status OK
EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785; EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
......
...@@ -538,7 +538,7 @@ PARTITION BY LIST (a) ...@@ -538,7 +538,7 @@ PARTITION BY LIST (a)
(PARTITION x1 VALUES IN (10), PARTITION x2 VALUES IN (20)); (PARTITION x1 VALUES IN (10), PARTITION x2 VALUES IN (20));
analyze table t1; analyze table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze note The storage engine for the table doesn't support analyze test.t1 analyze status OK
drop table t1; drop table t1;
create table t1 create table t1
(a int) (a int)
...@@ -1239,7 +1239,11 @@ SHOW TABLE STATUS; ...@@ -1239,7 +1239,11 @@ SHOW TABLE STATUS;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 1 14 14 0 0 7 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned t1 MyISAM 10 Fixed 1 14 14 0 0 7 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned
ALTER TABLE t1 OPTIMIZE PARTITION p0; ALTER TABLE t1 OPTIMIZE PARTITION p0;
ERROR 42000: The storage engine for the table doesn't support optimize partition Table Op Msg_type Msg_text
test.t1 optimize status OK
SHOW TABLE STATUS;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 1 7 7 0 1024 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a int, index(a)) PARTITION BY KEY(a); CREATE TABLE t1 (a int, index(a)) PARTITION BY KEY(a);
ALTER TABLE t1 DISABLE KEYS; ALTER TABLE t1 DISABLE KEYS;
...@@ -1499,13 +1503,17 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ...@@ -1499,13 +1503,17 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
ALTER TABLE t1 ANALYZE PARTITION p1 EXTENDED; ALTER TABLE t1 ANALYZE PARTITION p1 EXTENDED;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'EXTENDED' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'EXTENDED' at line 1
ALTER TABLE t1 ANALYZE PARTITION p1; ALTER TABLE t1 ANALYZE PARTITION p1;
ERROR 42000: The storage engine for the table doesn't support analyze partition Table Op Msg_type Msg_text
test.t1 analyze status OK
ALTER TABLE t1 CHECK PARTITION p1; ALTER TABLE t1 CHECK PARTITION p1;
ERROR 42000: The storage engine for the table doesn't support check partition Table Op Msg_type Msg_text
test.t1 check status OK
ALTER TABLE t1 REPAIR PARTITION p1; ALTER TABLE t1 REPAIR PARTITION p1;
ERROR 42000: The storage engine for the table doesn't support repair partition Table Op Msg_type Msg_text
test.t1 repair status OK
ALTER TABLE t1 OPTIMIZE PARTITION p1; ALTER TABLE t1 OPTIMIZE PARTITION p1;
ERROR 42000: The storage engine for the table doesn't support optimize partition Table Op Msg_type Msg_text
test.t1 optimize status OK
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (s1 BIGINT UNSIGNED) CREATE TABLE t1 (s1 BIGINT UNSIGNED)
PARTITION BY RANGE (s1) ( PARTITION BY RANGE (s1) (
......
...@@ -19,6 +19,7 @@ a b ...@@ -19,6 +19,7 @@ a b
THE LION 13 THE LION 13
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
select trigger_schema, trigger_name, event_object_schema, select trigger_schema, trigger_name, event_object_schema,
event_object_table, action_statement from information_schema.triggers event_object_table, action_statement from information_schema.triggers
......
...@@ -192,14 +192,30 @@ DROP TABLE t1; ...@@ -192,14 +192,30 @@ DROP TABLE t1;
CREATE TABLE t1 (a int primary key) CREATE TABLE t1 (a int primary key)
ENGINE=NDB ENGINE=NDB
PARTITION BY KEY(a); PARTITION BY KEY(a);
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze note The storage engine for the table doesn't support analyze
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check note The storage engine for the table doesn't support check
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize note The storage engine for the table doesn't support optimize
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
ALTER TABLE t1 OPTIMIZE PARTITION p0; ALTER TABLE t1 OPTIMIZE PARTITION p0;
ERROR HY000: Table storage engine for 't1' doesn't have this option Table Op Msg_type Msg_text
test.t1 optimize note The storage engine for the table doesn't support optimize
ALTER TABLE t1 CHECK PARTITION p0; ALTER TABLE t1 CHECK PARTITION p0;
ERROR HY000: Table storage engine for 't1' doesn't have this option Table Op Msg_type Msg_text
test.t1 check note The storage engine for the table doesn't support check
ALTER TABLE t1 REPAIR PARTITION p0; ALTER TABLE t1 REPAIR PARTITION p0;
ERROR HY000: Table storage engine for 't1' doesn't have this option Table Op Msg_type Msg_text
test.t1 repair note The storage engine for the table doesn't support repair
ALTER TABLE t1 ANALYZE PARTITION p0; ALTER TABLE t1 ANALYZE PARTITION p0;
ERROR HY000: Table storage engine for 't1' doesn't have this option Table Op Msg_type Msg_text
test.t1 analyze note The storage engine for the table doesn't support analyze
ALTER TABLE t1 REBUILD PARTITION p0; ALTER TABLE t1 REBUILD PARTITION p0;
ERROR HY000: Table storage engine for 't1' doesn't have this option ERROR HY000: Table storage engine for 't1' doesn't have this option
DROP TABLE t1; DROP TABLE t1;
......
...@@ -175,15 +175,15 @@ DROP TABLE t1; ...@@ -175,15 +175,15 @@ DROP TABLE t1;
CREATE TABLE t1 (a int primary key) CREATE TABLE t1 (a int primary key)
ENGINE=NDB ENGINE=NDB
PARTITION BY KEY(a); PARTITION BY KEY(a);
--error 1031 ANALYZE TABLE t1;
CHECK TABLE t1;
OPTIMIZE TABLE t1;
REPAIR TABLE t1;
ALTER TABLE t1 OPTIMIZE PARTITION p0; ALTER TABLE t1 OPTIMIZE PARTITION p0;
--error 1031
ALTER TABLE t1 CHECK PARTITION p0; ALTER TABLE t1 CHECK PARTITION p0;
--error 1031
ALTER TABLE t1 REPAIR PARTITION p0; ALTER TABLE t1 REPAIR PARTITION p0;
--error 1031
ALTER TABLE t1 ANALYZE PARTITION p0; ALTER TABLE t1 ANALYZE PARTITION p0;
--error 1031 --error ER_ILLEGAL_HA
ALTER TABLE t1 REBUILD PARTITION p0; ALTER TABLE t1 REBUILD PARTITION p0;
DROP TABLE t1; DROP TABLE t1;
......
...@@ -31,6 +31,9 @@ let $alter= ALTER TABLE t1 ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10 ...@@ -31,6 +31,9 @@ let $alter= ALTER TABLE t1 ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10
--echo # 1.4 ALTER ... ANALYZE PARTITION part_1,part_1,part_1; --echo # 1.4 ALTER ... ANALYZE PARTITION part_1,part_1,part_1;
let $alter= ALTER TABLE t1 ANALYZE PARTITION part_1,part_1,part_1; let $alter= ALTER TABLE t1 ANALYZE PARTITION part_1,part_1,part_1;
--source suite/parts/inc/partition_alter_41.inc --source suite/parts/inc/partition_alter_41.inc
--echo # 1.5 ALTER ... ANALYZE PARTITION ALL;
let $alter= ALTER TABLE t1 ANALYZE PARTITION ALL;
--source suite/parts/inc/partition_alter_41.inc
--echo #------------------------------------------------------------------------ --echo #------------------------------------------------------------------------
--echo # 2 ALTER ... CHECK PARTITION --echo # 2 ALTER ... CHECK PARTITION
...@@ -47,6 +50,9 @@ let $alter= ALTER TABLE t1 CHECK PARTITION part_1,part_2,part_5,part_6,part_10; ...@@ -47,6 +50,9 @@ let $alter= ALTER TABLE t1 CHECK PARTITION part_1,part_2,part_5,part_6,part_10;
--echo # 2.4 ALTER ... CHECK PARTITION part_1,part_1,part_1; --echo # 2.4 ALTER ... CHECK PARTITION part_1,part_1,part_1;
let $alter= ALTER TABLE t1 CHECK PARTITION part_1,part_1,part_1; let $alter= ALTER TABLE t1 CHECK PARTITION part_1,part_1,part_1;
--source suite/parts/inc/partition_alter_41.inc --source suite/parts/inc/partition_alter_41.inc
--echo # 2.5 ALTER ... CHECK PARTITION ALL;
let $alter= ALTER TABLE t1 CHECK PARTITION ALL;
--source suite/parts/inc/partition_alter_41.inc
--echo #------------------------------------------------------------------------ --echo #------------------------------------------------------------------------
--echo # 3 ALTER ... OPTIMIZE PARTITION --echo # 3 ALTER ... OPTIMIZE PARTITION
...@@ -63,6 +69,9 @@ let $alter= ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_1 ...@@ -63,6 +69,9 @@ let $alter= ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_1
--echo # 3.4 ALTER ... OPTIMIZE PARTITION part_1,part_1,part_1; --echo # 3.4 ALTER ... OPTIMIZE PARTITION part_1,part_1,part_1;
let $alter= ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_1,part_1; let $alter= ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_1,part_1;
--source suite/parts/inc/partition_alter_41.inc --source suite/parts/inc/partition_alter_41.inc
--echo # 3.5 ALTER ... OPTIMIZE PARTITION ALL;
let $alter= ALTER TABLE t1 OPTIMIZE PARTITION ALL;
--source suite/parts/inc/partition_alter_41.inc
--echo #------------------------------------------------------------------------ --echo #------------------------------------------------------------------------
--echo # 4 ALTER ... REBUILD PARTITION --echo # 4 ALTER ... REBUILD PARTITION
...@@ -79,6 +88,9 @@ let $alter= ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10 ...@@ -79,6 +88,9 @@ let $alter= ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10
--echo # 4.4 ALTER ... REBUILD PARTITION part_1,part_1,part_1; --echo # 4.4 ALTER ... REBUILD PARTITION part_1,part_1,part_1;
let $alter= ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; let $alter= ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1;
--source suite/parts/inc/partition_alter_41.inc --source suite/parts/inc/partition_alter_41.inc
--echo # 4.5 ALTER ... REBUILD PARTITION ALL;
let $alter= ALTER TABLE t1 REBUILD PARTITION ALL;
--source suite/parts/inc/partition_alter_41.inc
--echo #------------------------------------------------------------------------ --echo #------------------------------------------------------------------------
--echo # 5 ALTER ... REPAIR PARTITION --echo # 5 ALTER ... REPAIR PARTITION
...@@ -95,6 +107,9 @@ let $alter= ALTER TABLE t1 REPAIR PARTITION part_1,part_2,part_5,part_6,part_10; ...@@ -95,6 +107,9 @@ let $alter= ALTER TABLE t1 REPAIR PARTITION part_1,part_2,part_5,part_6,part_10;
--echo # 5.4 ALTER ... REPAIR PARTITION part_1,part_1,part_1; --echo # 5.4 ALTER ... REPAIR PARTITION part_1,part_1,part_1;
let $alter= ALTER TABLE t1 REPAIR PARTITION part_1,part_1,part_1; let $alter= ALTER TABLE t1 REPAIR PARTITION part_1,part_1,part_1;
--source suite/parts/inc/partition_alter_41.inc --source suite/parts/inc/partition_alter_41.inc
--echo # 5.5 ALTER ... REPAIR PARTITION ALL;
let $alter= ALTER TABLE t1 REPAIR PARTITION ALL;
--source suite/parts/inc/partition_alter_41.inc
--echo #------------------------------------------------------------------------ --echo #------------------------------------------------------------------------
--echo # 6 ALTER ... REMOVE PARTITIONING --echo # 6 ALTER ... REMOVE PARTITIONING
......
...@@ -9,6 +9,7 @@ BEGIN; ...@@ -9,6 +9,7 @@ BEGIN;
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize error Lock wait timeout exceeded; try restarting transaction test.t1 optimize error Lock wait timeout exceeded; try restarting transaction
test.t1 optimize status Operation failed test.t1 optimize status Operation failed
Warnings: Warnings:
......
...@@ -570,6 +570,7 @@ test_rpl.t1 1837058639 ...@@ -570,6 +570,7 @@ test_rpl.t1 1837058639
******************** OPTIMIZE TABLE ******************** ******************** OPTIMIZE TABLE ********************
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test_rpl.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test_rpl.t1 optimize status OK test_rpl.t1 optimize status OK
******************** REPAIR TABLE ******************** ******************** REPAIR TABLE ********************
......
...@@ -1333,11 +1333,9 @@ SHOW TABLE STATUS; ...@@ -1333,11 +1333,9 @@ SHOW TABLE STATUS;
DELETE from t1 where a = 1; DELETE from t1 where a = 1;
--replace_column 9 0 12 NULL 13 NULL 14 NULL --replace_column 9 0 12 NULL 13 NULL 14 NULL
SHOW TABLE STATUS; SHOW TABLE STATUS;
# restore this after WL#4176 is completed
-- error ER_CHECK_NOT_IMPLEMENTED
ALTER TABLE t1 OPTIMIZE PARTITION p0; ALTER TABLE t1 OPTIMIZE PARTITION p0;
#--replace_column 12 NULL 13 NULL 14 NULL --replace_column 12 NULL 13 NULL 14 NULL
#SHOW TABLE STATUS; SHOW TABLE STATUS;
DROP TABLE t1; DROP TABLE t1;
# #
...@@ -1672,13 +1670,9 @@ PARTITION BY RANGE (a) ( ...@@ -1672,13 +1670,9 @@ PARTITION BY RANGE (a) (
ALTER TABLE t1 OPTIMIZE PARTITION p1 EXTENDED; ALTER TABLE t1 OPTIMIZE PARTITION p1 EXTENDED;
--error ER_PARSE_ERROR --error ER_PARSE_ERROR
ALTER TABLE t1 ANALYZE PARTITION p1 EXTENDED; ALTER TABLE t1 ANALYZE PARTITION p1 EXTENDED;
--error ER_CHECK_NOT_IMPLEMENTED
ALTER TABLE t1 ANALYZE PARTITION p1; ALTER TABLE t1 ANALYZE PARTITION p1;
--error ER_CHECK_NOT_IMPLEMENTED
ALTER TABLE t1 CHECK PARTITION p1; ALTER TABLE t1 CHECK PARTITION p1;
--error ER_CHECK_NOT_IMPLEMENTED
ALTER TABLE t1 REPAIR PARTITION p1; ALTER TABLE t1 REPAIR PARTITION p1;
--error ER_CHECK_NOT_IMPLEMENTED
ALTER TABLE t1 OPTIMIZE PARTITION p1; ALTER TABLE t1 OPTIMIZE PARTITION p1;
DROP TABLE t1; DROP TABLE t1;
......
This diff is collapsed.
...@@ -932,10 +932,6 @@ public: ...@@ -932,10 +932,6 @@ public:
virtual int analyze(THD* thd, HA_CHECK_OPT *check_opt); virtual int analyze(THD* thd, HA_CHECK_OPT *check_opt);
virtual int check(THD* thd, HA_CHECK_OPT *check_opt); virtual int check(THD* thd, HA_CHECK_OPT *check_opt);
virtual int repair(THD* thd, HA_CHECK_OPT *check_opt); virtual int repair(THD* thd, HA_CHECK_OPT *check_opt);
virtual int optimize_partitions(THD *thd);
virtual int analyze_partitions(THD *thd);
virtual int check_partitions(THD *thd);
virtual int repair_partitions(THD *thd);
virtual bool check_and_repair(THD *thd); virtual bool check_and_repair(THD *thd);
virtual bool auto_repair() const; virtual bool auto_repair() const;
virtual bool is_crashed() const; virtual bool is_crashed() const;
......
...@@ -3284,66 +3284,6 @@ handler::ha_rename_partitions(const char *path) ...@@ -3284,66 +3284,6 @@ handler::ha_rename_partitions(const char *path)
} }
/**
Optimize partitions: public interface.
@sa handler::optimize_partitions()
*/
int
handler::ha_optimize_partitions(THD *thd)
{
mark_trx_read_write();
return optimize_partitions(thd);
}
/**
Analyze partitions: public interface.
@sa handler::analyze_partitions()
*/
int
handler::ha_analyze_partitions(THD *thd)
{
mark_trx_read_write();
return analyze_partitions(thd);
}
/**
Check partitions: public interface.
@sa handler::check_partitions()
*/
int
handler::ha_check_partitions(THD *thd)
{
mark_trx_read_write();
return check_partitions(thd);
}
/**
Repair partitions: public interface.
@sa handler::repair_partitions()
*/
int
handler::ha_repair_partitions(THD *thd)
{
mark_trx_read_write();
return repair_partitions(thd);
}
/** /**
Tell the storage engine that it is allowed to "disable transaction" in the Tell the storage engine that it is allowed to "disable transaction" in the
handler. It is a hint that ACID is not required - it is used in NDB for handler. It is a hint that ACID is not required - it is used in NDB for
......
...@@ -1247,10 +1247,6 @@ public: ...@@ -1247,10 +1247,6 @@ public:
size_t pack_frm_len); size_t pack_frm_len);
int ha_drop_partitions(const char *path); int ha_drop_partitions(const char *path);
int ha_rename_partitions(const char *path); int ha_rename_partitions(const char *path);
int ha_optimize_partitions(THD *thd);
int ha_analyze_partitions(THD *thd);
int ha_check_partitions(THD *thd);
int ha_repair_partitions(THD *thd);
void adjust_next_insert_id_after_explicit_value(ulonglong nr); void adjust_next_insert_id_after_explicit_value(ulonglong nr);
int update_auto_increment(); int update_auto_increment();
...@@ -1911,14 +1907,6 @@ private: ...@@ -1911,14 +1907,6 @@ private:
{ return HA_ERR_WRONG_COMMAND; } { return HA_ERR_WRONG_COMMAND; }
virtual int rename_partitions(const char *path) virtual int rename_partitions(const char *path)
{ return HA_ERR_WRONG_COMMAND; } { return HA_ERR_WRONG_COMMAND; }
virtual int optimize_partitions(THD *thd)
{ return HA_ERR_WRONG_COMMAND; }
virtual int analyze_partitions(THD *thd)
{ return HA_ERR_WRONG_COMMAND; }
virtual int check_partitions(THD *thd)
{ return HA_ERR_WRONG_COMMAND; }
virtual int repair_partitions(THD *thd)
{ return HA_ERR_WRONG_COMMAND; }
}; };
......
...@@ -1571,6 +1571,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -1571,6 +1571,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
char *db, char *db,
const char *table_name, const char *table_name,
uint fast_alter_partition); uint fast_alter_partition);
uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
enum partition_state part_state);
uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
handlerton *old_db_type, handlerton *old_db_type,
......
...@@ -788,6 +788,9 @@ bool Protocol_text::store(const char *from, size_t length, ...@@ -788,6 +788,9 @@ bool Protocol_text::store(const char *from, size_t length,
{ {
CHARSET_INFO *tocs= this->thd->variables.character_set_results; CHARSET_INFO *tocs= this->thd->variables.character_set_results;
#ifndef DBUG_OFF #ifndef DBUG_OFF
DBUG_PRINT("info", ("Protocol_text::store field %u (%u): %s", field_pos,
field_count, from));
DBUG_ASSERT(field_pos < field_count);
DBUG_ASSERT(field_types == 0 || DBUG_ASSERT(field_types == 0 ||
field_types[field_pos] == MYSQL_TYPE_DECIMAL || field_types[field_pos] == MYSQL_TYPE_DECIMAL ||
field_types[field_pos] == MYSQL_TYPE_BIT || field_types[field_pos] == MYSQL_TYPE_BIT ||
......
...@@ -4079,6 +4079,38 @@ error: ...@@ -4079,6 +4079,38 @@ error:
} }
/*
Sets which partitions to be used in the command
*/
uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
enum partition_state part_state)
{
uint part_count= 0;
uint no_parts_found= 0;
List_iterator<partition_element> part_it(tab_part_info->partitions);
do
{
partition_element *part_elem= part_it++;
if ((alter_info->flags & ALTER_ALL_PARTITION) ||
(is_name_in_list(part_elem->partition_name,
alter_info->partition_names)))
{
/*
Mark the partition.
I.e mark the partition as a partition to be "changed" by
analyzing/optimizing/rebuilding/checking/repairing
*/
no_parts_found++;
part_elem->part_state= part_state;
DBUG_PRINT("info", ("Setting part_state to %u for partition %s",
part_state, part_elem->partition_name));
}
} while (++part_count < tab_part_info->no_parts);
return no_parts_found;
}
/* /*
Prepare for ALTER TABLE of partition structure Prepare for ALTER TABLE of partition structure
...@@ -4534,26 +4566,9 @@ that are reorganised. ...@@ -4534,26 +4566,9 @@ that are reorganised.
(alter_info->flags & ALTER_REPAIR_PARTITION) || (alter_info->flags & ALTER_REPAIR_PARTITION) ||
(alter_info->flags & ALTER_REBUILD_PARTITION)) (alter_info->flags & ALTER_REBUILD_PARTITION))
{ {
uint no_parts_found;
uint no_parts_opt= alter_info->partition_names.elements; uint no_parts_opt= alter_info->partition_names.elements;
uint part_count= 0; no_parts_found= set_part_state(alter_info, tab_part_info, PART_CHANGED);
uint no_parts_found= 0;
List_iterator<partition_element> part_it(tab_part_info->partitions);
do
{
partition_element *part_elem= part_it++;
if ((alter_info->flags & ALTER_ALL_PARTITION) ||
(is_name_in_list(part_elem->partition_name,
alter_info->partition_names)))
{
/*
Mark the partition as a partition to be "changed" by
analyzing/optimizing/rebuilding/checking/repairing
*/
no_parts_found++;
part_elem->part_state= PART_CHANGED;
}
} while (++part_count < tab_part_info->no_parts);
if (no_parts_found != no_parts_opt && if (no_parts_found != no_parts_opt &&
(!(alter_info->flags & ALTER_ALL_PARTITION))) (!(alter_info->flags & ALTER_ALL_PARTITION)))
{ {
...@@ -6026,48 +6041,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -6026,48 +6041,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
lpt->pack_frm_len= 0; lpt->pack_frm_len= 0;
thd->work_part_info= part_info; thd->work_part_info= part_info;
if (alter_info->flags & ALTER_OPTIMIZE_PARTITION || if (fast_alter_partition & HA_PARTITION_ONE_PHASE)
alter_info->flags & ALTER_ANALYZE_PARTITION ||
alter_info->flags & ALTER_CHECK_PARTITION ||
alter_info->flags & ALTER_REPAIR_PARTITION)
{
/*
In this case the user has specified that he wants a set of partitions
to be optimised and the partition engine can handle optimising
partitions natively without requiring a full rebuild of the
partitions.
In this case it is enough to call optimise_partitions, there is no
need to change frm files or anything else.
*/
int error;
written_bin_log= FALSE;
if (((alter_info->flags & ALTER_OPTIMIZE_PARTITION) &&
(error= table->file->ha_optimize_partitions(thd))) ||
((alter_info->flags & ALTER_ANALYZE_PARTITION) &&
(error= table->file->ha_analyze_partitions(thd))) ||
((alter_info->flags & ALTER_CHECK_PARTITION) &&
(error= table->file->ha_check_partitions(thd))) ||
((alter_info->flags & ALTER_REPAIR_PARTITION) &&
(error= table->file->ha_repair_partitions(thd))))
{
if (error == HA_ADMIN_NOT_IMPLEMENTED) {
if (alter_info->flags & ALTER_OPTIMIZE_PARTITION)
my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "optimize partition");
else if (alter_info->flags & ALTER_ANALYZE_PARTITION)
my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "analyze partition");
else if (alter_info->flags & ALTER_CHECK_PARTITION)
my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "check partition");
else if (alter_info->flags & ALTER_REPAIR_PARTITION)
my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "repair partition");
else
table->file->print_error(error, MYF(0));
} else
table->file->print_error(error, MYF(0));
goto err;
}
}
else if (fast_alter_partition & HA_PARTITION_ONE_PHASE)
{ {
/* /*
In the case where the engine supports one phase online partition In the case where the engine supports one phase online partition
......
...@@ -4194,6 +4194,46 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -4194,6 +4194,46 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
table->next_global= save_next_global; table->next_global= save_next_global;
table->next_local= save_next_local; table->next_local= save_next_local;
thd->open_options&= ~extra_open_options; thd->open_options&= ~extra_open_options;
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (table->table && table->table->part_info)
{
/*
Set up which partitions that should be processed
if ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR PARTITION ..
*/
Alter_info *alter_info= &lex->alter_info;
if (alter_info->flags & ALTER_ANALYZE_PARTITION ||
alter_info->flags & ALTER_CHECK_PARTITION ||
alter_info->flags & ALTER_OPTIMIZE_PARTITION ||
alter_info->flags & ALTER_REPAIR_PARTITION)
{
uint no_parts_found;
uint no_parts_opt= alter_info->partition_names.elements;
no_parts_found= set_part_state(alter_info, table->table->part_info,
PART_CHANGED);
if (no_parts_found != no_parts_opt &&
(!(alter_info->flags & ALTER_ALL_PARTITION)))
{
char buff[FN_REFLEN + MYSQL_ERRMSG_SIZE];
uint length;
DBUG_PRINT("admin", ("sending non existent partition error"));
protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info);
protocol->store(operator_name, system_charset_info);
protocol->store(STRING_WITH_LEN("error"), system_charset_info);
length= my_snprintf(buff, sizeof(buff),
ER(ER_DROP_PARTITION_NON_EXISTENT),
table_name);
protocol->store(buff, length, system_charset_info);
if(protocol->write())
goto err;
my_eof(thd);
goto err;
}
}
}
#endif
} }
DBUG_PRINT("admin", ("table: 0x%lx", (long) table->table)); DBUG_PRINT("admin", ("table: 0x%lx", (long) table->table));
...@@ -4428,9 +4468,17 @@ send_result_message: ...@@ -4428,9 +4468,17 @@ send_result_message:
This is currently used only by InnoDB. ha_innobase::optimize() answers This is currently used only by InnoDB. ha_innobase::optimize() answers
"try with alter", so here we close the table, do an ALTER TABLE, "try with alter", so here we close the table, do an ALTER TABLE,
reopen the table and do ha_innobase::analyze() on it. reopen the table and do ha_innobase::analyze() on it.
We have to end the row, so analyze could return more rows.
*/ */
protocol->store(STRING_WITH_LEN("note"), system_charset_info);
protocol->store(STRING_WITH_LEN(
"Table does not support optimize, doing recreate + analyze instead"),
system_charset_info);
if (protocol->write())
goto err;
ha_autocommit_or_rollback(thd, 0); ha_autocommit_or_rollback(thd, 0);
close_thread_tables(thd); close_thread_tables(thd);
DBUG_PRINT("info", ("HA_ADMIN_TRY_ALTER, trying analyze..."));
TABLE_LIST *save_next_local= table->next_local, TABLE_LIST *save_next_local= table->next_local,
*save_next_global= table->next_global; *save_next_global= table->next_global;
table->next_local= table->next_global= 0; table->next_local= table->next_global= 0;
...@@ -4453,6 +4501,10 @@ send_result_message: ...@@ -4453,6 +4501,10 @@ send_result_message:
((result_code= table->table->file->ha_analyze(thd, check_opt)) > 0)) ((result_code= table->table->file->ha_analyze(thd, check_opt)) > 0))
result_code= 0; // analyze went ok result_code= 0; // analyze went ok
} }
/* Start a new row for the final status row */
protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info);
protocol->store(operator_name, system_charset_info);
if (result_code) // either mysql_recreate_table or analyze failed if (result_code) // either mysql_recreate_table or analyze failed
{ {
DBUG_ASSERT(thd->is_error()); DBUG_ASSERT(thd->is_error());
...@@ -4468,7 +4520,8 @@ send_result_message: ...@@ -4468,7 +4520,8 @@ send_result_message:
/* Hijack the row already in-progress. */ /* Hijack the row already in-progress. */
protocol->store(STRING_WITH_LEN("error"), system_charset_info); protocol->store(STRING_WITH_LEN("error"), system_charset_info);
protocol->store(err_msg, system_charset_info); protocol->store(err_msg, system_charset_info);
(void)protocol->write(); if (protocol->write())
goto err;
/* Start off another row for HA_ADMIN_FAILED */ /* Start off another row for HA_ADMIN_FAILED */
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info); protocol->store(table_name, system_charset_info);
......
...@@ -5543,6 +5543,7 @@ alter_commands: ...@@ -5543,6 +5543,7 @@ alter_commands:
all_or_alt_part_name_list all_or_alt_part_name_list
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command = SQLCOM_OPTIMIZE;
lex->alter_info.flags|= ALTER_OPTIMIZE_PARTITION; lex->alter_info.flags|= ALTER_OPTIMIZE_PARTITION;
lex->no_write_to_binlog= $3; lex->no_write_to_binlog= $3;
lex->check_opt.init(); lex->check_opt.init();
...@@ -5552,6 +5553,7 @@ alter_commands: ...@@ -5552,6 +5553,7 @@ alter_commands:
all_or_alt_part_name_list all_or_alt_part_name_list
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command = SQLCOM_ANALYZE;
lex->alter_info.flags|= ALTER_ANALYZE_PARTITION; lex->alter_info.flags|= ALTER_ANALYZE_PARTITION;
lex->no_write_to_binlog= $3; lex->no_write_to_binlog= $3;
lex->check_opt.init(); lex->check_opt.init();
...@@ -5559,6 +5561,7 @@ alter_commands: ...@@ -5559,6 +5561,7 @@ alter_commands:
| CHECK_SYM PARTITION_SYM all_or_alt_part_name_list | CHECK_SYM PARTITION_SYM all_or_alt_part_name_list
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command = SQLCOM_CHECK;
lex->alter_info.flags|= ALTER_CHECK_PARTITION; lex->alter_info.flags|= ALTER_CHECK_PARTITION;
lex->check_opt.init(); lex->check_opt.init();
} }
...@@ -5567,6 +5570,7 @@ alter_commands: ...@@ -5567,6 +5570,7 @@ alter_commands:
all_or_alt_part_name_list all_or_alt_part_name_list
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command = SQLCOM_REPAIR;
lex->alter_info.flags|= ALTER_REPAIR_PARTITION; lex->alter_info.flags|= ALTER_REPAIR_PARTITION;
lex->no_write_to_binlog= $3; lex->no_write_to_binlog= $3;
lex->check_opt.init(); lex->check_opt.init();
...@@ -6009,6 +6013,7 @@ repair: ...@@ -6009,6 +6013,7 @@ repair:
lex->sql_command = SQLCOM_REPAIR; lex->sql_command = SQLCOM_REPAIR;
lex->no_write_to_binlog= $2; lex->no_write_to_binlog= $2;
lex->check_opt.init(); lex->check_opt.init();
lex->alter_info.reset();
} }
table_list opt_mi_repair_type table_list opt_mi_repair_type
{} {}
...@@ -6037,6 +6042,7 @@ analyze: ...@@ -6037,6 +6042,7 @@ analyze:
lex->sql_command = SQLCOM_ANALYZE; lex->sql_command = SQLCOM_ANALYZE;
lex->no_write_to_binlog= $2; lex->no_write_to_binlog= $2;
lex->check_opt.init(); lex->check_opt.init();
lex->alter_info.reset();
} }
table_list table_list
{} {}
...@@ -6062,6 +6068,7 @@ check: ...@@ -6062,6 +6068,7 @@ check:
} }
lex->sql_command = SQLCOM_CHECK; lex->sql_command = SQLCOM_CHECK;
lex->check_opt.init(); lex->check_opt.init();
lex->alter_info.reset();
} }
table_list opt_mi_check_type table_list opt_mi_check_type
{} {}
...@@ -6093,6 +6100,7 @@ optimize: ...@@ -6093,6 +6100,7 @@ optimize:
lex->sql_command = SQLCOM_OPTIMIZE; lex->sql_command = SQLCOM_OPTIMIZE;
lex->no_write_to_binlog= $2; lex->no_write_to_binlog= $2;
lex->check_opt.init(); lex->check_opt.init();
lex->alter_info.reset();
} }
table_list table_list
{} {}
......
...@@ -1338,7 +1338,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) ...@@ -1338,7 +1338,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
if (splits != info->s->state.split) if (splits != info->s->state.split)
{ {
mi_check_print_warning(param, mi_check_print_warning(param,
"Found %10s parts Should be: %s parts", "Found %10s key parts. Should be: %s",
llstr(splits,llbuff), llstr(splits,llbuff),
llstr(info->s->state.split,llbuff2)); llstr(info->s->state.split,llbuff2));
} }
......
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