summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorunknown <holyfoot/hf@hfmain.(none)>2007-06-14 16:42:43 +0500
committerunknown <holyfoot/hf@hfmain.(none)>2007-06-14 16:42:43 +0500
commitac3f69146c9c58d331ec9c71e5c8c7a3d74e9412 (patch)
tree970f3c802c31f6740056dc4d047fed4ec26d9ab9 /sql/sql_table.cc
parenta7bb31a7ad2e6ecc1c9d1dcfbe952ee4cc979412 (diff)
parentfec318f4253a9c6eaad6574cbb91dba1617a5db3 (diff)
downloadmariadb-git-ac3f69146c9c58d331ec9c71e5c8c7a3d74e9412.tar.gz
Merge bk@192.168.21.1:mysql-5.1
into mysql.com:/d2/hf/mrg/mysql-5.1-opt client/mysqltest.c: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/set_var.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_yacc.yy: Auto merged mysql-test/include/mix1.inc: merging mysql-test/r/innodb_mysql.result: merging sql/sql_select.cc: merging
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc78
1 files changed, 60 insertions, 18 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index cdedb05564d..5abf995d49a 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1161,6 +1161,31 @@ void release_ddl_log()
*/
+/**
+ @brief construct a temporary shadow file name.
+
+ @details Make a shadow file name used by ALTER TABLE to construct the
+ modified table (with keeping the original). The modified table is then
+ moved back as original table. The name must start with the temp file
+ prefix so it gets filtered out by table files listing routines.
+
+ @param[out] buff buffer to receive the constructed name
+ @param bufflen size of buff
+ @param lpt alter table data structure
+
+ @retval path length
+*/
+
+uint build_table_shadow_filename(char *buff, size_t bufflen,
+ ALTER_PARTITION_PARAM_TYPE *lpt)
+{
+ char tmp_name[FN_REFLEN];
+ my_snprintf (tmp_name, sizeof (tmp_name), "%s-%s", tmp_file_prefix,
+ lpt->table_name);
+ return build_table_filename(buff, bufflen, lpt->db, tmp_name, "", FN_IS_TMP);
+}
+
+
/*
SYNOPSIS
mysql_write_frm()
@@ -1201,8 +1226,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
/*
Build shadow frm file name
*/
- build_table_filename(shadow_path, sizeof(shadow_path), lpt->db,
- lpt->table_name, "#", 0);
+ build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
strxmov(shadow_frm_name, shadow_path, reg_ext, NullS);
if (flags & WFRM_WRITE_SHADOW)
{
@@ -1225,6 +1249,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
if (part_info)
{
+ TABLE_SHARE *share= lpt->table->s;
if (!(part_syntax_buf= generate_partition_syntax(part_info,
&syntax_len,
TRUE, TRUE)))
@@ -1232,7 +1257,16 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
DBUG_RETURN(TRUE);
}
part_info->part_info_string= part_syntax_buf;
- part_info->part_info_len= syntax_len;
+ share->partition_info_len= part_info->part_info_len= syntax_len;
+ if (share->partition_info_buffer_size < syntax_len + 1)
+ {
+ share->partition_info_buffer_size= syntax_len+1;
+ if (!(share->partition_info=
+ (char*) alloc_root(&share->mem_root, syntax_len+1)))
+ DBUG_RETURN(TRUE);
+
+ }
+ memcpy((char*) share->partition_info, part_syntax_buf, syntax_len + 1);
}
}
#endif
@@ -5713,21 +5747,31 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
table_list->table_name_length,
table_list->table_name, 0);
- /* Disable alter of enabled log tables */
- if (table_kind && logger.is_log_table_enabled(table_kind))
+ if (table_kind)
{
- my_error(ER_BAD_LOG_STATEMENT, MYF(0), "ALTER");
- DBUG_RETURN(TRUE);
- }
+ /* Disable alter of enabled log tables */
+ if (logger.is_log_table_enabled(table_kind))
+ {
+ my_error(ER_BAD_LOG_STATEMENT, MYF(0), "ALTER");
+ DBUG_RETURN(TRUE);
+ }
- /* Disable alter of log tables to unsupported engine */
- if (table_kind &&
- (create_info->used_fields & HA_CREATE_USED_ENGINE) &&
- (!create_info->db_type || /* unknown engine */
- !(create_info->db_type->flags & HTON_SUPPORT_LOG_TABLES)))
- {
- my_error(ER_UNSUPORTED_LOG_ENGINE, MYF(0));
- DBUG_RETURN(TRUE);
+ /* Disable alter of log tables to unsupported engine */
+ if ((create_info->used_fields & HA_CREATE_USED_ENGINE) &&
+ (!create_info->db_type || /* unknown engine */
+ !(create_info->db_type->flags & HTON_SUPPORT_LOG_TABLES)))
+ {
+ my_error(ER_UNSUPORTED_LOG_ENGINE, MYF(0));
+ DBUG_RETURN(TRUE);
+ }
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (alter_info->flags & ALTER_PARTITION)
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "PARTITION", "log table");
+ DBUG_RETURN(TRUE);
+ }
+#endif
}
}
@@ -5756,8 +5800,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
strxnmov(new_name_buff, sizeof (new_name_buff) - 1, mysql_data_home, "/", db,
"/", table_name, reg_ext, NullS);
(void) unpack_filename(new_name_buff, new_name_buff);
- if (lower_case_table_names != 2)
- my_casedn_str(files_charset_info, new_name_buff);
/*
If this is just a rename of a view, short cut to the
following scenario: 1) lock LOCK_open 2) do a RENAME