mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
build_frm_image(): don't try to guess the "real table name" from the
field list, it doesn't work if ALTER TABLE has replaced all fields. Instead, pass the correct original table name down from the caller.
This commit is contained in:
@ -408,4 +408,7 @@ Warning 1688 Comment for index 'i1' is too long (max = 1024)
|
||||
CREATE INDEX i2 ON t1_toupg(c2) COMMENT '01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234';
|
||||
Warnings:
|
||||
Warning 1688 Comment for index 'i2' is too long (max = 1024)
|
||||
ALTER TABLE t1_toupg drop column c1, drop column c2, drop column c3, add column c4 int, COMMENT='012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012301234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234';
|
||||
Warnings:
|
||||
Warning 1628 Comment for table 't1_toupg' is too long (max = 2048)
|
||||
drop table t1_toupg;
|
||||
|
@ -125,6 +125,8 @@ ALTER TABLE t1_toupg ADD c3 TIMESTAMP COMMENT 'abcdefghijabcdefghijabcdefghijabc
|
||||
ALTER TABLE t1_toupg ADD INDEX i1(c1) COMMENT '01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234';
|
||||
# Add index with comment using CREATE INDEX
|
||||
CREATE INDEX i2 ON t1_toupg(c2) COMMENT '01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234';
|
||||
# Alter the existing table, replace all columns, change comment
|
||||
ALTER TABLE t1_toupg drop column c1, drop column c2, drop column c3, add column c4 int, COMMENT='012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012301234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234';
|
||||
drop table t1_toupg;
|
||||
|
||||
|
||||
|
@ -4559,6 +4559,9 @@ err:
|
||||
Create a table
|
||||
|
||||
@param thd Thread object
|
||||
@param orig_db Database for error messages
|
||||
@param orig_table_name Table name for error messages
|
||||
(it's different from table_name for ALTER TABLE)
|
||||
@param db Database
|
||||
@param table_name Table name
|
||||
@param path Path to table (i.e. to its .FRM file without
|
||||
@ -4587,6 +4590,7 @@ err:
|
||||
|
||||
static
|
||||
int create_table_impl(THD *thd,
|
||||
const char *orig_db, const char *orig_table_name,
|
||||
const char *db, const char *table_name,
|
||||
const char *path,
|
||||
HA_CREATE_INFO *create_info,
|
||||
@ -4767,8 +4771,9 @@ int create_table_impl(THD *thd,
|
||||
}
|
||||
else
|
||||
{
|
||||
file= mysql_create_frm_image(thd, db, table_name, create_info, alter_info,
|
||||
create_table_mode, key_info, key_count, frm);
|
||||
file= mysql_create_frm_image(thd, orig_db, orig_table_name, create_info,
|
||||
alter_info, create_table_mode, key_info,
|
||||
key_count, frm);
|
||||
if (!file)
|
||||
goto err;
|
||||
if (rea_create_table(thd, frm, path, db, table_name, create_info,
|
||||
@ -4884,9 +4889,9 @@ int mysql_create_table_no_lock(THD *thd,
|
||||
}
|
||||
}
|
||||
|
||||
res= create_table_impl(thd, db, table_name, path, create_info,
|
||||
alter_info, create_table_mode, is_trans,
|
||||
¬_used_1, ¬_used_2, &frm);
|
||||
res= create_table_impl(thd, db, table_name, db, table_name, path,
|
||||
create_info, alter_info, create_table_mode,
|
||||
is_trans, ¬_used_1, ¬_used_2, &frm);
|
||||
my_free(const_cast<uchar*>(frm.str));
|
||||
return res;
|
||||
}
|
||||
@ -8514,7 +8519,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
|
||||
tmp_disable_binlog(thd);
|
||||
create_info->options|=HA_CREATE_TMP_ALTER;
|
||||
error= create_table_impl(thd, alter_ctx.new_db, alter_ctx.tmp_name,
|
||||
error= create_table_impl(thd,
|
||||
alter_ctx.db, alter_ctx.table_name,
|
||||
alter_ctx.new_db, alter_ctx.tmp_name,
|
||||
alter_ctx.get_tmp_path(),
|
||||
create_info, alter_info,
|
||||
C_ALTER_TABLE_FRM_ONLY, NULL,
|
||||
|
@ -173,24 +173,15 @@ LEX_CUSTRING build_frm_image(THD *thd, const char *table,
|
||||
|
||||
if (tmp_len < create_info->comment.length)
|
||||
{
|
||||
char *real_table_name= (char*) table;
|
||||
List_iterator<Create_field> it(create_fields);
|
||||
Create_field *field;
|
||||
while ((field=it++))
|
||||
{
|
||||
if (field->field && field->field->table &&
|
||||
(real_table_name= field->field->table->s->table_name.str))
|
||||
break;
|
||||
}
|
||||
if (thd->is_strict_mode())
|
||||
{
|
||||
my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0),
|
||||
real_table_name, TABLE_COMMENT_MAXLEN);
|
||||
table, TABLE_COMMENT_MAXLEN);
|
||||
DBUG_RETURN(frm);
|
||||
}
|
||||
char warn_buff[MYSQL_ERRMSG_SIZE];
|
||||
my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_TOO_LONG_TABLE_COMMENT),
|
||||
real_table_name, TABLE_COMMENT_MAXLEN);
|
||||
table, TABLE_COMMENT_MAXLEN);
|
||||
push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
ER_TOO_LONG_TABLE_COMMENT, warn_buff);
|
||||
create_info->comment.length= tmp_len;
|
||||
|
Reference in New Issue
Block a user