summaryrefslogtreecommitdiff
path: root/mysql-test/r
diff options
context:
space:
mode:
authorunknown <ingo/istruewing@chilla.local>2006-08-02 17:57:06 +0200
committerunknown <ingo/istruewing@chilla.local>2006-08-02 17:57:06 +0200
commitef976d20c95cb547dcb6123f0072d06bea61f177 (patch)
treede85448d58986b9ff6d72d59f3e8595b8c2e1a72 /mysql-test/r
parent4b6e8fa61dc5ca225bfd54f460206a3088a115c2 (diff)
downloadmariadb-git-ef976d20c95cb547dcb6123f0072d06bea61f177.tar.gz
Bug#18775 - Temporary table from alter table visible to other threads
Continued implementation of WL#1324 (table name to filename encoding) The intermediate (not temporary) files of the new table during ALTER TABLE was visible for SHOW TABLES. These intermediate files are copies of the original table with the changes done by ALTER TABLE. After all the data is copied over from the original table, these files are renamed to the original tables file names. So they are not temporary files. They persist after ALTER TABLE, but just with another name. In 5.0 the intermediate files are invisible for SHOW TABLES because all file names beginning with "#sql" were suppressed. This failed since 5.1.6 because even temporary table names were converted when making file names from them. The prefix became converted to "@0023sql". Converting the prefix during SHOW TABLES would suppress the listing of user tables that start with "#sql". The solution of the problem is to continue the implementation of the table name to file name conversion feature. One requirement is to suppress the conversion for temporary table names. This change is straightforward for real temporary tables as there is a function that creates temporary file names. But the generated path names are located in TMPDIR and have no relation to the internal table name. This cannot be used for ALTER TABLE. Its intermediate files need to be in the same directory as the old table files. And it is necessary to be able to deduce the same path from the same table name repeatedly. Consequently the intermediate table files must be handled like normal tables. Their internal names shall start with tmp_file_prefix (#sql) and they shall not be converted like normal table names. I added a flags parameter to all relevant functions that are called from ALTER TABLE. It is used to suppress the conversion for the intermediate table files. The outcome is that the suppression of #sql in SHOW TABLES works again. It does not suppress user tables as these are converted to @0023sql on file level. This patch does also fix ALTER TABLE ... RENAME, which could not rename a table with non-ASCII characters in its name. It does also fix the problem that a user could create a table like `#sql-xxxx-yyyy`, where xxxx is mysqld's pid and yyyy is the thread ID of some other thread, which prevented this thread from running ALTER TABLE. Some of the above problems are mentioned in Bug 1405, which can be closed with this patch. This patch does also contain some minor fixes for other forgotten conversions. Still known problems are reported as bugs 21370, 21373, and 21387. mysql-test/r/alter_table.result: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added test results. mysql-test/r/backup.result: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added test results. mysql-test/r/repair.result: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added test results. mysql-test/t/alter_table.test: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added test cases. mysql-test/t/backup.test: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added test cases. mysql-test/t/repair.test: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added a test case. sql/ha_myisam.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added missing table name mapping calls to backup() and restore(). sql/ha_myisammrg.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added an zero argument for the new 'flags' parameter. sql/ha_ndbcluster.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added an zero argument for the new 'flags' parameter. sql/ha_ndbcluster_binlog.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added an zero argument for the new 'flags' parameter. sql/ha_ndbcluster_binlog.h: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Removed unnecessary check for wrong temp file prefix. sql/mysql_priv.h: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Extended quick_rm_table(), mysql_rename_table(), and build_table_filename() by an flags argument, which can indicate temporary table names that should not be converted. Added symbolic flag values. sql/sql_acl.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added an zero argument for the new 'flags' parameter. sql/sql_base.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Fixed a comment. Added DBUG calls. sql/sql_db.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added an zero argument for the new 'flags' parameter. sql/sql_delete.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added an zero argument for the new 'flags' parameter. sql/sql_insert.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added an zero argument for the new 'flags' parameter. sql/sql_partition.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added an zero argument for the new 'flags' parameter. sql/sql_rename.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added an zero argument for the new 'flags' parameter. sql/sql_show.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Reverted the former fix for this bug. tmp_file_prefix is now used verbatim in the comparison of file names. sql/sql_table.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added a check for a tmp_file_prefix file name to filename_to_tablename(). These names are now accepted without conversion. Extended quick_rm_table(), mysql_rename_table(), and build_table_filename() by an flags argument, which can indicate temporary table names that should not be converted. Removed the table to file name conversion from build_tmptable_filename(). Disabled REPAIR TABLE ... USE_FRM for temporary tables. Added the forgotten conversion to mysql_alter_table() for the case of ALTER TABLE ... RENAME. Added comments and DBUG calls. sql/sql_trigger.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added an zero argument for the new 'flags' parameter. sql/sql_view.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Added an zero argument for the new 'flags' parameter. sql/table.cc: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Replaced a literal ".frm" by reg_ext. Added DBUG calls. storage/innobase/row/row0mysql.c: Bug#18775 - Temporary table from alter table visible to other threads Continued implementation of WL#1324 (table name to filename encoding) Changed back the encoded temp file prefix to #sql.
Diffstat (limited to 'mysql-test/r')
-rw-r--r--mysql-test/r/alter_table.result60
-rw-r--r--mysql-test/r/backup.result20
-rw-r--r--mysql-test/r/repair.result6
3 files changed, 86 insertions, 0 deletions
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index f4332ea9888..3095d5337ed 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -657,3 +657,63 @@ SELECT * FROM t1;
v b
abc 5
DROP TABLE t1;
+DROP DATABASE IF EXISTS mysqltest;
+CREATE DATABASE mysqltest;
+use mysqltest;
+DROP TABLE IF EXISTS `t1_nägel`, `t1_blüten`;
+CREATE TABLE `t1_nägel` (c1 INT);
+ALTER TABLE `t1_nägel` RENAME `t1_blüten`;
+CREATE TABLE `t1_nägel` (c1 INT);
+ALTER TABLE `t1_nägel` RENAME `t1_blüten`;
+ERROR 42S01: Table 't1_blЭten' already exists
+DROP TABLE `t1_nägel`, `t1_blüten`;
+CREATE TEMPORARY TABLE `tt1_nägel` (c1 INT);
+ALTER TABLE `tt1_nägel` RENAME `tt1_blüten`;
+CREATE TEMPORARY TABLE `tt1_nägel` (c1 INT);
+ALTER TABLE `tt1_nägel` RENAME `tt1_blüten`;
+ERROR 42S01: Table 'tt1_blЭten' already exists
+SHOW CREATE TABLE `tt1_blüten`;
+Table Create Table
+tt1_blüten CREATE TEMPORARY TABLE `tt1_blüten` (
+ `c1` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE `tt1_nägel`, `tt1_blüten`;
+CREATE TABLE `#sql1` (c1 INT);
+CREATE TABLE `@0023sql2` (c1 INT);
+SHOW TABLES;
+Tables_in_mysqltest
+#sql1
+@0023sql2
+RENAME TABLE `#sql1` TO `@0023sql1`;
+RENAME TABLE `@0023sql2` TO `#sql2`;
+SHOW TABLES;
+Tables_in_mysqltest
+#sql2
+@0023sql1
+ALTER TABLE `@0023sql1` RENAME `#sql-1`;
+ALTER TABLE `#sql2` RENAME `@0023sql-2`;
+SHOW TABLES;
+Tables_in_mysqltest
+#sql-1
+@0023sql-2
+INSERT INTO `#sql-1` VALUES (1);
+INSERT INTO `@0023sql-2` VALUES (2);
+DROP TABLE `#sql-1`, `@0023sql-2`;
+CREATE TEMPORARY TABLE `#sql1` (c1 INT);
+CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
+SHOW TABLES;
+Tables_in_mysqltest
+ALTER TABLE `#sql1` RENAME `@0023sql1`;
+ALTER TABLE `@0023sql2` RENAME `#sql2`;
+SHOW TABLES;
+Tables_in_mysqltest
+INSERT INTO `#sql2` VALUES (1);
+INSERT INTO `@0023sql1` VALUES (2);
+SHOW CREATE TABLE `@0023sql1`;
+Table Create Table
+@0023sql1 CREATE TEMPORARY TABLE `@0023sql1` (
+ `c1` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE `#sql2`, `@0023sql1`;
+use test;
+DROP DATABASE mysqltest;
diff --git a/mysql-test/r/backup.result b/mysql-test/r/backup.result
index a65808bbdd6..05761240ca7 100644
--- a/mysql-test/r/backup.result
+++ b/mysql-test/r/backup.result
@@ -101,3 +101,23 @@ test.t5 backup status OK
Warnings:
Warning 1541 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
drop table t5;
+DROP TABLE IF EXISTS `t-blüten`;
+CREATE TABLE `t-blüten` (c1 INT);
+INSERT INTO `t-blüten` VALUES (1), (2), (3);
+BACKUP TABLE `t-blüten` TO '../tmp';
+Table Op Msg_type Msg_text
+test.t-blüten backup status OK
+Warnings:
+Warning 1541 The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
+DROP TABLE `t-blüten`;
+RESTORE TABLE `t-blüten` FROM '../tmp';
+Table Op Msg_type Msg_text
+test.t-blüten restore status OK
+Warnings:
+Warning 1541 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead.
+SELECT * FROM `t-blüten`;
+c1
+1
+2
+3
+DROP TABLE `t-blüten`;
diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result
index d8fa4dbbb72..f08dc6a8a4a 100644
--- a/mysql-test/r/repair.result
+++ b/mysql-test/r/repair.result
@@ -41,3 +41,9 @@ Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 1
test.t1 repair status OK
drop table t1;
+DROP TABLE IF EXISTS tt1;
+CREATE TEMPORARY TABLE tt1 (c1 INT);
+REPAIR TABLE tt1 USE_FRM;
+Table Op Msg_type Msg_text
+tt1 repair error Cannot repair temporary table from .frm file
+DROP TABLE tt1;