diff options
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/extra/binlog_tests/insert_select-binlog.test | 4 | ||||
-rwxr-xr-x | mysql-test/mysql-test-run.pl | 3 | ||||
-rw-r--r-- | mysql-test/mysql-test-run.sh | 1 | ||||
-rw-r--r-- | mysql-test/r/binlog_stm_insert_select.result | 1 | ||||
-rw-r--r-- | mysql-test/r/index_merge.result | 22 | ||||
-rw-r--r-- | mysql-test/r/merge.result | 2 | ||||
-rw-r--r-- | mysql-test/r/ndb_partition_error.result | 8 | ||||
-rw-r--r-- | mysql-test/r/ndb_partition_range.result | 104 | ||||
-rw-r--r-- | mysql-test/r/ps.result | 14 | ||||
-rw-r--r-- | mysql-test/r/trigger.result | 103 | ||||
-rw-r--r-- | mysql-test/r/view.result | 10 | ||||
-rw-r--r-- | mysql-test/t/index_merge.test | 26 | ||||
-rw-r--r-- | mysql-test/t/ndb_partition_error.test | 12 | ||||
-rw-r--r-- | mysql-test/t/ndb_partition_range.test | 130 | ||||
-rw-r--r-- | mysql-test/t/ps.test | 21 | ||||
-rw-r--r-- | mysql-test/t/trigger.test | 88 | ||||
-rw-r--r-- | mysql-test/t/view.test | 15 |
17 files changed, 560 insertions, 4 deletions
diff --git a/mysql-test/extra/binlog_tests/insert_select-binlog.test b/mysql-test/extra/binlog_tests/insert_select-binlog.test index d4041f86ab5..a665dfda2b0 100644 --- a/mysql-test/extra/binlog_tests/insert_select-binlog.test +++ b/mysql-test/extra/binlog_tests/insert_select-binlog.test @@ -1,6 +1,10 @@ # Embedded server doesn't support binlog -- source include/not_embedded.inc +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + # Check if a partly-completed INSERT SELECT in a MyISAM table goes into the # binlog diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 10645fdf12e..62ce4da253e 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1156,6 +1156,7 @@ sub environment_setup () { $ENV{'USE_RUNNING_SERVER'}= $glob_use_running_server; $ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir; $ENV{'MYSQLTEST_VARDIR'}= $opt_vardir; + $ENV{'MYSQL_TMP_DIR'}= $opt_tmpdir; $ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_mysock'}; $ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_mysock'}; $ENV{'MASTER_MYPORT'}= $master->[0]->{'path_myport'}; @@ -2876,7 +2877,7 @@ sub run_mysqltest ($) { if ( $opt_debug ) { $cmdline_mysqlcheck .= - " --debug=d:t:A,$opt_vardir_trace/log/mysqldump.trace"; + " --debug=d:t:A,$opt_vardir_trace/log/mysqlcheck.trace"; } my $cmdline_mysqldump= "$exe_mysqldump --no-defaults -uroot " . diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index ce62964a3c0..7869a9f6f3a 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -202,6 +202,7 @@ SYST=0 REALT=0 FAST_START="" MYSQL_TMP_DIR=$MYSQL_TEST_DIR/var/tmp +export MYSQL_TMP_DIR # Use a relative path for where the slave will find the dumps # generated by "LOAD DATA" on the master. The path is relative diff --git a/mysql-test/r/binlog_stm_insert_select.result b/mysql-test/r/binlog_stm_insert_select.result index 35e328a769c..646a76b254d 100644 --- a/mysql-test/r/binlog_stm_insert_select.result +++ b/mysql-test/r/binlog_stm_insert_select.result @@ -1,3 +1,4 @@ +drop table if exists t1,t2; create table t1(a int, unique(a)); insert into t1 values(2); create table t2(a int); diff --git a/mysql-test/r/index_merge.result b/mysql-test/r/index_merge.result index db87253e19a..3a69f56cbd3 100644 --- a/mysql-test/r/index_merge.result +++ b/mysql-test/r/index_merge.result @@ -402,3 +402,25 @@ explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'b id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge cola,colb cola,colb 3,3 NULL 24 Using intersect(cola,colb); Using where drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 ( +a int, b int, +filler1 char(200), filler2 char(200), +key(a),key(b) +); +insert into t1 select @v:= A.a, @v, 't1', 'filler2' from t0 A, t0 B, t0 C; +create table t2 like t1; +create table t3 ( +a int, b int, +filler1 char(200), filler2 char(200), +key(a),key(b) +) engine=merge union=(t1,t2); +explain select * from t1 where a=1 and b=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL # Using intersect(a,b); Using where +explain select * from t3 where a=1 and b=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 index_merge a,b a,b 5,5 NULL # Using intersect(a,b); Using where +drop table t3; +drop table t0, t1, t2; diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index c700de5ccc6..caab508ad96 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -56,8 +56,8 @@ a b 4 Testing 5 table 5 table -6 t1 6 t2 +6 t1 7 Testing 7 Testing 8 table diff --git a/mysql-test/r/ndb_partition_error.result b/mysql-test/r/ndb_partition_error.result index 3fd111a7c0f..66f623dee13 100644 --- a/mysql-test/r/ndb_partition_error.result +++ b/mysql-test/r/ndb_partition_error.result @@ -28,3 +28,11 @@ partitions 3 partition x2 values less than (10), partition x3 values less than (20)); drop table t1; +CREATE TABLE t1 (id INT) ENGINE=NDB +PARTITION BY LIST(id) +(PARTITION p0 VALUES IN (2, 4), +PARTITION p1 VALUES IN (42, 142)); +INSERT INTO t1 VALUES (2); +UPDATE t1 SET id=5 WHERE id=2; +ERROR HY000: Table has no partition for value 5 +DROP TABLE t1; diff --git a/mysql-test/r/ndb_partition_range.result b/mysql-test/r/ndb_partition_range.result index 2b9c55c3929..e078f38c166 100644 --- a/mysql-test/r/ndb_partition_range.result +++ b/mysql-test/r/ndb_partition_range.result @@ -117,3 +117,107 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `a` (`a`) ) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (b) (PARTITION x1 VALUES LESS THAN (5) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (10) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (20) ENGINE = ndbcluster) drop table t1; +CREATE TABLE t1 +(id MEDIUMINT NOT NULL, +b1 BIT(8), +vc VARCHAR(255), +bc CHAR(255), +d DECIMAL(10,4) DEFAULT 0, +f FLOAT DEFAULT 0, +total BIGINT UNSIGNED, +y YEAR, +t DATE) ENGINE=NDB +PARTITION BY RANGE (YEAR(t)) +(PARTITION p0 VALUES LESS THAN (1901), +PARTITION p1 VALUES LESS THAN (1946), +PARTITION p2 VALUES LESS THAN (1966), +PARTITION p3 VALUES LESS THAN (1986), +PARTITION p4 VALUES LESS THAN (2005), +PARTITION p5 VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +SELECT * FROM t1; +id b1 vc bc d f total y t +0 NULL NULL NULL NULL NULL NULL NULL NULL +ALTER TABLE t1 ENGINE=MYISAM; +SELECT * FROM t1; +id b1 vc bc d f total y t +0 NULL NULL NULL NULL NULL NULL NULL NULL +DROP TABLE t1; +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' + INITIAL_SIZE 16M +UNDO_BUFFER_SIZE=1M +ENGINE=NDB; +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' + USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; +CREATE TABLE test.t1 ( +a1 INT, +a2 TEXT NOT NULL, +a3 BIT NOT NULL, +a4 DECIMAL(8,3), +a5 INT NOT NULL, +a6 VARCHAR(255), +PRIMARY KEY(a1)) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB +PARTITION BY LIST (a1) +(PARTITION p0 VALUES IN (1,2,3,4,5), +PARTITION p1 VALUES IN (6,7,8,9, 10), +PARTITION p2 VALUES IN (11, 12, 13, 14, 15)); +SELECT COUNT(*) FROM test.t1; +COUNT(*) +15 +ALTER TABLE test.t1 DROP COLUMN a4; +SELECT COUNT(*) FROM test.t1; +COUNT(*) +15 +DROP TABLE t1; +CREATE TABLE test.t1 ( +a1 INT, +a2 TEXT NOT NULL, +a3 BIT NOT NULL, +a4 DECIMAL(8,3), +a5 INT NOT NULL, +a6 VARCHAR(255), +PRIMARY KEY(a1)) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB +PARTITION BY HASH(a1) +PARTITIONS 4; +SELECT COUNT(*) FROM test.t1; +COUNT(*) +15 +ALTER TABLE test.t1 DROP COLUMN a4; +SELECT COUNT(*) FROM test.t1; +COUNT(*) +15 +DROP TABLE t1; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE=NDB; +DROP TABLESPACE ts1 ENGINE=NDB; +DROP LOGFILE GROUP lg1 ENGINE=NDB; +CREATE TABLE t1 +(id MEDIUMINT NOT NULL, +b1 BIT(8), +vc VARCHAR(255), +bc CHAR(255), +d DECIMAL(10,4) DEFAULT 0, +f FLOAT DEFAULT 0, +total BIGINT UNSIGNED, +y YEAR, +t DATE) ENGINE=NDB +PARTITION BY LIST(id) +(PARTITION p0 VALUES IN (2, 4), +PARTITION p1 VALUES IN (42, 142)); +INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +SELECT * FROM t1; +id b1 vc bc d f total y t +2 NULL NULL NULL NULL NULL NULL NULL NULL +ALTER TABLE t1 ADD PARTITION +(PARTITION p2 VALUES IN (412)); +SELECT * FROM t1; +id b1 vc bc d f total y t +2 NULL NULL NULL NULL NULL NULL NULL NULL +DROP TABLE t1; diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 5c0a13fe640..e24cee9e875 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -859,6 +859,20 @@ count(*) 5 deallocate prepare stmt; drop table t1; +prepare stmt from 'create table t1 (a varchar(10) character set utf8)'; +execute stmt; +insert into t1 (a) values (repeat('a', 20)); +select length(a) from t1; +length(a) +10 +drop table t1; +execute stmt; +insert into t1 (a) values (repeat('a', 20)); +select length(a) from t1; +length(a) +10 +drop table t1; +deallocate prepare stmt; create table t1 (id int); prepare ins_call from "insert into t1 (id) values (1)"; execute ins_call; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 62c0d01327d..320f4e5c3d9 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1,4 +1,4 @@ -drop table if exists t1, t2, t3; +drop table if exists t1, t2, t3, t4; drop view if exists v1; drop database if exists mysqltest; drop function if exists f1; @@ -785,6 +785,107 @@ create trigger test.t1_bi before insert on t1 for each row set @a:=0; ERROR 3D000: No database selected drop trigger t1_bi; ERROR 3D000: No database selected +create table t1 (id int); +create trigger t1_bi before insert on t1 for each row set @a:=new.id; +insert into t1 values (101); +select @a; +@a +101 +select trigger_schema, trigger_name, event_object_schema, +event_object_table, action_statement from information_schema.triggers +where event_object_schema = 'test'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +test t1_bi test t1 set @a:=new.id +rename table t1 to t2; +insert into t2 values (102); +select @a; +@a +102 +select trigger_schema, trigger_name, event_object_schema, +event_object_table, action_statement from information_schema.triggers +where event_object_schema = 'test'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +test t1_bi test t2 set @a:=new.id +alter table t2 rename to t3; +insert into t3 values (103); +select @a; +@a +103 +select trigger_schema, trigger_name, event_object_schema, +event_object_table, action_statement from information_schema.triggers +where event_object_schema = 'test'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +test t1_bi test t3 set @a:=new.id +alter table t3 rename to t4, add column val int default 0; +insert into t4 values (104, 1); +select @a; +@a +104 +select trigger_schema, trigger_name, event_object_schema, +event_object_table, action_statement from information_schema.triggers +where event_object_schema = 'test'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +test t1_bi test t4 set @a:=new.id +drop trigger t1_bi; +drop table t4; +create database mysqltest; +use mysqltest; +create table t1 (id int); +create trigger t1_bi before insert on t1 for each row set @a:=new.id; +insert into t1 values (101); +select @a; +@a +101 +select trigger_schema, trigger_name, event_object_schema, +event_object_table, action_statement from information_schema.triggers +where event_object_schema = 'test' or event_object_schema = 'mysqltest'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +mysqltest t1_bi mysqltest t1 set @a:=new.id +rename table t1 to test.t2; +ERROR HY000: Trigger in wrong schema +insert into t1 values (102); +select @a; +@a +102 +select trigger_schema, trigger_name, event_object_schema, +event_object_table, action_statement from information_schema.triggers +where event_object_schema = 'test' or event_object_schema = 'mysqltest'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +mysqltest t1_bi mysqltest t1 set @a:=new.id +drop trigger test.t1_bi; +ERROR HY000: Trigger does not exist +drop trigger t1_bi; +drop table t1; +drop database mysqltest; +use test; +create table t1 (id int); +create trigger t1_bi before insert on t1 for each row set @a:=new.id; +create trigger t1_ai after insert on t1 for each row set @b:=new.id; +insert into t1 values (101); +select @a, @b; +@a @b +101 101 +select trigger_schema, trigger_name, event_object_schema, +event_object_table, action_statement from information_schema.triggers +where event_object_schema = 'test'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +test t1_bi test t1 set @a:=new.id +test t1_ai test t1 set @b:=new.id +rename table t1 to t2; +ERROR HY000: Can't create/write to file './test/t1_ai.TRN~' (Errcode: 13) +insert into t1 values (102); +select @a, @b; +@a @b +102 102 +select trigger_schema, trigger_name, event_object_schema, +event_object_table, action_statement from information_schema.triggers +where event_object_schema = 'test'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +test t1_bi test t1 set @a:=new.id +test t1_ai test t1 set @b:=new.id +drop trigger t1_bi; +drop trigger t1_ai; +drop table t1; create table t1 (i int); create trigger t1_bi before insert on t1 for each row return 0; ERROR 42000: RETURN is only allowed in a FUNCTION diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 5396db82965..e3d683a58dc 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2529,3 +2529,13 @@ Warnings: Warning 1052 Column 'x' in group statement is ambiguous DROP VIEW v1; DROP TABLE t1; +drop table if exists t1; +drop view if exists v1; +create table t1 (id int); +create view v1 as select * from t1; +drop table t1; +show create view v1; +drop view v1; +// +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache `test`.`t1`.`id` AS `id` from `t1` diff --git a/mysql-test/t/index_merge.test b/mysql-test/t/index_merge.test index 10512902409..3da5711bf7a 100644 --- a/mysql-test/t/index_merge.test +++ b/mysql-test/t/index_merge.test @@ -357,3 +357,29 @@ explain select * from t1 WHERE cola = 'foo' AND colb = 'bar'; explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'bar'; drop table t1; +# +# BUG#17314: Index_merge/intersection not choosen by the optimizer for MERGE tables +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 ( + a int, b int, + filler1 char(200), filler2 char(200), + key(a),key(b) +); +insert into t1 select @v:= A.a, @v, 't1', 'filler2' from t0 A, t0 B, t0 C; +create table t2 like t1; + +create table t3 ( + a int, b int, + filler1 char(200), filler2 char(200), + key(a),key(b) +) engine=merge union=(t1,t2); + +--replace_column 9 # +explain select * from t1 where a=1 and b=1; +--replace_column 9 # +explain select * from t3 where a=1 and b=1; + +drop table t3; +drop table t0, t1, t2; diff --git a/mysql-test/t/ndb_partition_error.test b/mysql-test/t/ndb_partition_error.test index cf570cc0234..c84266b66f7 100644 --- a/mysql-test/t/ndb_partition_error.test +++ b/mysql-test/t/ndb_partition_error.test @@ -44,3 +44,15 @@ partitions 3 partition x3 values less than (20)); drop table t1; + +# +# Bug #17763 mysqld cores with list partitioning if update to missing partition +# +CREATE TABLE t1 (id INT) ENGINE=NDB + PARTITION BY LIST(id) + (PARTITION p0 VALUES IN (2, 4), + PARTITION p1 VALUES IN (42, 142)); +INSERT INTO t1 VALUES (2); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +UPDATE t1 SET id=5 WHERE id=2; +DROP TABLE t1; diff --git a/mysql-test/t/ndb_partition_range.test b/mysql-test/t/ndb_partition_range.test index 2eb324ccdcb..66235b0e9eb 100644 --- a/mysql-test/t/ndb_partition_range.test +++ b/mysql-test/t/ndb_partition_range.test @@ -93,3 +93,133 @@ show create table t1; drop table t1; +# +# Bug #17499, #17687 +# Alter partitioned NDB table causes mysqld to core +# + +CREATE TABLE t1 + (id MEDIUMINT NOT NULL, + b1 BIT(8), + vc VARCHAR(255), + bc CHAR(255), + d DECIMAL(10,4) DEFAULT 0, + f FLOAT DEFAULT 0, + total BIGINT UNSIGNED, + y YEAR, + t DATE) ENGINE=NDB + PARTITION BY RANGE (YEAR(t)) + (PARTITION p0 VALUES LESS THAN (1901), + PARTITION p1 VALUES LESS THAN (1946), + PARTITION p2 VALUES LESS THAN (1966), + PARTITION p3 VALUES LESS THAN (1986), + PARTITION p4 VALUES LESS THAN (2005), + PARTITION p5 VALUES LESS THAN MAXVALUE); + +INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +SELECT * FROM t1; +ALTER TABLE t1 ENGINE=MYISAM; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE LOGFILE GROUP lg1 + ADD UNDOFILE 'undofile.dat' + INITIAL_SIZE 16M + UNDO_BUFFER_SIZE=1M + ENGINE=NDB; + +CREATE TABLESPACE ts1 + ADD DATAFILE 'datafile.dat' + USE LOGFILE GROUP lg1 + INITIAL_SIZE 12M + ENGINE NDB; + +CREATE TABLE test.t1 ( + a1 INT, + a2 TEXT NOT NULL, + a3 BIT NOT NULL, + a4 DECIMAL(8,3), + a5 INT NOT NULL, + a6 VARCHAR(255), + PRIMARY KEY(a1)) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB + PARTITION BY LIST (a1) + (PARTITION p0 VALUES IN (1,2,3,4,5), + PARTITION p1 VALUES IN (6,7,8,9, 10), + PARTITION p2 VALUES IN (11, 12, 13, 14, 15)); + +let $j= 15; +--disable_query_log +while ($j) +{ +eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA", +b'1',$j.00,$j+1,"By NIK $j"); +dec $j; +} +--enable_query_log +SELECT COUNT(*) FROM test.t1; + +ALTER TABLE test.t1 DROP COLUMN a4; +SELECT COUNT(*) FROM test.t1; + +DROP TABLE t1; + +CREATE TABLE test.t1 ( + a1 INT, + a2 TEXT NOT NULL, + a3 BIT NOT NULL, + a4 DECIMAL(8,3), + a5 INT NOT NULL, + a6 VARCHAR(255), + PRIMARY KEY(a1)) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB + PARTITION BY HASH(a1) + PARTITIONS 4; + +let $j= 15; +--disable_query_log +while ($j) +{ +eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA", +b'1',$j.00,$j+1,"By NIK $j"); +dec $j; +} +--enable_query_log +SELECT COUNT(*) FROM test.t1; + +ALTER TABLE test.t1 DROP COLUMN a4; +SELECT COUNT(*) FROM test.t1; + +DROP TABLE t1; + +ALTER TABLESPACE ts1 + DROP DATAFILE 'datafile.dat' + ENGINE=NDB; +DROP TABLESPACE ts1 ENGINE=NDB; +DROP LOGFILE GROUP lg1 ENGINE=NDB; + + +# +# Bug #17701 ALTER TABLE t1 ADD PARTITION for PARTITION BY LIST hangs test +# + +CREATE TABLE t1 + (id MEDIUMINT NOT NULL, + b1 BIT(8), + vc VARCHAR(255), + bc CHAR(255), + d DECIMAL(10,4) DEFAULT 0, + f FLOAT DEFAULT 0, + total BIGINT UNSIGNED, + y YEAR, + t DATE) ENGINE=NDB + PARTITION BY LIST(id) + (PARTITION p0 VALUES IN (2, 4), + PARTITION p1 VALUES IN (42, 142)); + +INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +SELECT * FROM t1; +ALTER TABLE t1 ADD PARTITION + (PARTITION p2 VALUES IN (412)); +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 48a9f4c19f3..ffbba991fb6 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -900,6 +900,27 @@ execute stmt using @like; deallocate prepare stmt; drop table t1; +# +# Bug#13134 "Length of VARCHAR() utf8 column is increasing when table is +# recreated with PS/SP" +# + +prepare stmt from 'create table t1 (a varchar(10) character set utf8)'; +execute stmt; +--disable_warnings +insert into t1 (a) values (repeat('a', 20)); +--enable_warnings +select length(a) from t1; +drop table t1; +execute stmt; +--disable_warnings +insert into t1 (a) values (repeat('a', 20)); +--enable_warnings +# Check that the data is truncated to the same length +select length(a) from t1; +drop table t1; +deallocate prepare stmt; + # End of 4.1 tests # diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index c3cc8e3f8e8..0ac57394c2f 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -3,7 +3,7 @@ # --disable_warnings -drop table if exists t1, t2, t3; +drop table if exists t1, t2, t3, t4; drop view if exists v1; drop database if exists mysqltest; drop function if exists f1; @@ -959,6 +959,92 @@ create trigger test.t1_bi before insert on t1 for each row set @a:=0; drop trigger t1_bi; connection default; +# +# Test for bug #13525 "Rename table does not keep info of triggers" +# +create table t1 (id int); +create trigger t1_bi before insert on t1 for each row set @a:=new.id; +insert into t1 values (101); +select @a; +select trigger_schema, trigger_name, event_object_schema, + event_object_table, action_statement from information_schema.triggers + where event_object_schema = 'test'; +rename table t1 to t2; +# Trigger should work after rename +insert into t2 values (102); +select @a; +select trigger_schema, trigger_name, event_object_schema, + event_object_table, action_statement from information_schema.triggers + where event_object_schema = 'test'; +# Let us check that the same works for simple ALTER TABLE ... RENAME +alter table t2 rename to t3; +insert into t3 values (103); +select @a; +select trigger_schema, trigger_name, event_object_schema, + event_object_table, action_statement from information_schema.triggers + where event_object_schema = 'test'; +# And for more complex ALTER TABLE +alter table t3 rename to t4, add column val int default 0; +insert into t4 values (104, 1); +select @a; +select trigger_schema, trigger_name, event_object_schema, + event_object_table, action_statement from information_schema.triggers + where event_object_schema = 'test'; +# .TRN file should be updated with new table name +drop trigger t1_bi; +drop table t4; +# Rename between different databases if triggers exist should fail +create database mysqltest; +use mysqltest; +create table t1 (id int); +create trigger t1_bi before insert on t1 for each row set @a:=new.id; +insert into t1 values (101); +select @a; +select trigger_schema, trigger_name, event_object_schema, + event_object_table, action_statement from information_schema.triggers + where event_object_schema = 'test' or event_object_schema = 'mysqltest'; +--error ER_TRG_IN_WRONG_SCHEMA +rename table t1 to test.t2; +insert into t1 values (102); +select @a; +select trigger_schema, trigger_name, event_object_schema, + event_object_table, action_statement from information_schema.triggers + where event_object_schema = 'test' or event_object_schema = 'mysqltest'; +# There should be no fantom .TRN files +--error ER_TRG_DOES_NOT_EXIST +drop trigger test.t1_bi; +drop trigger t1_bi; +drop table t1; +drop database mysqltest; +use test; +# And now let us check that the properly handle rename if there is some +# error during it (that we rollback such renames completely). +create table t1 (id int); +create trigger t1_bi before insert on t1 for each row set @a:=new.id; +create trigger t1_ai after insert on t1 for each row set @b:=new.id; +insert into t1 values (101); +select @a, @b; +select trigger_schema, trigger_name, event_object_schema, + event_object_table, action_statement from information_schema.triggers + where event_object_schema = 'test'; +# Trick which makes update of second .TRN file impossible +system echo dummy >$MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; +system chmod 000 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; +--error 1 +rename table t1 to t2; +# 't1' should be still there and triggers should work correctly +insert into t1 values (102); +select @a, @b; +select trigger_schema, trigger_name, event_object_schema, + event_object_table, action_statement from information_schema.triggers + where event_object_schema = 'test'; +system chmod 600 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; +system rm $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; +# Let us check that updates to .TRN files were rolled back too +drop trigger t1_bi; +drop trigger t1_ai; +drop table t1; + # Test for bug #16829 "Firing trigger with RETURN crashes the server" # RETURN is not supposed to be used anywhere except functions, so error # should be returned when one attempts to create trigger with RETURN. diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 5d1b5a80a9b..294a254390f 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2375,3 +2375,18 @@ SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1 GROUP BY x; DROP VIEW v1; DROP TABLE t1; + +# +# BUG#15943: mysql_next_result hangs on invalid SHOW CREATE VIEW +# + +delimiter //; +drop table if exists t1; +drop view if exists v1; +create table t1 (id int); +create view v1 as select * from t1; +drop table t1; +show create view v1; +drop view v1; +// +delimiter ;// |