Commit 8075b05b authored by Michael Widenius's avatar Michael Widenius

More merge fixes:

- mdl.cc and mdl.h merged completely
- mysql_system_tables*.sql merged completely
- Fixed wrong merge of lock_tables
- Added some missing functions:
 - bool THD::notify_shared_lock()
 - Dynamic_array::pop, Dynamic_array::del
- Added MDL_context_owner to THD
- Added metadata_locks_hash_instances
parent 7c1abe15
...@@ -20,7 +20,7 @@ IF(NOT CMAKE_CROSSCOMPILING) ...@@ -20,7 +20,7 @@ IF(NOT CMAKE_CROSSCOMPILING)
ENDIF() ENDIF()
# Build mysql_fix_privilege_tables.sql (concatenate 2 sql scripts) # Build mysql_fix_privilege_tables.sql (concatenate 3 sql scripts)
IF(NOT WIN32 OR CMAKE_CROSSCOMPILING) IF(NOT WIN32 OR CMAKE_CROSSCOMPILING)
FIND_PROGRAM(CAT_EXECUTABLE cat DOC "path to the executable") FIND_PROGRAM(CAT_EXECUTABLE cat DOC "path to the executable")
MARK_AS_ADVANCED(CAT_EXECUTABLE) MARK_AS_ADVANCED(CAT_EXECUTABLE)
......
...@@ -80,7 +80,7 @@ DROP PREPARE stmt; ...@@ -80,7 +80,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_waits_current(" SET @cmd="CREATE TABLE performance_schema.events_waits_current("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"EVENT_ID BIGINT unsigned not null," "EVENT_ID BIGINT unsigned not null,"
"END_EVENT_ID BIGINT unsigned," "END_EVENT_ID BIGINT unsigned,"
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
...@@ -111,7 +111,7 @@ DROP PREPARE stmt; ...@@ -111,7 +111,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_waits_history(" SET @cmd="CREATE TABLE performance_schema.events_waits_history("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"EVENT_ID BIGINT unsigned not null," "EVENT_ID BIGINT unsigned not null,"
"END_EVENT_ID BIGINT unsigned," "END_EVENT_ID BIGINT unsigned,"
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
...@@ -142,7 +142,7 @@ DROP PREPARE stmt; ...@@ -142,7 +142,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_waits_history_long(" SET @cmd="CREATE TABLE performance_schema.events_waits_history_long("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"EVENT_ID BIGINT unsigned not null," "EVENT_ID BIGINT unsigned not null,"
"END_EVENT_ID BIGINT unsigned," "END_EVENT_ID BIGINT unsigned,"
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
...@@ -250,7 +250,7 @@ DROP PREPARE stmt; ...@@ -250,7 +250,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_thread_by_event_name(" SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_thread_by_event_name("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
"COUNT_STAR BIGINT unsigned not null," "COUNT_STAR BIGINT unsigned not null,"
"SUM_TIMER_WAIT BIGINT unsigned not null," "SUM_TIMER_WAIT BIGINT unsigned not null,"
...@@ -377,7 +377,7 @@ DROP PREPARE stmt; ...@@ -377,7 +377,7 @@ DROP PREPARE stmt;
SET @cmd="CREATE TABLE performance_schema.socket_instances(" SET @cmd="CREATE TABLE performance_schema.socket_instances("
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
"OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
"THREAD_ID INTEGER," "THREAD_ID BIGINT unsigned,"
"SOCKET_ID INTEGER not null," "SOCKET_ID INTEGER not null,"
"IP VARCHAR(64) not null," "IP VARCHAR(64) not null,"
"PORT INTEGER not null," "PORT INTEGER not null,"
...@@ -490,13 +490,14 @@ SET @cmd="CREATE TABLE performance_schema.host_cache(" ...@@ -490,13 +490,14 @@ SET @cmd="CREATE TABLE performance_schema.host_cache("
"COUNT_INIT_CONNECT_ERRORS BIGINT not null," "COUNT_INIT_CONNECT_ERRORS BIGINT not null,"
"COUNT_LOCAL_ERRORS BIGINT not null," "COUNT_LOCAL_ERRORS BIGINT not null,"
"COUNT_UNKNOWN_ERRORS BIGINT not null," "COUNT_UNKNOWN_ERRORS BIGINT not null,"
"FIRST_SEEN TIMESTAMP(0) default 0," "FIRST_SEEN TIMESTAMP(0) NOT NULL default 0,"
"LAST_SEEN TIMESTAMP(0) default 0," "LAST_SEEN TIMESTAMP(0) NOT NULL default 0,"
"FIRST_ERROR_SEEN TIMESTAMP(0) null default 0," "FIRST_ERROR_SEEN TIMESTAMP(0) null default 0,"
"LAST_ERROR_SEEN TIMESTAMP(0) null default 0" "LAST_ERROR_SEEN TIMESTAMP(0) null default 0"
")ENGINE=PERFORMANCE_SCHEMA;"; ")ENGINE=PERFORMANCE_SCHEMA;";
SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
# Host cache is disable until host cache code is merged from 5.6
#PREPARE stmt FROM @str; #PREPARE stmt FROM @str;
#EXECUTE stmt; #EXECUTE stmt;
#DROP PREPARE stmt; #DROP PREPARE stmt;
...@@ -508,7 +509,7 @@ SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); ...@@ -508,7 +509,7 @@ SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
SET @cmd="CREATE TABLE performance_schema.mutex_instances(" SET @cmd="CREATE TABLE performance_schema.mutex_instances("
"NAME VARCHAR(128) not null," "NAME VARCHAR(128) not null,"
"OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
"LOCKED_BY_THREAD_ID INTEGER" "LOCKED_BY_THREAD_ID BIGINT unsigned"
")ENGINE=PERFORMANCE_SCHEMA;"; ")ENGINE=PERFORMANCE_SCHEMA;";
SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
...@@ -559,7 +560,7 @@ DROP PREPARE stmt; ...@@ -559,7 +560,7 @@ DROP PREPARE stmt;
SET @cmd="CREATE TABLE performance_schema.rwlock_instances(" SET @cmd="CREATE TABLE performance_schema.rwlock_instances("
"NAME VARCHAR(128) not null," "NAME VARCHAR(128) not null,"
"OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
"WRITE_LOCKED_BY_THREAD_ID INTEGER," "WRITE_LOCKED_BY_THREAD_ID BIGINT unsigned,"
"READ_LOCKED_BY_COUNT INTEGER unsigned not null" "READ_LOCKED_BY_COUNT INTEGER unsigned not null"
")ENGINE=PERFORMANCE_SCHEMA;"; ")ENGINE=PERFORMANCE_SCHEMA;";
...@@ -834,10 +835,10 @@ DROP PREPARE stmt; ...@@ -834,10 +835,10 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.threads(" SET @cmd="CREATE TABLE performance_schema.threads("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"NAME VARCHAR(128) not null," "NAME VARCHAR(128) not null,"
"TYPE VARCHAR(10) not null," "TYPE VARCHAR(10) not null,"
"PROCESSLIST_ID INTEGER," "PROCESSLIST_ID BIGINT unsigned,"
"PROCESSLIST_USER VARCHAR(16)," "PROCESSLIST_USER VARCHAR(16),"
"PROCESSLIST_HOST VARCHAR(60)," "PROCESSLIST_HOST VARCHAR(60),"
"PROCESSLIST_DB VARCHAR(64)," "PROCESSLIST_DB VARCHAR(64),"
...@@ -845,7 +846,7 @@ SET @cmd="CREATE TABLE performance_schema.threads(" ...@@ -845,7 +846,7 @@ SET @cmd="CREATE TABLE performance_schema.threads("
"PROCESSLIST_TIME BIGINT," "PROCESSLIST_TIME BIGINT,"
"PROCESSLIST_STATE VARCHAR(64)," "PROCESSLIST_STATE VARCHAR(64),"
"PROCESSLIST_INFO LONGTEXT," "PROCESSLIST_INFO LONGTEXT,"
"PARENT_THREAD_ID INTEGER," "PARENT_THREAD_ID BIGINT unsigned,"
"ROLE VARCHAR(64)," "ROLE VARCHAR(64),"
"INSTRUMENTED ENUM ('YES', 'NO') not null" "INSTRUMENTED ENUM ('YES', 'NO') not null"
")ENGINE=PERFORMANCE_SCHEMA;"; ")ENGINE=PERFORMANCE_SCHEMA;";
...@@ -860,7 +861,7 @@ DROP PREPARE stmt; ...@@ -860,7 +861,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_stages_current(" SET @cmd="CREATE TABLE performance_schema.events_stages_current("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"EVENT_ID BIGINT unsigned not null," "EVENT_ID BIGINT unsigned not null,"
"END_EVENT_ID BIGINT unsigned," "END_EVENT_ID BIGINT unsigned,"
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
...@@ -882,7 +883,7 @@ DROP PREPARE stmt; ...@@ -882,7 +883,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_stages_history(" SET @cmd="CREATE TABLE performance_schema.events_stages_history("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"EVENT_ID BIGINT unsigned not null," "EVENT_ID BIGINT unsigned not null,"
"END_EVENT_ID BIGINT unsigned," "END_EVENT_ID BIGINT unsigned,"
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
...@@ -904,7 +905,7 @@ DROP PREPARE stmt; ...@@ -904,7 +905,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_stages_history_long(" SET @cmd="CREATE TABLE performance_schema.events_stages_history_long("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"EVENT_ID BIGINT unsigned not null," "EVENT_ID BIGINT unsigned not null,"
"END_EVENT_ID BIGINT unsigned," "END_EVENT_ID BIGINT unsigned,"
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
...@@ -926,7 +927,7 @@ DROP PREPARE stmt; ...@@ -926,7 +927,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_thread_by_event_name(" SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_thread_by_event_name("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
"COUNT_STAR BIGINT unsigned not null," "COUNT_STAR BIGINT unsigned not null,"
"SUM_TIMER_WAIT BIGINT unsigned not null," "SUM_TIMER_WAIT BIGINT unsigned not null,"
...@@ -1021,7 +1022,7 @@ DROP PREPARE stmt; ...@@ -1021,7 +1022,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_statements_current(" SET @cmd="CREATE TABLE performance_schema.events_statements_current("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"EVENT_ID BIGINT unsigned not null," "EVENT_ID BIGINT unsigned not null,"
"END_EVENT_ID BIGINT unsigned," "END_EVENT_ID BIGINT unsigned,"
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
...@@ -1073,7 +1074,7 @@ DROP PREPARE stmt; ...@@ -1073,7 +1074,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_statements_history(" SET @cmd="CREATE TABLE performance_schema.events_statements_history("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"EVENT_ID BIGINT unsigned not null," "EVENT_ID BIGINT unsigned not null,"
"END_EVENT_ID BIGINT unsigned," "END_EVENT_ID BIGINT unsigned,"
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
...@@ -1125,7 +1126,7 @@ DROP PREPARE stmt; ...@@ -1125,7 +1126,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_statements_history_long(" SET @cmd="CREATE TABLE performance_schema.events_statements_history_long("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"EVENT_ID BIGINT unsigned not null," "EVENT_ID BIGINT unsigned not null,"
"END_EVENT_ID BIGINT unsigned," "END_EVENT_ID BIGINT unsigned,"
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
...@@ -1177,7 +1178,7 @@ DROP PREPARE stmt; ...@@ -1177,7 +1178,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_thread_by_event_name(" SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_thread_by_event_name("
"THREAD_ID INTEGER not null," "THREAD_ID BIGINT unsigned not null,"
"EVENT_NAME VARCHAR(128) not null," "EVENT_NAME VARCHAR(128) not null,"
"COUNT_STAR BIGINT unsigned not null," "COUNT_STAR BIGINT unsigned not null,"
"SUM_TIMER_WAIT BIGINT unsigned not null," "SUM_TIMER_WAIT BIGINT unsigned not null,"
...@@ -1413,6 +1414,7 @@ DROP PREPARE stmt; ...@@ -1413,6 +1414,7 @@ DROP PREPARE stmt;
-- --
SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_digest(" SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_digest("
"SCHEMA_NAME VARCHAR(64),"
"DIGEST VARCHAR(32)," "DIGEST VARCHAR(32),"
"DIGEST_TEXT LONGTEXT," "DIGEST_TEXT LONGTEXT,"
"COUNT_STAR BIGINT unsigned not null," "COUNT_STAR BIGINT unsigned not null,"
...@@ -1439,8 +1441,8 @@ SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_digest(" ...@@ -1439,8 +1441,8 @@ SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_digest("
"SUM_SORT_SCAN BIGINT unsigned not null," "SUM_SORT_SCAN BIGINT unsigned not null,"
"SUM_NO_INDEX_USED BIGINT unsigned not null," "SUM_NO_INDEX_USED BIGINT unsigned not null,"
"SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null," "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null,"
"FIRST_SEEN TIMESTAMP(0) default 0," "FIRST_SEEN TIMESTAMP(0) NOT NULL default 0,"
"LAST_SEEN TIMESTAMP(0) default 0" "LAST_SEEN TIMESTAMP(0) NOT NULL default 0"
")ENGINE=PERFORMANCE_SCHEMA;"; ")ENGINE=PERFORMANCE_SCHEMA;";
...@@ -1449,3 +1451,30 @@ PREPARE stmt FROM @str; ...@@ -1449,3 +1451,30 @@ PREPARE stmt FROM @str;
EXECUTE stmt; EXECUTE stmt;
DROP PREPARE stmt; DROP PREPARE stmt;
--
-- TABLE SESSION_CONNECT_ATTRS
--
SET @cmd="CREATE TABLE performance_schema.session_connect_attrs("
"PROCESSLIST_ID INT NOT NULL,"
"ATTR_NAME VARCHAR(32) NOT NULL,"
"ATTR_VALUE VARCHAR(1024),"
"ORDINAL_POSITION INT"
")ENGINE=PERFORMANCE_SCHEMA CHARACTER SET utf8 COLLATE utf8_bin;";
SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;
--
-- TABLE SESSION_ACCOUNT_CONNECT_ATTRS
--
SET @cmd="CREATE TABLE performance_schema.session_account_connect_attrs "
" LIKE performance_schema.session_connect_attrs;";
SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;
This diff is collapsed.
-- Copyright (C) 2003, 2011 Oracle and/or its affiliates. -- Copyright (C) 2003, 2011 Oracle and/or its affiliates.
-- Copyright (C) 2010, 2011 Monty Program Ab -- Copyright (C) 2010-2013 Monty Program Ab & SkySQL Ab
-- --
-- This program is free software; you can redistribute it and/or modify -- 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 -- it under the terms of the GNU General Public License as published by
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
# because these just mean that your tables are already up to date. # because these just mean that your tables are already up to date.
# This script is safe to run even if your tables are already up to date! # This script is safe to run even if your tables are already up to date!
# Warning message(s) produced for a statement can be printed by explicitly
# adding a 'SHOW WARNINGS' after the statement.
set sql_mode=''; set sql_mode='';
set storage_engine=MyISAM; set storage_engine=MyISAM;
...@@ -234,18 +237,21 @@ ALTER TABLE func ...@@ -234,18 +237,21 @@ ALTER TABLE func
SET @old_log_state = @@global.general_log; SET @old_log_state = @@global.general_log;
SET GLOBAL general_log = 'OFF'; SET GLOBAL general_log = 'OFF';
ALTER TABLE general_log ALTER TABLE general_log
MODIFY event_time TIMESTAMP(6) NOT NULL, MODIFY event_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
MODIFY user_host MEDIUMTEXT NOT NULL, MODIFY user_host MEDIUMTEXT NOT NULL,
MODIFY thread_id INTEGER NOT NULL, MODIFY thread_id INTEGER NOT NULL,
MODIFY server_id INTEGER UNSIGNED NOT NULL, MODIFY server_id INTEGER UNSIGNED NOT NULL,
MODIFY command_type VARCHAR(64) NOT NULL, MODIFY command_type VARCHAR(64) NOT NULL,
MODIFY argument MEDIUMTEXT NOT NULL; MODIFY argument MEDIUMTEXT NOT NULL,
MODIFY thread_id BIGINT(21) UNSIGNED NOT NULL;
SET GLOBAL general_log = @old_log_state; SET GLOBAL general_log = @old_log_state;
SET @old_log_state = @@global.slow_query_log; SET @old_log_state = @@global.slow_query_log;
SET GLOBAL slow_query_log = 'OFF'; SET GLOBAL slow_query_log = 'OFF';
ALTER TABLE slow_log ALTER TABLE slow_log
MODIFY start_time TIMESTAMP(6) NOT NULL, ADD COLUMN thread_id BIGINT(21) UNSIGNED NOT NULL AFTER sql_text;
ALTER TABLE slow_log
MODIFY start_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
MODIFY user_host MEDIUMTEXT NOT NULL, MODIFY user_host MEDIUMTEXT NOT NULL,
MODIFY query_time TIME(6) NOT NULL, MODIFY query_time TIME(6) NOT NULL,
MODIFY lock_time TIME(6) NOT NULL, MODIFY lock_time TIME(6) NOT NULL,
...@@ -255,7 +261,8 @@ ALTER TABLE slow_log ...@@ -255,7 +261,8 @@ ALTER TABLE slow_log
MODIFY last_insert_id INTEGER NOT NULL, MODIFY last_insert_id INTEGER NOT NULL,
MODIFY insert_id INTEGER NOT NULL, MODIFY insert_id INTEGER NOT NULL,
MODIFY server_id INTEGER UNSIGNED NOT NULL, MODIFY server_id INTEGER UNSIGNED NOT NULL,
MODIFY sql_text MEDIUMTEXT NOT NULL; MODIFY sql_text MEDIUMTEXT NOT NULL,
MODIFY thread_id BIGINT(21) UNSIGNED NOT NULL;
SET GLOBAL slow_query_log = @old_log_state; SET GLOBAL slow_query_log = @old_log_state;
ALTER TABLE plugin ALTER TABLE plugin
...@@ -383,7 +390,7 @@ ALTER TABLE procs_priv ...@@ -383,7 +390,7 @@ ALTER TABLE procs_priv
COLLATE utf8_general_ci NOT NULL AFTER Routine_name; COLLATE utf8_general_ci NOT NULL AFTER Routine_name;
ALTER TABLE procs_priv ALTER TABLE procs_priv
MODIFY Timestamp timestamp AFTER Proc_priv; MODIFY Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER Proc_priv;
# #
# proc # proc
...@@ -622,8 +629,8 @@ ALTER TABLE user MODIFY Create_tablespace_priv enum('N','Y') COLLATE utf8_genera ...@@ -622,8 +629,8 @@ ALTER TABLE user MODIFY Create_tablespace_priv enum('N','Y') COLLATE utf8_genera
UPDATE user SET Create_tablespace_priv = Super_priv WHERE @hadCreateTablespacePriv = 0; UPDATE user SET Create_tablespace_priv = Super_priv WHERE @hadCreateTablespacePriv = 0;
ALTER TABLE user ADD plugin char(64) DEFAULT '', ADD authentication_string TEXT; ALTER TABLE user ADD plugin char(64) DEFAULT '', ADD authentication_string TEXT;
ALTER TABLE user MODIFY plugin char(64) CHARACTER SET latin1 DEFAULT '' NOT NULL; ALTER TABLE user ADD password_expired ENUM('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
ALTER TABLE user MODIFY authentication_string TEXT NOT NULL; ALTER TABLE user MODIFY plugin char(64) CHARACTER SET latin1 DEFAULT '' NOT NULL, user MODIFY authentication_string TEXT NOT NULL;
-- Need to pre-fill mysql.proxies_priv with access for root even when upgrading from -- Need to pre-fill mysql.proxies_priv with access for root even when upgrading from
-- older versions -- older versions
......
This diff is collapsed.
#ifndef MDL_H #ifndef MDL_H
#define MDL_H #define MDL_H
/* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software Foundation,
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
#if defined(__IBMC__) || defined(__IBMCPP__) #if defined(__IBMC__) || defined(__IBMCPP__)
/* Further down, "next_in_lock" and "next_in_context" have the same type, /* Further down, "next_in_lock" and "next_in_context" have the same type,
...@@ -26,10 +26,11 @@ ...@@ -26,10 +26,11 @@
#include "sql_plist.h" #include "sql_plist.h"
#include <my_sys.h> #include <my_sys.h>
#include <my_pthread.h>
#include <m_string.h> #include <m_string.h>
#include <mysql_com.h> #include <mysql_com.h>
#include <algorithm>
class THD; class THD;
class MDL_context; class MDL_context;
...@@ -54,6 +55,67 @@ class MDL_ticket; ...@@ -54,6 +55,67 @@ class MDL_ticket;
*/ */
#define EXIT_COND(S) exit_cond(S, __func__, __FILE__, __LINE__) #define EXIT_COND(S) exit_cond(S, __func__, __FILE__, __LINE__)
/**
An interface to separate the MDL module from the THD, and the rest of the
server code.
*/
class MDL_context_owner
{
public:
virtual ~MDL_context_owner() {}
/**
Enter a condition wait.
For @c enter_cond() / @c exit_cond() to work the mutex must be held before
@c enter_cond(); this mutex is then released by @c exit_cond().
Usage must be: lock mutex; enter_cond(); your code; exit_cond().
@param cond the condition to wait on
@param mutex the associated mutex
@param [in] stage the stage to enter, or NULL
@param [out] old_stage the previous stage, or NULL
@param src_function function name of the caller
@param src_file file name of the caller
@param src_line line number of the caller
@sa ENTER_COND(), THD::enter_cond()
@sa EXIT_COND(), THD::exit_cond()
*/
virtual void enter_cond(mysql_cond_t *cond, mysql_mutex_t *mutex,
const PSI_stage_info *stage, PSI_stage_info *old_stage,
const char *src_function, const char *src_file,
int src_line) = 0;
/**
@def EXIT_COND(S)
End a wait on a condition
@param [in] stage the new stage to enter
@param src_function function name of the caller
@param src_file file name of the caller
@param src_line line number of the caller
@sa ENTER_COND(), THD::enter_cond()
@sa EXIT_COND(), THD::exit_cond()
*/
virtual void exit_cond(const PSI_stage_info *stage,
const char *src_function, const char *src_file,
int src_line) = 0;
/**
Has the owner thread been killed?
*/
virtual int is_killed() = 0;
/**
This one is only used for DEBUG_SYNC.
(Do not use it to peek/poke into other parts of THD.)
*/
virtual THD* get_thd() = 0;
/**
@see THD::notify_shared_lock()
*/
virtual bool notify_shared_lock(MDL_context_owner *in_use,
bool needs_thr_lock_abort) = 0;
};
/** /**
Type of metadata lock request. Type of metadata lock request.
...@@ -273,8 +335,16 @@ public: ...@@ -273,8 +335,16 @@ public:
const char *db, const char *name) const char *db, const char *name)
{ {
m_ptr[0]= (char) mdl_namespace; m_ptr[0]= (char) mdl_namespace;
m_db_name_length= (uint16) (strmov(m_ptr + 1, db) - m_ptr - 1); /*
m_length= (uint16) (strmov(m_ptr + m_db_name_length + 2, name) - m_ptr + 1); It is responsibility of caller to ensure that db and object names
are not longer than NAME_LEN. Still we play safe and try to avoid
buffer overruns.
*/
DBUG_ASSERT(strlen(db) <= NAME_LEN && strlen(name) <= NAME_LEN);
m_db_name_length= static_cast<uint16>(strmake(m_ptr + 1, db, NAME_LEN) -
m_ptr - 1);
m_length= static_cast<uint16>(strmake(m_ptr + m_db_name_length + 2, name,
NAME_LEN) - m_ptr + 1);
} }
void mdl_key_init(const MDL_key *rhs) void mdl_key_init(const MDL_key *rhs)
{ {
...@@ -297,7 +367,8 @@ public: ...@@ -297,7 +367,8 @@ public:
character set is utf-8, we can safely assume that no character set is utf-8, we can safely assume that no
character starts with a zero byte. character starts with a zero byte.
*/ */
return memcmp(m_ptr, rhs->m_ptr, MY_MIN(m_length, rhs->m_length)); using std::min;
return memcmp(m_ptr, rhs->m_ptr, min(m_length, rhs->m_length));
} }
MDL_key(const MDL_key *rhs) MDL_key(const MDL_key *rhs)
...@@ -624,7 +695,7 @@ public: ...@@ -624,7 +695,7 @@ public:
bool set_status(enum_wait_status result_arg); bool set_status(enum_wait_status result_arg);
enum_wait_status get_status(); enum_wait_status get_status();
void reset_status(); void reset_status();
enum_wait_status timed_wait(THD *thd, enum_wait_status timed_wait(MDL_context_owner *owner,
struct timespec *abs_timeout, struct timespec *abs_timeout,
bool signal_timeout, bool signal_timeout,
const PSI_stage_info *wait_state_name); const PSI_stage_info *wait_state_name);
...@@ -706,7 +777,7 @@ public: ...@@ -706,7 +777,7 @@ public:
void release_transactional_locks(); void release_transactional_locks();
void rollback_to_savepoint(const MDL_savepoint &mdl_savepoint); void rollback_to_savepoint(const MDL_savepoint &mdl_savepoint);
inline THD *get_thd() const { return m_thd; } MDL_context_owner *get_owner() { return m_owner; }
/** @pre Only valid if we started waiting for lock. */ /** @pre Only valid if we started waiting for lock. */
inline uint get_deadlock_weight() const inline uint get_deadlock_weight() const
...@@ -719,7 +790,7 @@ public: ...@@ -719,7 +790,7 @@ public:
already has received some signal or closed already has received some signal or closed
signal slot. signal slot.
*/ */
void init(THD *thd_arg) { m_thd= thd_arg; } void init(MDL_context_owner *arg) { m_owner= arg; }
void set_needs_thr_lock_abort(bool needs_thr_lock_abort) void set_needs_thr_lock_abort(bool needs_thr_lock_abort)
{ {
...@@ -799,7 +870,7 @@ private: ...@@ -799,7 +870,7 @@ private:
involved schemas and global intention exclusive lock. involved schemas and global intention exclusive lock.
*/ */
Ticket_list m_tickets[MDL_DURATION_END]; Ticket_list m_tickets[MDL_DURATION_END];
THD *m_thd; MDL_context_owner *m_owner;
/** /**
TRUE - if for this context we will break protocol and try to TRUE - if for this context we will break protocol and try to
acquire table-level locks while having only S lock on acquire table-level locks while having only S lock on
...@@ -828,6 +899,7 @@ private: ...@@ -828,6 +899,7 @@ private:
*/ */
MDL_wait_for_subgraph *m_waiting_for; MDL_wait_for_subgraph *m_waiting_for;
private: private:
THD *get_thd() const { return m_owner->get_thd(); }
MDL_ticket *find_ticket(MDL_request *mdl_req, MDL_ticket *find_ticket(MDL_request *mdl_req,
enum_mdl_duration *duration); enum_mdl_duration *duration);
void release_locks_stored_before(enum_mdl_duration duration, MDL_ticket *sentinel); void release_locks_stored_before(enum_mdl_duration duration, MDL_ticket *sentinel);
...@@ -872,8 +944,6 @@ private: ...@@ -872,8 +944,6 @@ private:
void mdl_init(); void mdl_init();
void mdl_destroy(); void mdl_destroy();
extern bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use,
bool needs_thr_lock_abort);
#ifndef DBUG_OFF #ifndef DBUG_OFF
extern mysql_mutex_t LOCK_open; extern mysql_mutex_t LOCK_open;
...@@ -887,6 +957,14 @@ extern mysql_mutex_t LOCK_open; ...@@ -887,6 +957,14 @@ extern mysql_mutex_t LOCK_open;
extern ulong mdl_locks_cache_size; extern ulong mdl_locks_cache_size;
static const ulong MDL_LOCKS_CACHE_SIZE_DEFAULT = 1024; static const ulong MDL_LOCKS_CACHE_SIZE_DEFAULT = 1024;
/*
Start-up parameter for the number of partitions of the hash
containing all the MDL_lock objects and a constant for
its default value.
*/
extern ulong mdl_locks_hash_partitions;
static const ulong MDL_LOCKS_HASH_PARTITIONS_DEFAULT = 8;
/* /*
Metadata locking subsystem tries not to grant more than Metadata locking subsystem tries not to grant more than
max_write_lock_count high-prio, strong locks successively, max_write_lock_count high-prio, strong locks successively,
......
...@@ -124,6 +124,17 @@ public: ...@@ -124,6 +124,17 @@ public:
return (insert_dynamic(&array, (uchar*)&el)); return (insert_dynamic(&array, (uchar*)&el));
} }
/// Pops the last element. Does nothing if array is empty.
Elem& pop()
{
return *((Elem*)pop_dynamic(&array));
}
void del(uint idx)
{
delete_dynamic_element(&array, idx);
}
int elements() int elements()
{ {
return array.elements; return array.elements;
......
...@@ -4860,55 +4860,20 @@ lock_table_names(THD *thd, ...@@ -4860,55 +4860,20 @@ lock_table_names(THD *thd,
continue; continue;
} }
/* /* Write lock on normal tables is not allowed in a read only transaction. */
Write lock on normal tables is not allowed in a read only transaction.
*/
if (thd->tx_read_only) if (thd->tx_read_only)
{ {
my_error(ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION, MYF(0)); my_error(ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION, MYF(0));
DBUG_RETURN(true); DBUG_RETURN(true);
} }
if (! (flags & MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK) && schema_set.insert(table)) if (! (flags & MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK) &&
schema_set.insert(table))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
mdl_requests.push_front(&table->mdl_request); mdl_requests.push_front(&table->mdl_request);
} }
if (! (flags & MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK) &&
! mdl_requests.is_empty())
{
/*
Scoped locks: Take intention exclusive locks on all involved
schemas.
*/
Hash_set<TABLE_LIST, schema_set_get_key>::Iterator it(schema_set);
while ((table= it++))
{
MDL_request *schema_request= new (thd->mem_root) MDL_request;
if (schema_request == NULL)
return TRUE;
schema_request->init(MDL_key::SCHEMA, table->db, "",
MDL_INTENTION_EXCLUSIVE,
MDL_TRANSACTION);
mdl_requests.push_front(schema_request);
}
/*
Protect this statement against concurrent global read lock
by acquiring global intention exclusive lock with statement
duration.
*/
if (thd->global_read_lock.can_acquire_protection())
return TRUE;
global_request.init(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE,
MDL_STATEMENT);
mdl_requests.push_front(&global_request);
}
if (thd->mdl_context.acquire_locks(&mdl_requests, lock_wait_timeout))
return TRUE;
if (mdl_requests.is_empty()) if (mdl_requests.is_empty())
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#include "debug_sync.h" #include "debug_sync.h"
#include "sql_parse.h" // is_update_query #include "sql_parse.h" // is_update_query
#include "sql_callback.h" #include "sql_callback.h"
#include "lock.h"
#include "sql_connect.h" #include "sql_connect.h"
/* /*
...@@ -1788,6 +1789,46 @@ void THD::disconnect() ...@@ -1788,6 +1789,46 @@ void THD::disconnect()
} }
bool THD::notify_shared_lock(MDL_context_owner *ctx_in_use,
bool needs_thr_lock_abort)
{
THD *in_use= ctx_in_use->get_thd();
bool signalled= FALSE;
if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) &&
!in_use->killed)
{
in_use->killed= KILL_CONNECTION;
mysql_mutex_lock(&in_use->mysys_var->mutex);
if (in_use->mysys_var->current_cond)
mysql_cond_broadcast(in_use->mysys_var->current_cond);
mysql_mutex_unlock(&in_use->mysys_var->mutex);
signalled= TRUE;
}
if (needs_thr_lock_abort)
{
mysql_mutex_lock(&in_use->LOCK_thd_data);
for (TABLE *thd_table= in_use->open_tables;
thd_table ;
thd_table= thd_table->next)
{
/*
Check for TABLE::needs_reopen() is needed since in some places we call
handler::close() for table instance (and set TABLE::db_stat to 0)
and do not remove such instances from the THD::open_tables
for some time, during which other thread can see those instances
(e.g. see partitioning code).
*/
if (!thd_table->needs_reopen())
signalled|= mysql_lock_abort_for_thread(this, thd_table);
}
mysql_mutex_unlock(&in_use->LOCK_thd_data);
}
return signalled;
}
/* /*
Get error number for killed state Get error number for killed state
Note that the error message can't have any parameters. Note that the error message can't have any parameters.
......
...@@ -1571,6 +1571,7 @@ void dbug_serve_apcs(THD *thd, int n_calls); ...@@ -1571,6 +1571,7 @@ void dbug_serve_apcs(THD *thd, int n_calls);
*/ */
class THD :public Statement, class THD :public Statement,
public MDL_context_owner,
public Open_tables_state public Open_tables_state
{ {
private: private:
...@@ -2583,6 +2584,37 @@ public: ...@@ -2583,6 +2584,37 @@ public:
mysql_mutex_unlock(&mysys_var->mutex); mysql_mutex_unlock(&mysys_var->mutex);
return; return;
} }
virtual int is_killed() { return killed; }
virtual THD* get_thd() { return this; }
/**
A callback to the server internals that is used to address
special cases of the locking protocol.
Invoked when acquiring an exclusive lock, for each thread that
has a conflicting shared metadata lock.
This function:
- aborts waiting of the thread on a data lock, to make it notice
the pending exclusive lock and back off.
- if the thread is an INSERT DELAYED thread, sends it a KILL
signal to terminate it.
@note This function does not wait for the thread to give away its
locks. Waiting is done outside for all threads at once.
@param ctx_in_use The MDL context owner (thread) to wake up.
@param needs_thr_lock_abort Indicates that to wake up thread
this call needs to abort its waiting
on table-level lock.
@retval TRUE if the thread was woken up
@retval FALSE otherwise.
*/
virtual bool notify_shared_lock(MDL_context_owner *ctx_in_use,
bool needs_thr_lock_abort);
// End implementation of MDL_context_owner interface.
inline bool is_strict_mode() const inline bool is_strict_mode() const
{ {
return variables.sql_mode & (MODE_STRICT_TRANS_TABLES | return variables.sql_mode & (MODE_STRICT_TRANS_TABLES |
......
...@@ -3520,7 +3520,6 @@ Prepared_statement::execute_loop(String *expanded_query, ...@@ -3520,7 +3520,6 @@ Prepared_statement::execute_loop(String *expanded_query,
Reprepare_observer reprepare_observer; Reprepare_observer reprepare_observer;
bool error; bool error;
int reprepare_attempt= 0; int reprepare_attempt= 0;
bool need_set_parameters= true;
/* Check if we got an error when sending long data */ /* Check if we got an error when sending long data */
if (state == Query_arena::STMT_ERROR) if (state == Query_arena::STMT_ERROR)
...@@ -3529,20 +3528,19 @@ Prepared_statement::execute_loop(String *expanded_query, ...@@ -3529,20 +3528,19 @@ Prepared_statement::execute_loop(String *expanded_query,
return TRUE; return TRUE;
} }
reexecute: if (set_parameters(expanded_query, packet, packet_end))
if (need_set_parameters &&
set_parameters(expanded_query, packet, packet_end))
return TRUE; return TRUE;
/* #ifdef NOT_YET_FROM_MYSQL_5_6
if set_parameters() has generated warnings, if (unlikely(thd->security_ctx->password_expired &&
we need to repeat it when reexecuting, to recreate these !lex->is_change_password))
warnings. {
*/ my_error(ER_MUST_CHANGE_PASSWORD, MYF(0));
need_set_parameters= thd->get_stmt_da()->statement_warn_count(); return true;
}
reprepare_observer.reset_reprepare_observer(); #endif
reexecute:
/* /*
If the free_list is not empty, we'll wrongly free some externally If the free_list is not empty, we'll wrongly free some externally
allocated items when cleaning up after validation of the prepared allocated items when cleaning up after validation of the prepared
...@@ -3556,18 +3554,20 @@ reexecute: ...@@ -3556,18 +3554,20 @@ reexecute:
the observer method will be invoked to push an error into the observer method will be invoked to push an error into
the error stack. the error stack.
*/ */
if (sql_command_flags[lex->sql_command] &
CF_REEXECUTION_FRAGILE) if (sql_command_flags[lex->sql_command] & CF_REEXECUTION_FRAGILE)
{ {
reprepare_observer.reset_reprepare_observer();
DBUG_ASSERT(thd->m_reprepare_observer == NULL); DBUG_ASSERT(thd->m_reprepare_observer == NULL);
thd->m_reprepare_observer = &reprepare_observer; thd->m_reprepare_observer= &reprepare_observer;
} }
error= execute(expanded_query, open_cursor) || thd->is_error(); error= execute(expanded_query, open_cursor) || thd->is_error();
thd->m_reprepare_observer= NULL; thd->m_reprepare_observer= NULL;
if (error && !thd->is_fatal_error && !thd->killed && if ((sql_command_flags[lex->sql_command] & CF_REEXECUTION_FRAGILE) &&
error && !thd->is_fatal_error && !thd->killed &&
reprepare_observer.is_invalidated() && reprepare_observer.is_invalidated() &&
reprepare_attempt++ < MAX_REPREPARE_ATTEMPTS) reprepare_attempt++ < MAX_REPREPARE_ATTEMPTS)
{ {
......
...@@ -1331,6 +1331,12 @@ static Sys_var_ulong Sys_metadata_locks_cache_size( ...@@ -1331,6 +1331,12 @@ static Sys_var_ulong Sys_metadata_locks_cache_size(
VALID_RANGE(1, 1024*1024), DEFAULT(MDL_LOCKS_CACHE_SIZE_DEFAULT), VALID_RANGE(1, 1024*1024), DEFAULT(MDL_LOCKS_CACHE_SIZE_DEFAULT),
BLOCK_SIZE(1)); BLOCK_SIZE(1));
static Sys_var_ulong Sys_metadata_locks_hash_instances(
"metadata_locks_hash_instances", "Number of metadata locks hash instances",
READ_ONLY GLOBAL_VAR(mdl_locks_hash_partitions), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(1, 1024), DEFAULT(MDL_LOCKS_HASH_PARTITIONS_DEFAULT),
BLOCK_SIZE(1));
/* /*
"pseudo_thread_id" variable used in the test suite to detect 32/64bit "pseudo_thread_id" variable used in the test suite to detect 32/64bit
systems. If you change it to something else then ulong then fix the tests systems. If you change it to something else then ulong then fix the tests
......
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