summaryrefslogtreecommitdiff
path: root/mysql-test/suite/perfschema/t/func_mutex.test
diff options
context:
space:
mode:
authorMarc Alff <marc.alff@sun.com>2010-01-11 18:47:27 -0700
committerMarc Alff <marc.alff@sun.com>2010-01-11 18:47:27 -0700
commite0e0f9e3d46917fe9b611fc9769e64032c267446 (patch)
treec111d4c62b1e1eb7a74ec68860756418e29cb61e /mysql-test/suite/perfschema/t/func_mutex.test
parent3d915225611a921fad03934e58bf281b48fc15b0 (diff)
downloadmariadb-git-e0e0f9e3d46917fe9b611fc9769e64032c267446.tar.gz
WL#2360 Performance schema
Part V: performance schema implementation
Diffstat (limited to 'mysql-test/suite/perfschema/t/func_mutex.test')
-rw-r--r--mysql-test/suite/perfschema/t/func_mutex.test131
1 files changed, 131 insertions, 0 deletions
diff --git a/mysql-test/suite/perfschema/t/func_mutex.test b/mysql-test/suite/perfschema/t/func_mutex.test
new file mode 100644
index 00000000000..98cb905c67c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/func_mutex.test
@@ -0,0 +1,131 @@
+# Copyright (C) 2008-2009 Sun Microsystems, Inc
+#
+# 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
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+##
+## WL#4818, 4.1.3 MUTEXES, RW-LOCKS, ...
+##
+## Functional testing of mutexes and RW-locks
+##
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+UPDATE performance_schema.SETUP_INSTRUMENTS SET enabled = 'NO', timed = 'YES';
+
+UPDATE performance_schema.SETUP_INSTRUMENTS SET enabled = 'YES'
+WHERE name LIKE 'wait/synch/mutex/%'
+ OR name LIKE 'wait/synch/rwlock/%';
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+#
+# TODO: Change to InnoDB when it gets instrumentation
+#
+
+CREATE TABLE t1 (id INT PRIMARY KEY, b CHAR(100) DEFAULT 'initial value')
+ENGINE=MyISAM;
+
+INSERT INTO t1 (id) VALUES (1), (2), (3), (4), (5), (6), (7), (8);
+
+#
+# FM1: Count for mutex should increase with instrumentation enabled and
+# FM2: Count for mutex should not increase with instrumentation disabled
+#
+
+TRUNCATE TABLE performance_schema.EVENTS_WAITS_HISTORY_LONG;
+TRUNCATE TABLE performance_schema.EVENTS_WAITS_HISTORY;
+TRUNCATE TABLE performance_schema.EVENTS_WAITS_CURRENT;
+
+SELECT * FROM t1 WHERE id = 1;
+
+SET @before_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.EVENTS_WAITS_HISTORY_LONG
+ WHERE (EVENT_NAME = 'wait/synch/mutex/sql/LOCK_open'));
+
+SELECT * FROM t1;
+
+SET @after_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.EVENTS_WAITS_HISTORY_LONG
+ WHERE (EVENT_NAME = 'wait/synch/mutex/sql/LOCK_open'));
+
+SELECT IF((@after_count - @before_count) > 0, 'Success', 'Failure') test_fm1_timed;
+
+UPDATE performance_schema.SETUP_INSTRUMENTS SET enabled = 'NO'
+WHERE NAME = 'wait/synch/mutex/sql/LOCK_open';
+
+TRUNCATE TABLE performance_schema.EVENTS_WAITS_HISTORY_LONG;
+TRUNCATE TABLE performance_schema.EVENTS_WAITS_HISTORY;
+TRUNCATE TABLE performance_schema.EVENTS_WAITS_CURRENT;
+
+SELECT * FROM t1 WHERE id = 1;
+
+SET @before_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.EVENTS_WAITS_HISTORY_LONG
+ WHERE (EVENT_NAME = 'wait/synch/mutex/sql/LOCK_open'));
+
+SELECT * FROM t1;
+
+SET @after_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.EVENTS_WAITS_HISTORY_LONG
+ WHERE (EVENT_NAME = 'wait/synch/mutex/sql/LOCK_open'));
+
+SELECT IF((COALESCE(@after_count, 0) - COALESCE(@before_count, 0)) = 0, 'Success', 'Failure') test_fm2_timed;
+
+#
+# Repeat for RW-lock
+#
+
+TRUNCATE TABLE performance_schema.EVENTS_WAITS_HISTORY_LONG;
+TRUNCATE TABLE performance_schema.EVENTS_WAITS_HISTORY;
+TRUNCATE TABLE performance_schema.EVENTS_WAITS_CURRENT;
+
+SELECT * FROM t1 WHERE id = 1;
+
+SET @before_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.EVENTS_WAITS_HISTORY_LONG
+ WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_grant'));
+
+SELECT * FROM t1;
+
+SET @after_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.EVENTS_WAITS_HISTORY_LONG
+ WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_grant'));
+
+SELECT IF((@after_count - @before_count) > 0, 'Success', 'Failure') test_fm1_rw_timed;
+
+UPDATE performance_schema.SETUP_INSTRUMENTS SET enabled = 'NO'
+WHERE NAME = 'wait/synch/rwlock/sql/LOCK_grant';
+
+TRUNCATE TABLE performance_schema.EVENTS_WAITS_HISTORY_LONG;
+TRUNCATE TABLE performance_schema.EVENTS_WAITS_HISTORY;
+TRUNCATE TABLE performance_schema.EVENTS_WAITS_CURRENT;
+
+SELECT * FROM t1 WHERE id = 1;
+
+SET @before_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.EVENTS_WAITS_HISTORY_LONG
+ WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_grant'));
+
+SELECT * FROM t1;
+
+SET @after_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.EVENTS_WAITS_HISTORY_LONG
+ WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_grant'));
+
+SELECT IF((COALESCE(@after_count, 0) - COALESCE(@before_count, 0)) = 0, 'Success', 'Failure') test_fm2_rw_timed;
+
+DROP TABLE t1;