summaryrefslogtreecommitdiff
path: root/sql/mdl.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2012-09-27 20:09:46 +0200
committerSergei Golubchik <sergii@pisem.net>2012-09-27 20:09:46 +0200
commit474fe6d9d9e0b4d8803bdf439dd017ba0c729729 (patch)
tree6b088655217934bf0cbb6cdf85df0a217ef1d939 /sql/mdl.cc
parentcd9f773020c6ddfc1ea39e9037e4258b8bc32a08 (diff)
downloadmariadb-git-474fe6d9d9e0b4d8803bdf439dd017ba0c729729.tar.gz
fixes for test failures
and small collateral changes mysql-test/lib/My/Test.pm: somehow with "print" we get truncated writes sometimes mysql-test/suite/perfschema/r/digest_table_full.result: md5 hashes of statement digests differ, because yacc token codes are different in mariadb mysql-test/suite/perfschema/r/dml_handler.result: host table is not ported over yet mysql-test/suite/perfschema/r/information_schema.result: host table is not ported over yet mysql-test/suite/perfschema/r/nesting.result: this differs, because we don't rewrite general log queries, and multi-statement packets are logged as a one entry. this result file is identical to what mysql-5.6.5 produces with the --log-raw option. mysql-test/suite/perfschema/r/relaylog.result: MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB. mysql-test/suite/perfschema/r/server_init.result: MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup. mysql-test/suite/perfschema/r/stage_mdl_global.result: this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not do that, and this causes useless mutex locks and waits. mysql-test/suite/perfschema/r/statement_digest.result: md5 hashes of statement digests differ, because yacc token codes are different in mariadb mysql-test/suite/perfschema/r/statement_digest_consumers.result: md5 hashes of statement digests differ, because yacc token codes are different in mariadb mysql-test/suite/perfschema/r/statement_digest_long_query.result: md5 hashes of statement digests differ, because yacc token codes are different in mariadb mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result: will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result: will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
Diffstat (limited to 'sql/mdl.cc')
-rw-r--r--sql/mdl.cc65
1 files changed, 41 insertions, 24 deletions
diff --git a/sql/mdl.cc b/sql/mdl.cc
index ca552a540b9..0e30e44c19a 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -10,16 +10,18 @@
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 */
#include "mdl.h"
+#include "sql_class.h"
#include "debug_sync.h"
#include <hash.h>
#include <mysqld_error.h>
#include <mysql/plugin.h>
#include <mysql/service_thd_wait.h>
+#include <mysql/psi/mysql_stage.h>
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key key_MDL_map_mutex;
@@ -53,20 +55,18 @@ static PSI_cond_info all_mdl_conds[]=
*/
static void init_mdl_psi_keys(void)
{
- const char *category= "sql";
int count;
- if (PSI_server == NULL)
- return;
-
count= array_elements(all_mdl_mutexes);
- PSI_server->register_mutex(category, all_mdl_mutexes, count);
+ mysql_mutex_register("sql", all_mdl_mutexes, count);
count= array_elements(all_mdl_rwlocks);
- PSI_server->register_rwlock(category, all_mdl_rwlocks, count);
+ mysql_rwlock_register("sql", all_mdl_rwlocks, count);
count= array_elements(all_mdl_conds);
- PSI_server->register_cond(category, all_mdl_conds, count);
+ mysql_cond_register("sql", all_mdl_conds, count);
+
+ MDL_key::init_psi_keys();
}
#endif /* HAVE_PSI_INTERFACE */
@@ -76,18 +76,35 @@ static void init_mdl_psi_keys(void)
belonging to certain namespace.
*/
-const char *MDL_key::m_namespace_to_wait_state_name[NAMESPACE_END]=
+PSI_stage_info MDL_key::m_namespace_to_wait_state_name[NAMESPACE_END]=
{
- "Waiting for global read lock",
- "Waiting for schema metadata lock",
- "Waiting for table metadata lock",
- "Waiting for stored function metadata lock",
- "Waiting for stored procedure metadata lock",
- "Waiting for trigger metadata lock",
- "Waiting for event metadata lock",
- "Waiting for commit lock"
+ {0, "Waiting for global read lock", 0},
+ {0, "Waiting for schema metadata lock", 0},
+ {0, "Waiting for table metadata lock", 0},
+ {0, "Waiting for stored function metadata lock", 0},
+ {0, "Waiting for stored procedure metadata lock", 0},
+ {0, "Waiting for trigger metadata lock", 0},
+ {0, "Waiting for event metadata lock", 0},
+ {0, "Waiting for commit lock", 0}
};
+#ifdef HAVE_PSI_INTERFACE
+void MDL_key::init_psi_keys()
+{
+ int i;
+ int count;
+ PSI_stage_info *info __attribute__((unused));
+
+ count= array_elements(MDL_key::m_namespace_to_wait_state_name);
+ for (i= 0; i<count; i++)
+ {
+ /* mysql_stage_register wants an array of pointers, registering 1 by 1. */
+ info= & MDL_key::m_namespace_to_wait_state_name[i];
+ mysql_stage_register("sql", &info, 1);
+ }
+}
+#endif
+
static bool mdl_initialized= 0;
@@ -1140,18 +1157,18 @@ void MDL_wait::reset_status()
MDL_wait::enum_wait_status
MDL_wait::timed_wait(THD *thd, struct timespec *abs_timeout,
- bool set_status_on_timeout, const char *wait_state_name)
+ bool set_status_on_timeout,
+ const PSI_stage_info *wait_state_name)
{
- const char *old_msg;
+ PSI_stage_info old_stage;
enum_wait_status result;
int wait_result= 0;
DBUG_ENTER("MDL_wait::timed_wait");
mysql_mutex_lock(&m_LOCK_wait_status);
- old_msg= thd_enter_cond(thd, &m_COND_wait_status, &m_LOCK_wait_status,
- wait_state_name);
-
+ THD_ENTER_COND(thd, &m_COND_wait_status, &m_LOCK_wait_status,
+ wait_state_name, & old_stage);
thd_wait_begin(thd, THD_WAIT_META_DATA_LOCK);
while (!m_wait_status && !thd_killed(thd) &&
wait_result != ETIMEDOUT && wait_result != ETIME)
@@ -1182,7 +1199,7 @@ MDL_wait::timed_wait(THD *thd, struct timespec *abs_timeout,
}
result= m_wait_status;
- thd_exit_cond(thd, old_msg);
+ thd->EXIT_COND(& old_stage);
DBUG_RETURN(result);
}