MDEV-24491 db_name mismatch happens during virtual column computation

    Database name mismatch happens while opening the table for
virtual column computation. Because table_name_parse() returns
the length of database and table name before converting the
filename to table name. This issue is caused by
commit 8b0d4cff (MDEV-15855).
Fix should be that table_name_parse() should return the length of
database and table name after converting the filename to table name.

Reviewed-by: Marko Mäkelä
parent 479b4214
......@@ -793,6 +793,9 @@ DROP TABLE t1;
#
# MDEV-24041 Generated column DELETE with FOREIGN KEY crash InnoDB
#
SET FOREIGN_KEY_CHECKS=1;
CREATE DATABASE `a-b`;
USE `a-b`;
CREATE TABLE emails (
id int,
PRIMARY KEY (id)
......@@ -802,6 +805,7 @@ id int,
email_id int,
date_sent char(4),
generated_email_id int as (email_id),
#generated_sent_date DATE GENERATED ALWAYS AS (date_sent),
PRIMARY KEY (id),
KEY mautic_generated_sent_date_email_id (generated_email_id),
FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE SET NULL
......@@ -818,3 +822,4 @@ DELETE FROM emails;
DROP TABLE email_stats;
DROP TABLE emails_metadata;
DROP TABLE emails;
DROP DATABASE `a-b`;
......@@ -653,7 +653,9 @@ DROP TABLE t1;
--echo #
--echo # MDEV-24041 Generated column DELETE with FOREIGN KEY crash InnoDB
--echo #
SET FOREIGN_KEY_CHECKS=1;
CREATE DATABASE `a-b`;
USE `a-b`;
CREATE TABLE emails (
id int,
PRIMARY KEY (id)
......@@ -664,6 +666,7 @@ CREATE TABLE email_stats (
email_id int,
date_sent char(4),
generated_email_id int as (email_id),
#generated_sent_date DATE GENERATED ALWAYS AS (date_sent),
PRIMARY KEY (id),
KEY mautic_generated_sent_date_email_id (generated_email_id),
FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE SET NULL
......@@ -686,3 +689,4 @@ DELETE FROM emails;
DROP TABLE email_stats;
DROP TABLE emails_metadata;
DROP TABLE emails;
DROP DATABASE `a-b`;
......@@ -21543,7 +21543,7 @@ static bool table_name_parse(
memcpy(tbl_buf, tbl_name.m_name + dbnamelen + 1, tblnamelen);
tbl_buf[tblnamelen] = 0;
filename_to_tablename(db_buf, dbname, MAX_DATABASE_NAME_LEN + 1, true);
dbnamelen = filename_to_tablename(db_buf, dbname, MAX_DATABASE_NAME_LEN + 1, true);
if (tblnamelen > TEMP_FILE_PREFIX_LENGTH
&& !strncmp(tbl_buf, TEMP_FILE_PREFIX, TEMP_FILE_PREFIX_LENGTH)) {
......@@ -21555,7 +21555,7 @@ static bool table_name_parse(
tblnamelen = is_part - tbl_buf;
}
filename_to_tablename(tbl_buf, tblname, MAX_TABLE_NAME_LEN + 1, true);
tblnamelen = filename_to_tablename(tbl_buf, tblname, MAX_TABLE_NAME_LEN + 1, true);
return 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