summaryrefslogtreecommitdiff
path: root/mysql-test/r/create-big.result
diff options
context:
space:
mode:
authorunknown <dlenev@mockturtle.local>2007-05-23 15:26:16 +0400
committerunknown <dlenev@mockturtle.local>2007-05-23 15:26:16 +0400
commit206a6bb1764cef00452f0e8afb83480cc0ee65c1 (patch)
tree42739778f9a4bab9fc7e71504ec087dc4770be33 /mysql-test/r/create-big.result
parent3d01594f349a540068943b1ba7ddea2ec2e448ef (diff)
downloadmariadb-git-206a6bb1764cef00452f0e8afb83480cc0ee65c1.tar.gz
5.1 version of fix for:
Bug #23667 "CREATE TABLE LIKE is not isolated from alteration by other connections" Bug #18950 "CREATE TABLE LIKE does not obtain LOCK_open" As well as: Bug #25578 "CREATE TABLE LIKE does not require any privileges on source table". The first and the second bugs resulted in various errors and wrong binary log order when one tried to execute concurrently CREATE TABLE LIKE statement and DDL statements on source table or DML/DDL statements on its target table. The problem was caused by incomplete protection/table-locking against concurrent statements implemented in mysql_create_like_table() routine. We solve it by simply implementing such protection in proper way. Most of actual work for 5.1 was already done by fix for bug 20662 and preliminary patch changing locking in ALTER TABLE. The third bug allowed user who didn't have any privileges on table create its copy and therefore circumvent privilege check for SHOW CREATE TABLE. This patch solves this problem by adding privilege check, which was missing. Finally it also removes some duplicated code from mysql_create_like_table() and thus fixes bug #26869 "TABLE_LIST::table_name_length inconsistent with TABLE_LIST::table_name". mysql-test/r/create-big.result: Added test coverage for concurrency-related issues with CREATE TABLE LIKE. mysql-test/r/create.result: Adjusted error-code in the test case after refactoring code that implements CREATE TABLE ... LIKE. mysql-test/r/grant2.result: Added test for bug#25578 "CREATE TABLE LIKE does not require any privileges on source table". mysql-test/t/create-big.test: Added test coverage for concurrency-related issues with CREATE TABLE LIKE. mysql-test/t/create.test: Adjusted error-code in the test case after refactoring code that implements CREATE TABLE ... LIKE. mysql-test/t/disabled.def: Recent code changes ensured that CREATE TABLE LIKE statement is properly isolated against other statements, so synchronization.test should no longer fail (see fix for bug 20662 and preliminary patch for bug 23667 changing ALTER TABLE locking). mysql-test/t/grant2.test: Added test for bug#25578 "CREATE TABLE LIKE does not require any privileges on source table". sql/handler.h: Introduced new flag for HA_CREATE_INFO::options in order to be able to distinguish CREATE TABLE ... LIKE from other types of CREATE TABLE. sql/mysql_priv.h: mysql_create_like_table() now takes source table name not as a Table_ident object but as regular table list element. sql/sql_lex.h: Removed LEX::like_name member. Now we use special flag in LEX::create_info::options for distinguishing CREATE TABLE ... LIKE from other types of CREATE TABLE and store name of source table as regular element in statement's table list. sql/sql_parse.cc: CREATE TABLE ... LIKE implementation now uses statement's table list for storing information about the source table. We also use flag in LEX::create_info.options for distinguishing it from other types of CREATE TABLE. Finally CREATE TABLE ... LIKE now requires the same privileges on the source tables as SHOW CREATE TABLE. Moved this privilege check to check_show_create_table_access() function. sql/sql_partition.cc: Now we use special flag in LEX::create_info::options for distinguishing CREATE TABLE ... LIKE from other types of CREATE TABLE and store name of source table as regular element in statement's table list. sql/sql_table.cc: mysql_create_like_table(): - Commented and cleaned-up a bit code which is responsible for achieving isolation from concurrent statements. Most of actual work was done by fix for bug 20662 and preliminary patch changing locking locking in ALTER TABLE, so here we do minor things like relaxing locking on source table (we don't need lock on it, to have it open is enough) and adjusting code to make it more friendly against code implementing I_S. - Get rid of duplicated code related to source database/table name handling. All these operations are already done in st_select_lex::add_table_to_list(), so we achieve the same effect by including source table into the statement's table list. sql/sql_yacc.yy: Now we use special flag in LEX::create_info::options for distinguishing CREATE TABLE ... LIKE from other types of CREATE TABLE and store name of source table as regular element in statement's table list.
Diffstat (limited to 'mysql-test/r/create-big.result')
-rw-r--r--mysql-test/r/create-big.result247
1 files changed, 247 insertions, 0 deletions
diff --git a/mysql-test/r/create-big.result b/mysql-test/r/create-big.result
new file mode 100644
index 00000000000..eb57bf59084
--- /dev/null
+++ b/mysql-test/r/create-big.result
@@ -0,0 +1,247 @@
+drop table if exists t1,t2,t3,t4,t5;
+set session debug="+d,sleep_create_select_before_create";
+create table t1 select 1 as i;;
+create table t1 (j char(5));
+ERROR 42S01: Table 't1' already exists
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(1) NOT NULL DEFAULT '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 select 1 as i;;
+create table t1 select "Test" as j;
+ERROR 42S01: Table 't1' already exists
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(1) NOT NULL DEFAULT '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t3 (j char(5));
+create table t1 select 1 as i;;
+create table t1 like t3;
+ERROR 42S01: Table 't1' already exists
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(1) NOT NULL DEFAULT '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 select 1 as i;;
+rename table t3 to t1;
+ERROR 42S01: Table 't1' already exists
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(1) NOT NULL DEFAULT '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 select 1 as i;;
+alter table t3 rename to t1;
+ERROR 42S01: Table 't1' already exists
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(1) NOT NULL DEFAULT '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 select 1 as i;;
+alter table t3 rename to t1, add k int;
+ERROR 42S01: Table 't1' already exists
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(1) NOT NULL DEFAULT '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t3;
+set session debug="-d,sleep_create_select_before_create:+d,sleep_create_select_before_open";
+create table t1 select 1 as i;;
+drop table t1;
+create table t1 select 1 as i;;
+rename table t1 to t2;
+drop table t2;
+create table t1 select 1 as i;;
+select * from t1;
+i
+1
+drop table t1;
+create table t1 select 1 as i;;
+insert into t1 values (2);
+select * from t1;
+i
+1
+2
+drop table t1;
+set @a:=0;
+create table t1 select 1 as i;;
+create trigger t1_bi before insert on t1 for each row set @a:=1;
+select @a;
+@a
+0
+drop table t1;
+set session debug="-d,sleep_create_select_before_open:+d,sleep_create_select_before_lock";
+create table t1 select 1 as i;;
+drop table t1;
+create table t1 select 1 as i;;
+rename table t1 to t2;
+drop table t2;
+create table t1 select 1 as i;;
+select * from t1;
+i
+1
+drop table t1;
+create table t1 select 1 as i;;
+insert into t1 values (2);
+select * from t1;
+i
+1
+2
+drop table t1;
+set @a:=0;
+create table t1 select 1 as i;;
+create trigger t1_bi before insert on t1 for each row set @a:=1;
+select @a;
+@a
+0
+drop table t1;
+set session debug="-d,sleep_create_select_before_lock:+d,sleep_create_select_before_check_if_exists";
+create table t1 (i int);
+create table if not exists t1 select 1 as i;;
+drop table t1;
+Warnings:
+Note 1050 Table 't1' already exists
+create table t1 (i int);
+set @a:=0;
+create table if not exists t1 select 1 as i;;
+create trigger t1_bi before insert on t1 for each row set @a:=1;
+Warnings:
+Note 1050 Table 't1' already exists
+select @a;
+@a
+0
+select * from t1;
+i
+1
+drop table t1;
+set session debug="-d,sleep_create_select_before_check_if_exists";
+create table t2 (a int);
+create table t4 (b int);
+lock table t4 write;
+select 1;
+1
+1
+create table t3 as select * from t4;;
+create table t1 select * from t2, t3;;
+unlock tables;
+select * from t1;
+a b
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t3;
+lock table t4 read;
+select 1;
+1
+1
+rename table t4 to t3;;
+create table if not exists t1 select 1 as i from t2, t3;;
+create table t5 (j int);
+rename table t5 to t1;
+unlock tables;
+Warnings:
+Note 1050 Table 't1' already exists
+select * from t1;
+j
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `j` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2, t3;
+drop table if exists t1,t2;
+create table t1 (i int);
+set session debug="+d,sleep_create_like_before_check_if_exists";
+reset master;
+create table t2 like t1;;
+insert into t1 values (1);
+drop table t1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t2;
+show binlog events in 'master-bin.000001' from 106;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query 1 # use `test`; insert into t1 values (1)
+master-bin.000001 # Query 1 # use `test`; create table t2 like t1
+master-bin.000001 # Query 1 # use `test`; drop table t1
+master-bin.000001 # Query 1 # use `test`; drop table t2
+create table t1 (i int);
+set session debug="-d,sleep_create_like_before_check_if_exists:+d,sleep_create_like_before_copy";
+create table t2 like t1;;
+create table if not exists t2 (j int);
+Warnings:
+Note 1050 Table 't2' already exists
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t2;
+reset master;
+create table t2 like t1;;
+drop table t1;
+drop table t2;
+show binlog events in 'master-bin.000001' from 106;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query 1 # use `test`; create table t2 like t1
+master-bin.000001 # Query 1 # use `test`; drop table t1
+master-bin.000001 # Query 1 # use `test`; drop table t2
+create table t1 (i int);
+set session debug="-d,sleep_create_like_before_copy:+d,sleep_create_like_before_ha_create";
+reset master;
+create table t2 like t1;;
+insert into t2 values (1);
+drop table t2;
+create table t2 like t1;;
+drop table t2;
+create table t2 like t1;;
+drop table t1;
+drop table t2;
+show binlog events in 'master-bin.000001' from 106;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query 1 # use `test`; create table t2 like t1
+master-bin.000001 # Query 1 # use `test`; insert into t2 values (1)
+master-bin.000001 # Query 1 # use `test`; drop table t2
+master-bin.000001 # Query 1 # use `test`; create table t2 like t1
+master-bin.000001 # Query 1 # use `test`; drop table t2
+master-bin.000001 # Query 1 # use `test`; create table t2 like t1
+master-bin.000001 # Query 1 # use `test`; drop table t1
+master-bin.000001 # Query 1 # use `test`; drop table t2
+create table t1 (i int);
+set session debug="-d,sleep_create_like_before_ha_create:+d,sleep_create_like_before_binlogging";
+reset master;
+create table t2 like t1;;
+insert into t2 values (1);
+drop table t2;
+create table t2 like t1;;
+drop table t2;
+create table t2 like t1;;
+drop table t1;
+drop table t2;
+show binlog events in 'master-bin.000001' from 106;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query 1 # use `test`; create table t2 like t1
+master-bin.000001 # Query 1 # use `test`; insert into t2 values (1)
+master-bin.000001 # Query 1 # use `test`; drop table t2
+master-bin.000001 # Query 1 # use `test`; create table t2 like t1
+master-bin.000001 # Query 1 # use `test`; drop table t2
+master-bin.000001 # Query 1 # use `test`; create table t2 like t1
+master-bin.000001 # Query 1 # use `test`; drop table t1
+master-bin.000001 # Query 1 # use `test`; drop table t2
+set session debug="-d,sleep_create_like_before_binlogging";