1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

Post-merge fix.

This commit is contained in:
igor@olga.mysql.com
2007-06-04 03:03:15 -07:00
parent ca49b83d5a
commit 31c57a1efc
9 changed files with 155 additions and 127 deletions

View File

@@ -232,18 +232,6 @@ uint build_tmptable_filename(THD* thd, char *buff, size_t bufflen)
DBUG_RETURN(length);
}
/*
Return values for compare_tables().
If you make compare_tables() non-static, move them to a header file.
*/
enum enum_compare_tables_result
{
ALTER_TABLE_METADATA_ONLY= 0,
ALTER_TABLE_DATA_CHANGED= 1,
ALTER_TABLE_INDEX_CHANGED= 2
};
/*
--------------------------------------------------------------------------
@@ -4921,7 +4909,7 @@ compare_tables(TABLE *table,
Alter_info *alter_info,
HA_CREATE_INFO *create_info,
uint order_num,
enum enum_compare_tables_result *need_copy_table,
enum_alter_table_change_level *need_copy_table,
KEY **key_info_buffer,
uint **index_drop_buffer, uint *index_drop_count,
uint **index_add_buffer, uint *index_add_count)
@@ -5414,6 +5402,23 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change, table->s->table_name);
goto err;
}
/*
Check that the DATE/DATETIME not null field we are going to add is
either has a default value or the '0000-00-00' is allowed by the
set sql mode.
If the '0000-00-00' value isn't allowed then raise the error_if_not_empty
flag to allow ALTER TABLE only if the table to be altered is empty.
*/
if ((def->sql_type == MYSQL_TYPE_DATE ||
def->sql_type == MYSQL_TYPE_NEWDATE ||
def->sql_type == MYSQL_TYPE_DATETIME) &&
!alter_info->datetime_field &&
!(~def->flags & (NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG)) &&
thd->variables.sql_mode & MODE_NO_ZERO_DATE)
{
alter_info->datetime_field= def;
alter_info->error_if_not_empty= TRUE;
}
if (!def->after)
new_create_list.push_back(def);
else if (def->after == first_keyword)
@@ -5433,6 +5438,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
goto err;
}
find_it.after(def); // Put element after this
alter_info->change_level= ALTER_TABLE_DATA_CHANGED;
}
}
if (alter_info->alter_list.elements)
@@ -5674,7 +5680,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
handlerton *old_db_type, *new_db_type, *save_old_db_type;
legacy_db_type table_type;
frm_type_enum frm_type;
enum_compare_tables_result need_copy_table= ALTER_TABLE_METADATA_ONLY;
enum_alter_table_change_level need_copy_table= ALTER_TABLE_METADATA_ONLY;
#ifdef WITH_PARTITION_STORAGE_ENGINE
uint fast_alter_partition= 0;
bool partition_changed= FALSE;
@@ -6058,6 +6064,8 @@ view_err:
if (mysql_prepare_alter_table(thd, table, create_info, alter_info))
goto err;
need_copy_table= alter_info->change_level;
set_table_default_charset(thd, create_info, db);
@@ -6070,7 +6078,7 @@ view_err:
need_copy_table= ALTER_TABLE_DATA_CHANGED;
else
{
enum_compare_tables_result need_copy_table_res;
enum_alter_table_change_level need_copy_table_res;
/* Check how much the tables differ. */
if (compare_tables(table, alter_info,
create_info, order_num,
@@ -6317,7 +6325,7 @@ view_err:
alter_info->create_list, ignore,
order_num, order, &copied, &deleted,
alter_info->keys_onoff,
error_if_not_empty);
alter_info->error_if_not_empty);
}
else
{
@@ -6675,11 +6683,11 @@ err:
the table to be altered isn't empty.
Report error here.
*/
if (error_if_not_empty && thd->row_count)
if (alter_info->error_if_not_empty && thd->row_count)
{
const char *f_val= 0;
enum enum_mysql_timestamp_type t_type= MYSQL_TIMESTAMP_DATE;
switch (new_datetime_field->sql_type)
switch (alter_info->datetime_field->sql_type)
{
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_NEWDATE:
@@ -6698,7 +6706,7 @@ err:
thd->abort_on_warning= TRUE;
make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
f_val, strlength(f_val), t_type,
new_datetime_field->field_name);
alter_info->datetime_field->field_name);
thd->abort_on_warning= save_abort_on_warning;
}
if (name_lock)