summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2013-07-02 20:43:35 +0300
committerMichael Widenius <monty@askmonty.org>2013-07-02 20:43:35 +0300
commit99aae21ed25b42ee3cf62815ecfc8204de8b6fd0 (patch)
treeac9a51c525b3ad668a7c8dbde44e34e14771c512 /sql
parentb7b2a7ce81bf9d1bbcac9e0b3b0b19e271f2c276 (diff)
downloadmariadb-git-99aae21ed25b42ee3cf62815ecfc8204de8b6fd0.tar.gz
mdl_sync now works.
mysql-test/r/mdl_sync.result: Full merge with 5.6 mysql-test/t/mdl_sync.test: Full merge with 5.6 sql/debug_sync.cc: Full merge with 5.6 sql/debug_sync.h: Full merge with 5.6 sql/mdl.cc: Full merge with 5.6 sql/sql_base.cc: Removed code not in 5.6 anymore
Diffstat (limited to 'sql')
-rw-r--r--sql/debug_sync.cc24
-rw-r--r--sql/debug_sync.h3
-rw-r--r--sql/mdl.cc11
-rw-r--r--sql/sql_base.cc15
-rw-r--r--sql/sql_table.cc24
-rw-r--r--sql/table.cc7
6 files changed, 48 insertions, 36 deletions
diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc
index 1f3c86c5b67..750f770552e 100644
--- a/sql/debug_sync.cc
+++ b/sql/debug_sync.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2010, Oracle and/or its affiliates.
+/* Copyright (c) 2009, 2011, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -10,8 +10,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+ along with this program; if not, write to the Free Software Foundation,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
/* see include/mysql/service_debug_sync.h for debug sync documentation */
@@ -82,8 +82,6 @@ struct st_debug_sync_globals
};
static st_debug_sync_globals debug_sync_global; /* All globals in one object */
-extern uint opt_debug_sync_timeout;
-
/**
Callbacks from C files.
*/
@@ -112,14 +110,11 @@ static void init_debug_sync_psi_keys(void)
const char* category= "sql";
int count;
- if (PSI_server == NULL)
- return;
-
count= array_elements(all_debug_sync_mutexes);
- PSI_server->register_mutex(category, all_debug_sync_mutexes, count);
+ mysql_mutex_register(category, all_debug_sync_mutexes, count);
count= array_elements(all_debug_sync_conds);
- PSI_server->register_cond(category, all_debug_sync_conds, count);
+ mysql_cond_register(category, all_debug_sync_conds, count);
}
#endif /* HAVE_PSI_INTERFACE */
@@ -783,7 +778,7 @@ static bool debug_sync_set_action(THD *thd, st_debug_sync_action *action)
point decremented it to 0. In this case the following happened:
- an error message was reported with my_error() and
- - the statement was killed with thd->killed= KILL_QUERY.
+ - the statement was killed with thd->killed= THD::KILL_QUERY.
If a statement reports an error, it must not call send_ok().
The calling functions will not call send_ok(), if we return TRUE
@@ -985,7 +980,7 @@ static bool debug_sync_eval_action(THD *thd, char *action_str)
DBUG_ENTER("debug_sync_eval_action");
DBUG_ASSERT(thd);
DBUG_ASSERT(action_str);
- DBUG_PRINT("debug_sync", ("action_str='%s'", action_str));
+ DBUG_PRINT("debug_sync", ("action_str: '%s'", action_str));
/*
Get debug sync point name. Or a special command.
@@ -1450,8 +1445,13 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
sig_wait, sig_glob, error));});
if (error == ETIMEDOUT || error == ETIME)
{
+ // We should not make the statement fail, even if in strict mode.
+ const bool save_abort_on_warning= thd->abort_on_warning;
+ thd->abort_on_warning= false;
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
ER_DEBUG_SYNC_TIMEOUT, ER(ER_DEBUG_SYNC_TIMEOUT));
+ thd->abort_on_warning= save_abort_on_warning;
+ DBUG_EXECUTE_IF("debug_sync_abort_on_timeout", DBUG_ABORT(););
break;
}
error= 0;
diff --git a/sql/debug_sync.h b/sql/debug_sync.h
index 4d29d6e7508..bf1b3167dbc 100644
--- a/sql/debug_sync.h
+++ b/sql/debug_sync.h
@@ -32,6 +32,9 @@ class THD;
#if defined(ENABLED_DEBUG_SYNC)
+/* Command line option --debug-sync-timeout. See mysqld.cc. */
+extern MYSQL_PLUGIN_IMPORT uint opt_debug_sync_timeout;
+
/* Default WAIT_FOR timeout if command line option is given without argument. */
#define DEBUG_SYNC_DEFAULT_WAIT_TIMEOUT 300
diff --git a/sql/mdl.cc b/sql/mdl.cc
index 22d9d4e53e5..dd7d3f0fbf4 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -1872,6 +1872,8 @@ MDL_context::find_ticket(MDL_request *mdl_request,
if (mdl_request->key.is_equal(&ticket->m_lock->key) &&
ticket->has_stronger_or_equal_type(mdl_request->type))
{
+ DBUG_PRINT("info", ("Adding mdl lock %d to %d",
+ mdl_request->type, ticket->m_type));
*result_duration= duration;
return ticket;
}
@@ -2168,6 +2170,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, ulong lock_wait_timeout)
struct timespec abs_timeout;
MDL_wait::enum_wait_status wait_status;
DBUG_ENTER("MDL_context::acquire_lock");
+ DBUG_PRINT("enter", ("lock_type: %d", mdl_request->type));
/* Do some work outside the critical section. */
set_timespec(abs_timeout, lock_wait_timeout);
@@ -2182,6 +2185,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, ulong lock_wait_timeout)
MDL_lock, MDL_context and MDL_request were updated
accordingly, so we can simply return success.
*/
+ DBUG_PRINT("info", ("Got lock without waiting"));
DBUG_RETURN(FALSE);
}
@@ -2393,8 +2397,9 @@ MDL_context::upgrade_shared_lock(MDL_ticket *mdl_ticket,
MDL_request mdl_xlock_request;
MDL_savepoint mdl_svp= mdl_savepoint();
bool is_new_ticket;
-
DBUG_ENTER("MDL_context::upgrade_shared_lock");
+ DBUG_PRINT("enter",("new_type: %d lock_wait_timeout: %lu", new_type,
+ lock_wait_timeout));
DEBUG_SYNC(get_thd(), "mdl_upgrade_lock");
/*
@@ -2701,8 +2706,8 @@ void MDL_context::release_lock(enum_mdl_duration duration, MDL_ticket *ticket)
{
MDL_lock *lock= ticket->m_lock;
DBUG_ENTER("MDL_context::release_lock");
- DBUG_PRINT("enter", ("db=%s name=%s", lock->key.db_name(),
- lock->key.name()));
+ DBUG_PRINT("enter", ("db: '%s' name: '%s'",
+ lock->key.db_name(), lock->key.name()));
DBUG_ASSERT(this == ticket->get_ctx());
mysql_mutex_assert_not_owner(&LOCK_open);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index c7ac0695cf1..acc4f09cec4 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2952,7 +2952,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
}
/*
No table in the locked tables list. In case of explicit LOCK TABLES
- this can happen if a user did not include the able into the list.
+ this can happen if a user did not include the table into the list.
In case of pre-locked mode locked tables list is generated automatically,
so we may only end up here if the table did not exist when
locked tables list was created.
@@ -2972,19 +2972,6 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
if (! (flags & MYSQL_OPEN_HAS_MDL_LOCK))
{
/*
- Check if we're trying to take a write lock in a read only transaction.
- */
- if (table_list->mdl_request.type >= MDL_SHARED_WRITE &&
- thd->tx_read_only &&
- !(flags & (MYSQL_OPEN_HAS_MDL_LOCK |
- MYSQL_LOCK_LOG_TABLE |
- MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY)))
- {
- my_error(ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION, MYF(0));
- DBUG_RETURN(true);
- }
-
- /*
We are not under LOCK TABLES and going to acquire write-lock/
modify the base table. We need to acquire protection against
global read lock until end of this statement in order to have
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index f2c203744f4..626344ef93d 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2221,9 +2221,10 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
bool dont_log_query)
{
TABLE_LIST *table;
- char path[FN_REFLEN + 1], *alias= NULL;
+ char path[FN_REFLEN + 1], wrong_tables_buff[160], *alias= NULL;
+ String wrong_tables(wrong_tables_buff, sizeof(wrong_tables_buff)-1,
+ system_charset_info);
uint path_length= 0;
- String wrong_tables;
int error= 0;
int non_temp_tables_count= 0;
bool foreign_key_error=0;
@@ -2234,6 +2235,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
String built_trans_tmp_query, built_non_trans_tmp_query;
DBUG_ENTER("mysql_rm_table_no_locks");
+ wrong_tables.length(0);
/*
Prepares the drop statements that will be written into the binary
log as follows:
@@ -2453,9 +2455,17 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
. ./sql/datadict.cc +32 /Alfranio - TODO: We need to test this.
*/
if (if_exists)
- push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
- ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR),
- table->table_name);
+ {
+ char buff[FN_REFLEN];
+ String tbl_name(buff, sizeof(buff), system_charset_info);
+ tbl_name.length(0);
+ tbl_name.append(db);
+ tbl_name.append('.');
+ tbl_name.append(table->table_name);
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
+ ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR),
+ tbl_name.c_ptr_safe());
+ }
else
{
non_tmp_error = (drop_temporary ? non_tmp_error : TRUE);
@@ -2513,7 +2523,9 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
{
if (wrong_tables.length())
wrong_tables.append(',');
- wrong_tables.append(String(table->table_name,system_charset_info));
+ wrong_tables.append(db);
+ wrong_tables.append('.');
+ wrong_tables.append(table->table_name);
}
DBUG_PRINT("table", ("table: 0x%lx s: 0x%lx", (long) table->table,
table->table ? (long) table->table->s : (long) -1));
diff --git a/sql/table.cc b/sql/table.cc
index 197132d8d0a..fb81fe2616a 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -998,10 +998,15 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
}
key_part->store_length=key_part->length;
}
+
+ /*
+ Add primary key to end of extended keys for non unique keys for
+ storage engines that supports it.
+ */
keyinfo->ext_key_parts= keyinfo->user_defined_key_parts;
keyinfo->ext_key_flags= keyinfo->flags;
keyinfo->ext_key_part_map= 0;
- if (share->use_ext_keys && i)
+ if (share->use_ext_keys && i && !(keyinfo->flags & HA_NOSAME))
{
keyinfo->ext_key_part_map= 0;
for (j= 0;