summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <mikael@c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se>2006-06-13 11:44:43 -0400
committerunknown <mikael@c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se>2006-06-13 11:44:43 -0400
commitb19c1896adea1166adb8e80552ac3abfa7642205 (patch)
treeb1bf5355f10cab431d785e66842d88df528533fe /sql
parentb5697a5fc526deca33a0d71a7c0d48c28299f1b0 (diff)
parentf6d409613dd3598ef20816aa53909e49a69d5ea3 (diff)
downloadmariadb-git-b19c1896adea1166adb8e80552ac3abfa7642205.tar.gz
Merge c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/clean-mysql-5.1
into c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/bug19305
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_partition.cc6
-rw-r--r--sql/lock.cc34
-rw-r--r--sql/mysql_priv.h6
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_partition.cc232
-rw-r--r--sql/sql_partition.h3
-rw-r--r--sql/sql_show.cc5
-rw-r--r--sql/sql_table.cc4
8 files changed, 208 insertions, 84 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 77a150994ad..f151d89bb1a 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -611,6 +611,8 @@ int ha_partition::drop_partitions(const char *path)
DBUG_PRINT("info", ("Drop subpartition %s", part_name_buff));
if ((ret_error= file->delete_table((const char *) part_name_buff)))
error= ret_error;
+ if (deactivate_ddl_log_entry(sub_elem->log_entry->entry_pos))
+ error= 1;
} while (++j < no_subparts);
}
else
@@ -622,6 +624,8 @@ int ha_partition::drop_partitions(const char *path)
DBUG_PRINT("info", ("Drop partition %s", part_name_buff));
if ((ret_error= file->delete_table((const char *) part_name_buff)))
error= ret_error;
+ if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
+ error= 1;
}
if (part_elem->part_state == PART_IS_CHANGED)
part_elem->part_state= PART_NORMAL;
@@ -629,6 +633,7 @@ int ha_partition::drop_partitions(const char *path)
part_elem->part_state= PART_IS_DROPPED;
}
} while (++i < no_parts);
+ VOID(sync_ddl_log());
DBUG_RETURN(error);
}
@@ -745,6 +750,7 @@ int ha_partition::rename_partitions(const char *path)
*/
part_elem= part_it++;
if (part_elem->part_state == PART_IS_CHANGED ||
+ part_elem->part_state == PART_TO_BE_DROPPED ||
(part_elem->part_state == PART_IS_ADDED && temp_partitions))
{
if (m_is_sub_partitioned)
diff --git a/sql/lock.cc b/sql/lock.cc
index 80861e3beb5..e5003325df6 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -828,7 +828,7 @@ int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list)
if (wait_if_global_read_lock(thd, 0, 1))
DBUG_RETURN(1);
VOID(pthread_mutex_lock(&LOCK_open));
- if ((lock_retcode = lock_table_name(thd, table_list)) < 0)
+ if ((lock_retcode = lock_table_name(thd, table_list, TRUE)) < 0)
goto end;
if (lock_retcode && wait_for_locked_table_names(thd, table_list))
{
@@ -851,6 +851,7 @@ end:
lock_table_name()
thd Thread handler
table_list Lock first table in this list
+ check_in_use Do we need to check if table already in use by us
WARNING
If you are going to update the table, you should use
@@ -870,7 +871,7 @@ end:
> 0 table locked, but someone is using it
*/
-int lock_table_name(THD *thd, TABLE_LIST *table_list)
+int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use)
{
TABLE *table;
char key[MAX_DBKEY_LENGTH];
@@ -882,17 +883,22 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
key_length= create_table_def_key(thd, key, table_list, 0);
- /* Only insert the table if we haven't insert it already */
- for (table=(TABLE*) hash_first(&open_cache, (byte*)key, key_length, &state);
- table ;
- table = (TABLE*) hash_next(&open_cache,(byte*) key,key_length, &state))
+ if (check_in_use)
{
- if (table->in_use == thd)
+ /* Only insert the table if we haven't insert it already */
+ for (table=(TABLE*) hash_first(&open_cache, (byte*)key,
+ key_length, &state);
+ table ;
+ table = (TABLE*) hash_next(&open_cache,(byte*) key,
+ key_length, &state))
{
- DBUG_PRINT("info", ("Table is in use"));
- table->s->version= 0; // Ensure no one can use this
- table->locked_by_name= 1;
- DBUG_RETURN(0);
+ if (table->in_use == thd)
+ {
+ DBUG_PRINT("info", ("Table is in use"));
+ table->s->version= 0; // Ensure no one can use this
+ table->locked_by_name= 1;
+ DBUG_RETURN(0);
+ }
}
}
/*
@@ -917,10 +923,10 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
my_free((gptr) table,MYF(0));
DBUG_RETURN(-1);
}
-
+
/* Return 1 if table is in use */
DBUG_RETURN(test(remove_table_from_cache(thd, db, table_list->table_name,
- RTFC_NO_FLAG)));
+ check_in_use ? RTFC_NO_FLAG : RTFC_WAIT_OTHER_THREAD_FLAG)));
}
@@ -1003,7 +1009,7 @@ bool lock_table_names(THD *thd, TABLE_LIST *table_list)
for (lock_table= table_list; lock_table; lock_table= lock_table->next_local)
{
int got_lock;
- if ((got_lock=lock_table_name(thd,lock_table)) < 0)
+ if ((got_lock=lock_table_name(thd,lock_table, TRUE)) < 0)
goto end; // Fatal error
if (got_lock)
got_all_locks=0; // Someone is using table
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 76d8aa18f59..3d499b67519 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -1174,7 +1174,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
HA_CREATE_INFO *create_info,
TABLE_LIST *table_list,
List<create_field> *create_list,
- List<Key> *key_list, const char *db,
+ List<Key> *key_list, char *db,
const char *table_name,
uint fast_alter_partition);
uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info,
@@ -1204,10 +1204,12 @@ void create_subpartition_name(char *out, const char *in1,
typedef struct st_lock_param_type
{
+ TABLE_LIST table_list;
ulonglong copied;
ulonglong deleted;
THD *thd;
HA_CREATE_INFO *create_info;
+ ALTER_INFO *alter_info;
List<create_field> *create_list;
List<create_field> new_create_list;
List<Key> *key_list;
@@ -1687,7 +1689,7 @@ void unset_protect_against_global_read_lock(void);
/* Lock based on name */
int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list);
-int lock_table_name(THD *thd, TABLE_LIST *table_list);
+int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use);
void unlock_table_name(THD *thd, TABLE_LIST *table_list);
bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list);
bool lock_table_names(THD *thd, TABLE_LIST *table_list);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 2298de7eeb5..9b7d46119b7 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2686,7 +2686,7 @@ retry:
goto err;
// Code below is for repairing a crashed file
- if ((error= lock_table_name(thd, table_list)))
+ if ((error= lock_table_name(thd, table_list, TRUE)))
{
if (error < 0)
goto err;
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index a10a04ba9f9..2f79da7edf4 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -1675,6 +1675,7 @@ static int add_partition_options(File fptr, partition_element *p_elem)
{
int err= 0;
+ err+= add_space(fptr);
if (p_elem->tablespace_name)
err+= add_keyword_string(fptr,"TABLESPACE", FALSE,
p_elem->tablespace_name);
@@ -1702,7 +1703,7 @@ static int add_partition_values(File fptr, partition_info *part_info,
if (part_info->part_type == RANGE_PARTITION)
{
- err+= add_string(fptr, "VALUES LESS THAN ");
+ err+= add_string(fptr, " VALUES LESS THAN ");
if (p_elem->range_value != LONGLONG_MAX)
{
err+= add_begin_parenthesis(fptr);
@@ -1716,7 +1717,7 @@ static int add_partition_values(File fptr, partition_info *part_info,
{
uint i;
List_iterator<longlong> list_val_it(p_elem->list_val_list);
- err+= add_string(fptr, "VALUES IN ");
+ err+= add_string(fptr, " VALUES IN ");
uint no_items= p_elem->list_val_list.elements;
err+= add_begin_parenthesis(fptr);
if (p_elem->has_null_value)
@@ -1740,7 +1741,7 @@ static int add_partition_values(File fptr, partition_info *part_info,
err+= add_end_parenthesis(fptr);
}
end:
- return err + add_space(fptr);
+ return err;
}
/*
@@ -1754,6 +1755,7 @@ end:
buf_length A pointer to the returned buffer length
use_sql_alloc Allocate buffer from sql_alloc if true
otherwise use my_malloc
+ show_partition_options Should we display partition options
RETURN VALUES
NULL error
@@ -1781,7 +1783,8 @@ end:
char *generate_partition_syntax(partition_info *part_info,
uint *buf_length,
- bool use_sql_alloc)
+ bool use_sql_alloc,
+ bool show_partition_options)
{
uint i,j, tot_no_parts, no_subparts, no_parts;
partition_element *part_elem;
@@ -1882,12 +1885,12 @@ char *generate_partition_syntax(partition_info *part_info,
first= FALSE;
err+= add_partition(fptr);
err+= add_name_string(fptr, part_elem->partition_name);
- err+= add_space(fptr);
err+= add_partition_values(fptr, part_info, part_elem);
if (!part_info->is_sub_partitioned() ||
part_info->use_default_subpartitions)
{
- err+= add_partition_options(fptr, part_elem);
+ if (show_partition_options)
+ err+= add_partition_options(fptr, part_elem);
}
else
{
@@ -1900,8 +1903,8 @@ char *generate_partition_syntax(partition_info *part_info,
part_elem= sub_it++;
err+= add_subpartition(fptr);
err+= add_name_string(fptr, part_elem->partition_name);
- err+= add_space(fptr);
- err+= add_partition_options(fptr, part_elem);
+ if (show_partition_options)
+ err+= add_partition_options(fptr, part_elem);
if (j != (no_subparts-1))
{
err+= add_comma(fptr);
@@ -4996,8 +4999,7 @@ static bool write_log_dropped_partitions(ALTER_PARTITION_PARAM_TYPE *lpt,
DBUG_RETURN(TRUE);
}
*next_entry= log_entry->entry_pos;
- if (temp_list)
- sub_elem->log_entry= log_entry;
+ sub_elem->log_entry= log_entry;
insert_part_info_log_entry_list(part_info, log_entry);
} while (++j < no_subparts);
}
@@ -5015,8 +5017,7 @@ static bool write_log_dropped_partitions(ALTER_PARTITION_PARAM_TYPE *lpt,
DBUG_RETURN(TRUE);
}
*next_entry= log_entry->entry_pos;
- if (temp_list)
- part_elem->log_entry= log_entry;
+ part_elem->log_entry= log_entry;
insert_part_info_log_entry_list(part_info, log_entry);
}
}
@@ -5290,7 +5291,7 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
lpt->table_name, "#");
pthread_mutex_lock(&LOCK_gdl);
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
- TRUE))
+ lpt->alter_info->flags & ALTER_REORGANIZE_PARTITION))
goto error;
if (write_log_changed_partitions(lpt, &next_entry, (const char*)path))
goto error;
@@ -5378,6 +5379,79 @@ static void release_log_entries(partition_info *part_info)
/*
+ Get a lock on table name to avoid that anyone can open the table in
+ a critical part of the ALTER TABLE.
+ SYNOPSIS
+ get_name_lock()
+ lpt Struct carrying parameters
+ RETURN VALUES
+ FALSE Success
+ TRUE Failure
+*/
+
+static int get_name_lock(ALTER_PARTITION_PARAM_TYPE *lpt)
+{
+ int error= 0;
+ DBUG_ENTER("get_name_lock");
+
+ bzero(&lpt->table_list, sizeof(lpt->table_list));
+ lpt->table_list.db= (char*)lpt->db;
+ lpt->table_list.table= lpt->table;
+ lpt->table_list.table_name= (char*)lpt->table_name;
+ pthread_mutex_lock(&LOCK_open);
+ error= lock_table_name(lpt->thd, &lpt->table_list, FALSE);
+ pthread_mutex_unlock(&LOCK_open);
+ DBUG_RETURN(error);
+}
+
+
+/*
+ Unlock and close table before renaming and dropping partitions
+ SYNOPSIS
+ alter_close_tables()
+ lpt Struct carrying parameters
+ RETURN VALUES
+ 0
+*/
+
+static int alter_close_tables(ALTER_PARTITION_PARAM_TYPE *lpt)
+{
+ THD *thd= lpt->thd;
+ TABLE *table= lpt->table;
+ DBUG_ENTER("alter_close_tables");
+ /*
+ We need to also unlock tables and close all handlers.
+ We set lock to zero to ensure we don't do this twice
+ and we set db_stat to zero to ensure we don't close twice.
+ */
+ mysql_unlock_tables(thd, thd->lock);
+ thd->lock= 0;
+ table->file->close();
+ table->db_stat= 0;
+ DBUG_RETURN(0);
+}
+
+
+/*
+ Release a lock name
+ SYNOPSIS
+ release_name_lock()
+ lpt
+ RETURN VALUES
+ 0
+*/
+
+static int release_name_lock(ALTER_PARTITION_PARAM_TYPE *lpt)
+{
+ DBUG_ENTER("release_name_lock");
+ pthread_mutex_lock(&LOCK_open);
+ unlock_table_name(lpt->thd, &lpt->table_list);
+ pthread_mutex_unlock(&LOCK_open);
+ DBUG_RETURN(0);
+}
+
+
+/*
Handle errors for ALTER TABLE for partitioning
SYNOPSIS
handle_alter_part_error()
@@ -5527,7 +5601,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
HA_CREATE_INFO *create_info,
TABLE_LIST *table_list,
List<create_field> *create_list,
- List<Key> *key_list, const char *db,
+ List<Key> *key_list, char *db,
const char *table_name,
uint fast_alter_partition)
{
@@ -5544,6 +5618,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
lpt->thd= thd;
lpt->part_info= part_info;
+ lpt->alter_info= alter_info;
lpt->create_info= create_info;
lpt->create_list= create_list;
lpt->key_list= key_list;
@@ -5667,8 +5742,17 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
2) Write the ddl log to ensure that the operation is completed
even in the presence of a MySQL Server crash
3) Lock the table in TL_WRITE_ONLY to ensure all other accesses to
- the table have completed
- 4) Write the bin log
+ the table have completed. This ensures that other threads can not
+ execute on the table in parallel.
+ 4) Get a name lock on the table. This ensures that we can release all
+ locks on the table and since no one can open the table, there can
+ be no new threads accessing the table. They will be hanging on the
+ name lock.
+ 5) Close all tables that have already been opened but didn't stumble on
+ the abort locked previously. This is done as part of the
+ get_name_lock call.
+ 6) We are now ready to release all locks we got in this thread.
+ 7) Write the bin log
Unfortunately the writing of the binlog is not synchronised with
other logging activities. So no matter in which order the binlog
is written compared to other activities there will always be cases
@@ -5679,14 +5763,13 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
require writing the statement first in the ddl log and then
when recovering from the crash read the binlog and insert it into
the binlog if not written already.
- 5) Install the previously written shadow frm file
- 6) Ensure that any users that has opened the table but not yet
- reached the abort lock do that before downgrading the lock.
- 7) Prepare MyISAM handlers for drop of partitions
- 8) Drop the partitions
- 9) Remove entries from ddl log
- 10) Wait until all accesses using the old frm file has completed
- 11) Complete query
+ 8) Install the previously written shadow frm file
+ 9) Prepare handlers for drop of partitions
+ 10) Drop the partitions
+ 11) Remove entries from ddl log
+ 12) Release name lock so that all other threads can access the table
+ again.
+ 13) Complete query
We insert Error injections at all places where it could be interesting
to test if recovery is properly done.
@@ -5699,22 +5782,24 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
ERROR_INJECT_CRASH("crash_drop_partition_3") ||
(not_completed= FALSE) ||
abort_and_upgrade_lock(lpt) || /* Always returns 0 */
+ ERROR_INJECT_CRASH("crash_drop_partition_4") ||
+ get_name_lock(lpt) ||
+ ERROR_INJECT_CRASH("crash_drop_partition_5") ||
+ alter_close_tables(lpt) ||
+ ERROR_INJECT_CRASH("crash_drop_partition_6") ||
((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE,
thd->query, thd->query_length), FALSE)) ||
- ERROR_INJECT_CRASH("crash_drop_partition_4") ||
- (table->file->extra(HA_EXTRA_PREPARE_FOR_DELETE), FALSE) ||
- ERROR_INJECT_CRASH("crash_drop_partition_5") ||
+ ERROR_INJECT_CRASH("crash_drop_partition_7") ||
((frm_install= TRUE), FALSE) ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
((frm_install= FALSE), FALSE) ||
- (close_open_tables_and_downgrade(lpt), FALSE) ||
- ERROR_INJECT_CRASH("crash_drop_partition_6") ||
+ ERROR_INJECT_CRASH("crash_drop_partition_8") ||
mysql_drop_partitions(lpt) ||
- ERROR_INJECT_CRASH("crash_drop_partition_7") ||
+ ERROR_INJECT_CRASH("crash_drop_partition_9") ||
(write_log_completed(lpt, FALSE), FALSE) ||
- ERROR_INJECT_CRASH("crash_drop_partition_8") ||
- (mysql_wait_completed_table(lpt, table), FALSE))
+ ERROR_INJECT_CRASH("crash_drop_partition_10") ||
+ (release_name_lock(lpt), FALSE))
{
handle_alter_part_error(lpt, not_completed, TRUE, frm_install);
DBUG_RETURN(TRUE);
@@ -5740,15 +5825,24 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
3) Lock all partitions in TL_WRITE_ONLY to ensure that no users
are still using the old partitioning scheme. Wait until all
ongoing users have completed before progressing.
- 4) Write binlog
- 5) Now the change is completed except for the installation of the
+ 4) Get a name lock on the table. This ensures that we can release all
+ locks on the table and since no one can open the table, there can
+ be no new threads accessing the table. They will be hanging on the
+ name lock.
+ 5) Close all tables that have already been opened but didn't stumble on
+ the abort locked previously. This is done as part of the
+ get_name_lock call.
+ 6) Close all table handlers and unlock all handlers but retain name lock
+ 7) Write binlog
+ 8) Now the change is completed except for the installation of the
new frm file. We thus write an action in the log to change to
the shadow frm file
- 6) Install the new frm file of the table where the partitions are
+ 9) Install the new frm file of the table where the partitions are
added to the table.
- 7) Wait until all accesses using the old frm file has completed
- 8) Remove entries from ddl log
- 9) Complete query
+ 10)Wait until all accesses using the old frm file has completed
+ 11)Remove entries from ddl log
+ 12)Release name lock
+ 13)Complete query
*/
if (write_log_add_change_partition(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_1") ||
@@ -5757,19 +5851,24 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
mysql_change_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_3") ||
abort_and_upgrade_lock(lpt) || /* Always returns 0 */
+ ERROR_INJECT_CRASH("crash_add_partition_3") ||
+ get_name_lock(lpt) ||
+ ERROR_INJECT_CRASH("crash_add_partition_4") ||
+ alter_close_tables(lpt) ||
+ ERROR_INJECT_CRASH("crash_add_partition_5") ||
((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE,
thd->query, thd->query_length), FALSE)) ||
- ERROR_INJECT_CRASH("crash_add_partition_4") ||
+ ERROR_INJECT_CRASH("crash_add_partition_6") ||
write_log_rename_frm(lpt) ||
(not_completed= FALSE) ||
- ERROR_INJECT_CRASH("crash_add_partition_5") ||
+ ERROR_INJECT_CRASH("crash_add_partition_7") ||
((frm_install= TRUE), FALSE) ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
- ERROR_INJECT_CRASH("crash_add_partition_6") ||
- (close_open_tables_and_downgrade(lpt), FALSE) ||
+ ERROR_INJECT_CRASH("crash_add_partition_8") ||
(write_log_completed(lpt, FALSE), FALSE) ||
- ERROR_INJECT_CRASH("crash_add_partition_7"))
+ ERROR_INJECT_CRASH("crash_add_partition_9") ||
+ (release_name_lock(lpt), FALSE))
{
handle_alter_part_error(lpt, not_completed, FALSE, frm_install);
DBUG_RETURN(TRUE);
@@ -5819,16 +5918,20 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
5) Lock all partitions in TL_WRITE_ONLY to ensure that no users
are still using the old partitioning scheme. Wait until all
ongoing users have completed before progressing.
- 6) Prepare MyISAM handlers for rename and delete of partitions
- 7) Rename the reorged partitions such that they are no longer
- used and rename those added to their real new names.
- 8) Write bin log
- 9) Install the shadow frm file
- 10) Wait until all accesses using the old frm file has completed
- 11) Drop the reorganised partitions
- 12) Remove log entry
- 13)Wait until all accesses using the old frm file has completed
- 14)Complete query
+ 6) Get a name lock of the table
+ 7) Close all tables opened but not yet locked, after this call we are
+ certain that no other thread is in the lock wait queue or has
+ opened the table. The name lock will ensure that they are blocked
+ on the open call. This is achieved also by get_name_lock call.
+ 8) Close all partitions opened by this thread, but retain name lock.
+ 9) Write bin log
+ 10) Prepare handlers for rename and delete of partitions
+ 11) Rename and drop the reorged partitions such that they are no
+ longer used and rename those added to their real new names.
+ 12) Install the shadow frm file
+ 13) Release the name lock to enable other threads to start using the
+ table again.
+ 14) Complete query
*/
if (write_log_add_change_partition(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_1") ||
@@ -5840,22 +5943,25 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
ERROR_INJECT_CRASH("crash_change_partition_4") ||
(not_completed= FALSE) ||
abort_and_upgrade_lock(lpt) || /* Always returns 0 */
- ((!thd->lex->no_write_to_binlog) &&
- (write_bin_log(thd, FALSE,
- thd->query, thd->query_length), FALSE)) ||
ERROR_INJECT_CRASH("crash_change_partition_5") ||
- (table->file->extra(HA_EXTRA_PREPARE_FOR_DELETE), FALSE) ||
+ get_name_lock(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_6") ||
- mysql_rename_partitions(lpt) ||
- ((frm_install= TRUE), FALSE) ||
+ alter_close_tables(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_7") ||
- mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
+ ((!thd->lex->no_write_to_binlog) &&
+ (write_bin_log(thd, FALSE,
+ thd->query, thd->query_length), FALSE)) ||
ERROR_INJECT_CRASH("crash_change_partition_8") ||
- (close_open_tables_and_downgrade(lpt), FALSE) ||
+ mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
ERROR_INJECT_CRASH("crash_change_partition_9") ||
- (write_log_completed(lpt, FALSE), FALSE) ||
+ mysql_drop_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_10") ||
- (mysql_wait_completed_table(lpt, table), FALSE))
+ mysql_rename_partitions(lpt) ||
+ ((frm_install= TRUE), FALSE) ||
+ ERROR_INJECT_CRASH("crash_change_partition_11") ||
+ (write_log_completed(lpt, FALSE), FALSE) ||
+ ERROR_INJECT_CRASH("crash_change_partition_12") ||
+ (release_name_lock(lpt), FALSE))
{
handle_alter_part_error(lpt, not_completed, FALSE, frm_install);
DBUG_RETURN(TRUE);
diff --git a/sql/sql_partition.h b/sql/sql_partition.h
index 87f9a751ca3..7b07fd2eb53 100644
--- a/sql/sql_partition.h
+++ b/sql/sql_partition.h
@@ -69,7 +69,8 @@ bool check_partition_info(partition_info *part_info,handlerton **eng_type,
bool fix_partition_func(THD *thd, const char *name, TABLE *table,
bool create_table_ind);
char *generate_partition_syntax(partition_info *part_info,
- uint *buf_length, bool use_sql_alloc);
+ uint *buf_length, bool use_sql_alloc,
+ bool show_partition_options);
bool partition_key_modified(TABLE *table, List<Item> &fields);
void get_partition_set(const TABLE *table, byte *buf, const uint index,
const key_range *key_spec,
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 83f64e2c9c9..f500e3bf481 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -970,6 +970,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
handler *file= table->file;
TABLE_SHARE *share= table->s;
HA_CREATE_INFO create_info;
+ bool show_table_options= FALSE;
bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL |
MODE_ORACLE |
MODE_MSSQL |
@@ -1195,6 +1196,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
packet->append(STRING_WITH_LEN("\n)"));
if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode)
{
+ show_table_options= TRUE;
/*
Get possible table space definitions and append them
to the CREATE TABLE statement
@@ -1335,7 +1337,8 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
(!table->part_info->is_auto_partitioned) &&
((part_syntax= generate_partition_syntax(table->part_info,
&part_syntax_len,
- FALSE))))
+ FALSE,
+ show_table_options))))
{
packet->append(part_syntax, part_syntax_len);
my_free(part_syntax, MYF(0));
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index e9c89b4983d..a49b7a2cc42 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1233,7 +1233,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
{
if (!(part_syntax_buf= generate_partition_syntax(part_info,
&syntax_len,
- TRUE)))
+ TRUE, TRUE)))
{
DBUG_RETURN(TRUE);
}
@@ -3155,7 +3155,7 @@ bool mysql_create_table_internal(THD *thd,
*/
if (!(part_syntax_buf= generate_partition_syntax(part_info,
&syntax_len,
- TRUE)))
+ TRUE, TRUE)))
goto err;
part_info->part_info_string= part_syntax_buf;
part_info->part_info_len= syntax_len;