diff options
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/binlog_delete_and_flush_index.result | 50 | ||||
-rw-r--r-- | mysql-test/r/count_distinct.result | 20 | ||||
-rw-r--r-- | mysql-test/r/user_var.result | 15 | ||||
-rw-r--r-- | mysql-test/t/binlog_delete_and_flush_index.test | 119 | ||||
-rw-r--r-- | mysql-test/t/count_distinct.test | 19 | ||||
-rw-r--r-- | mysql-test/t/user_var.test | 20 |
6 files changed, 243 insertions, 0 deletions
diff --git a/mysql-test/r/binlog_delete_and_flush_index.result b/mysql-test/r/binlog_delete_and_flush_index.result new file mode 100644 index 00000000000..7500c17759c --- /dev/null +++ b/mysql-test/r/binlog_delete_and_flush_index.result @@ -0,0 +1,50 @@ +RESET MASTER; +CREATE TABLE t1 (a int); +### assertion: index file contains regular entries +SET @index=LOAD_FILE('MYSQLD_DATADIR/master-bin.index'); +SELECT @index; +@index +MYSQLD_DATADIR/master-bin.000001 + +### assertion: show original binlogs +show binary logs; +Log_name File_size +master-bin.000001 # +### assertion: binlog contents from regular entries +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) +FLUSH LOGS; +### assertion: index file contains renamed binlog and the new one +SET @index=LOAD_FILE('MYSQLD_DATADIR/master-bin.index'); +SELECT @index; +@index +MYSQLD_DATADIR/master-bin-b34582.000001 +MYSQLD_DATADIR/master-bin.000002 + +### assertion: original binlog content still exists, despite we +### renamed and changed the index file +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin-b34582.000001 # Query # # use `test`; CREATE TABLE t1 (a int) +### assertion: user changed binlog index shows correct entries +show binary logs; +Log_name File_size +master-bin-b34582.000001 # +master-bin.000002 # +DROP TABLE t1; +### assertion: purging binlogs up to binlog created after instrumenting index file should work +PURGE BINARY LOGS TO 'master-bin.000002'; +### assertion: show binary logs should only contain latest binlog +show binary logs; +Log_name File_size +master-bin.000002 # +### assertion: assert that binlog files were indeed purged (using file_exists calls) +### assertion: assert that not purged binlog file exists +### assertion: show index file contents and these should match show binary logs issued above +SET @index=LOAD_FILE('MYSQLD_DATADIR/master-bin.index'); +SELECT @index; +@index +MYSQLD_DATADIR/master-bin.000002 + +RESET MASTER; diff --git a/mysql-test/r/count_distinct.result b/mysql-test/r/count_distinct.result index a21748359b9..804bc1f4788 100644 --- a/mysql-test/r/count_distinct.result +++ b/mysql-test/r/count_distinct.result @@ -40,6 +40,26 @@ select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join isbn city libname a 007 Berkeley Berkeley Public1 2 000 New York New York Public Libra 2 +select t2.isbn,city,@bar:=t1.libname,count(distinct t1.libname) as a +from t3 left join t1 on t3.libname=t1.libname left join t2 +on t3.isbn=t2.isbn group by city having count(distinct +t1.libname) > 1; +isbn city @bar:=t1.libname a +007 Berkeley Berkeley Public1 2 +000 New York New York Public Libra 2 +SELECT @bar; +@bar +Berkeley Public2 +select t2.isbn,city,concat(@bar:=t1.libname),count(distinct t1.libname) as a +from t3 left join t1 on t3.libname=t1.libname left join t2 +on t3.isbn=t2.isbn group by city having count(distinct +t1.libname) > 1; +isbn city concat(@bar:=t1.libname) a +007 Berkeley Berkeley Public1 2 +000 New York New York Public Libra 2 +SELECT @bar; +@bar +Berkeley Public2 drop table t1, t2, t3; create table t1 (f1 int); insert into t1 values (1); diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index bfa95d8f92b..8236dbe94ac 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -363,4 +363,19 @@ SELECT a, b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; a b 2 3 DROP TABLE t1; +CREATE TABLE t1 (f1 int(11) default NULL, f2 int(11) default NULL); +CREATE TABLE t2 (f1 int(11) default NULL, f2 int(11) default NULL, foo int(11)); +CREATE TABLE t3 (f1 int(11) default NULL, f2 int(11) default NULL); +INSERT INTO t1 VALUES(10, 10); +INSERT INTO t1 VALUES(10, 10); +INSERT INTO t2 VALUES(10, 10, 10); +INSERT INTO t2 VALUES(10, 10, 10); +INSERT INTO t3 VALUES(10, 10); +INSERT INTO t3 VALUES(10, 10); +SELECT MIN(t2.f1), +@bar:= (SELECT MIN(t3.f2) FROM t3 WHERE t3.f2 > foo) +FROM t1,t2 WHERE t1.f1 = t2.f1 ORDER BY t2.f1; +MIN(t2.f1) @bar:= (SELECT MIN(t3.f2) FROM t3 WHERE t3.f2 > foo) +10 NULL +DROP TABLE t1, t2, t3; End of 5.0 tests diff --git a/mysql-test/t/binlog_delete_and_flush_index.test b/mysql-test/t/binlog_delete_and_flush_index.test new file mode 100644 index 00000000000..2899b96e317 --- /dev/null +++ b/mysql-test/t/binlog_delete_and_flush_index.test @@ -0,0 +1,119 @@ +# BUG#34582: FLUSH LOGS does not close and reopen the binlog index +# file +# +# WHAT +# ==== +# +# We want to test that FLUSH LOGS closes and reopens binlog index +# file. +# +# HOW +# === +# +# PREPARE: +# 1. create some binlog events +# 2. show index content, binlog events and binlog contents +# for mysql-bin.000001 +# 3. copy the mysql-bin.000001 to mysql-bin-b34582.000001 +# 4. change the index file so that mysql-bin.000001 is replaced +# with mysql-bin-b34582.000001 +# 5. FLUSH the logs so that new index is closed and reopened +# +# ASSERTIONS: +# 1. index file contents shows mysql-bin-b34582.000001 and +# mysql-bin.000002 +# 1. show binary logs shows current index entries +# 2. binlog contents for mysql-bin-b34582.000001 are displayed +# 3. Purge binlogs up to the latest one succeeds +# 4. SHOW BINARY LOGS presents the latest one only after purging +# 5. Purged binlogs files don't exist in the filesystem +# 6. Not purged binlog file exists in the filesystem +# +# CLEAN UP: +# 1. RESET MASTER +# + +-- source include/have_log_bin.inc + +RESET MASTER; + +-- let $datadir= $MYSQLTEST_VARDIR/log +-- let $index=$datadir/master-bin.index +-- chmod 0666 $index + +# action: issue one command so that binlog gets some event +CREATE TABLE t1 (a int); + +-- echo ### assertion: index file contains regular entries +-- replace_result $datadir MYSQLD_DATADIR +-- eval SET @index=LOAD_FILE('$index') +-- replace_result $datadir MYSQLD_DATADIR +SELECT @index; + +--echo ### assertion: show original binlogs +-- source include/show_binary_logs.inc + +--echo ### assertion: binlog contents from regular entries +-- source include/show_binlog_events.inc + +# action: copy binlogs to other names and change entries in index file +-- copy_file $datadir/master-bin.000001 $datadir/master-bin-b34582.000001 +-- let newbinfile= $datadir/master-bin-b34582.000001 +-- let INDEX_FILE= $index +perl; +use File::Spec; +$newbinfile= File::Spec->rel2abs($ENV{'newbinfile'}); +$file= $ENV{'INDEX_FILE'}; +open(FILE, ">$file") || die "Unable to open $file."; +truncate(FILE,0); +print FILE "$newbinfile"; +close ($file); +EOF + +# append a new line (platform independent) +-- append_file $index + +EOF + +# action: should cause rotation, and creation of new binlogs +FLUSH LOGS; + +# file is not used anymore - remove it (mysql closed on flush logs). +-- remove_file $datadir/master-bin.000001 + +-- echo ### assertion: index file contains renamed binlog and the new one +-- replace_result $datadir MYSQLD_DATADIR +-- eval SET @index=LOAD_FILE('$index') +-- replace_result $datadir MYSQLD_DATADIR +SELECT @index; + +-- echo ### assertion: original binlog content still exists, despite we +-- echo ### renamed and changed the index file +-- source include/show_binlog_events.inc + +-- echo ### assertion: user changed binlog index shows correct entries +-- source include/show_binary_logs.inc + +DROP TABLE t1; + +-- echo ### assertion: purging binlogs up to binlog created after instrumenting index file should work +-- let $current_binlog= query_get_value(SHOW MASTER STATUS, File, 1) +-- eval PURGE BINARY LOGS TO '$current_binlog' + +-- echo ### assertion: show binary logs should only contain latest binlog +-- source include/show_binary_logs.inc + +-- echo ### assertion: assert that binlog files were indeed purged (using file_exists calls) +-- error 1 +-- file_exists $datadir/master-bin-b34852.000001 + +-- echo ### assertion: assert that not purged binlog file exists +-- file_exists $datadir/$current_binlog + +-- echo ### assertion: show index file contents and these should match show binary logs issued above +-- replace_result $datadir MYSQLD_DATADIR +-- eval SET @index=LOAD_FILE('$index') +-- replace_result $datadir MYSQLD_DATADIR +SELECT @index; + +RESET MASTER; diff --git a/mysql-test/t/count_distinct.test b/mysql-test/t/count_distinct.test index e63bdabdb95..d0996689aeb 100644 --- a/mysql-test/t/count_distinct.test +++ b/mysql-test/t/count_distinct.test @@ -35,6 +35,25 @@ insert into t1 values ('NYC Lib','New York'); select t2.isbn,city,t1.libname,count(t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city,t1.libname; select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct t1.libname) > 1; select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct concat(t1.libname,'a')) > 1; + +select t2.isbn,city,@bar:=t1.libname,count(distinct t1.libname) as a + from t3 left join t1 on t3.libname=t1.libname left join t2 + on t3.isbn=t2.isbn group by city having count(distinct + t1.libname) > 1; +# +# Wrong result, see bug#49872 +# +SELECT @bar; + +select t2.isbn,city,concat(@bar:=t1.libname),count(distinct t1.libname) as a + from t3 left join t1 on t3.libname=t1.libname left join t2 + on t3.isbn=t2.isbn group by city having count(distinct + t1.libname) > 1; +# +# Wrong result, see bug#49872 +# +SELECT @bar; + drop table t1, t2, t3; # diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index d39b49a0e87..59a5238b35b 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -248,4 +248,24 @@ SELECT @a, @b; SELECT a, b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; DROP TABLE t1; +# +# Bug#47371: reference by same column name +# +CREATE TABLE t1 (f1 int(11) default NULL, f2 int(11) default NULL); +CREATE TABLE t2 (f1 int(11) default NULL, f2 int(11) default NULL, foo int(11)); +CREATE TABLE t3 (f1 int(11) default NULL, f2 int(11) default NULL); + +INSERT INTO t1 VALUES(10, 10); +INSERT INTO t1 VALUES(10, 10); +INSERT INTO t2 VALUES(10, 10, 10); +INSERT INTO t2 VALUES(10, 10, 10); +INSERT INTO t3 VALUES(10, 10); +INSERT INTO t3 VALUES(10, 10); + +SELECT MIN(t2.f1), +@bar:= (SELECT MIN(t3.f2) FROM t3 WHERE t3.f2 > foo) +FROM t1,t2 WHERE t1.f1 = t2.f1 ORDER BY t2.f1; + +DROP TABLE t1, t2, t3; + --echo End of 5.0 tests |