mariadb/mysql-test/t/truncate-stale-6500.test
Vicențiu Ciorbaru a477cd1754 MDEV-6500: Stale data returned after TRUNCATE PARTITION operation
When truncating a table's partition, we also need to invalidate the
query cache for it.
2015-06-04 18:04:31 +03:00

32 lines
1,006 B
Text

--source include/have_innodb.inc
--source include/have_partition.inc
SET GLOBAL query_cache_size=1024*1024*8;
CREATE TABLE `test` (
`uniqueId` INT NOT NULL,
`partitionId` INT NOT NULL,
PRIMARY KEY (`uniqueId`,`partitionId`)
) ENGINE=InnoDB PARTITION BY LIST (partitionId) (
PARTITION p01 VALUES IN (1),
PARTITION p02 VALUES IN (2)
);
INSERT INTO `test`(`uniqueId`,`partitionId`) VALUES(407237055, 2);
SELECT * FROM `test`;
--echo #Confirms 1 row in partition 'p02'
SELECT TABLE_NAME, PARTITION_NAME, TABLE_ROWS FROM information_schema.PARTITIONS where TABLE_NAME = 'test';
ALTER TABLE `test` TRUNCATE PARTITION `p02`;
--echo #Confirms no more rows in partition 'p02'
SELECT TABLE_NAME, PARTITION_NAME, TABLE_ROWS FROM information_schema.PARTITIONS where TABLE_NAME = 'test';
--echo #Before the patch, this returned the previously existing values.
SELECT * FROM `test`;
SELECT SQL_CACHE * FROM `test`;
SELECT SQL_NO_CACHE * FROM `test`;
DROP TABLE test;
SET GLOBAL query_cache_size=DEFAULT;