Commit 99aae21e authored by Michael Widenius's avatar Michael Widenius

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
parent b7b2a7ce
......@@ -1229,7 +1229,7 @@ DROP TABLE t1;
SET NAMES utf8;
DROP TABLE IF EXISTS t1;
Warnings:
Note 1051 Unknown table 't1'
Note 1051 Unknown table 'test.t1'
CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
INSERT INTO t1 VALUES('uu');
......
......@@ -1256,7 +1256,7 @@ DROP TABLE t1;
SET NAMES utf8mb4;
DROP TABLE IF EXISTS t1;
Warnings:
Note 1051 Unknown table 't1'
Note 1051 Unknown table 'test.t1'
CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
......
......@@ -1231,7 +1231,7 @@ DROP TABLE t1;
SET NAMES utf8mb4;
DROP TABLE IF EXISTS t1;
Warnings:
Note 1051 Unknown table 't1'
Note 1051 Unknown table 'test.t1'
CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
......
This diff is collapsed.
This diff is collapsed.
/* 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;
......
......@@ -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
......
......@@ -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);
......
......@@ -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.
......@@ -2971,19 +2971,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
......
......@@ -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));
......
......@@ -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;
......
......@@ -11225,7 +11225,7 @@ ha_innobase::info_low(
KEY *key_info= table->key_info+i;
key_part_map ext_key_part_map=
key_info->ext_key_part_map;
key_info->ext_key_part_map;
if (key_info->user_defined_key_parts !=
key_info->ext_key_parts)
......
......@@ -512,7 +512,7 @@ int ha_myisammrg::add_children_list(void)
DDL on implicitly locked underlying tables of a MERGE table.
*/
if (! thd->locked_tables_mode &&
parent_l->mdl_request.type == MDL_SHARED_NO_WRITE)
parent_l->mdl_request.type == MDL_SHARED_UPGRADABLE)
child_l->mdl_request.set_type(MDL_SHARED_NO_WRITE);
/* Link TABLE_LIST object into the children list. */
if (this->children_last_l)
......@@ -1372,8 +1372,6 @@ int ha_myisammrg::reset(void)
int ha_myisammrg::extra_opt(enum ha_extra_function operation, ulong cache_size)
{
DBUG_ASSERT(this->file->children_attached);
if ((specialflag & SPECIAL_SAFE_MODE) && operation == HA_EXTRA_WRITE_CACHE)
return 0;
return myrg_extra(file, operation, (void*) &cache_size);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment