From 7d4beb7286d53be07ff552de9d37ea90c2762651 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 8 Oct 2018 21:06:42 +0530 Subject: [PATCH] MDEV-16980 Wrongly set tablename len while opening the table for purge thread Problem: ======= Purge tries to fetch mdl lock for the whole table even though it tries to open one of the partition. But table name length was wrongly set to indicate the partition name too. Solution: ======== - Table name length should identify the table name only not the partition name. --- .../suite/gcol/r/gcol_partition_innodb.result | 17 ++++++++++++++++ .../suite/gcol/t/gcol_partition_innodb.test | 20 +++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 1 + 3 files changed, 38 insertions(+) diff --git a/mysql-test/suite/gcol/r/gcol_partition_innodb.result b/mysql-test/suite/gcol/r/gcol_partition_innodb.result index 9a0e676e76f..7600c9792f1 100644 --- a/mysql-test/suite/gcol/r/gcol_partition_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_partition_innodb.result @@ -1,4 +1,6 @@ SET @@session.default_storage_engine = 'InnoDB'; +SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; +SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; drop table if exists t1; # Case 1. Partitioning by RANGE based on a non-stored generated column. CREATE TABLE t1 ( @@ -86,6 +88,20 @@ CHECK TABLE t EXTENDED; Table Op Msg_type Msg_text test.t check status OK DROP TABLE t; +# +# MDEV-16980 Wrongly set tablename len while opening the +# table for purge thread +# +CREATE TABLE t1(pk SERIAL, d DATE, vd DATE AS (d) VIRTUAL, +PRIMARY KEY(pk), KEY (vd))ENGINE=InnoDB +PARTITION BY HASH(pk) PARTITIONS 2; +INSERT IGNORE INTO t1 (d) VALUES ('2015-04-14'); +SET sql_mode= ''; +REPLACE INTO t1 SELECT * FROM t1; +Warnings: +Warning 1906 The value specified for generated column 'vd' in table 't1' ignored +DROP TABLE t1; +InnoDB 0 transactions not purged DROP VIEW IF EXISTS v1,v2; DROP TABLE IF EXISTS t1,t2,t3; DROP PROCEDURE IF EXISTS p1; @@ -93,3 +109,4 @@ DROP FUNCTION IF EXISTS f1; DROP TRIGGER IF EXISTS trg1; DROP TRIGGER IF EXISTS trg2; set sql_warnings = 0; +SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency; diff --git a/mysql-test/suite/gcol/t/gcol_partition_innodb.test b/mysql-test/suite/gcol/t/gcol_partition_innodb.test index 06e6ccc1ba4..75e2f80af20 100644 --- a/mysql-test/suite/gcol/t/gcol_partition_innodb.test +++ b/mysql-test/suite/gcol/t/gcol_partition_innodb.test @@ -30,6 +30,8 @@ # Set the session storage engine --source include/have_innodb.inc eval SET @@session.default_storage_engine = 'InnoDB'; +SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; +SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; ##### Workarounds for known open engine specific bugs # none @@ -41,6 +43,24 @@ eval SET @@session.default_storage_engine = 'InnoDB'; #------------------------------------------------------------------------------# # Execute storage engine specific tests +--echo # +--echo # MDEV-16980 Wrongly set tablename len while opening the +--echo # table for purge thread +--echo # + +CREATE TABLE t1(pk SERIAL, d DATE, vd DATE AS (d) VIRTUAL, + PRIMARY KEY(pk), KEY (vd))ENGINE=InnoDB + PARTITION BY HASH(pk) PARTITIONS 2; + +INSERT IGNORE INTO t1 (d) VALUES ('2015-04-14'); +SET sql_mode= ''; +REPLACE INTO t1 SELECT * FROM t1; + +# Cleanup +DROP TABLE t1; + +--source suite/innodb/include/wait_all_purged.inc #------------------------------------------------------------------------------# # Cleanup --source suite/gcol/inc/gcol_cleanup.inc +SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 4ad97597b8b..32c72ade7b2 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -20373,6 +20373,7 @@ static bool table_name_parse( if (char *is_part = strchr(tbl_buf, '#')) { *is_part = '\0'; + tblnamelen = is_part - tbl_buf; } filename_to_tablename(tbl_buf, tblname, MAX_TABLE_NAME_LEN + 1, true);