3475 Dmitry Lenev 2012-01-31
WL#5534 Online ALTER, Phase 1.
Patch #81:
- Documented how contents of Alter_inplace_info::key_info_buffer
are produced.
- Got rid of redundant calls to mysql_prepare_create_table().
modified:
mysql-test/r/archive.result
mysql-test/r/ctype_utf8mb4.result
mysql-test/suite/innodb/r/innodb_index_large_prefix.result
mysql-test/suite/innodb/r/innodb_mysql.result
mysql-test/suite/innodb/r/innodb_prefix_index_liftedlimit.result
sql/ha_partition.cc
sql/handler.h
sql/sql_table.cc
3474 Jon Olav Hauglid 2012-01-31 [merge]
Merge from mysql-trunk to mysql-trunk-wl5534
No conflicts
added:
mysql-test/suite/opt_trace/r/eq_range_statistics.result
mysql-test/suite/opt_trace/t/eq_range_statistics.test
mysql-test/suite/sys_vars/r/eq_range_index_dive_limit_basic.result
mysql-test/suite/sys_vars/t/eq_range_index_dive_limit_basic.test
modified:
include/my_base.h
libmysql/CMakeLists.txt
mysql-test/include/func_in.inc
mysql-test/include/join_cache.inc
mysql-test/include/subquery_mat.inc
mysql-test/include/subquery_sj.inc
mysql-test/include/wait_for_slave_io_error.inc
mysql-test/r/change_user.result
mysql-test/r/connect.result
mysql-test/r/derived.result
mysql-test/r/func_in_all.result
mysql-test/r/func_in_icp.result
mysql-test/r/func_in_icp_mrr.result
mysql-test/r/func_in_mrr.result
mysql-test/r/func_in_mrr_cost.result
mysql-test/r/func_in_none.result
mysql-test/r/greedy_optimizer.result
mysql-test/r/group_by.result
mysql-test/r/group_min_max.result
mysql-test/r/index_merge_myisam.result
mysql-test/r/innodb_icp_all.result
mysql-test/r/innodb_mrr_all.result
mysql-test/r/innodb_mrr_cost_all.result
mysql-test/r/join_cache_bka.result
mysql-test/r/join_cache_bka_nixbnl.result
mysql-test/r/join_cache_bkaunique.result
mysql-test/r/join_cache_bnl.result
mysql-test/r/join_cache_nojb.result
mysql-test/r/join_nested.result
mysql-test/r/join_nested_bka.result
mysql-test/r/join_nested_bka_nixbnl.result
mysql-test/r/lowercase_fs_off.result
mysql-test/r/merge.result
mysql-test/r/myisam_explain_non_select_all.result
mysql-test/r/mysql_upgrade.result
mysql-test/r/mysqld--help-notwin.result
mysql-test/r/mysqld--help-win.result
mysql-test/r/optimizer_debug_sync.result
mysql-test/r/order_by_all.result
mysql-test/r/sp-security.result
mysql-test/r/sp.result
mysql-test/r/subquery_all.result
mysql-test/r/subquery_all_bka.result
mysql-test/r/subquery_mat.result
mysql-test/r/subquery_mat_all.result
mysql-test/r/subquery_mat_none.result
mysql-test/r/subquery_sj_all.result
mysql-test/r/subquery_sj_all_bka.result
mysql-test/r/subquery_sj_all_bka_nixbnl.result
mysql-test/r/subquery_sj_all_bkaunique.result
mysql-test/r/subquery_sj_dupsweed.result
mysql-test/r/subquery_sj_dupsweed_bka.result
mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result
mysql-test/r/subquery_sj_dupsweed_bkaunique.result
mysql-test/r/subquery_sj_firstmatch.result
mysql-test/r/subquery_sj_firstmatch_bka.result
mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result
mysql-test/r/subquery_sj_firstmatch_bkaunique.result
mysql-test/r/subquery_sj_loosescan.result
mysql-test/r/subquery_sj_loosescan_bka.result
mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result
mysql-test/r/subquery_sj_loosescan_bkaunique.result
mysql-test/r/subquery_sj_mat.result
mysql-test/r/subquery_sj_mat_bka.result
mysql-test/r/subquery_sj_mat_bka_nixbnl.result
mysql-test/r/subquery_sj_mat_bkaunique.result
mysql-test/r/subquery_sj_mat_nosj.result
mysql-test/r/subquery_sj_none.result
mysql-test/r/subquery_sj_none_bka.result
mysql-test/r/subquery_sj_none_bka_nixbnl.result
mysql-test/r/subquery_sj_none_bkaunique.result
mysql-test/r/subselect_innodb.result
mysql-test/suite/innodb/r/innodb_mysql.result
mysql-test/suite/opt_trace/include/range.inc
mysql-test/suite/opt_trace/r/bugs_no_prot_all.result
mysql-test/suite/opt_trace/r/bugs_no_prot_none.result
mysql-test/suite/opt_trace/r/bugs_ps_prot_all.result
mysql-test/suite/opt_trace/r/bugs_ps_prot_none.result
mysql-test/suite/opt_trace/r/charset.result
mysql-test/suite/opt_trace/r/general2_no_prot.result
mysql-test/suite/opt_trace/r/general2_ps_prot.result
mysql-test/suite/opt_trace/r/general_no_prot_all.result
mysql-test/suite/opt_trace/r/general_no_prot_none.result
mysql-test/suite/opt_trace/r/general_ps_prot_all.result
mysql-test/suite/opt_trace/r/general_ps_prot_none.result
mysql-test/suite/opt_trace/r/range_no_prot.result
mysql-test/suite/opt_trace/r/range_ps_prot.result
mysql-test/suite/opt_trace/r/subquery_no_prot.result
mysql-test/suite/opt_trace/r/subquery_ps_prot.result
mysql-test/suite/parts/inc/partition-dml-1-7.inc
mysql-test/suite/parts/inc/partition-dml-1-8.inc
mysql-test/suite/parts/inc/partition_key_16col.inc
mysql-test/suite/parts/inc/partition_key_32col.inc
mysql-test/suite/parts/inc/partition_key_4col.inc
mysql-test/suite/parts/inc/partition_key_8col.inc
mysql-test/suite/parts/r/partition_special_myisam.result
mysql-test/suite/rpl/r/rpl_checksum.result
mysql-test/suite/rpl/r/rpl_log_pos.result
mysql-test/suite/rpl/r/rpl_manual_change_index_file.result
mysql-test/suite/rpl/r/rpl_packet.result
mysql-test/suite/rpl/r/rpl_row_event_max_size.result
mysql-test/suite/rpl/t/rpl_checksum.test
mysql-test/suite/rpl/t/rpl_log_pos.test
mysql-test/suite/rpl/t/rpl_manual_change_index_file.test
mysql-test/suite/rpl/t/rpl_packet.test
mysql-test/suite/rpl/t/rpl_row_event_max_size.test
mysql-test/suite/sys_vars/r/old_passwords_func.result
mysql-test/suite/sys_vars/r/optimizer_switch_basic.result
mysql-test/suite/sys_vars/r/secure_auth_basic.result
mysql-test/suite/sys_vars/r/secure_auth_func.result
mysql-test/suite/sys_vars/t/secure_auth_basic.test
mysql-test/t/change_user.test
mysql-test/t/connect.test
mysql-test/t/group_by.test
mysql-test/t/merge.test
mysql-test/t/mysql_upgrade.test
mysql-test/t/optimizer_debug_sync.test
mysql-test/t/sp-security.test
mysql-test/t/sp.test
mysql-test/valgrind.supp
scripts/mysql_system_tables_fix.sql
sql/filesort.cc
sql/filesort_utils.h
sql/handler.cc
sql/item.cc
sql/item_cmpfunc.h
sql/item_func.cc
sql/item_func.h
sql/mysqld.cc
sql/opt_range.cc
sql/sql_acl.cc
sql/sql_class.h
sql/sql_executor.cc
sql/sql_join_buffer.cc
sql/sql_join_buffer.h
sql/sql_optimizer.cc
sql/sql_optimizer.h
sql/sql_parse.cc
sql/sql_priv.h
sql/sql_select.cc
sql/structs.h
sql/sys_vars.cc
sql/table.h
storage/innobase/lock/lock0lock.cc
storage/innobase/os/os0file.cc
storage/myisammrg/ha_myisammrg.cc
storage/perfschema/pfs_instr_class.cc
storage/perfschema/pfs_instr_class.h
storage/perfschema/pfs_server.cc
unittest/gunit/filesort_buffer-t.cc
=== modified file 'mysql-test/r/archive.result'
--- a/mysql-test/r/archive.result 2011-12-12 12:06:08 +0000
+++ b/mysql-test/r/archive.result 2012-01-31 14:35:18 +0000
@@ -12892,7 +12892,6 @@ ERROR HY000: Can't create table 'test.#s
SHOW WARNINGS;
Level Code Message
Warning 1071 Specified key was too long; max key length is 8 bytes
-Warning 1071 Specified key was too long; max key length is 8 bytes
Warning 1194 Found wrong key definition in #sql-temporary; Please do "ALTER TABLE `#sql-temporary` FORCE" to fix it!
Warning 1194 Found wrong key definition in #sql-temporary; Please do "ALTER TABLE `#sql-temporary` FORCE" to fix it!
Error 1005 Can't create table 'test.#sql-temporary' (errno: -1)
=== modified file 'mysql-test/r/ctype_utf8mb4.result'
--- a/mysql-test/r/ctype_utf8mb4.result 2011-06-24 12:53:57 +0000
+++ b/mysql-test/r/ctype_utf8mb4.result 2012-01-31 14:35:18 +0000
@@ -2515,7 +2515,6 @@ MODIFY subject varchar(255) CHARACTER SE
MODIFY p varchar(255) CHARACTER SET utf8;
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
-Warning 1071 Specified key was too long; max key length is 1000 bytes
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
=== modified file 'mysql-test/suite/innodb/r/innodb_index_large_prefix.result'
--- a/mysql-test/suite/innodb/r/innodb_index_large_prefix.result 2011-11-20 21:00:25 +0000
+++ b/mysql-test/suite/innodb/r/innodb_index_large_prefix.result 2012-01-31 14:35:18 +0000
@@ -93,7 +93,6 @@ ERROR HY000: Too big row
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
-Warning 1071 Specified key was too long; max key length is 767 bytes
Error 139 Too big row
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
Error 1030 Got error 139 from storage engine
@@ -103,7 +102,6 @@ ERROR HY000: Too big row
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
-Warning 1071 Specified key was too long; max key length is 3072 bytes
Error 139 Too big row
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
Error 1030 Got error 139 from storage engine
@@ -131,18 +129,15 @@ set global innodb_large_prefix=0;
create index idx1 on worklog5743_2(a2(4000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
-Warning 1071 Specified key was too long; max key length is 767 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
-Warning 1071 Specified key was too long; max key length is 767 bytes
set global innodb_large_prefix=1;
create index idx2 on worklog5743_2(a2(4000));
ERROR HY000: Too big row
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
-Warning 1071 Specified key was too long; max key length is 3072 bytes
Error 139 Too big row
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
Error 1030 Got error 139 from storage engine
@@ -170,18 +165,15 @@ set global innodb_large_prefix=0;
create index idx1 on worklog5743_4(a2(4000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
-Warning 1071 Specified key was too long; max key length is 767 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
-Warning 1071 Specified key was too long; max key length is 767 bytes
set global innodb_large_prefix=1;
create index idx2 on worklog5743_4(a2(4000));
ERROR HY000: Too big row
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
-Warning 1071 Specified key was too long; max key length is 3072 bytes
Error 139 Too big row
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
Error 1030 Got error 139 from storage engine
@@ -209,20 +201,16 @@ set global innodb_large_prefix=0;
create index idx1 on worklog5743_8(a2(1000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
-Warning 1071 Specified key was too long; max key length is 767 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
-Warning 1071 Specified key was too long; max key length is 767 bytes
set global innodb_large_prefix=1;
create index idx2 on worklog5743_8(a2(3073));
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
-Warning 1071 Specified key was too long; max key length is 3072 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
-Warning 1071 Specified key was too long; max key length is 3072 bytes
create index idx3 on worklog5743_8(a2(3072));
show warnings;
Level Code Message
@@ -246,20 +234,16 @@ set global innodb_large_prefix=0;
create index idx1 on worklog5743_16(a2(1000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
-Warning 1071 Specified key was too long; max key length is 767 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 767 bytes
-Warning 1071 Specified key was too long; max key length is 767 bytes
set global innodb_large_prefix=1;
create index idx2 on worklog5743_16(a2(3073));
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
-Warning 1071 Specified key was too long; max key length is 3072 bytes
show warnings;
Level Code Message
Warning 1071 Specified key was too long; max key length is 3072 bytes
-Warning 1071 Specified key was too long; max key length is 3072 bytes
create index idx3 on worklog5743_16(a2(3072));
show warnings;
Level Code Message
@@ -401,11 +385,9 @@ ROW_FORMAT=DYNAMIC;
create index idx1 on worklog5743(a2);
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
-Warning 1071 Specified key was too long; max key length is 3072 bytes
create index idx2 on worklog5743(a3);
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
-Warning 1071 Specified key was too long; max key length is 3072 bytes
create index idx3 on worklog5743(a4);
show warnings;
Level Code Message
@@ -492,7 +474,6 @@ create table worklog5743(a TEXT not null
create index idx1 on worklog5743(a(3073));
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
-Warning 1071 Specified key was too long; max key length is 3072 bytes
create index idx2 on worklog5743(a(3072));
show create table worklog5743;
Table Create Table
=== modified file 'mysql-test/suite/innodb/r/innodb_mysql.result'
--- a/mysql-test/suite/innodb/r/innodb_mysql.result 2012-01-30 13:13:15 +0000
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result 2012-01-31 14:35:18 +0000
@@ -1131,7 +1131,6 @@ insert into t1 values('aaa');
alter table t1 add index(a(1024));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
-Warning 1071 Specified key was too long; max key length is 767 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
=== modified file 'mysql-test/suite/innodb/r/innodb_prefix_index_liftedlimit.result'
--- a/mysql-test/suite/innodb/r/innodb_prefix_index_liftedlimit.result 2011-12-08 20:34:49 +0000
+++ b/mysql-test/suite/innodb/r/innodb_prefix_index_liftedlimit.result 2012-01-31 14:35:18 +0000
@@ -1194,7 +1194,6 @@ DROP INDEX prefix_idx ON worklog5743;
CREATE INDEX prefix_idx ON worklog5743(col_1_varbinary (4000));
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
-Warning 1071 Specified key was too long; max key length is 3072 bytes
INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000));
SELECT col_1_varbinary = REPEAT("a", 4000) FROM worklog5743;
col_1_varbinary = REPEAT("a", 4000)
@@ -1252,7 +1251,6 @@ DROP INDEX prefix_idx ON worklog5743;
CREATE INDEX prefix_idx ON worklog5743(col_1_text (4000));
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
-Warning 1071 Specified key was too long; max key length is 3072 bytes
INSERT INTO worklog5743 VALUES(REPEAT("a", 4000),REPEAT("o", 4000));
SELECT col_1_text = REPEAT("a", 4000) FROM worklog5743;
col_1_text = REPEAT("a", 4000)
@@ -1368,5 +1366,4 @@ PRIMARY KEY (col_1_varchar(767))
CREATE INDEX prefix_idx ON worklog5743(col_1_varchar (1000));
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
-Warning 1071 Specified key was too long; max key length is 767 bytes
DROP TABLE worklog5743;
=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc 2012-01-26 10:02:26 +0000
+++ b/sql/ha_partition.cc 2012-01-31 14:35:18 +0000
@@ -7100,7 +7100,7 @@ err:
Alter_inplace_info::ADD_UNIQUE_INDEX |
Alter_inplace_info::ADD_PK_INDEX))
{
- Alter_inplace_info drop_info(ha_alter_info->ignore);
+ Alter_inplace_info drop_info(ha_alter_info->ignore, NULL, 0);
if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX)
drop_info.handler_flags|= Alter_inplace_info::DROP_INDEX;
if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_UNIQUE_INDEX)
=== modified file 'sql/handler.h'
--- a/sql/handler.h 2012-01-26 13:11:26 +0000
+++ b/sql/handler.h 2012-01-31 14:35:18 +0000
@@ -1027,16 +1027,21 @@ public:
// Table is renamed
static const HA_ALTER_FLAGS ALTER_RENAME = 1L << 17;
- /*
- TODO/FIXME: Specify if key_info_buffer contains KEY objects produced
- as result of mysql_prepare_create_table() or correspond
- to KEYs in opened new .FRM. KEY_PART::fieldnr and some
- flags may differ in these cases...
+ /**
+ Array of KEYs for new version of table - including KEYs to be added.
+
+ @note Currently this array is produced as result of
+ mysql_prepare_create_table() call.
+ This means that it follows different convention for
+ KEY_PART_INFO::fieldnr values than objects in TABLE::key_info
+ array.
+
+ @todo This is mainly due to the fact that we need to keep compatibility
+ with deprecated handler::add_index() call. We plan to switch to
+ TABLE::key_info numbering once the deprecated API is removed.
KEYs are sorted - see sort_keys().
*/
-
- /** Array of KEYs for new version of table - including KEYs to be added. */
KEY *key_info_buffer;
/** Size of key_info_buffer array. */
@@ -1076,9 +1081,9 @@ public:
/** true for ALTER IGNORE TABLE ... */
const bool ignore;
- Alter_inplace_info(bool ignore_arg)
- :key_info_buffer(NULL),
- key_count(0),
+ Alter_inplace_info(bool ignore_arg, KEY *key_info_arg, uint key_count_arg)
+ :key_info_buffer(key_info_arg),
+ key_count(key_count_arg),
index_drop_count(0),
index_drop_buffer(NULL),
index_add_count(0),
=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc 2012-01-30 08:37:12 +0000
+++ b/sql/sql_table.cc 2012-01-31 14:35:18 +0000
@@ -4066,6 +4066,9 @@ void sp_prepare_create_field(THD *thd, C
in the storage engine.
@param[out] is_trans Identifies the type of engine where the table
was created: either trans or non-trans.
+ @param[out] key_info Array of KEY objects describing keys in table
+ which was created.
+ @param[out] key_count Number of keys in table which was created.
If one creates a temporary table, this is automatically opened
@@ -4087,11 +4090,12 @@ bool create_table_impl(THD *thd,
bool internal_tmp_table,
uint select_field_count,
bool no_ha_table,
- bool *is_trans)
+ bool *is_trans,
+ KEY **key_info,
+ uint *key_count)
{
const char *alias;
- uint db_options, key_count;
- KEY *key_info_buffer;
+ uint db_options;
handler *file;
bool error= TRUE;
DBUG_ENTER("create_table_impl");
@@ -4286,7 +4290,7 @@ bool create_table_impl(THD *thd,
if (mysql_prepare_create_table(thd, create_info, alter_info,
internal_tmp_table,
&db_options, file,
- &key_info_buffer, &key_count,
+ key_info, key_count,
select_field_count))
goto err;
@@ -4444,7 +4448,7 @@ bool create_table_impl(THD *thd,
*/
if (rea_create_table(thd, path, db, table_name,
create_info, alter_info->create_list,
- key_count, key_info_buffer, file, no_ha_table))
+ *key_count, *key_info, file, no_ha_table))
goto err;
if (!no_ha_table && create_info->options & HA_LEX_CREATE_TMP_TABLE)
@@ -4531,6 +4535,8 @@ bool mysql_create_table_no_lock(THD *thd
uint select_field_count,
bool *is_trans)
{
+ KEY *not_used_1;
+ uint not_used_2;
char path[FN_REFLEN + 1];
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
@@ -4539,7 +4545,8 @@ bool mysql_create_table_no_lock(THD *thd
build_table_filename(path, sizeof(path) - 1, db, table_name, "", 0);
return create_table_impl(thd, db, table_name, path, create_info, alter_info,
- false, select_field_count, false, is_trans);
+ false, select_field_count, false, is_trans,
+ ¬_used_1, ¬_used_2);
}
@@ -5080,6 +5087,8 @@ static int compare_uint(const uint *s, c
@param alter_info Alter options, fields and keys for the new
table.
@param create_info Create options for the new table.
+ @param varchar Indicates that new definition has new
+ VARCHAR column.
@param[out] ha_alter_info Data structures needed for in-place alter
First argument 'table' contains information of the original
@@ -5113,6 +5122,7 @@ static bool fill_alter_inplace_info(THD
TABLE *table,
Alter_info *alter_info,
HA_CREATE_INFO *create_info,
+ bool varchar,
Alter_inplace_info *ha_alter_info)
{
Field **f_ptr, *field;
@@ -5120,26 +5130,9 @@ static bool fill_alter_inplace_info(THD
Create_field *new_field;
KEY_PART_INFO *key_part, *new_part;
KEY_PART_INFO *end;
- /*
- Remember if the new definition has new VARCHAR column;
- create_info->varchar will be reset in mysql_prepare_create_table.
- */
- bool varchar= create_info->varchar;
uint candidate_key_count= 0;
DBUG_ENTER("fill_alter_inplace_info");
- uint not_used= 0;
-
- /* Create the prepared information. */
- if (mysql_prepare_create_table(thd, create_info,
- alter_info,
- (table->s->tmp_table != NO_TMP_TABLE),
- ¬_used,
- table->file,
- &ha_alter_info->key_info_buffer,
- &ha_alter_info->key_count,
- /* select_field_count */ 0))
- DBUG_RETURN(true);
/* Allocate result buffers. */
if (! (ha_alter_info->index_drop_buffer=
(KEY**) thd->alloc(sizeof(KEY*) * table->s->keys)) ||
@@ -7027,30 +7020,25 @@ bool mysql_alter_table(THD *thd,char *ne
Create .FRM for new version of table with a temporary name.
We don't log the statement, it will be logged later.
- Create a copy of HA_CREATE_INFO and Alter_info.
- mysql_prepare_create_table() which is called as part of .FRM
- creation process will change these structures.
- OTOH fill_alter_inplace_info() which might be called later
- needs unchanged copies of these structures in order to be
- able to call this function too. So copies of HA_CREATE_INFO
- and Alter_info have to be created.
-
- TODO/FIXME: This can be avoided in future if we change the code
- to pass structures built during .FRM creation (such as a KEY array)
- from create_table_impl() to fill_alter_inplace_info() or,
- alternatively, will change the in-place SE API to accept structures
- which are constructed during opening new .FRM version instead
- (unbelievable, but the former and the latter have significant
- differences in field numbering and key flags).
+ Keep information about keys in newly created table as it
+ will be used later to construct Alter_inplace_info object
+ and by fill_alter_inplace_info() call.
*/
- HA_CREATE_INFO save_create_info(*create_info);
- Alter_info save_alter_info(*alter_info, thd->mem_root);
+ KEY *key_info;
+ uint key_count;
+ /*
+ Remember if the new definition has new VARCHAR column;
+ create_info->varchar will be reset in create_table_impl()/
+ mysql_prepare_create_table().
+ */
+ bool varchar= create_info->varchar;
tmp_disable_binlog(thd);
error= create_table_impl(thd, alter_ctx.new_db, alter_ctx.tmp_name,
alter_ctx.get_tmp_path(),
create_info, alter_info,
- true, 0, true, NULL);
+ true, 0, true, NULL,
+ &key_info, &key_count);
reenable_binlog(thd);
if (error)
@@ -7061,14 +7049,13 @@ bool mysql_alter_table(THD *thd,char *ne
if (alter_info->requested_algorithm != Alter_info::ALTER_TABLE_ALGORITHM_COPY)
{
- Alter_inplace_info ha_alter_info(ignore);
+ Alter_inplace_info ha_alter_info(ignore, key_info, key_count);
TABLE *altered_table= NULL;
bool use_inplace= true;
/* Fill the Alter_inplace_info structure. */
- if (fill_alter_inplace_info(thd, table, &save_alter_info,
- &save_create_info,
- &ha_alter_info))
+ if (fill_alter_inplace_info(thd, table, alter_info, create_info,
+ varchar, &ha_alter_info))
goto err_new_table_cleanup;
// We assume that the table is non-temporary.
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk-wl5534 branch (Dmitry.Lenev:3474 to 3475) WL#5534 | Dmitry Lenev | 31 Jan |