summaryrefslogtreecommitdiffstats
path: root/mysql-test/include/query_cache_partitions.inc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:24:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:24:36 +0000
commit06eaf7232e9a920468c0f8d74dcf2fe8b555501c (patch)
treee2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/include/query_cache_partitions.inc
parentInitial commit. (diff)
downloadmariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.tar.xz
mariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.zip
Adding upstream version 1:10.11.6.upstream/1%10.11.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/include/query_cache_partitions.inc')
-rw-r--r--mysql-test/include/query_cache_partitions.inc138
1 files changed, 138 insertions, 0 deletions
diff --git a/mysql-test/include/query_cache_partitions.inc b/mysql-test/include/query_cache_partitions.inc
new file mode 100644
index 00000000..6c51300a
--- /dev/null
+++ b/mysql-test/include/query_cache_partitions.inc
@@ -0,0 +1,138 @@
+# include/query_cache_partitions.inc
+#
+# The variables
+# $engine_type -- storage engine to be tested
+# have to be set before sourcing this script.
+
+# Tests will be skipped for the view protocol because the view protocol creates
+# an additional util connection and other statistics data
+-- source include/no_view_protocol.inc
+
+SET global query_cache_type=ON;
+SET local query_cache_type=ON;
+eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
+
+# Initialise
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+set @save_query_cache_size = @@global.query_cache_size;
+
+--echo # Test that partitions works with query cache
+
+flush query cache;
+
+SET GLOBAL query_cache_size=1024*1024*512;
+ CREATE TABLE `t1` (
+ `id` int(11) NOT NULL ,
+ `created_at` datetime NOT NULL,
+ `cool` tinyint default 0
+ );
+
+ ALTER TABLE t1 PARTITION BY RANGE (TO_DAYS(created_at)) (
+ PARTITION month_2010_4 VALUES LESS THAN (734258),
+ PARTITION month_2010_5 VALUES LESS THAN (734289),
+ PARTITION month_max VALUES LESS THAN MAXVALUE
+ );
+
+show create table t1;
+
+INSERT INTO t1 VALUES (1, now(), 0);
+
+flush status;
+show status like "Qcache_queries_in_cache";
+show status like "Qcache_hits";
+
+--disable_ps2_protocol
+SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
+SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
+SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
+
+show status like "Qcache_queries_in_cache";
+show status like "Qcache_hits";
+--enable_ps2_protocol
+
+drop table t1;
+
+--echo # Test that sub-partitions works with query cache
+
+flush query cache;
+
+SET GLOBAL query_cache_size=1024*1024*512;
+ CREATE TABLE `t1` (
+ `id` int(11) NOT NULL ,
+ `created_at` datetime NOT NULL,
+ `cool` tinyint default 0
+ )
+ PARTITION BY RANGE (TO_DAYS(created_at))
+ subpartition by hash(cool) subpartitions 3 (
+ PARTITION month_2010_4 VALUES LESS THAN (734258),
+ PARTITION month_2010_5 VALUES LESS THAN (734289),
+ PARTITION month_max VALUES LESS THAN MAXVALUE
+ );
+
+show create table t1;
+
+INSERT INTO t1 VALUES (1, now(), 0);
+
+flush status;
+show status like "Qcache_queries_in_cache";
+show status like "Qcache_hits";
+
+--disable_ps2_protocol
+SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
+SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
+SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
+
+show status like "Qcache_queries_in_cache";
+show status like "Qcache_hits";
+--enable_ps2_protocol
+
+drop table t1;
+
+--echo #
+--echo # MySQL bug#53775 Query on partitioned table returns cached result
+--echo # from previous transaction
+--echo #
+
+flush query cache;
+flush status;
+
+SET GLOBAL query_cache_size=1024*1024*512;
+ CREATE TABLE `t1` (
+ `id` int(11) NOT NULL ,
+ `created_at` datetime NOT NULL,
+ `cool` tinyint default 0
+ );
+
+ ALTER TABLE t1 PARTITION BY RANGE (TO_DAYS(created_at)) (
+ PARTITION month_2010_4 VALUES LESS THAN (734258),
+ PARTITION month_2010_5 VALUES LESS THAN (734289),
+ PARTITION month_max VALUES LESS THAN MAXVALUE
+ );
+
+INSERT INTO t1 VALUES (1, now(), 0);
+
+show status like "Qcache_queries_in_cache";
+show status like "Qcache_hits";
+
+--disable_ps2_protocol
+BEGIN;
+UPDATE `t1` SET `cool` = 1 WHERE `id` = 1;
+SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
+ROLLBACK;
+SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
+BEGIN;
+SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
+ROLLBACK;
+SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
+
+show status like "Qcache_queries_in_cache";
+show status like "Qcache_hits";
+--enable_ps2_protocol
+
+drop table t1;
+
+set @@global.query_cache_size = @save_query_cache_size;
+SET global query_cache_type=default;