Commit 2b0c42f8 authored by Jon Olav Hauglid's avatar Jon Olav Hauglid

This patch backports test coverage for:

Bug #22909 Using CREATE ... LIKE is possible to create
           field with invalid default value
Bug #35935 CREATE TABLE under LOCK TABLES ignores FLUSH
           TABLES WITH READ LOCK
Bug #37371 CREATE TABLE LIKE merge loses UNION parameter

These bugs were originally fixed in the 6.1-fk tree and the fixes
were backported as part of the fix for Bug #42546 "Backup: RESTORE
fails, thinking it finds an existing table". This patch backports
test coverage missing in the original backport. The patch contains
no code changes.
parent 41d95c50
...@@ -99,6 +99,14 @@ create table t1 (`` int); ...@@ -99,6 +99,14 @@ create table t1 (`` int);
ERROR 42000: Incorrect column name '' ERROR 42000: Incorrect column name ''
create table t1 (i int, index `` (i)); create table t1 (i int, index `` (i));
ERROR 42000: Incorrect index name '' ERROR 42000: Incorrect index name ''
create table t1 (i int);
lock tables t1 read;
create table t2 (j int);
ERROR HY000: Table 't2' was not locked with LOCK TABLES
create temporary table t2 (j int);
drop temporary table t2;
unlock tables;
drop table t1;
create table t1 (a int auto_increment not null primary key, B CHAR(20)); create table t1 (a int auto_increment not null primary key, B CHAR(20));
insert into t1 (b) values ("hello"),("my"),("world"); insert into t1 (b) values ("hello"),("my"),("world");
create table t2 (key (b)) select * from t1; create table t2 (key (b)) select * from t1;
...@@ -377,6 +385,17 @@ ERROR 42S01: Table 't3' already exists ...@@ -377,6 +385,17 @@ ERROR 42S01: Table 't3' already exists
drop table t1, t2, t3; drop table t1, t2, t3;
drop table t3; drop table t3;
drop database mysqltest; drop database mysqltest;
create table t1 (i int);
create table t2 (j int);
lock tables t1 read;
create table t3 like t1;
ERROR HY000: Table 't3' was not locked with LOCK TABLES
create temporary table t3 like t1;
drop temporary table t3;
create temporary table t3 like t2;
ERROR HY000: Table 't2' was not locked with LOCK TABLES
unlock tables;
drop tables t1, t2;
SET SESSION storage_engine="heap"; SET SESSION storage_engine="heap";
SELECT @@storage_engine; SELECT @@storage_engine;
@@storage_engine @@storage_engine
...@@ -2033,3 +2052,39 @@ ID ...@@ -2033,3 +2052,39 @@ ID
3 3
DROP TABLE t1; DROP TABLE t1;
DROP TEMPORARY TABLE t2; DROP TEMPORARY TABLE t2;
#
# Bug #22909 "Using CREATE ... LIKE is possible to create field
# with invalid default value"
#
# Altough original bug report suggests to use older version of MySQL
# for producing .FRM with invalid defaults we use sql_mode to achieve
# the same effect.
drop tables if exists t1, t2;
# Attempt to create table with invalid default should fail in normal mode
create table t1 (dt datetime default '2008-02-31 00:00:00');
ERROR 42000: Invalid default value for 'dt'
set @old_mode= @@sql_mode;
set @@sql_mode='ALLOW_INVALID_DATES';
# The same should be possible in relaxed mode
create table t1 (dt datetime default '2008-02-31 00:00:00');
set @@sql_mode= @old_mode;
# In normal mode attempt to create copy of table with invalid
# default should fail
create table t2 like t1;
ERROR 42000: Invalid default value for 'dt'
set @@sql_mode='ALLOW_INVALID_DATES';
# But should work in relaxed mode
create table t2 like t1;
# Check that table definitions match
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`dt` datetime DEFAULT '2008-02-31 00:00:00'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`dt` datetime DEFAULT '2008-02-31 00:00:00'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
set @@sql_mode= @old_mode;
drop tables t1, t2;
...@@ -2699,4 +2699,23 @@ LOCK TABLE m1 WRITE; ...@@ -2699,4 +2699,23 @@ LOCK TABLE m1 WRITE;
ALTER TABLE m1 ADD INDEX (c1); ALTER TABLE m1 ADD INDEX (c1);
UNLOCK TABLES; UNLOCK TABLES;
DROP TABLE m1, t1; DROP TABLE m1, t1;
#
# Test for bug #37371 "CREATE TABLE LIKE merge loses UNION parameter"
#
drop tables if exists t1, m1, m2;
create table t1 (i int) engine=myisam;
create table m1 (i int) engine=mrg_myisam union=(t1) insert_method=first;
create table m2 like m1;
# Table definitions should match
show create table m1;
Table Create Table
m1 CREATE TABLE `m1` (
`i` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`)
show create table m2;
Table Create Table
m2 CREATE TABLE `m2` (
`i` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`)
drop tables m1, m2, t1;
End of 6.0 tests End of 6.0 tests
...@@ -101,6 +101,22 @@ create table t1 (`` int); ...@@ -101,6 +101,22 @@ create table t1 (`` int);
--error 1280 --error 1280
create table t1 (i int, index `` (i)); create table t1 (i int, index `` (i));
#
# CREATE TABLE under LOCK TABLES
#
# We don't allow creation of non-temporary tables under LOCK TABLES
# as following meta-data locking protocol in this case can lead to
# deadlock.
create table t1 (i int);
lock tables t1 read;
--error ER_TABLE_NOT_LOCKED
create table t2 (j int);
# OTOH creating of temporary table should be OK
create temporary table t2 (j int);
drop temporary table t2;
unlock tables;
drop table t1;
# #
# Test of CREATE ... SELECT with indexes # Test of CREATE ... SELECT with indexes
# #
...@@ -314,6 +330,26 @@ drop table t1, t2, t3; ...@@ -314,6 +330,26 @@ drop table t1, t2, t3;
drop table t3; drop table t3;
drop database mysqltest; drop database mysqltest;
#
# CREATE TABLE LIKE under LOCK TABLES
#
# Similarly to ordinary CREATE TABLE we don't allow creation of
# non-temporary tables under LOCK TABLES. Also we require source
# table to be locked.
create table t1 (i int);
create table t2 (j int);
lock tables t1 read;
--error ER_TABLE_NOT_LOCKED
create table t3 like t1;
# OTOH creating of temporary table should be OK
create temporary table t3 like t1;
drop temporary table t3;
# Source table should be locked
--error ER_TABLE_NOT_LOCKED
create temporary table t3 like t2;
unlock tables;
drop tables t1, t2;
# #
# Test default table type # Test default table type
# #
...@@ -1731,3 +1767,34 @@ DROP TABLE t1; ...@@ -1731,3 +1767,34 @@ DROP TABLE t1;
DROP TEMPORARY TABLE t2; DROP TEMPORARY TABLE t2;
--echo #
--echo # Bug #22909 "Using CREATE ... LIKE is possible to create field
--echo # with invalid default value"
--echo #
--echo # Altough original bug report suggests to use older version of MySQL
--echo # for producing .FRM with invalid defaults we use sql_mode to achieve
--echo # the same effect.
--disable_warnings
drop tables if exists t1, t2;
--enable_warnings
--echo # Attempt to create table with invalid default should fail in normal mode
--error ER_INVALID_DEFAULT
create table t1 (dt datetime default '2008-02-31 00:00:00');
set @old_mode= @@sql_mode;
set @@sql_mode='ALLOW_INVALID_DATES';
--echo # The same should be possible in relaxed mode
create table t1 (dt datetime default '2008-02-31 00:00:00');
set @@sql_mode= @old_mode;
--echo # In normal mode attempt to create copy of table with invalid
--echo # default should fail
--error ER_INVALID_DEFAULT
create table t2 like t1;
set @@sql_mode='ALLOW_INVALID_DATES';
--echo # But should work in relaxed mode
create table t2 like t1;
--echo # Check that table definitions match
show create table t1;
show create table t2;
set @@sql_mode= @old_mode;
drop tables t1, t2;
...@@ -2187,5 +2187,20 @@ UNLOCK TABLES; ...@@ -2187,5 +2187,20 @@ UNLOCK TABLES;
DROP TABLE m1, t1; DROP TABLE m1, t1;
--echo #
--echo # Test for bug #37371 "CREATE TABLE LIKE merge loses UNION parameter"
--echo #
--disable_warnings
drop tables if exists t1, m1, m2;
--enable_warnings
create table t1 (i int) engine=myisam;
create table m1 (i int) engine=mrg_myisam union=(t1) insert_method=first;
create table m2 like m1;
--echo # Table definitions should match
show create table m1;
show create table m2;
drop tables m1, m2, t1;
--echo End of 6.0 tests --echo End of 6.0 tests
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