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.
parent 1ebe841f
SET @@session.default_storage_engine = 'InnoDB'; 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; drop table if exists t1;
# Case 1. Partitioning by RANGE based on a non-stored generated column. # Case 1. Partitioning by RANGE based on a non-stored generated column.
CREATE TABLE t1 ( CREATE TABLE t1 (
...@@ -86,6 +88,20 @@ CHECK TABLE t EXTENDED; ...@@ -86,6 +88,20 @@ CHECK TABLE t EXTENDED;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t check status OK test.t check status OK
DROP TABLE t; 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 VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3; DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1; DROP PROCEDURE IF EXISTS p1;
...@@ -93,3 +109,4 @@ DROP FUNCTION IF EXISTS f1; ...@@ -93,3 +109,4 @@ DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1; DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2; DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0; set sql_warnings = 0;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
# Set the session storage engine # Set the session storage engine
--source include/have_innodb.inc --source include/have_innodb.inc
eval SET @@session.default_storage_engine = 'InnoDB'; 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 ##### Workarounds for known open engine specific bugs
# none # none
...@@ -41,6 +43,24 @@ eval SET @@session.default_storage_engine = 'InnoDB'; ...@@ -41,6 +43,24 @@ eval SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------------# #------------------------------------------------------------------------------#
# Execute storage engine specific tests # 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 # Cleanup
--source suite/gcol/inc/gcol_cleanup.inc --source suite/gcol/inc/gcol_cleanup.inc
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
...@@ -1765,6 +1765,8 @@ struct TABLE_LIST ...@@ -1765,6 +1765,8 @@ struct TABLE_LIST
mdl_type= MDL_SHARED_READ; mdl_type= MDL_SHARED_READ;
bzero((char*) this, sizeof(*this)); bzero((char*) this, sizeof(*this));
DBUG_ASSERT(!db_name_arg || strlen(db_name_arg) == db_length_arg);
DBUG_ASSERT(!table_name_arg || strlen(table_name_arg) == table_name_length_arg);
db= (char*) db_name_arg; db= (char*) db_name_arg;
db_length= db_length_arg; db_length= db_length_arg;
table_name= (char*) table_name_arg; table_name= (char*) table_name_arg;
......
...@@ -21341,6 +21341,7 @@ static bool table_name_parse( ...@@ -21341,6 +21341,7 @@ static bool table_name_parse(
if (char *is_part = strchr(tbl_buf, '#')) { if (char *is_part = strchr(tbl_buf, '#')) {
*is_part = '\0'; *is_part = '\0';
tblnamelen = is_part - tbl_buf;
} }
filename_to_tablename(tbl_buf, tblname, MAX_TABLE_NAME_LEN + 1, true); filename_to_tablename(tbl_buf, tblname, MAX_TABLE_NAME_LEN + 1, true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment