diff options
Diffstat (limited to 'mysql-test')
323 files changed, 11095 insertions, 1777 deletions
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 66f931133e3..fb97dd5b1de 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -30,7 +30,7 @@ dist-hook: $(INSTALL_DATA) $(srcdir)/t/*.test $(srcdir)/t/*.opt $(srcdir)/t/*.sh $(srcdir)/t/*.slave-mi $(distdir)/t $(INSTALL_DATA) $(srcdir)/include/*.inc $(distdir)/include $(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.require $(distdir)/r - $(INSTALL_DATA) $(srcdir)/std_data/*.dat $(srcdir)/std_data/*.001 $(distdir)/std_data + $(INSTALL_DATA) $(srcdir)/std_data/*.dat $(srcdir)/std_data/*.000001 $(distdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(distdir)/std_data install-data-local: diff --git a/mysql-test/README b/mysql-test/README index c5dc3e219de..7c6efe7940e 100644 --- a/mysql-test/README +++ b/mysql-test/README @@ -1,6 +1,10 @@ This directory contains a test suite for mysql daemon. To run the currently existing test cases, simply execute ./mysql-test-run in this directory. It will fire up the newly built mysqld and test it. + +If you want to run the test with a running MySQL server use the --external +option to mysql-test-run. + Note that you do not have to have to do make install, and you could actually have a co-existing MySQL installation - the tests will not conflict with it. @@ -13,8 +17,7 @@ http://www.mysql.com/doc/M/y/MySQL_test_suite.html You can create your own test cases. To create a test case: - cd t - vi test_case_name.test + xeamacs t/test_case_name.test in the file, put a set of SQL commands that will create some tables, load test data, run some queries to manipulate it. diff --git a/mysql-test/create-test-result b/mysql-test/create-test-result index bfd64f32fc5..b9be2300976 100755 --- a/mysql-test/create-test-result +++ b/mysql-test/create-test-result @@ -27,14 +27,13 @@ test_name=$1 [ -z $test_name ] && usage result_file=$RESULT_DIR/$test_name.result +reject_file=$RESULT_DIR/$test_name.reject [ -f $result_file ] && die "result file $result_file has already been created" touch $result_file echo "Running the test case against empty file, will fail, but don't worry" -./mysql-test-run --do-test=$test_name - -reject_file=$result_file.reject +./mysql-test-run --local $test_name if [ -f $reject_file ] ; then echo "Below are the contents of the reject file:" diff --git a/mysql-test/include/master-slave.inc b/mysql-test/include/master-slave.inc index 474b1357e9e..5ec4b4379f8 100644 --- a/mysql-test/include/master-slave.inc +++ b/mysql-test/include/master-slave.inc @@ -3,17 +3,24 @@ connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,); connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,); connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,); connection slave; ---error 0,1199 -!slave stop; +#we expect STOP SLAVE to produce a warning as the slave is stopped +#(the server was started with skip-slave-start) +--disable_warnings +stop slave; +--enable_warnings @r/slave-stopped.result show status like 'Slave_running'; connection master; +--disable_warnings drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +--enable_warnings reset master; connection slave; reset slave; # Clean up old test tables +--disable_warnings drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +--enable_warnings +start slave; @r/slave-running.result show status like 'Slave_running'; # Set the default connection to 'master' diff --git a/mysql-test/install_test_db.sh b/mysql-test/install_test_db.sh index 8f90301d2d8..fc3e00d8501 100644 --- a/mysql-test/install_test_db.sh +++ b/mysql-test/install_test_db.sh @@ -66,6 +66,9 @@ c_h="" i_h="" c_u="" i_u="" c_f="" i_f="" c_t="" c_c="" +c_hl="" c_hl="" +c_hc="" c_hc="" +c_clr="" c_clr="" # Check for old tables if test ! -f $mdata/db.frm @@ -123,7 +126,7 @@ then c_u="$c_u CREATE TABLE user (" c_u="$c_u Host char(60) binary DEFAULT '' NOT NULL," c_u="$c_u User char(16) binary DEFAULT '' NOT NULL," - c_u="$c_u Password char(16) binary DEFAULT '' NOT NULL," + c_u="$c_u Password char(45) binary DEFAULT '' NOT NULL," c_u="$c_u Select_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_u="$c_u Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_u="$c_u Update_priv enum('N','Y') DEFAULT 'N' NOT NULL," @@ -207,6 +210,42 @@ then c_c="$c_c comment='Column privileges';" fi +if test ! -f $mdata/help_topic.frm +then + c_hl="$c_hl CREATE TABLE help_topic (" + c_hl="$c_hl help_topic_id int unsigned not null auto_increment," + c_hl="$c_hl name varchar(64) not null," + c_hl="$c_hl description text not null," + c_hl="$c_hl example text not null," + c_hl="$c_hl url varchar(128) not null," + c_hl="$c_hl primary key (help_topic_id)," + c_hl="$c_hl unique index (name)" + c_hl="$c_hl )" + c_hl="$c_hl comment='help topics';" +fi + +if test ! -f $mdata/help_category.frm +then + c_clr="$c_clr CREATE TABLE help_category (" + c_clr="$c_clr help_category_id smallint unsigned not null auto_increment," + c_clr="$c_clr name varchar(64) not null," + c_clr="$c_clr url varchar(128) not null," + c_clr="$c_clr primary key (help_category_id)," + c_clr="$c_clr unique index (name)" + c_clr="$c_clr )" + c_clr="$c_clr comment='help topics-categories relation';" +fi + +if test ! -f $mdata/help_relation.frm +then + c_hc="$c_hc CREATE TABLE help_relation (" + c_hc="$c_hc help_topic_id int unsigned not null references help_topic," + c_hc="$c_hc help_category_id smallint unsigned not null references help_category," + c_hc="$c_hc primary key (help_category_id, help_topic_id)," + c_hc="$c_hc )" + c_hc="$c_hc comment='categories of help topics';" +fi + mysqld_boot=" $execdir/mysqld --no-defaults --bootstrap --skip-grant-tables \ --basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb $EXTRA_ARG" echo "running $mysqld_boot" @@ -227,6 +266,10 @@ $i_f $c_t $c_c + +$c_hl +$c_hc +$c_clr END_OF_DATA then exit 0 diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 65c960d13fa..8e0490f441e 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -191,7 +191,7 @@ USER_TEST= EXTRA_MASTER_OPT="" EXTRA_MYSQL_TEST_OPT="" -USE_RUNNING_SERVER=1 +USE_RUNNING_SERVER="" DO_GCOV="" DO_GDB="" MANUAL_GDB="" @@ -207,6 +207,7 @@ CHARACTER_SET=latin1 DBUSER="" START_WAIT_TIMEOUT=10 STOP_WAIT_TIMEOUT=10 +TEST_REPLICATION=0 MYSQL_TEST_SSL_OPTS="" while test $# -gt 0; do @@ -284,6 +285,9 @@ while test $# -gt 0; do --user-test=*) USER_TEST=`$ECHO "$1" | $SED -e "s;--user-test=;;"` ;; + --rpl) + TEST_REPLICATION=1 + ;; --mysqld=*) TMP=`$ECHO "$1" | $SED -e "s;--mysqld=;;"` EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT $TMP" @@ -334,7 +338,7 @@ while test $# -gt 0; do EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc" SLEEP_TIME_AFTER_RESTART=10 - SLEEP_TIME_FOR_DELETE=120 + SLEEP_TIME_FOR_DELETE=60 USE_RUNNING_SERVER="" ;; --valgrind-options=*) @@ -627,7 +631,7 @@ report_stats () { # Find errors for i in "^Warning:" "^Error:" "^==.* at 0x" do - if `$GREP "$i" $MY_LOG_DIR/warnings.tmp >> $MY_LOG_DIR/warnings` + if $GREP "$i" $MY_LOG_DIR/warnings.tmp >> $MY_LOG_DIR/warnings then found_error=1 fi @@ -811,8 +815,6 @@ start_master() if [ x$MASTER_RUNNING = x1 ] || [ x$LOCAL_MASTER = x1 ] ; then return fi - # Remove old berkeley db log files that can confuse the server - $RM -f $MASTER_MYDDIR/log.* # Remove stale binary logs $RM -f $MYSQL_TEST_DIR/var/log/master-bin.* # Remove old master.info and relay-log.info files @@ -1327,6 +1329,9 @@ then # Remove files that can cause problems $RM -f $MYSQL_TEST_DIR/var/run/* $MYSQL_TEST_DIR/var/tmp/* + # Remove old berkeley db log files that can confuse the server + $RM -f $MASTER_MYDDIR/log.* + wait_for_master=$SLEEP_TIME_FOR_FIRST_MASTER wait_for_slave=$SLEEP_TIME_FOR_FIRST_SLAVE $ECHO "Installing Test Databases" @@ -1378,15 +1383,22 @@ $ECHO $DASH72 if [ -z "$1" ] ; then - if [ x$RECORD = x1 ]; then - $ECHO "Will not run in record mode without a specific test case." - else - for tf in $TESTDIR/*.$TESTSUFFIX - do - run_testcase $tf - done - $RM -f $TIMEFILE # Remove for full test - fi + if [ x$RECORD = x1 ]; then + $ECHO "Will not run in record mode without a specific test case." + else + if [ x$TEST_REPLICATION = x1 ]; then + for tf in $TESTDIR/rpl*.$TESTSUFFIX + do + run_testcase $tf + done + else + for tf in $TESTDIR/*.$TESTSUFFIX + do + run_testcase $tf + done + fi + $RM -f $TIMEFILE # Remove for full test + fi else while [ ! -z "$1" ]; do tname=`$BASENAME $1 .test` diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 096ef2fd79e..456dfa860df 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -50,10 +50,10 @@ PRIMARY KEY (GROUP_ID,LANG_ID), KEY NAME (NAME)); ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null; SHOW FULL COLUMNS FROM t1; -Field Type Null Key Default Extra Privileges -GROUP_ID int(10) unsigned PRI 0 select,insert,update,references -LANG_ID smallint(5) unsigned PRI 0 select,insert,update,references -NAME char(80) MUL select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +GROUP_ID int(10) unsigned binary PRI 0 select,insert,update,references +LANG_ID smallint(5) unsigned binary PRI 0 select,insert,update,references +NAME char(80) latin1 MUL select,insert,update,references DROP TABLE t1; create table t1 (n int); insert into t1 values(9),(3),(12),(10); @@ -118,7 +118,7 @@ create table t1 (i int unsigned not null auto_increment primary key); alter table t1 rename t2; alter table t2 rename t1, add c char(10) comment "no comment"; show columns from t1; -Field Type Null Key Default Extra -i int(10) unsigned PRI NULL auto_increment -c char(10) YES NULL +Field Type Collation Null Key Default Extra +i int(10) unsigned binary PRI NULL auto_increment +c char(10) latin1 YES NULL drop table t1; diff --git a/mysql-test/r/analyse.result b/mysql-test/r/analyse.result index 5e859bb0b7a..48882f42219 100644 --- a/mysql-test/r/analyse.result +++ b/mysql-test/r/analyse.result @@ -1,26 +1,20 @@ drop table if exists t1,t2; -create table t1 (i int, j int, empty_string char(10), bool char(1), d date); -insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6,"","Y","2002-03-04"), (7,8,"","N","2002-03-05"); +create table t1 (i int, j int); +insert into t1 values (1,2), (3,4), (5,6), (7,8); +select count(*) from t1 procedure analyse(); +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +count(*) 4 4 1 1 0 0 4.0000 0.0000 ENUM('4') NOT NULL select * from t1 procedure analyse(); Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL -t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL -t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL -t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL -select * from t1 procedure analyse(2); -Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype -t1.i 1 7 1 1 0 0 4.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL -t1.j 2 8 1 1 0 0 5.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL -t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL -t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL -t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL create table t2 select * from t1 procedure analyse(); select * from t2; Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL -t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL -t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL -t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL drop table t1,t2; +EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> system NULL NULL NULL NULL 1 +2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used diff --git a/mysql-test/r/backup.result b/mysql-test/r/backup.result index 0e0a87172f2..e4f41517f94 100644 --- a/mysql-test/r/backup.result +++ b/mysql-test/r/backup.result @@ -1,24 +1,20 @@ set SQL_LOG_BIN=0; -create table t4(n int); -backup table t4 to '../bogus'; -Table Op Msg_type Msg_text -test.t4 backup error Failed copying .frm file (errno: X) -test.t4 backup status Operation failed -backup table t4 to '../tmp'; +drop table if exists t1, t2, t3; +create table t1(n int); +backup table t1 to '../bogus'; Table Op Msg_type Msg_text -test.t4 backup status OK -backup table t4 to '../tmp'; +test.t1 backup error Failed copying .frm file: errno = X +test.t1 backup status Operation failed +backup table t1 to '../tmp'; Table Op Msg_type Msg_text -test.t4 backup error Failed copying .frm file (errno: X) -test.t4 backup status Operation failed -drop table t4; -restore table t4 from '../tmp'; +test.t1 backup status OK +drop table t1; +restore table t1 from '../tmp'; Table Op Msg_type Msg_text -test.t4 restore status OK -select count(*) from t4; +test.t1 restore status OK +select count(*) from t1; count(*) 0 -create table t1(n int); insert into t1 values (23),(45),(67); backup table t1 to '../tmp'; Table Op Msg_type Msg_text @@ -39,8 +35,9 @@ create table t2(m int not null primary key); create table t3(k int not null primary key); insert into t2 values (123),(145),(167); insert into t3 values (223),(245),(267); -backup table t2,t3 to '../tmp'; +backup table t1,t2,t3 to '../tmp'; Table Op Msg_type Msg_text +test.t1 backup status OK test.t2 backup status OK test.t3 backup status OK drop table t1,t2,t3; @@ -64,14 +61,13 @@ k 223 245 267 -drop table t1,t2,t3,t4; +drop table t1,t2,t3; restore table t1 from '../tmp'; Table Op Msg_type Msg_text test.t1 restore status OK -rename table t1 to t5; -lock tables t5 write; -backup table t5 to '../tmp'; +lock tables t1 write; +backup table t1 to '../tmp'; unlock tables; Table Op Msg_type Msg_text -test.t5 backup status OK -drop table t5; +test.t1 backup status OK +drop table t1; diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index eb97d19136d..2c7d3136369 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -139,14 +139,14 @@ id parent_id level 1010 102 2 1015 102 2 explain select level from t1 where level=1; -table type possible_keys key key_len ref rows Extra -t1 ref level level 1 const 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref level level 1 const 1 Using where; Using index explain select level,id from t1 where level=1; -table type possible_keys key key_len ref rows Extra -t1 ref level level 1 const 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref level level 1 const 1 Using where; Using index explain select level,id,parent_id from t1 where level=1; -table type possible_keys key key_len ref rows Extra -t1 ref level level 1 const 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref level level 1 const 1 Using where select level,id from t1 where level=1; level id 1 1002 @@ -624,8 +624,8 @@ id parent_id level 1025 102 2 1016 102 2 explain select level from t1 where level=1; -table type possible_keys key key_len ref rows Extra -t1 ref level level 1 const 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref level level 1 const 1 Using where; Using index select level,id from t1 where level=1; level id 1 1004 @@ -797,7 +797,6 @@ select * from t1 where i=1 and j=2; i j 1 2 drop table t1; -drop table if exists t1, t2, t3, t4, t5, t6, t7; create table t1 ( branch_id int auto_increment primary key, @@ -806,7 +805,6 @@ branch_active int not null default 1, unique branch_name(branch_name), index branch_active(branch_active) ) type=bdb; -drop table if exists t2 ; create table t2 ( target_id int auto_increment primary key, @@ -815,7 +813,6 @@ target_active int not null default 1, unique target_name(target_name), index target_active(target_active) ) type=bdb; -drop table if exists t3 ; create table t3 ( platform_id int auto_increment primary key, @@ -824,7 +821,6 @@ platform_active int not null default 1, unique platform_name(platform_name), index platform_active(platform_active) ) type=bdb; -drop table if exists t4 ; create table t4 ( product_id int auto_increment primary key, @@ -834,7 +830,6 @@ product_active int not null default 1, unique product_name(product_name), index product_active(product_active) ) type=bdb; -drop table if exists t5 ; create table t5 ( product_file_id int auto_increment primary key, @@ -847,7 +842,6 @@ file_included int not null default 1, unique product_file(product_id,file_name), index file_included(file_included) ) type=bdb; -drop table if exists t6 ; create table t6 ( file_platform_id int auto_increment primary key, @@ -860,7 +854,6 @@ build_filename varchar(255) not null, archive_filename varchar(255) not null, unique file_platform(product_file_id,platform_id,branch_id) ) type=bdb; -drop table if exists t8 ; create table t8 ( archive_id int auto_increment primary key, @@ -872,7 +865,6 @@ status_id int not null default 1, unique archive(branch_id,target_id,platform_id,product_id), index status_id(status_id) ) type=bdb; -drop table if exists t7 ; create table t7 ( build_id int auto_increment primary key, @@ -1057,7 +1049,6 @@ KINMU_DATE select T1.KINMU_DATE from t1 T1 ,t2 T2 where T1.SYAIN_NO = '12345' and T1.KINMU_DATE = '200106' and T2.SYAIN_NO = T1.SYAIN_NO; KINMU_DATE DROP TABLE t1,t2; -drop table if exists t1; create table t1 (a int(11) not null, b int(11) not null, unique (a,b)) type=bdb; insert into t1 values (1,1), (1,2); select * from t1 where a = 1; diff --git a/mysql-test/r/bdb_cache.result b/mysql-test/r/bdb_cache.result index e5c6923162a..ea00feb2111 100644 --- a/mysql-test/r/bdb_cache.result +++ b/mysql-test/r/bdb_cache.result @@ -98,3 +98,4 @@ commit; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 1 +drop table if exists t1, t2, t3; diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index d7d811dc5f3..12dc146ba2b 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -1,3 +1,4 @@ +drop table if exists t1; select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296; 0 256 00000000000000065536 2147483647 -2147483648 2147483648 +4294967296 0 256 65536 2147483647 -2147483648 2147483648 4294967296 @@ -13,7 +14,6 @@ cast(9223372036854775808 as unsigned)+1 select 9223372036854775808+1; 9223372036854775808+1 9223372036854775809 -drop table if exists t1; create table t1 (a bigint unsigned not null, primary key(a)); insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE); select * from t1; diff --git a/mysql-test/r/binary.result b/mysql-test/r/binary.result index 4d5eb62cc71..5da627a30b9 100644 --- a/mysql-test/r/binary.result +++ b/mysql-test/r/binary.result @@ -45,29 +45,30 @@ name drop table t1,t2; create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b)); insert into t1 values ("hello ","hello "),("hello2 ","hello2 "); -select * from t1 where a="hello"; -a b -hello hello -select * from t1 where a="hello "; -a b -hello hello -select * from t1 ignore index (a) where a="hello "; -a b -hello hello -select * from t1 where b="hello"; -a b -hello hello -select * from t1 where b="hello "; -a b -hello hello -select * from t1 ignore index (b) where b="hello "; -a b +select concat("-",a,"-",b,"-") from t1 where a="hello"; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 where a="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 where b="hello"; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 where b="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello "; +concat("-",a,"-",b,"-") +-hello-hello- alter table t1 modify b tinytext not null, drop key b, add key (b(100)); -select * from t1 where b="hello "; -a b -select * from t1 ignore index (b) where b="hello "; -a b -hello hello +select concat("-",a,"-",b,"-") from t1 where b="hello "; +concat("-",a,"-",b,"-") +select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello "; +concat("-",a,"-",b,"-") +-hello-hello- drop table t1; create table t1 (b char(8)); insert into t1 values(NULL); diff --git a/mysql-test/r/bool.result b/mysql-test/r/bool.result index cb82c6baa0f..890c85dc946 100644 --- a/mysql-test/r/bool.result +++ b/mysql-test/r/bool.result @@ -46,10 +46,9 @@ SELECT @a, @b; @a @b 0 6 DROP TABLE t1; -drop table if exists t; -create table t(a int, b int); -insert into t values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1); -select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t; +create table t1 (a int, b int); +insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1); +select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1; A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB N N N N N N N N N N 0 N 1 N 0 1 1 N N N @@ -60,7 +59,7 @@ N 1 N 0 N N N 1 0 0 0 1 1 0 0 1 1 1 0 0 1 0 0 1 0 1 1 1 0 0 1 1 0 0 1 0 0 1 0 0 -select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t; +select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t1; A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB N N N N N N N N N N 0 N 1 N 0 1 1 N N N @@ -71,4 +70,4 @@ N 1 N 0 N N N 1 0 0 0 1 1 0 0 1 1 1 0 0 1 0 0 1 0 1 1 1 0 0 1 1 0 0 1 0 0 1 0 0 -drop table t; +drop table t1; diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result index 4c16b375400..914e05efa7a 100644 --- a/mysql-test/r/case.result +++ b/mysql-test/r/case.result @@ -10,10 +10,10 @@ CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END 3 select CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END; CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END -ok +0 select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END; CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END -ok +0 select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end; CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end a diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 572b32c171c..db28038526b 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -24,10 +24,10 @@ cast("A" as binary) = "a" cast(BINARY "a" as CHAR) = "A" 0 1 select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME); cast("2001-1-1" as DATE) cast("2001-1-1" as DATETIME) -2001-1-1 2001-1-1 +2001-01-01 2001-01-01 00:00:00 select cast("1:2:3" as TIME); cast("1:2:3" as TIME) -1:2:3 +01:02:03 select cast("2001-1-1" as date) = "2001-01-01"; cast("2001-1-1" as date) = "2001-01-01" 0 diff --git a/mysql-test/r/compare.result b/mysql-test/r/compare.result index afd2a1a086b..3ad3465fac0 100644 --- a/mysql-test/r/compare.result +++ b/mysql-test/r/compare.result @@ -2,8 +2,8 @@ drop table if exists t1; CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id)); insert into t1 values ('000000000001'),('000000000002'); explain select * from t1 where id=000000000001; -table type possible_keys key key_len ref rows Extra -t1 index PRIMARY PRIMARY 12 NULL 2 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 12 NULL 2 Using where; Using index select * from t1 where id=000000000001; id 000000000001 diff --git a/mysql-test/r/connect.result b/mysql-test/r/connect.result new file mode 100644 index 00000000000..b7243ac5d0b --- /dev/null +++ b/mysql-test/r/connect.result @@ -0,0 +1,43 @@ +show tables; +Tables_in_mysql +columns_priv +db +func +help_category +help_relation +help_topic +host +tables_priv +user +show tables; +Tables_in_test +grant ALL on *.* to test@localhost identified by "gambling"; +grant ALL on *.* to test@127.0.0.1 identified by "gambling"; +show tables; +Tables_in_mysql +columns_priv +db +func +help_category +help_relation +help_topic +host +tables_priv +user +show tables; +Tables_in_test +update mysql.user set password=old_password("gambling2") where user="test"; +flush privileges; +show tables; +Tables_in_mysql +columns_priv +db +func +help_category +help_relation +help_topic +host +tables_priv +user +show tables; +Tables_in_test diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 0cc98c38d49..2ec2759ad7a 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1,4 +1,4 @@ -drop table if exists t1,t2; +drop table if exists t1,t2,t3; create table t1 (b char(0)); insert into t1 values (""),(null); select * from t1; @@ -13,23 +13,25 @@ select * from t1; b -drop table if exists t1; +drop table t1; create table t2 type=heap select * from t1; Table 'test.t1' doesn't exist create table t2 select auto+1 from t1; Table 'test.t1' doesn't exist drop table if exists t1,t2; +Warnings: +Note 1051 Unknown table 't1' +Note 1051 Unknown table 't2' create table t1 (b char(0) not null, index(b)); The used table handler can't index column 'b' create table t1 (a int not null auto_increment,primary key (a)) type=heap; -The used table type doesn't support AUTO_INCREMENT columns create table t1 (a int not null,b text) type=heap; The used table type doesn't support BLOB/TEXT columns create table t1 (a int ,primary key(a)) type=heap; All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead drop table if exists t1; create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap; -The used table type doesn't support AUTO_INCREMENT columns +Incorrect table definition; There can only be one auto column and it must be defined as a key create table t1 (ordid int(8), primary key (ordid)); All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead create table not_existing_database.test (a int); @@ -49,6 +51,8 @@ drop table 1ea10; create table t1 (t1.index int); drop table t1; drop database if exists test_$1; +Warnings: +Note 1008 Can't drop database 'test_$1'. Database doesn't exist create database test_$1; create table test_$1.$test1 (a$1 int, $b int, c$ int); insert into test_$1.$test1 values (1,2,3); @@ -69,8 +73,8 @@ create table t1 (a int auto_increment not null primary key, B CHAR(20)); insert into t1 (b) values ("hello"),("my"),("world"); create table t2 (key (b)) select * from t1; explain select * from t2 where b="world"; -table type possible_keys key key_len ref rows Extra -t2 ref B B 21 const 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref B B 21 const 1 Using where select * from t2 where b="world"; a B 3 world @@ -78,29 +82,53 @@ drop table t1,t2; create table t1(x varchar(50) ); create table t2 select x from t1 where 1=2; describe t1; -Field Type Null Key Default Extra -x varchar(50) YES NULL +Field Type Collation Null Key Default Extra +x varchar(50) latin1 YES NULL describe t2; -Field Type Null Key Default Extra -x char(50) YES NULL +Field Type Collation Null Key Default Extra +x char(50) latin1 YES NULL drop table t2; create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f; describe t2; -Field Type Null Key Default Extra -a datetime 0000-00-00 00:00:00 -b time 00:00:00 -c date 0000-00-00 -d bigint(17) 0 -e double(18,1) 0.0 -f bigint(17) 0 +Field Type Collation Null Key Default Extra +a datetime latin1 0000-00-00 00:00:00 +b time latin1 00:00:00 +c date latin1 0000-00-00 +d bigint(17) binary 0 +e double(18,1) binary 0.0 +f bigint(17) binary 0 drop table t2; create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29 20:45:11" AS DATETIME) as dt; describe t2; -Field Type Null Key Default Extra -d date 0000-00-00 -t time 00:00:00 -dt datetime 0000-00-00 00:00:00 +Field Type Collation Null Key Default Extra +d date latin1 0000-00-00 +t time latin1 00:00:00 +dt datetime latin1 0000-00-00 00:00:00 drop table t1,t2; +create table t1 (a tinyint); +create table t2 (a int) select * from t1; +describe t1; +Field Type Collation Null Key Default Extra +a tinyint(4) binary YES NULL +describe t2; +Field Type Collation Null Key Default Extra +a int(11) binary YES NULL +drop table if exists t2; +create table t2 (a int, a float) select * from t1; +Duplicate column name 'a' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 't2' +create table t2 (a int) select a as b, a+1 as b from t1; +Duplicate column name 'b' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 't2' +create table t2 (b int) select a as b, a+1 as b from t1; +Duplicate column name 'b' +drop table if exists t1,t2; +Warnings: +Note 1051 Unknown table 't2' create table t1 (a int not null, b int, primary key(a), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b)); show create table t1; Table Create Table @@ -139,7 +167,7 @@ t1 CREATE TABLE `t1` ( KEY `b_29` (`b`), KEY `b_30` (`b`), KEY `b_31` (`b`) -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 drop table t1; create table t1 select if(1,'1','0'), month("2002-08-02"); drop table t1; @@ -148,3 +176,78 @@ select * from t1; if('2002'='2002','Y','N') Y drop table if exists t1; +create table t1 (a int, key(a)); +create table t2 (b int, foreign key(b) references t1(a), key(b)); +drop table if exists t1,t2; +create table t1(id int not null, name char(20)); +insert into t1 values(10,'mysql'),(20,'monty- the creator'); +create table t2(id int not null); +insert into t2 values(10),(20); +create table t3 like t1; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `id` int(11) NOT NULL default '0', + `name` char(20) default NULL +) TYPE=MyISAM CHARSET=latin1 +select * from t3; +id name +create table if not exists t3 like t1; +Warnings: +Warning 1050 Table 't3' already exists +select @@warning_count; +@@warning_count +1 +create temporary table t3 like t2; +show create table t3; +Table Create Table +t3 CREATE TEMPORARY TABLE `t3` ( + `id` int(11) NOT NULL default '0' +) TYPE=MyISAM CHARSET=latin1 +select * from t3; +id +drop table t3; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `id` int(11) NOT NULL default '0', + `name` char(20) default NULL +) TYPE=MyISAM CHARSET=latin1 +select * from t3; +id name +drop table t2, t3; +drop database if exists test_$1; +Warnings: +Note 1008 Can't drop database 'test_$1'. Database doesn't exist +create database test_$1; +create table test_$1.t3 like t1; +create temporary table t3 like test_$1.t3; +show create table t3; +Table Create Table +t3 CREATE TEMPORARY TABLE `t3` ( + `id` int(11) NOT NULL default '0', + `name` char(20) default NULL +) TYPE=MyISAM CHARSET=latin1 +create table t2 like t3; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL default '0', + `name` char(20) default NULL +) TYPE=MyISAM CHARSET=latin1 +select * from t2; +id name +create table t3 like t1; +create table t3 like test_$1.t3; +Table 't3' already exists +create table non_existing_database.t1 like t1; +Got one of the listed errors +create table t3 like non_existing_table; +Unknown table 'non_existing_table' +create temporary table t3 like t1; +Table 't3' already exists +create table t3 like `a/a`; +Incorrect table name 'a/a' +drop table t1, t2, t3; +drop table t3; +drop database test_$1; diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result new file mode 100644 index 00000000000..21429709d93 --- /dev/null +++ b/mysql-test/r/ctype_collate.result @@ -0,0 +1,574 @@ +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 ( +latin1_f CHAR(32) CHARACTER SET latin1 NOT NULL +); +CREATE TABLE t2 ( +latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r NOT NULL +); +COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1' +INSERT INTO t1 (latin1_f) VALUES (_latin1'A'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'a'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'AD'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ad'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'AE'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ae'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'AF'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'af'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'Ä'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ä'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'Å'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'å'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'B'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'b'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'U'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'u'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'UE'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ue'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'Ü'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ü'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'SS'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ss'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ß'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'Y'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'y'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'Z'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'z'); +SELECT latin1_f FROM t1 ORDER BY latin1_f; +latin1_f +A +a +AD +ad +AE +ae +AF +af +B +b +SS +ss +U +u +UE +ue +Ü +ü +Y +y +Z +z +Å +å +Ä +ä +ß +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1; +latin1_f +A +a +AD +ad +AE +ae +AF +af +B +b +SS +ss +U +u +UE +ue +Ü +ü +Y +y +Z +z +Å +å +Ä +ä +ß +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_de; +latin1_f +A +a +Å +å +AD +ad +AE +ae +Ä +ä +AF +af +B +b +SS +ss +ß +U +u +UE +ue +Ü +ü +Y +y +Z +z +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_ci_as; +latin1_f +A +a +AD +ad +AE +ae +AF +af +Ä +ä +Å +å +B +b +SS +ss +ß +U +u +UE +ue +Ü +ü +Y +y +Z +z +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_bin; +latin1_f +A +AD +AE +AF +B +SS +U +UE +Y +Z +a +ad +ae +af +b +ss +u +ue +y +z +Ä +Å +Ü +ß +ä +å +ü +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r; +COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1' +SELECT latin1_f COLLATE latin1 AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +latin1_f_as +A +a +AD +ad +AE +ae +AF +af +B +b +SS +ss +U +u +UE +ue +Ü +ü +Y +y +Z +z +Å +å +Ä +ä +ß +SELECT latin1_f COLLATE latin1_de AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +latin1_f_as +A +a +Å +å +AD +ad +AE +ae +Ä +ä +AF +af +B +b +SS +ss +ß +U +u +UE +ue +Ü +ü +Y +y +Z +z +SELECT latin1_f COLLATE latin1_ci_as AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +latin1_f_as +A +a +AD +ad +AE +ae +AF +af +Ä +ä +Å +å +B +b +SS +ss +ß +U +u +UE +ue +Ü +ü +Y +y +Z +z +SELECT latin1_f COLLATE latin1_bin AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +latin1_f_as +A +AD +AE +AF +B +SS +U +UE +Y +Z +a +ad +ae +af +b +ss +u +ue +y +z +Ä +Å +Ü +ß +ä +å +ü +SELECT latin1_f COLLATE koi8r AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1' +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f; +latin1_f count(*) +A 2 +AD 2 +AE 2 +AF 2 +B 2 +SS 2 +U 2 +UE 2 +Ü 4 +Z 2 +Å 2 +Ä 2 +ß 1 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1; +latin1_f count(*) +A 2 +AD 2 +AE 2 +AF 2 +B 2 +SS 2 +U 2 +UE 2 +Ü 4 +Z 2 +Å 2 +Ä 2 +ß 1 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_de; +latin1_f count(*) +A 4 +AD 2 +AE 2 +Ä 2 +AF 2 +B 2 +SS 2 +ß 1 +U 2 +UE 2 +Ü 2 +Y 2 +Z 2 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_ci_as; +latin1_f count(*) +A 2 +AD 2 +AE 2 +AF 2 +Ä 2 +Å 2 +B 2 +SS 2 +ß 1 +U 2 +UE 2 +Ü 2 +Y 2 +Z 2 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_bin; +latin1_f count(*) +A 1 +AD 1 +AE 1 +AF 1 +B 1 +SS 1 +U 1 +UE 1 +Y 1 +Z 1 +a 1 +ad 1 +ae 1 +af 1 +b 1 +ss 1 +u 1 +ue 1 +y 1 +z 1 +Ä 1 +Å 1 +Ü 1 +ß 1 +ä 1 +å 1 +ü 1 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r; +COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1' +SELECT DISTINCT latin1_f FROM t1; +latin1_f +A +AD +AE +AF +Ä +Å +B +U +UE +Ü +SS +ß +Z +SELECT DISTINCT latin1_f COLLATE latin1 FROM t1; +latin1_f COLLATE latin1 +A +AD +AE +AF +Ä +Å +B +U +UE +Ü +SS +ß +Z +SELECT DISTINCT latin1_f COLLATE latin1_de FROM t1; +latin1_f COLLATE latin1_de +A +AD +AE +AF +Ä +B +U +UE +Ü +SS +ß +Y +Z +SELECT DISTINCT latin1_f COLLATE latin1_ci_as FROM t1; +latin1_f COLLATE latin1_ci_as +A +AD +AE +AF +Ä +Å +B +U +UE +Ü +SS +ß +Y +Z +SELECT DISTINCT latin1_f COLLATE latin1_bin FROM t1; +latin1_f COLLATE latin1_bin +A +a +AD +ad +AE +ae +AF +af +Ä +ä +Å +å +B +b +U +u +UE +ue +Ü +ü +SS +ss +ß +Y +y +Z +z +SELECT DISTINCT latin1_f COLLATE koi8r FROM t1; +COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `latin1_f` char(32) NOT NULL default '' +) TYPE=MyISAM CHARSET=latin1 +SHOW FIELDS FROM t1; +Field Type Collation Null Key Default Extra +latin1_f char(32) latin1 +ALTER TABLE t1 CHANGE latin1_f +latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `latin1_f` char(32) character set latin1 collate latin1_bin default NULL +) TYPE=MyISAM CHARSET=latin1 +SHOW FIELDS FROM t1; +Field Type Collation Null Key Default Extra +latin1_f char(32) character set latin1 latin1_bin YES NULL +ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `latin1_f` char(32) collate latin1_bin default NULL +) TYPE=MyISAM CHARSET=latin1 COLLATE=latin1_bin +SHOW FIELDS FROM t1; +Field Type Collation Null Key Default Extra +latin1_f char(32) latin1_bin YES NULL +SET NAMES 'latin1'; +SHOW VARIABLES LIKE 'client_collation'; +Variable_name Value +client_collation latin1 +SET NAMES latin1; +SHOW VARIABLES LIKE 'client_collation'; +Variable_name Value +client_collation latin1 +SHOW VARIABLES LIKE 'client_collation'; +Variable_name Value +client_collation latin1 +SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +charset('a') collation('a') coercibility('a') 'a'='A' +latin1 latin1 2 1 +SET NAMES latin1 COLLATE latin1_bin; +SHOW VARIABLES LIKE 'client_collation'; +Variable_name Value +client_collation latin1_bin +SET NAMES LATIN1 COLLATE Latin1_Bin; +SHOW VARIABLES LIKE 'client_collation'; +Variable_name Value +client_collation latin1_bin +SET NAMES 'latin1' COLLATE 'latin1_bin'; +SHOW VARIABLES LIKE 'client_collation'; +Variable_name Value +client_collation latin1_bin +SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +charset('a') collation('a') coercibility('a') 'a'='A' +latin1 latin1_bin 2 0 +SET NAMES koi8r; +SHOW VARIABLES LIKE 'client_collation'; +Variable_name Value +client_collation koi8r +SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +charset('a') collation('a') coercibility('a') 'a'='A' +koi8r koi8r 2 1 +SET COLLATION koi8r_bin; +SHOW VARIABLES LIKE 'client_collation'; +Variable_name Value +client_collation koi8r_bin +SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +charset('a') collation('a') coercibility('a') 'a'='A' +koi8r koi8r_bin 2 0 +SET COLLATION DEFAULT; +SHOW VARIABLES LIKE 'client_collation'; +Variable_name Value +client_collation koi8r +SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +charset('a') collation('a') coercibility('a') 'a'='A' +koi8r koi8r 2 1 +SET NAMES DEFAULT; +SHOW VARIABLES LIKE 'client_collation'; +Variable_name Value +client_collation latin1 +SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +charset('a') collation('a') coercibility('a') 'a'='A' +latin1 latin1 2 1 +SET NAMES latin1 COLLATE koi8r; +COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1' +SET NAMES 'DEFAULT'; +Unknown character set: 'DEFAULT' +DROP TABLE t1; diff --git a/mysql-test/r/ctype_many.result b/mysql-test/r/ctype_many.result new file mode 100644 index 00000000000..0bbb0073420 --- /dev/null +++ b/mysql-test/r/ctype_many.result @@ -0,0 +1,1399 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +comment CHAR(32) ASCII NOT NULL, +koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL +) CHARSET=latin5; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `comment` char(32) character set latin1 NOT NULL default '', + `koi8_ru_f` char(32) character set koi8r NOT NULL default '' +) TYPE=MyISAM CHARSET=latin5 +ALTER TABLE t1 CHANGE comment comment CHAR(32) CHARACTER SET latin2 NOT NULL; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `comment` char(32) character set latin2 NOT NULL default '', + `koi8_ru_f` char(32) character set koi8r NOT NULL default '' +) TYPE=MyISAM CHARSET=latin5 +ALTER TABLE t1 ADD latin5_f CHAR(32) NOT NULL; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `comment` char(32) character set latin2 NOT NULL default '', + `koi8_ru_f` char(32) character set koi8r NOT NULL default '', + `latin5_f` char(32) NOT NULL default '' +) TYPE=MyISAM CHARSET=latin5 +ALTER TABLE t1 CHARSET=latin2; +ALTER TABLE t1 ADD latin2_f CHAR(32) NOT NULL; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `comment` char(32) NOT NULL default '', + `koi8_ru_f` char(32) character set koi8r NOT NULL default '', + `latin5_f` char(32) character set latin5 NOT NULL default '', + `latin2_f` char(32) NOT NULL default '' +) TYPE=MyISAM CHARSET=latin2 +ALTER TABLE t1 DROP latin2_f, DROP latin5_f; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `comment` char(32) NOT NULL default '', + `koi8_ru_f` char(32) character set koi8r NOT NULL default '' +) TYPE=MyISAM CHARSET=latin2 +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('a','LAT SMALL A'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('b','LAT SMALL B'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('c','LAT SMALL C'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('d','LAT SMALL D'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('e','LAT SMALL E'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('f','LAT SMALL F'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('g','LAT SMALL G'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('h','LAT SMALL H'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('i','LAT SMALL I'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('j','LAT SMALL J'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('k','LAT SMALL K'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('l','LAT SMALL L'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('m','LAT SMALL M'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('n','LAT SMALL N'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('o','LAT SMALL O'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('p','LAT SMALL P'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('q','LAT SMALL Q'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('r','LAT SMALL R'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('s','LAT SMALL S'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('t','LAT SMALL T'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('u','LAT SMALL U'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('v','LAT SMALL V'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('w','LAT SMALL W'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('x','LAT SMALL X'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('y','LAT SMALL Y'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('z','LAT SMALL Z'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('A','LAT CAPIT A'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('B','LAT CAPIT B'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('C','LAT CAPIT C'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('D','LAT CAPIT D'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('E','LAT CAPIT E'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('F','LAT CAPIT F'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('G','LAT CAPIT G'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('H','LAT CAPIT H'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('I','LAT CAPIT I'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('J','LAT CAPIT J'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('K','LAT CAPIT K'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('L','LAT CAPIT L'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('M','LAT CAPIT M'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('N','LAT CAPIT N'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('O','LAT CAPIT O'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('P','LAT CAPIT P'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Q','LAT CAPIT Q'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('R','LAT CAPIT R'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('S','LAT CAPIT S'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('T','LAT CAPIT T'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('U','LAT CAPIT U'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('V','LAT CAPIT V'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('W','LAT CAPIT W'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('X','LAT CAPIT X'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Y','LAT CAPIT Y'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Z','LAT CAPIT Z'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Á','CYR SMALL A'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Â','CYR SMALL BE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'×','CYR SMALL VE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ç','CYR SMALL GE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ä','CYR SMALL DE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Å','CYR SMALL IE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'£','CYR SMALL IO'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ö','CYR SMALL ZHE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ú','CYR SMALL ZE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'É','CYR SMALL I'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ë','CYR SMALL KA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ì','CYR SMALL EL'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Í','CYR SMALL EM'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Î','CYR SMALL EN'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ï','CYR SMALL O'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ð','CYR SMALL PE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ò','CYR SMALL ER'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ó','CYR SMALL ES'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ô','CYR SMALL TE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Õ','CYR SMALL U'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Æ','CYR SMALL EF'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'È','CYR SMALL HA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ã','CYR SMALL TSE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Þ','CYR SMALL CHE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Û','CYR SMALL SHA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ý','CYR SMALL SCHA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ß','CYR SMALL HARD SIGN'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ù','CYR SMALL YERU'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ø','CYR SMALL SOFT SIGN'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ü','CYR SMALL E'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'À','CYR SMALL YU'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ñ','CYR SMALL YA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'á','CYR CAPIT A'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'â','CYR CAPIT BE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'÷','CYR CAPIT VE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ç','CYR CAPIT GE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ä','CYR CAPIT DE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'å','CYR CAPIT IE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'³','CYR CAPIT IO'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ö','CYR CAPIT ZHE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ú','CYR CAPIT ZE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'é','CYR CAPIT I'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ë','CYR CAPIT KA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ì','CYR CAPIT EL'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'í','CYR CAPIT EM'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'î','CYR CAPIT EN'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ï','CYR CAPIT O'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ð','CYR CAPIT PE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ò','CYR CAPIT ER'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ó','CYR CAPIT ES'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ô','CYR CAPIT TE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'õ','CYR CAPIT U'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'æ','CYR CAPIT EF'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'è','CYR CAPIT HA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ã','CYR CAPIT TSE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'þ','CYR CAPIT CHE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'û','CYR CAPIT SHA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ý','CYR CAPIT SCHA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ÿ','CYR CAPIT HARD SIGN'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ù','CYR CAPIT YERU'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ø','CYR CAPIT SOFT SIGN'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ü','CYR CAPIT E'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'à','CYR CAPIT YU'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ñ','CYR CAPIT YA'); +SELECT CONVERT(koi8_ru_f USING utf8),MIN(comment),COUNT(*) FROM t1 GROUP BY 1; +CONVERT(koi8_ru_f USING utf8) MIN(comment) COUNT(*) +a LAT CAPIT A 2 +b LAT CAPIT B 2 +c LAT CAPIT C 2 +d LAT CAPIT D 2 +e LAT CAPIT E 2 +f LAT CAPIT F 2 +g LAT CAPIT G 2 +h LAT CAPIT H 2 +i LAT CAPIT I 2 +j LAT CAPIT J 2 +k LAT CAPIT K 2 +l LAT CAPIT L 2 +m LAT CAPIT M 2 +n LAT CAPIT N 2 +o LAT CAPIT O 2 +p LAT CAPIT P 2 +q LAT CAPIT Q 2 +r LAT CAPIT R 2 +s LAT CAPIT S 2 +t LAT CAPIT T 2 +u LAT CAPIT U 2 +v LAT CAPIT V 2 +w LAT CAPIT W 2 +x LAT CAPIT X 2 +y LAT CAPIT Y 2 +z LAT CAPIT Z 2 +а CYR CAPIT A 2 +б CYR CAPIT BE 2 +в CYR CAPIT VE 2 +г CYR CAPIT GE 2 +д CYR CAPIT DE 2 +е CYR CAPIT IE 4 +ж CYR CAPIT ZHE 2 +з CYR CAPIT ZE 2 +и CYR CAPIT I 2 +к CYR CAPIT KA 2 +л CYR CAPIT EL 2 +м CYR CAPIT EM 2 +н CYR CAPIT EN 2 +о CYR CAPIT O 2 +п CYR CAPIT PE 2 +Ñ€ CYR CAPIT ER 2 +Ñ CYR CAPIT ES 2 +Ñ‚ CYR CAPIT TE 2 +у CYR CAPIT U 2 +Ñ„ CYR CAPIT EF 2 +Ñ… CYR CAPIT HA 2 +ц CYR CAPIT TSE 2 +ч CYR CAPIT CHE 2 +ш CYR CAPIT SHA 2 +щ CYR CAPIT SCHA 2 +ÑŠ CYR CAPIT HARD SIGN 2 +Ñ‹ CYR CAPIT YERU 2 +ÑŒ CYR CAPIT SOFT SIGN 2 +Ñ CYR CAPIT E 2 +ÑŽ CYR CAPIT YU 2 +Ñ CYR CAPIT YA 2 +ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL; +UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8); +SELECT * FROM t1; +comment koi8_ru_f utf8_f +LAT SMALL A a a +LAT SMALL B b b +LAT SMALL C c c +LAT SMALL D d d +LAT SMALL E e e +LAT SMALL F f f +LAT SMALL G g g +LAT SMALL H h h +LAT SMALL I i i +LAT SMALL J j j +LAT SMALL K k k +LAT SMALL L l l +LAT SMALL M m m +LAT SMALL N n n +LAT SMALL O o o +LAT SMALL P p p +LAT SMALL Q q q +LAT SMALL R r r +LAT SMALL S s s +LAT SMALL T t t +LAT SMALL U u u +LAT SMALL V v v +LAT SMALL W w w +LAT SMALL X x x +LAT SMALL Y y y +LAT SMALL Z z z +LAT CAPIT A A A +LAT CAPIT B B B +LAT CAPIT C C C +LAT CAPIT D D D +LAT CAPIT E E E +LAT CAPIT F F F +LAT CAPIT G G G +LAT CAPIT H H H +LAT CAPIT I I I +LAT CAPIT J J J +LAT CAPIT K K K +LAT CAPIT L L L +LAT CAPIT M M M +LAT CAPIT N N N +LAT CAPIT O O O +LAT CAPIT P P P +LAT CAPIT Q Q Q +LAT CAPIT R R R +LAT CAPIT S S S +LAT CAPIT T T T +LAT CAPIT U U U +LAT CAPIT V V V +LAT CAPIT W W W +LAT CAPIT X X X +LAT CAPIT Y Y Y +LAT CAPIT Z Z Z +CYR SMALL A Á а +CYR SMALL BE  б +CYR SMALL VE × Ð² +CYR SMALL GE Ç Ð³ +CYR SMALL DE Ä Ð´ +CYR SMALL IE Šе +CYR SMALL IO £ Ñ‘ +CYR SMALL ZHE Ö Ð¶ +CYR SMALL ZE Ú Ð· +CYR SMALL I É Ð¸ +CYR SMALL KA Ë Ðº +CYR SMALL EL Ì Ð» +CYR SMALL EM Í Ð¼ +CYR SMALL EN Πн +CYR SMALL O Ï Ð¾ +CYR SMALL PE Рп +CYR SMALL ER Ò Ñ€ +CYR SMALL ES Ó Ñ +CYR SMALL TE Ô Ñ‚ +CYR SMALL U Õ Ñƒ +CYR SMALL EF Æ Ñ„ +CYR SMALL HA È Ñ… +CYR SMALL TSE à ц +CYR SMALL CHE Þ Ñ‡ +CYR SMALL SHA Û Ñˆ +CYR SMALL SCHA Ý Ñ‰ +CYR SMALL HARD SIGN ß ÑŠ +CYR SMALL YERU Ù Ñ‹ +CYR SMALL SOFT SIGN Ø ÑŒ +CYR SMALL E Ü Ñ +CYR SMALL YU À ÑŽ +CYR SMALL YA Ñ Ñ +CYR CAPIT A á Ð +CYR CAPIT BE â Б +CYR CAPIT VE ÷ Ð’ +CYR CAPIT GE ç Г +CYR CAPIT DE ä Д +CYR CAPIT IE å Е +CYR CAPIT IO ³ Ð +CYR CAPIT ZHE ö Ж +CYR CAPIT ZE ú З +CYR CAPIT I é И +CYR CAPIT KA ë К +CYR CAPIT EL ì Л +CYR CAPIT EM í Ðœ +CYR CAPIT EN î Ð +CYR CAPIT O ï О +CYR CAPIT PE ð П +CYR CAPIT ER ò Ð +CYR CAPIT ES ó С +CYR CAPIT TE ô Т +CYR CAPIT U õ У +CYR CAPIT EF æ Ф +CYR CAPIT HA è Ð¥ +CYR CAPIT TSE ã Ц +CYR CAPIT CHE þ Ч +CYR CAPIT SHA û Ш +CYR CAPIT SCHA ý Щ +CYR CAPIT HARD SIGN ÿ Ъ +CYR CAPIT YERU ù Ы +CYR CAPIT SOFT SIGN ø Ь +CYR CAPIT E ü Ð +CYR CAPIT YU à Ю +CYR CAPIT YA ñ Я +ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL; +UPDATE t1 SET bin_f=koi8_ru_f; +SELECT COUNT(DISTINCT bin_f),COUNT(DISTINCT koi8_ru_f),COUNT(DISTINCT utf8_f) FROM t1; +COUNT(DISTINCT bin_f) COUNT(DISTINCT koi8_ru_f) COUNT(DISTINCT utf8_f) +116 58 57 +SELECT koi8_ru_f,MIN(comment) FROM t1 GROUP BY 1; +koi8_ru_f MIN(comment) +a LAT CAPIT A +b LAT CAPIT B +c LAT CAPIT C +d LAT CAPIT D +e LAT CAPIT E +f LAT CAPIT F +g LAT CAPIT G +h LAT CAPIT H +i LAT CAPIT I +j LAT CAPIT J +k LAT CAPIT K +l LAT CAPIT L +m LAT CAPIT M +n LAT CAPIT N +o LAT CAPIT O +p LAT CAPIT P +q LAT CAPIT Q +r LAT CAPIT R +s LAT CAPIT S +t LAT CAPIT T +u LAT CAPIT U +v LAT CAPIT V +w LAT CAPIT W +x LAT CAPIT X +y LAT CAPIT Y +z LAT CAPIT Z +Á CYR CAPIT A + CYR CAPIT BE +× CYR CAPIT VE +Ç CYR CAPIT GE +Ä CYR CAPIT DE +Å CYR CAPIT IE +£ CYR CAPIT IO +Ö CYR CAPIT ZHE +Ú CYR CAPIT ZE +É CYR CAPIT I +Ë CYR CAPIT KA +Ì CYR CAPIT EL +Í CYR CAPIT EM +Î CYR CAPIT EN +Ï CYR CAPIT O +Ð CYR CAPIT PE +Ò CYR CAPIT ER +Ó CYR CAPIT ES +Ô CYR CAPIT TE +Õ CYR CAPIT U +Æ CYR CAPIT EF +È CYR CAPIT HA +à CYR CAPIT TSE +Þ CYR CAPIT CHE +Û CYR CAPIT SHA +Ý CYR CAPIT SCHA +ß CYR CAPIT HARD SIGN +Ù CYR CAPIT YERU +Ø CYR CAPIT SOFT SIGN +Ü CYR CAPIT E +À CYR CAPIT YU +Ñ CYR CAPIT YA +SELECT utf8_f,MIN(comment) FROM t1 GROUP BY 1; +utf8_f MIN(comment) +a LAT CAPIT A +b LAT CAPIT B +c LAT CAPIT C +d LAT CAPIT D +e LAT CAPIT E +f LAT CAPIT F +g LAT CAPIT G +h LAT CAPIT H +i LAT CAPIT I +j LAT CAPIT J +k LAT CAPIT K +l LAT CAPIT L +m LAT CAPIT M +n LAT CAPIT N +o LAT CAPIT O +p LAT CAPIT P +q LAT CAPIT Q +r LAT CAPIT R +s LAT CAPIT S +t LAT CAPIT T +u LAT CAPIT U +v LAT CAPIT V +w LAT CAPIT W +x LAT CAPIT X +y LAT CAPIT Y +z LAT CAPIT Z +а CYR CAPIT A +б CYR CAPIT BE +в CYR CAPIT VE +г CYR CAPIT GE +д CYR CAPIT DE +е CYR CAPIT IE +ж CYR CAPIT ZHE +з CYR CAPIT ZE +и CYR CAPIT I +к CYR CAPIT KA +л CYR CAPIT EL +м CYR CAPIT EM +н CYR CAPIT EN +о CYR CAPIT O +п CYR CAPIT PE +Ñ€ CYR CAPIT ER +Ñ CYR CAPIT ES +Ñ‚ CYR CAPIT TE +у CYR CAPIT U +Ñ„ CYR CAPIT EF +Ñ… CYR CAPIT HA +ц CYR CAPIT TSE +ч CYR CAPIT CHE +ш CYR CAPIT SHA +щ CYR CAPIT SCHA +ÑŠ CYR CAPIT HARD SIGN +Ñ‹ CYR CAPIT YERU +ÑŒ CYR CAPIT SOFT SIGN +Ñ CYR CAPIT E +ÑŽ CYR CAPIT YU +Ñ CYR CAPIT YA +SELECT DISTINCT koi8_ru_f FROM t1; +koi8_ru_f +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x +y +z +Á + +× +Ç +Ä +Å +£ +Ö +Ú +É +Ë +Ì +Í +Î +Ï +Ð +Ò +Ó +Ô +Õ +Æ +È +à +Þ +Û +Ý +ß +Ù +Ø +Ü +À +Ñ +SELECT DISTINCT utf8_f FROM t1; +utf8_f +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x +y +z +а +б +в +г +д +е +ж +з +и +к +л +м +н +о +п +Ñ€ +Ñ +Ñ‚ +у +Ñ„ +Ñ… +ц +ч +ш +щ +ÑŠ +Ñ‹ +ÑŒ +Ñ +ÑŽ +Ñ +SELECT lower(koi8_ru_f) FROM t1 ORDER BY 1 DESC; +lower(koi8_ru_f) +Ñ +Ñ +À +À +Ü +Ü +Ø +Ø +Ù +Ù +ß +ß +Ý +Ý +Û +Û +Þ +Þ +à +à +È +È +Æ +Æ +Õ +Õ +Ô +Ô +Ó +Ó +Ò +Ò +Ð +Ð +Ï +Ï +Î +Î +Í +Í +Ì +Ì +Ë +Ë +É +É +Ú +Ú +Ö +Ö +£ +£ +Å +Å +Ä +Ä +Ç +Ç +× +× + + +Á +Á +z +z +y +y +x +x +w +w +v +v +u +u +t +t +s +s +r +r +q +q +p +p +o +o +n +n +m +m +l +l +k +k +j +j +i +i +h +h +g +g +f +f +e +e +d +d +c +c +b +b +a +a +SELECT lower(utf8_f) FROM t1 ORDER BY 1 DESC; +lower(utf8_f) +Ñ +Ñ +ÑŽ +ÑŽ +Ñ +Ñ +ÑŒ +ÑŒ +Ñ‹ +Ñ‹ +ÑŠ +ÑŠ +щ +щ +ш +ш +ч +ч +ц +ц +Ñ… +Ñ… +Ñ„ +Ñ„ +у +у +Ñ‚ +Ñ‚ +Ñ +Ñ +Ñ€ +Ñ€ +п +п +о +о +н +н +м +м +л +л +к +к +и +и +з +з +ж +ж +е +Ñ‘ +е +Ñ‘ +д +д +г +г +в +в +б +б +а +а +z +z +y +y +x +x +w +w +v +v +u +u +t +t +s +s +r +r +q +q +p +p +o +o +n +n +m +m +l +l +k +k +j +j +i +i +h +h +g +g +f +f +e +e +d +d +c +c +b +b +a +a +SELECT t11.comment,t12.comment +FROM t1 t11,t1 t12 WHERE CONVERT(t11.koi8_ru_f USING utf8)=t12.utf8_f +ORDER BY t11.koi8_ru_f,t11.comment,t12.comment; +comment comment +LAT CAPIT A LAT CAPIT A +LAT CAPIT A LAT SMALL A +LAT SMALL A LAT CAPIT A +LAT SMALL A LAT SMALL A +LAT CAPIT B LAT CAPIT B +LAT CAPIT B LAT SMALL B +LAT SMALL B LAT CAPIT B +LAT SMALL B LAT SMALL B +LAT CAPIT C LAT CAPIT C +LAT CAPIT C LAT SMALL C +LAT SMALL C LAT CAPIT C +LAT SMALL C LAT SMALL C +LAT CAPIT D LAT CAPIT D +LAT CAPIT D LAT SMALL D +LAT SMALL D LAT CAPIT D +LAT SMALL D LAT SMALL D +LAT CAPIT E LAT CAPIT E +LAT CAPIT E LAT SMALL E +LAT SMALL E LAT CAPIT E +LAT SMALL E LAT SMALL E +LAT CAPIT F LAT CAPIT F +LAT CAPIT F LAT SMALL F +LAT SMALL F LAT CAPIT F +LAT SMALL F LAT SMALL F +LAT CAPIT G LAT CAPIT G +LAT CAPIT G LAT SMALL G +LAT SMALL G LAT CAPIT G +LAT SMALL G LAT SMALL G +LAT CAPIT H LAT CAPIT H +LAT CAPIT H LAT SMALL H +LAT SMALL H LAT CAPIT H +LAT SMALL H LAT SMALL H +LAT CAPIT I LAT CAPIT I +LAT CAPIT I LAT SMALL I +LAT SMALL I LAT CAPIT I +LAT SMALL I LAT SMALL I +LAT CAPIT J LAT CAPIT J +LAT CAPIT J LAT SMALL J +LAT SMALL J LAT CAPIT J +LAT SMALL J LAT SMALL J +LAT CAPIT K LAT CAPIT K +LAT CAPIT K LAT SMALL K +LAT SMALL K LAT CAPIT K +LAT SMALL K LAT SMALL K +LAT CAPIT L LAT CAPIT L +LAT CAPIT L LAT SMALL L +LAT SMALL L LAT CAPIT L +LAT SMALL L LAT SMALL L +LAT CAPIT M LAT CAPIT M +LAT CAPIT M LAT SMALL M +LAT SMALL M LAT CAPIT M +LAT SMALL M LAT SMALL M +LAT CAPIT N LAT CAPIT N +LAT CAPIT N LAT SMALL N +LAT SMALL N LAT CAPIT N +LAT SMALL N LAT SMALL N +LAT CAPIT O LAT CAPIT O +LAT CAPIT O LAT SMALL O +LAT SMALL O LAT CAPIT O +LAT SMALL O LAT SMALL O +LAT CAPIT P LAT CAPIT P +LAT CAPIT P LAT SMALL P +LAT SMALL P LAT CAPIT P +LAT SMALL P LAT SMALL P +LAT CAPIT Q LAT CAPIT Q +LAT CAPIT Q LAT SMALL Q +LAT SMALL Q LAT CAPIT Q +LAT SMALL Q LAT SMALL Q +LAT CAPIT R LAT CAPIT R +LAT CAPIT R LAT SMALL R +LAT SMALL R LAT CAPIT R +LAT SMALL R LAT SMALL R +LAT CAPIT S LAT CAPIT S +LAT CAPIT S LAT SMALL S +LAT SMALL S LAT CAPIT S +LAT SMALL S LAT SMALL S +LAT CAPIT T LAT CAPIT T +LAT CAPIT T LAT SMALL T +LAT SMALL T LAT CAPIT T +LAT SMALL T LAT SMALL T +LAT CAPIT U LAT CAPIT U +LAT CAPIT U LAT SMALL U +LAT SMALL U LAT CAPIT U +LAT SMALL U LAT SMALL U +LAT CAPIT V LAT CAPIT V +LAT CAPIT V LAT SMALL V +LAT SMALL V LAT CAPIT V +LAT SMALL V LAT SMALL V +LAT CAPIT W LAT CAPIT W +LAT CAPIT W LAT SMALL W +LAT SMALL W LAT CAPIT W +LAT SMALL W LAT SMALL W +LAT CAPIT X LAT CAPIT X +LAT CAPIT X LAT SMALL X +LAT SMALL X LAT CAPIT X +LAT SMALL X LAT SMALL X +LAT CAPIT Y LAT CAPIT Y +LAT CAPIT Y LAT SMALL Y +LAT SMALL Y LAT CAPIT Y +LAT SMALL Y LAT SMALL Y +LAT CAPIT Z LAT CAPIT Z +LAT CAPIT Z LAT SMALL Z +LAT SMALL Z LAT CAPIT Z +LAT SMALL Z LAT SMALL Z +CYR CAPIT A CYR CAPIT A +CYR CAPIT A CYR SMALL A +CYR SMALL A CYR CAPIT A +CYR SMALL A CYR SMALL A +CYR CAPIT BE CYR CAPIT BE +CYR CAPIT BE CYR SMALL BE +CYR SMALL BE CYR CAPIT BE +CYR SMALL BE CYR SMALL BE +CYR CAPIT VE CYR CAPIT VE +CYR CAPIT VE CYR SMALL VE +CYR SMALL VE CYR CAPIT VE +CYR SMALL VE CYR SMALL VE +CYR CAPIT GE CYR CAPIT GE +CYR CAPIT GE CYR SMALL GE +CYR SMALL GE CYR CAPIT GE +CYR SMALL GE CYR SMALL GE +CYR CAPIT DE CYR CAPIT DE +CYR CAPIT DE CYR SMALL DE +CYR SMALL DE CYR CAPIT DE +CYR SMALL DE CYR SMALL DE +CYR CAPIT IE CYR CAPIT IE +CYR CAPIT IE CYR CAPIT IO +CYR CAPIT IE CYR SMALL IE +CYR CAPIT IE CYR SMALL IO +CYR SMALL IE CYR CAPIT IE +CYR SMALL IE CYR CAPIT IO +CYR SMALL IE CYR SMALL IE +CYR SMALL IE CYR SMALL IO +CYR CAPIT IO CYR CAPIT IE +CYR CAPIT IO CYR CAPIT IO +CYR CAPIT IO CYR SMALL IE +CYR CAPIT IO CYR SMALL IO +CYR SMALL IO CYR CAPIT IE +CYR SMALL IO CYR CAPIT IO +CYR SMALL IO CYR SMALL IE +CYR SMALL IO CYR SMALL IO +CYR CAPIT ZHE CYR CAPIT ZHE +CYR CAPIT ZHE CYR SMALL ZHE +CYR SMALL ZHE CYR CAPIT ZHE +CYR SMALL ZHE CYR SMALL ZHE +CYR CAPIT ZE CYR CAPIT ZE +CYR CAPIT ZE CYR SMALL ZE +CYR SMALL ZE CYR CAPIT ZE +CYR SMALL ZE CYR SMALL ZE +CYR CAPIT I CYR CAPIT I +CYR CAPIT I CYR SMALL I +CYR SMALL I CYR CAPIT I +CYR SMALL I CYR SMALL I +CYR CAPIT KA CYR CAPIT KA +CYR CAPIT KA CYR SMALL KA +CYR SMALL KA CYR CAPIT KA +CYR SMALL KA CYR SMALL KA +CYR CAPIT EL CYR CAPIT EL +CYR CAPIT EL CYR SMALL EL +CYR SMALL EL CYR CAPIT EL +CYR SMALL EL CYR SMALL EL +CYR CAPIT EM CYR CAPIT EM +CYR CAPIT EM CYR SMALL EM +CYR SMALL EM CYR CAPIT EM +CYR SMALL EM CYR SMALL EM +CYR CAPIT EN CYR CAPIT EN +CYR CAPIT EN CYR SMALL EN +CYR SMALL EN CYR CAPIT EN +CYR SMALL EN CYR SMALL EN +CYR CAPIT O CYR CAPIT O +CYR CAPIT O CYR SMALL O +CYR SMALL O CYR CAPIT O +CYR SMALL O CYR SMALL O +CYR CAPIT PE CYR CAPIT PE +CYR CAPIT PE CYR SMALL PE +CYR SMALL PE CYR CAPIT PE +CYR SMALL PE CYR SMALL PE +CYR CAPIT ER CYR CAPIT ER +CYR CAPIT ER CYR SMALL ER +CYR SMALL ER CYR CAPIT ER +CYR SMALL ER CYR SMALL ER +CYR CAPIT ES CYR CAPIT ES +CYR CAPIT ES CYR SMALL ES +CYR SMALL ES CYR CAPIT ES +CYR SMALL ES CYR SMALL ES +CYR CAPIT TE CYR CAPIT TE +CYR CAPIT TE CYR SMALL TE +CYR SMALL TE CYR CAPIT TE +CYR SMALL TE CYR SMALL TE +CYR CAPIT U CYR CAPIT U +CYR CAPIT U CYR SMALL U +CYR SMALL U CYR CAPIT U +CYR SMALL U CYR SMALL U +CYR CAPIT EF CYR CAPIT EF +CYR CAPIT EF CYR SMALL EF +CYR SMALL EF CYR CAPIT EF +CYR SMALL EF CYR SMALL EF +CYR CAPIT HA CYR CAPIT HA +CYR CAPIT HA CYR SMALL HA +CYR SMALL HA CYR CAPIT HA +CYR SMALL HA CYR SMALL HA +CYR CAPIT TSE CYR CAPIT TSE +CYR CAPIT TSE CYR SMALL TSE +CYR SMALL TSE CYR CAPIT TSE +CYR SMALL TSE CYR SMALL TSE +CYR CAPIT CHE CYR CAPIT CHE +CYR CAPIT CHE CYR SMALL CHE +CYR SMALL CHE CYR CAPIT CHE +CYR SMALL CHE CYR SMALL CHE +CYR CAPIT SHA CYR CAPIT SHA +CYR CAPIT SHA CYR SMALL SHA +CYR SMALL SHA CYR CAPIT SHA +CYR SMALL SHA CYR SMALL SHA +CYR CAPIT SCHA CYR CAPIT SCHA +CYR CAPIT SCHA CYR SMALL SCHA +CYR SMALL SCHA CYR CAPIT SCHA +CYR SMALL SCHA CYR SMALL SCHA +CYR CAPIT HARD SIGN CYR CAPIT HARD SIGN +CYR CAPIT HARD SIGN CYR SMALL HARD SIGN +CYR SMALL HARD SIGN CYR CAPIT HARD SIGN +CYR SMALL HARD SIGN CYR SMALL HARD SIGN +CYR CAPIT YERU CYR CAPIT YERU +CYR CAPIT YERU CYR SMALL YERU +CYR SMALL YERU CYR CAPIT YERU +CYR SMALL YERU CYR SMALL YERU +CYR CAPIT SOFT SIGN CYR CAPIT SOFT SIGN +CYR CAPIT SOFT SIGN CYR SMALL SOFT SIGN +CYR SMALL SOFT SIGN CYR CAPIT SOFT SIGN +CYR SMALL SOFT SIGN CYR SMALL SOFT SIGN +CYR CAPIT E CYR CAPIT E +CYR CAPIT E CYR SMALL E +CYR SMALL E CYR CAPIT E +CYR SMALL E CYR SMALL E +CYR CAPIT YU CYR CAPIT YU +CYR CAPIT YU CYR SMALL YU +CYR SMALL YU CYR CAPIT YU +CYR SMALL YU CYR SMALL YU +CYR CAPIT YA CYR CAPIT YA +CYR CAPIT YA CYR SMALL YA +CYR SMALL YA CYR CAPIT YA +CYR SMALL YA CYR SMALL YA +SELECT t11.comment,t12.comment +FROM t1 t11,t1 t12 +WHERE t11.koi8_ru_f=CONVERT(t12.utf8_f USING koi8r) +ORDER BY t12.utf8_f,t11.comment,t12.comment; +comment comment +LAT CAPIT A LAT CAPIT A +LAT CAPIT A LAT SMALL A +LAT SMALL A LAT CAPIT A +LAT SMALL A LAT SMALL A +LAT CAPIT B LAT CAPIT B +LAT CAPIT B LAT SMALL B +LAT SMALL B LAT CAPIT B +LAT SMALL B LAT SMALL B +LAT CAPIT C LAT CAPIT C +LAT CAPIT C LAT SMALL C +LAT SMALL C LAT CAPIT C +LAT SMALL C LAT SMALL C +LAT CAPIT D LAT CAPIT D +LAT CAPIT D LAT SMALL D +LAT SMALL D LAT CAPIT D +LAT SMALL D LAT SMALL D +LAT CAPIT E LAT CAPIT E +LAT CAPIT E LAT SMALL E +LAT SMALL E LAT CAPIT E +LAT SMALL E LAT SMALL E +LAT CAPIT F LAT CAPIT F +LAT CAPIT F LAT SMALL F +LAT SMALL F LAT CAPIT F +LAT SMALL F LAT SMALL F +LAT CAPIT G LAT CAPIT G +LAT CAPIT G LAT SMALL G +LAT SMALL G LAT CAPIT G +LAT SMALL G LAT SMALL G +LAT CAPIT H LAT CAPIT H +LAT CAPIT H LAT SMALL H +LAT SMALL H LAT CAPIT H +LAT SMALL H LAT SMALL H +LAT CAPIT I LAT CAPIT I +LAT CAPIT I LAT SMALL I +LAT SMALL I LAT CAPIT I +LAT SMALL I LAT SMALL I +LAT CAPIT J LAT CAPIT J +LAT CAPIT J LAT SMALL J +LAT SMALL J LAT CAPIT J +LAT SMALL J LAT SMALL J +LAT CAPIT K LAT CAPIT K +LAT CAPIT K LAT SMALL K +LAT SMALL K LAT CAPIT K +LAT SMALL K LAT SMALL K +LAT CAPIT L LAT CAPIT L +LAT CAPIT L LAT SMALL L +LAT SMALL L LAT CAPIT L +LAT SMALL L LAT SMALL L +LAT CAPIT M LAT CAPIT M +LAT CAPIT M LAT SMALL M +LAT SMALL M LAT CAPIT M +LAT SMALL M LAT SMALL M +LAT CAPIT N LAT CAPIT N +LAT CAPIT N LAT SMALL N +LAT SMALL N LAT CAPIT N +LAT SMALL N LAT SMALL N +LAT CAPIT O LAT CAPIT O +LAT CAPIT O LAT SMALL O +LAT SMALL O LAT CAPIT O +LAT SMALL O LAT SMALL O +LAT CAPIT P LAT CAPIT P +LAT CAPIT P LAT SMALL P +LAT SMALL P LAT CAPIT P +LAT SMALL P LAT SMALL P +LAT CAPIT Q LAT CAPIT Q +LAT CAPIT Q LAT SMALL Q +LAT SMALL Q LAT CAPIT Q +LAT SMALL Q LAT SMALL Q +LAT CAPIT R LAT CAPIT R +LAT CAPIT R LAT SMALL R +LAT SMALL R LAT CAPIT R +LAT SMALL R LAT SMALL R +LAT CAPIT S LAT CAPIT S +LAT CAPIT S LAT SMALL S +LAT SMALL S LAT CAPIT S +LAT SMALL S LAT SMALL S +LAT CAPIT T LAT CAPIT T +LAT CAPIT T LAT SMALL T +LAT SMALL T LAT CAPIT T +LAT SMALL T LAT SMALL T +LAT CAPIT U LAT CAPIT U +LAT CAPIT U LAT SMALL U +LAT SMALL U LAT CAPIT U +LAT SMALL U LAT SMALL U +LAT CAPIT V LAT CAPIT V +LAT CAPIT V LAT SMALL V +LAT SMALL V LAT CAPIT V +LAT SMALL V LAT SMALL V +LAT CAPIT W LAT CAPIT W +LAT CAPIT W LAT SMALL W +LAT SMALL W LAT CAPIT W +LAT SMALL W LAT SMALL W +LAT CAPIT X LAT CAPIT X +LAT CAPIT X LAT SMALL X +LAT SMALL X LAT CAPIT X +LAT SMALL X LAT SMALL X +LAT CAPIT Y LAT CAPIT Y +LAT CAPIT Y LAT SMALL Y +LAT SMALL Y LAT CAPIT Y +LAT SMALL Y LAT SMALL Y +LAT CAPIT Z LAT CAPIT Z +LAT CAPIT Z LAT SMALL Z +LAT SMALL Z LAT CAPIT Z +LAT SMALL Z LAT SMALL Z +CYR CAPIT A CYR CAPIT A +CYR CAPIT A CYR SMALL A +CYR SMALL A CYR CAPIT A +CYR SMALL A CYR SMALL A +CYR CAPIT BE CYR CAPIT BE +CYR CAPIT BE CYR SMALL BE +CYR SMALL BE CYR CAPIT BE +CYR SMALL BE CYR SMALL BE +CYR CAPIT VE CYR CAPIT VE +CYR CAPIT VE CYR SMALL VE +CYR SMALL VE CYR CAPIT VE +CYR SMALL VE CYR SMALL VE +CYR CAPIT GE CYR CAPIT GE +CYR CAPIT GE CYR SMALL GE +CYR SMALL GE CYR CAPIT GE +CYR SMALL GE CYR SMALL GE +CYR CAPIT DE CYR CAPIT DE +CYR CAPIT DE CYR SMALL DE +CYR SMALL DE CYR CAPIT DE +CYR SMALL DE CYR SMALL DE +CYR CAPIT IE CYR CAPIT IE +CYR CAPIT IE CYR SMALL IE +CYR CAPIT IO CYR CAPIT IO +CYR CAPIT IO CYR SMALL IO +CYR SMALL IE CYR CAPIT IE +CYR SMALL IE CYR SMALL IE +CYR SMALL IO CYR CAPIT IO +CYR SMALL IO CYR SMALL IO +CYR CAPIT ZHE CYR CAPIT ZHE +CYR CAPIT ZHE CYR SMALL ZHE +CYR SMALL ZHE CYR CAPIT ZHE +CYR SMALL ZHE CYR SMALL ZHE +CYR CAPIT ZE CYR CAPIT ZE +CYR CAPIT ZE CYR SMALL ZE +CYR SMALL ZE CYR CAPIT ZE +CYR SMALL ZE CYR SMALL ZE +CYR CAPIT I CYR CAPIT I +CYR CAPIT I CYR SMALL I +CYR SMALL I CYR CAPIT I +CYR SMALL I CYR SMALL I +CYR CAPIT KA CYR CAPIT KA +CYR CAPIT KA CYR SMALL KA +CYR SMALL KA CYR CAPIT KA +CYR SMALL KA CYR SMALL KA +CYR CAPIT EL CYR CAPIT EL +CYR CAPIT EL CYR SMALL EL +CYR SMALL EL CYR CAPIT EL +CYR SMALL EL CYR SMALL EL +CYR CAPIT EM CYR CAPIT EM +CYR CAPIT EM CYR SMALL EM +CYR SMALL EM CYR CAPIT EM +CYR SMALL EM CYR SMALL EM +CYR CAPIT EN CYR CAPIT EN +CYR CAPIT EN CYR SMALL EN +CYR SMALL EN CYR CAPIT EN +CYR SMALL EN CYR SMALL EN +CYR CAPIT O CYR CAPIT O +CYR CAPIT O CYR SMALL O +CYR SMALL O CYR CAPIT O +CYR SMALL O CYR SMALL O +CYR CAPIT PE CYR CAPIT PE +CYR CAPIT PE CYR SMALL PE +CYR SMALL PE CYR CAPIT PE +CYR SMALL PE CYR SMALL PE +CYR CAPIT ER CYR CAPIT ER +CYR CAPIT ER CYR SMALL ER +CYR SMALL ER CYR CAPIT ER +CYR SMALL ER CYR SMALL ER +CYR CAPIT ES CYR CAPIT ES +CYR CAPIT ES CYR SMALL ES +CYR SMALL ES CYR CAPIT ES +CYR SMALL ES CYR SMALL ES +CYR CAPIT TE CYR CAPIT TE +CYR CAPIT TE CYR SMALL TE +CYR SMALL TE CYR CAPIT TE +CYR SMALL TE CYR SMALL TE +CYR CAPIT U CYR CAPIT U +CYR CAPIT U CYR SMALL U +CYR SMALL U CYR CAPIT U +CYR SMALL U CYR SMALL U +CYR CAPIT EF CYR CAPIT EF +CYR CAPIT EF CYR SMALL EF +CYR SMALL EF CYR CAPIT EF +CYR SMALL EF CYR SMALL EF +CYR CAPIT HA CYR CAPIT HA +CYR CAPIT HA CYR SMALL HA +CYR SMALL HA CYR CAPIT HA +CYR SMALL HA CYR SMALL HA +CYR CAPIT TSE CYR CAPIT TSE +CYR CAPIT TSE CYR SMALL TSE +CYR SMALL TSE CYR CAPIT TSE +CYR SMALL TSE CYR SMALL TSE +CYR CAPIT CHE CYR CAPIT CHE +CYR CAPIT CHE CYR SMALL CHE +CYR SMALL CHE CYR CAPIT CHE +CYR SMALL CHE CYR SMALL CHE +CYR CAPIT SHA CYR CAPIT SHA +CYR CAPIT SHA CYR SMALL SHA +CYR SMALL SHA CYR CAPIT SHA +CYR SMALL SHA CYR SMALL SHA +CYR CAPIT SCHA CYR CAPIT SCHA +CYR CAPIT SCHA CYR SMALL SCHA +CYR SMALL SCHA CYR CAPIT SCHA +CYR SMALL SCHA CYR SMALL SCHA +CYR CAPIT HARD SIGN CYR CAPIT HARD SIGN +CYR CAPIT HARD SIGN CYR SMALL HARD SIGN +CYR SMALL HARD SIGN CYR CAPIT HARD SIGN +CYR SMALL HARD SIGN CYR SMALL HARD SIGN +CYR CAPIT YERU CYR CAPIT YERU +CYR CAPIT YERU CYR SMALL YERU +CYR SMALL YERU CYR CAPIT YERU +CYR SMALL YERU CYR SMALL YERU +CYR CAPIT SOFT SIGN CYR CAPIT SOFT SIGN +CYR CAPIT SOFT SIGN CYR SMALL SOFT SIGN +CYR SMALL SOFT SIGN CYR CAPIT SOFT SIGN +CYR SMALL SOFT SIGN CYR SMALL SOFT SIGN +CYR CAPIT E CYR CAPIT E +CYR CAPIT E CYR SMALL E +CYR SMALL E CYR CAPIT E +CYR SMALL E CYR SMALL E +CYR CAPIT YU CYR CAPIT YU +CYR CAPIT YU CYR SMALL YU +CYR SMALL YU CYR CAPIT YU +CYR SMALL YU CYR SMALL YU +CYR CAPIT YA CYR CAPIT YA +CYR CAPIT YA CYR SMALL YA +CYR SMALL YA CYR CAPIT YA +CYR SMALL YA CYR SMALL YA +ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2; +ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL; +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0391,'GREEK CAPIT ALPHA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0392,'GREEK CAPIT BETA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0393,'GREEK CAPIT GAMMA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0394,'GREEK CAPIT DELTA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0395,'GREEK CAPIT EPSILON'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B1,'GREEK SMALL ALPHA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B2,'GREEK SMALL BETA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B3,'GREEK SMALL GAMMA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B4,'GREEK SMALL DELTA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B5,'GREEK SMALL EPSILON'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0531,'ARMENIAN CAPIT AYB'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0532,'ARMENIAN CAPIT BEN'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0533,'ARMENIAN CAPIT GIM'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0534,'ARMENIAN CAPIT DA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0535,'ARMENIAN CAPIT ECH'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0536,'ARMENIAN CAPIT ZA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0561,'ARMENIAN SMALL YAB'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0562,'ARMENIAN SMALL BEN'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0563,'ARMENIAN SMALL GIM'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0564,'ARMENIAN SMALL DA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0565,'ARMENIAN SMALL ECH'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0566,'ARMENIAN SMALL ZA'); +ALTER TABLE t1 ADD armscii8_f CHAR(32) CHARACTER SET armscii8 NOT NULL; +ALTER TABLE t1 ADD greek_f CHAR(32) CHARACTER SET greek NOT NULL; +UPDATE t1 SET greek_f=CONVERT(ucs2_f USING greek) WHERE comment LIKE 'GRE%'; +UPDATE t1 SET armscii8_f=CONVERT(ucs2_f USING armscii8) WHERE comment LIKE 'ARM%'; +UPDATE t1 SET utf8_f=CONVERT(ucs2_f USING utf8) WHERE utf8_f=''; +UPDATE t1 SET ucs2_f=CONVERT(utf8_f USING ucs2) WHERE ucs2_f=''; +SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f; +min(comment) count(*) +LAT CAPIT A 2 +LAT CAPIT B 2 +LAT CAPIT C 2 +LAT CAPIT D 2 +LAT CAPIT E 2 +LAT CAPIT F 2 +LAT CAPIT G 2 +LAT CAPIT H 2 +LAT CAPIT I 2 +LAT CAPIT J 2 +LAT CAPIT K 2 +LAT CAPIT L 2 +LAT CAPIT M 2 +LAT CAPIT N 2 +LAT CAPIT O 2 +LAT CAPIT P 2 +LAT CAPIT Q 2 +LAT CAPIT R 2 +LAT CAPIT S 2 +LAT CAPIT T 2 +LAT CAPIT U 2 +LAT CAPIT V 2 +LAT CAPIT W 2 +LAT CAPIT X 2 +LAT CAPIT Y 2 +LAT CAPIT Z 2 +GREEK CAPIT ALPHA 2 +GREEK CAPIT BETA 2 +GREEK CAPIT GAMMA 2 +GREEK CAPIT DELTA 2 +GREEK CAPIT EPSILON 2 +CYR CAPIT A 2 +CYR CAPIT BE 2 +CYR CAPIT VE 2 +CYR CAPIT GE 2 +CYR CAPIT DE 2 +CYR CAPIT IE 4 +CYR CAPIT ZHE 2 +CYR CAPIT ZE 2 +CYR CAPIT I 2 +CYR CAPIT KA 2 +CYR CAPIT EL 2 +CYR CAPIT EM 2 +CYR CAPIT EN 2 +CYR CAPIT O 2 +CYR CAPIT PE 2 +CYR CAPIT ER 2 +CYR CAPIT ES 2 +CYR CAPIT TE 2 +CYR CAPIT U 2 +CYR CAPIT EF 2 +CYR CAPIT HA 2 +CYR CAPIT TSE 2 +CYR CAPIT CHE 2 +CYR CAPIT SHA 2 +CYR CAPIT SCHA 2 +CYR CAPIT HARD SIGN 2 +CYR CAPIT YERU 2 +CYR CAPIT SOFT SIGN 2 +CYR CAPIT E 2 +CYR CAPIT YU 2 +CYR CAPIT YA 2 +ARMENIAN CAPIT AYB 2 +ARMENIAN CAPIT BEN 2 +ARMENIAN CAPIT GIM 2 +ARMENIAN CAPIT DA 2 +ARMENIAN CAPIT ECH 2 +ARMENIAN CAPIT ZA 2 +DROP TABLE t1; diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result index 9e375203e49..8e4b52a8366 100644 --- a/mysql-test/r/delayed.result +++ b/mysql-test/r/delayed.result @@ -12,9 +12,9 @@ select * from t1 where tmsp=0; a tmsp select * from t1 where tmsp=19711006010203; a tmsp -5 19711006010203 -6 19711006010203 -8 19711006010203 +5 1971-10-06 01:02:03 +6 1971-10-06 01:02:03 +8 1971-10-06 01:02:03 drop table t1; create table t1 (a int not null auto_increment primary key, b char(10)); insert delayed into t1 values (1,"b"); diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index 582ab894233..ee0c3ce1219 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -24,6 +24,14 @@ create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a)); insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); delete from t1 where a=27; drop table t1; +CREATE TABLE `t` ( +`i` int(10) NOT NULL default '0', +`i2` int(10) NOT NULL default '0', +PRIMARY KEY (`i`) +) TYPE=MyISAM CHARSET=latin1; +DELETE FROM t USING t WHERE post='1'; +Unknown column 'post' in 'where clause' +drop table if exists t; CREATE TABLE t1 ( bool char(0) default NULL, not_null varchar(20) binary NOT NULL default '', diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result new file mode 100644 index 00000000000..e335e316170 --- /dev/null +++ b/mysql-test/r/derived.result @@ -0,0 +1,150 @@ +drop table if exists t1,t2,t3; +select * from (select 2 from DUAL) b; +2 +2 +SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b; +Unknown column 'a' in 'field list' +SELECT 1 as a FROM (SELECT a UNION SELECT 1) b; +Unknown column 'a' in 'field list' +CREATE TABLE t1 (a int not null, b char (10) not null); +insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); +CREATE TABLE t2 (a int not null, b char (10) not null); +insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e'); +select t1.a,t3.y from t1,(select a as y from t2 where b='c') as t3 where t1.a = t3.y; +a y +3 3 +3 3 +select t1.a,t3.a from t1,(select * from t2 where b='c') as t3 where t1.a = t3.a; +a a +3 3 +3 3 +CREATE TABLE t3 (a int not null, b char (10) not null); +insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c'); +select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y; +a y +3 3 +3 3 +SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b; +Unknown column 'a' in 'having clause' +SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1; +Column: 'a' in having clause is ambiguous +SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2; +a a +1 2 +SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1; +a a +SELECT 1 FROM (SELECT 1) a WHERE a=2; +Unknown column 'a' in 'where clause' +SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a; +Unknown column 'a' in 'having clause' +select * from t1 as x1, (select * from t1) as x2; +a b a b +1 a 1 a +2 b 1 a +3 c 1 a +3 c 1 a +1 a 2 b +2 b 2 b +3 c 2 b +3 c 2 b +1 a 3 c +2 b 3 c +3 c 3 c +3 c 3 c +1 a 3 c +2 b 3 c +3 c 3 c +3 c 3 c +explain select * from t1 as x1, (select * from t1) as x2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY x1 ALL NULL NULL NULL NULL 4 +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 +2 DERIVED x1 ALL NULL NULL NULL NULL 4 +drop table if exists t2,t3; +select * from (select 1) as a; +1 +1 +select a from (select 1 as a) as b; +a +1 +select 1 from (select 1) as a; +1 +1 +select * from (select * from t1 union select * from t1) a; +a b +1 a +2 b +3 c +select * from (select * from t1 union all select * from t1) a; +a b +1 a +2 b +3 c +3 c +1 a +2 b +3 c +3 c +explain select * from (select * from t1 union select * from t1) a; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 +2 DERIVED t1 ALL NULL NULL NULL NULL 4 +3 UNION t1 ALL NULL NULL NULL NULL 4 +explain select * from (select * from t1 union all select * from t1) a; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 8 +2 DERIVED t1 ALL NULL NULL NULL NULL 4 +3 UNION t1 ALL NULL NULL NULL NULL 4 +CREATE TABLE t2 (a int not null); +insert into t2 values(1); +select * from (select * from t1 where t1.a=(select a from t2 where t2.a=t1.a)) a; +a b +1 a +select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a; +a b +1 a +2 b +3 c +drop table t1, t2; +create table t1(a int not null, t char(8), index(a)); +SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20; +a t +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +16 16 +17 17 +18 18 +19 19 +20 20 +explain select count(*) from t1 as tt1, (select * from t1) as tt2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +2 DERIVED tt1 index NULL a 4 NULL 10000 Using index +drop table t1; +SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b; +(SELECT * FROM (SELECT 1 as a) as a ) +1 +select * from (select 1 as a) b left join (select 2 as a) c using(a); +a a +1 NULL +SELECT * FROM (SELECT 1 UNION SELECT a) b; +Unknown column 'a' in 'field list' +SELECT 1 as a FROM (SELECT a UNION SELECT 1) b; +Unknown column 'a' in 'field list' +SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b; +Unknown column 'a' in 'field list' +select 1 from (select 2) a order by 0; +Unknown column '0' in 'order clause' diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index 5f4f7cced1e..1f459faa8f4 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -172,10 +172,10 @@ b INSERT INTO t2 values (1),(2),(3); INSERT INTO t3 VALUES (1,'1'),(2,'2'),(1,'1'),(2,'2'); explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; -table type possible_keys key key_len ref rows Extra -t3 index a a 5 NULL 6 Using index; Using temporary -t2 index a a 4 NULL 5 Using index; Distinct -t1 eq_ref PRIMARY PRIMARY 4 t2.a 1 Using where; Distinct +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 index a a 5 NULL 6 Using index; Using temporary +1 SIMPLE t2 index a a 4 NULL 5 Using index; Distinct +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 t2.a 1 Using where; Distinct SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; a 1 @@ -188,9 +188,9 @@ insert into t3 select * from t4; insert into t4 select * from t3; insert into t3 select * from t4; explain select distinct t1.a from t1,t3 where t1.a=t3.a; -table type possible_keys key key_len ref rows Extra -t1 index PRIMARY PRIMARY 4 NULL 2 Using index; Using temporary -t3 ref a a 5 t1.a 10 Using where; Using index; Distinct +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index; Using temporary +1 SIMPLE t3 ref a a 5 t1.a 10 Using where; Using index; Distinct select distinct t1.a from t1,t3 where t1.a=t3.a; a 1 @@ -199,29 +199,29 @@ select distinct 1 from t1,t3 where t1.a=t3.a; 1 1 explain SELECT distinct t1.a from t1; -table type possible_keys key key_len ref rows Extra -t1 index NULL PRIMARY 4 NULL 2 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index explain SELECT distinct t1.a from t1 order by a desc; -table type possible_keys key key_len ref rows Extra -t1 index NULL PRIMARY 4 NULL 2 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index explain SELECT t1.a from t1 group by a order by a desc; -table type possible_keys key key_len ref rows Extra -t1 index NULL PRIMARY 4 NULL 2 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index explain SELECT distinct t1.a from t1 order by a desc limit 1; -table type possible_keys key key_len ref rows Extra -t1 index NULL PRIMARY 4 NULL 2 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index explain SELECT distinct a from t3 order by a desc limit 2; -table type possible_keys key key_len ref rows Extra -t3 index NULL a 5 NULL 204 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 index NULL a 5 NULL 204 Using index explain SELECT distinct a,b from t3 order by a+1; -table type possible_keys key key_len ref rows Extra -t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort explain SELECT distinct a,b from t3 order by a limit 10; -table type possible_keys key key_len ref rows Extra -t3 index NULL a 5 NULL 204 Using temporary +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 index NULL a 5 NULL 204 Using temporary explain SELECT a,b from t3 group by a,b order by a+1; -table type possible_keys key key_len ref rows Extra -t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort drop table t1,t2,t3,t4; CREATE TABLE t1 (name varchar(255)); INSERT INTO t1 VALUES ('aa'),('ab'),('ac'),('ad'),('ae'); @@ -298,14 +298,14 @@ on j_lj_t3.id=t3_lj.id WHERE ((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2)) AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2)); -table type possible_keys key key_len ref rows Extra -t1 index id id 4 NULL 2 Using index; Using temporary -t2 index id id 8 NULL 1 Using index; Distinct -t3 index id id 8 NULL 1 Using index; Distinct -j_lj_t2 index id id 4 NULL 2 Using where; Using index; Distinct -t2_lj index id id 8 NULL 1 Using where; Using index; Distinct -j_lj_t3 index id id 4 NULL 2 Using where; Using index; Distinct -t3_lj index id id 8 NULL 1 Using where; Using index; Distinct +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index id id 4 NULL 2 Using index; Using temporary +1 SIMPLE t2 index id id 8 NULL 1 Using index; Distinct +1 SIMPLE t3 index id id 8 NULL 1 Using index; Distinct +1 SIMPLE j_lj_t2 index id id 4 NULL 2 Using where; Using index; Distinct +1 SIMPLE t2_lj index id id 8 NULL 1 Using where; Using index; Distinct +1 SIMPLE j_lj_t3 index id id 4 NULL 2 Using where; Using index; Distinct +1 SIMPLE t3_lj index id id 8 NULL 1 Using where; Using index; Distinct SELECT DISTINCT t1.id from @@ -326,7 +326,6 @@ AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2)); id 2 drop table t1,t2,t3; -drop table if exists t1; create table t1 (a int not null, b int not null, t time); insert into t1 values (1,1,"00:06:15"),(1,2,"00:06:15"),(1,2,"00:30:15"),(1,3,"00:06:15"),(1,3,"00:30:15"); select a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b; @@ -410,7 +409,7 @@ INSERT INTO t2 VALUES (33,6,'Kevin','0','kevin@stileproject.com',1,'',0,'http:// SELECT DISTINCT t1.*, t2.* FROM t1 LEFT JOIN t2 ON (t2.userid = t1.touserid); privatemessageid folderid userid touserid fromuserid title message dateline showsignature iconid messageread readtime receipt deleteprompt multiplerecipients userid usergroupid username password email styleid parentemail coppauser homepage icq aim yahoo signature adminemail showemail invisible usertitle customtitle joindate cookieuser daysprune lastvisit lastactivity lastpost posts timezoneoffset emailnotification buddylist ignorelist pmfolders receivepm emailonpm pmpopup avatarid avatarrevision options birthday maxposts startofweek ipaddress referrerid nosessionhash autorefresh messagepopup inforum ratenum ratetotal allowrate 128 0 33 33 8 :D 996121863 1 0 2 996122850 2 0 0 33 6 Kevin 0 kevin@stileproject.com 1 0 http://www.stileproject.com 1 1 0 Administrator 0 996120694 1 -1 1030996168 1031027028 1030599436 36 -6 0 1 0 1 0 0 15 0000-00-00 -1 1 64.0.0.0 0 1 -1 0 0 4 19 1 -DROP TABLE IF EXISTS t1,t2; +DROP TABLE t1,t2; CREATE TABLE t1 (a int primary key, b int, c int); INSERT t1 VALUES (1,2,3); CREATE TABLE t2 (a int primary key, b int, c int); @@ -418,4 +417,4 @@ INSERT t2 VALUES (3,4,5); SELECT DISTINCT t1.a, t2.b FROM t1, t2 WHERE t1.a=1 ORDER BY t2.c; a b 1 4 -DROP TABLE IF EXISTS t1,t2; +DROP TABLE t1,t2; diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index 178c3a8cb4f..a9048b65d51 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -1,5 +1,4 @@ drop table if exists t1; -drop table if exists t1; drop table t1; Unknown table 't1' create table t1(n int); @@ -13,6 +12,8 @@ select * from t1; n 1 drop database if exists mysqltest; +Warnings: +Note 1008 Can't drop database 'mysqltest'. Database doesn't exist create database mysqltest; drop database if exists mysqltest; create database mysqltest; @@ -25,6 +26,8 @@ drop database if exists mysqltest; create database mysqltest; drop database mysqltest; drop database if exists mysqltest; +Warnings: +Note 1008 Can't drop database 'mysqltest'. Database doesn't exist flush tables with read lock; create database mysqltest; Got one of the listed errors diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result index d433078a251..63e4f4030d3 100644 --- a/mysql-test/r/explain.result +++ b/mysql-test/r/explain.result @@ -1,8 +1,8 @@ drop table if exists t1; create table t1 (id int not null, str char(10), unique(str)); explain select * from t1; -table type possible_keys key key_len ref rows Extra -t1 system NULL NULL NULL NULL 0 const row not found +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found insert into t1 values (1, null),(2, null),(3, "foo"),(4, "bar"); select * from t1 where str is null; id str @@ -12,35 +12,35 @@ select * from t1 where str="foo"; id str 3 foo explain select * from t1 where str is null; -table type possible_keys key key_len ref rows Extra -t1 ref str str 11 const 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref str str 11 const 1 Using where explain select * from t1 where str="foo"; -table type possible_keys key key_len ref rows Extra -t1 const str str 11 const 1 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const str str 11 const 1 explain select * from t1 ignore key (str) where str="foo"; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where explain select * from t1 use key (str,str) where str="foo"; -table type possible_keys key key_len ref rows Extra -t1 const str str 11 const 1 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const str str 11 const 1 explain select * from t1 use key (str,str,foo) where str="foo"; Key column 'foo' doesn't exist in table explain select * from t1 ignore key (str,str,foo) where str="foo"; Key column 'foo' doesn't exist in table drop table t1; explain select 1; -Comment -No tables used +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used create table t1 (a int not null); explain select count(*) from t1; -Comment -Select tables optimized away +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away insert into t1 values(1); explain select count(*) from t1; -Comment -Select tables optimized away +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away insert into t1 values(1); explain select count(*) from t1; -Comment -Select tables optimized away +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away drop table t1; diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result index 7080f2b6145..4e7e4769f1b 100644 --- a/mysql-test/r/flush.result +++ b/mysql-test/r/flush.result @@ -1,6 +1,6 @@ -drop table if exists t1; +drop table if exists t1,t2; +drop database if exists mysqltest; create temporary table t1(n int not null primary key); -drop table if exists t2; create table t2(n int); insert into t2 values(3); select * from t1; @@ -11,7 +11,6 @@ drop table t2; Table 't2' was locked with a READ lock and can't be updated drop table t2; unlock tables; -drop database if exists mysqltest; create database mysqltest; create table mysqltest.t1(n int); insert into mysqltest.t1 values (23); diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index edf109fcc93..c40e9d9bfa2 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -16,6 +16,8 @@ select * from t1 where MATCH(a,b) AGAINST ("indexes collections"); a b Full-text indexes are called collections Only MyISAM tables support collections +select * from t1 where MATCH(a,b) AGAINST ("only"); +a b select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes"); a b Only MyISAM tables support collections @@ -144,7 +146,7 @@ t2 CREATE TABLE `t2` ( `inhalt` text, KEY `tig` (`ticket`), FULLTEXT KEY `tix` (`inhalt`) -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 select * from t2 where MATCH inhalt AGAINST (NULL); ticket inhalt select * from t2 where MATCH inhalt AGAINST ('foobar'); @@ -206,7 +208,6 @@ select 8 from t1; 8 8 drop table t1; -drop table if exists t1; create table t1 (a text, fulltext key (a)); insert into t1 values ('aaaa'); repair table t1; diff --git a/mysql-test/r/fulltext2.result b/mysql-test/r/fulltext2.result new file mode 100644 index 00000000000..8086faadba4 --- /dev/null +++ b/mysql-test/r/fulltext2.result @@ -0,0 +1,871 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +i int(10) unsigned not null auto_increment primary key, +a varchar(255) not null, +FULLTEXT KEY (a) +) TYPE=MyISAM; +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaaxxx'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaazzz'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +insert t1 (a) values ('aaayyy'); +repair table t1 quick; +Table Op Msg_type Msg_text +test.t1 repair status OK +select count(*) from t1 where match a against ('aaaxxx'); +count(*) +260 +select count(*) from t1 where match a against ('aaayyy'); +count(*) +250 +select count(*) from t1 where match a against ('aaazzz'); +count(*) +255 +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +count(*) +260 +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +count(*) +250 +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +count(*) +255 +select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz'); +count(*) +765 +select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode); +count(*) +765 +select count(*) from t1 where match a against ('aaax*' in boolean mode); +count(*) +260 +select count(*) from t1 where match a against ('aaay*' in boolean mode); +count(*) +250 +select count(*) from t1 where match a against ('aaa*' in boolean mode); +count(*) +765 +insert t1 (a) values ('aaaxxx'),('aaayyy'); +insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx'); +count(*) +261 +select count(*) from t1 where match a against ('aaayyy'); +count(*) +251 +select count(*) from t1 where match a against ('aaazzz'); +count(*) +260 +insert t1 (a) values ('aaaxxx 000000'); +select count(*) from t1 where match a against ('000000'); +count(*) +1 +delete from t1 where match a against ('000000'); +select count(*) from t1 where match a against ('000000'); +count(*) +0 +select count(*) from t1 where match a against ('aaaxxx'); +count(*) +261 +delete from t1 where match a against ('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +count(*) +261 +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +count(*) +251 +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +count(*) +0 +select count(*) from t1 where a = 'aaaxxx'; +count(*) +261 +select count(*) from t1 where a = 'aaayyy'; +count(*) +251 +select count(*) from t1 where a = 'aaazzz'; +count(*) +0 +insert t1 (a) values ('aaaxxx 000000'); +select count(*) from t1 where match a against ('000000'); +count(*) +1 +update t1 set a='aaazzz' where match a against ('000000'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +count(*) +261 +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +count(*) +1 +update t1 set a='aaazzz' where a = 'aaaxxx'; +update t1 set a='aaaxxx' where a = 'aaayyy'; +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +count(*) +251 +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +count(*) +0 +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +count(*) +262 +DROP TABLE IF EXISTS t1; diff --git a/mysql-test/r/fulltext_multi.result b/mysql-test/r/fulltext_multi.result index 72b7102fd3f..968b00020e2 100644 --- a/mysql-test/r/fulltext_multi.result +++ b/mysql-test/r/fulltext_multi.result @@ -1,4 +1,3 @@ -use test; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( a int(11) NOT NULL auto_increment, diff --git a/mysql-test/r/fulltext_order_by.result b/mysql-test/r/fulltext_order_by.result index c0e72ff789f..bfee9eba280 100644 --- a/mysql-test/r/fulltext_order_by.result +++ b/mysql-test/r/fulltext_order_by.result @@ -1,4 +1,3 @@ -use test; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( a INT AUTO_INCREMENT PRIMARY KEY, diff --git a/mysql-test/r/func_crypt.result b/mysql-test/r/func_crypt.result index 742de833bf7..461ae1e7e09 100644 --- a/mysql-test/r/func_crypt.result +++ b/mysql-test/r/func_crypt.result @@ -1,9 +1,15 @@ select length(encrypt('foo', 'ff')) <> 0; length(encrypt('foo', 'ff')) <> 0 1 -select old_password('test'), password('test'); -old_password('test') password('test') -378b243e220ca493 378b243e220ca493 -select length(encrypt('test')), encrypt('test','aa'); -length(encrypt('test')) encrypt('test','aa') -13 aaqPiZY5xR5l. +select password("a",""), password("a",NULL), password("","a"), password(NULL,"a"); +password("a","") password("a",NULL) password("","a") password(NULL,"a") +*2517f7235d68d4ba2e5019c93420523101157a792c01 NULL NULL +select password("aaaaaaaaaaaaaaaa","a"), password("a","aaaaaaaaaaaaaaaa"); +password("aaaaaaaaaaaaaaaa","a") password("a","aaaaaaaaaaaaaaaa") +*2cd3b9a44e9a9994789a30f935c92f45a96c5472f381 *37c7c5c794ff144819f2531bf03c57772cd84e40db09 +select old_password('test'), length(password("1")), length(encrypt('test')), encrypt('test','aa'); +old_password('test') length(password("1")) length(encrypt('test')) encrypt('test','aa') +378b243e220ca493 45 13 aaqPiZY5xR5l. +select old_password(""), old_password(NULL), password(""), password(NULL); +old_password("") old_password(NULL) password("") password(NULL) + NULL NULL diff --git a/mysql-test/r/func_date_add.result b/mysql-test/r/func_date_add.result index acdf2c5d7be..234fded9a68 100644 --- a/mysql-test/r/func_date_add.result +++ b/mysql-test/r/func_date_add.result @@ -31,17 +31,17 @@ INSERT INTO t1 VALUES (357917728,7,2,2,20000319145027); select visitor_id,max(ts) as mts from t1 group by visitor_id having mts < DATE_SUB(NOW(),INTERVAL 3 MONTH); visitor_id mts -48985536 20000319013932 -173865424 20000318233615 -357917728 20000319145027 -465931136 20000318160953 -1092858576 20000319013445 +48985536 2000-03-19 01:39:32 +173865424 2000-03-18 23:36:15 +357917728 2000-03-19 14:50:27 +465931136 2000-03-18 16:09:53 +1092858576 2000-03-19 01:34:45 select visitor_id,max(ts) as mts from t1 group by visitor_id having DATE_ADD(mts,INTERVAL 3 MONTH) < NOW(); visitor_id mts -48985536 20000319013932 -173865424 20000318233615 -357917728 20000319145027 -465931136 20000318160953 -1092858576 20000319013445 +48985536 2000-03-19 01:39:32 +173865424 2000-03-18 23:36:15 +357917728 2000-03-19 14:50:27 +465931136 2000-03-18 16:09:53 +1092858576 2000-03-19 01:34:45 drop table t1; diff --git a/mysql-test/r/func_equal.result b/mysql-test/r/func_equal.result index 32a911eedf8..352b76f2744 100644 --- a/mysql-test/r/func_equal.result +++ b/mysql-test/r/func_equal.result @@ -1,3 +1,4 @@ +drop table if exists t1,t2; select 0<=>0,0.0<=>0.0,"A"<=>"A",NULL<=>NULL; 0<=>0 0.0<=>0.0 "A"<=>"A" NULL<=>NULL 1 1 1 1 @@ -10,7 +11,6 @@ select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0; select "A"<=>"B","A"<=>NULL,NULL<=>"A"; "A"<=>"B" "A"<=>NULL NULL<=>"A" 0 0 0 -drop table if exists t1,t2; create table t1 (id int, value int); create table t2 (id int, value int); insert into t1 values (1,null); diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index b129beaac81..b7bf3a5cd80 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -42,21 +42,21 @@ insert into t1 values (null,null,''); select count(distinct a),count(distinct grp) from t1; count(distinct a) count(distinct grp) 6 3 -select sum(all a),count(all a),avg(all a),std(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1; -sum(all a) count(all a) avg(all a) std(all a) bit_or(all a) bit_and(all a) min(all a) max(all a) min(all c) max(all c) -21 6 3.5000 1.7078 7 0 1 6 E -select grp, sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp; -grp sum(a) count(a) avg(a) std(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c) -NULL 0 0 NULL NULL 0 0 NULL NULL -1 1 1 1.0000 0.0000 1 1 1 1 a a -2 5 2 2.5000 0.5000 3 2 2 3 b c -3 15 3 5.0000 0.8165 7 4 4 6 C E -select grp, sum(a)+count(a)+avg(a)+std(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp; +select sum(all a),count(all a),avg(all a),std(all a),variance(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1; +sum(all a) count(all a) avg(all a) std(all a) variance(all a) bit_or(all a) bit_and(all a) min(all a) max(all a) min(all c) max(all c) +21 6 3.5000 1.7078 2.9167 7 0 1 6 E +select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp; +grp sum(a) count(a) avg(a) std(a) variance(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c) +NULL 0 0 NULL NULL NULL 0 0 NULL NULL +1 1 1 1.0000 0.0000 0.0000 1 1 1 1 a a +2 5 2 2.5000 0.5000 0.2500 3 2 2 3 b c +3 15 3 5.0000 0.8165 0.6667 7 4 4 6 C E +select grp, sum(a)+count(a)+avg(a)+std(a)+variance(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp; grp sum NULL NULL 1 7 -2 20 -3 44.816496580928 +2 20.25 +3 45.483163247594 create table t2 (grp int, a bigint unsigned, c char(10)); insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp; replace into t2 select grp, a, c from t1 limit 2,1; @@ -72,14 +72,14 @@ CREATE TABLE t1 (id int(11),value1 float(10,2)); INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00); CREATE TABLE t2 (id int(11),name char(20)); INSERT INTO t2 VALUES (1,'Set One'),(2,'Set Two'); -select id, avg(value1), std(value1) from t1 group by id; -id avg(value1) std(value1) -1 1.000000 0.816497 -2 11.000000 0.816497 -select name, avg(value1), std(value1) from t1, t2 where t1.id = t2.id group by t1.id; -name avg(value1) std(value1) -Set One 1.000000 0.816497 -Set Two 11.000000 0.816497 +select id, avg(value1), std(value1), variance(value1) from t1 group by id; +id avg(value1) std(value1) variance(value1) +1 1.000000 0.816497 0.666667 +2 11.000000 0.816497 0.666667 +select name, avg(value1), std(value1), variance(value1) from t1, t2 where t1.id = t2.id group by t1.id; +name avg(value1) std(value1) variance(value1) +Set One 1.000000 0.816497 0.666667 +Set Two 11.000000 0.816497 0.666667 drop table t1,t2; create table t1 (id int not null); create table t2 (id int not null,rating int null); @@ -173,12 +173,23 @@ select max(t2.a2), max(t1.a1) from t1, t2; max(t2.a2) max(t1.a1) NULL NULL explain select min(a2) from t1; -Comment -Select tables optimized away +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away explain select max(t1.a1), max(t2.a2) from t1, t2; -Comment -No matching min/max row +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row insert into t2 values('AAA', 10, 0.5); +insert into t2 values('BBB', 20, 1.0); +select t1.a1, t1.a2, t2.a1, t2.a2 from t1,t2; +a1 a2 a1 a2 +10 aaa AAA 10 +10 NULL AAA 10 +10 bbb AAA 10 +20 zzz AAA 10 +10 aaa BBB 20 +10 NULL BBB 20 +10 bbb BBB 20 +20 zzz BBB 20 select max(t1.a1), max(t2.a1) from t1, t2 where t2.a2=9; max(t1.a1) max(t2.a1) NULL NULL @@ -188,19 +199,366 @@ NULL NULL select t1.a1, t1.a2, t2.a1, t2.a2 from t1 left outer join t2 on t1.a1=10; a1 a2 a1 a2 10 aaa AAA 10 +10 aaa BBB 20 10 NULL AAA 10 +10 NULL BBB 20 10 bbb AAA 10 +10 bbb BBB 20 20 zzz NULL NULL select max(t1.a2) from t1 left outer join t2 on t1.a1=10; max(t1.a2) zzz -select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=20; -max(t1.a2) -zzz -select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=10; -max(t1.a2) -bbb +select max(t2.a1) from t2 left outer join t1 on t2.a2=10 where t2.a2=20; +max(t2.a1) +BBB +select max(t2.a1) from t2 left outer join t1 on t2.a2=10 where t2.a2=10; +max(t2.a1) +AAA select max(t2.a1) from t1 left outer join t2 on t1.a2=t2.a1 and 1=0 where t2.a1='AAA'; max(t2.a1) NULL +select max(t1.a2),max(t2.a1) from t1 left outer join t2 on t1.a1=10; +max(t1.a2) max(t2.a1) +zzz BBB drop table t1,t2; +create table t1( +a1 char(3) primary key, +a2 smallint, +a3 char(3), +a4 real, +a5 date, +key k1(a2,a3), +key k2(a4 desc,a1), +key k3(a5,a1) +); +create table t2( +a1 char(3) primary key, +a2 char(17), +a3 char(2), +a4 char(3), +key k1(a3, a2), +key k2(a4) +); +insert into t1 values('AME',0,'SEA',0.100,date'1942-02-19'); +insert into t1 values('HBR',1,'SEA',0.085,date'1948-03-05'); +insert into t1 values('BOT',2,'SEA',0.085,date'1951-11-29'); +insert into t1 values('BMC',3,'SEA',0.085,date'1958-09-08'); +insert into t1 values('TWU',0,'LAX',0.080,date'1969-10-05'); +insert into t1 values('BDL',0,'DEN',0.080,date'1960-11-27'); +insert into t1 values('DTX',1,'NYC',0.080,date'1961-05-04'); +insert into t1 values('PLS',1,'WDC',0.075,date'1949-01-02'); +insert into t1 values('ZAJ',2,'CHI',0.075,date'1960-06-15'); +insert into t1 values('VVV',2,'MIN',0.075,date'1959-06-28'); +insert into t1 values('GTM',3,'DAL',0.070,date'1977-09-23'); +insert into t1 values('SSJ',null,'CHI',null,date'1974-03-19'); +insert into t1 values('KKK',3,'ATL',null,null); +insert into t1 values('XXX',null,'MIN',null,null); +insert into t2 values('TKF','Seattle','WA','AME'); +insert into t2 values('LCC','Los Angeles','CA','TWU'); +insert into t2 values('DEN','Denver','CO','BDL'); +insert into t2 values('SDC','San Diego','CA','TWU'); +insert into t2 values('NOL','New Orleans','LA','GTM'); +insert into t2 values('LAK','Los Angeles','CA','TWU'); +select * from t1; +a1 a2 a3 a4 a5 +AME 0 SEA 0.1 1942-02-19 +HBR 1 SEA 0.085 1948-03-05 +BOT 2 SEA 0.085 1951-11-29 +BMC 3 SEA 0.085 1958-09-08 +TWU 0 LAX 0.08 1969-10-05 +BDL 0 DEN 0.08 1960-11-27 +DTX 1 NYC 0.08 1961-05-04 +PLS 1 WDC 0.075 1949-01-02 +ZAJ 2 CHI 0.075 1960-06-15 +VVV 2 MIN 0.075 1959-06-28 +GTM 3 DAL 0.07 1977-09-23 +SSJ NULL CHI NULL 1974-03-19 +KKK 3 ATL NULL NULL +XXX NULL MIN NULL NULL +select * from t2; +a1 a2 a3 a4 +TKF Seattle WA AME +LCC Los Angeles CA TWU +DEN Denver CO BDL +SDC San Diego CA TWU +NOL New Orleans LA GTM +LAK Los Angeles CA TWU +explain +select min(a1) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(a1) from t1; +min(a1) +AME +explain +select max(a4) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select max(a4) from t1; +max(a4) +0.1 +explain +select min(a5), max(a5) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(a5), max(a5) from t1; +min(a5) max(a5) +1942-02-19 1977-09-23 +explain +select min(a3) from t1 where a2 = 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(a3) from t1 where a2 = 2; +min(a3) +CHI +explain +select min(a1), max(a1) from t1 where a4 = 0.080; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(a1), max(a1) from t1 where a4 = 0.080; +min(a1) max(a1) +BDL TWU +explain +select min(t1.a5), max(t2.a3) from t1, t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(t1.a5), max(t2.a3) from t1, t2; +min(t1.a5) max(t2.a3) +1942-02-19 WA +explain +select min(t1.a3), max(t2.a2) from t1, t2 where t1.a2 = 0 and t2.a3 = 'CA'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(t1.a3), max(t2.a2) from t1, t2 where t1.a2 = 0 and t2.a3 = 'CA'; +min(t1.a3) max(t2.a2) +DEN San Diego +explain +select min(a1) from t1 where a1 > 'KKK'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(a1) from t1 where a1 > 'KKK'; +min(a1) +PLS +explain +select min(a1) from t1 where a1 >= 'KKK'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(a1) from t1 where a1 >= 'KKK'; +min(a1) +KKK +explain +select max(a3) from t1 where a2 = 2 and a3 < 'SEA'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select max(a3) from t1 where a2 = 2 and a3 < 'SEA'; +max(a3) +MIN +explain +select max(a5) from t1 where a5 < date'1970-01-01'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select max(a5) from t1 where a5 < date'1970-01-01'; +max(a5) +1969-10-05 +explain +select max(a3) from t1 where a2 is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select max(a3) from t1 where a2 is null; +max(a3) +MIN +explain +select max(a3) from t1 where a2 = 0 and a3 between 'K' and 'Q'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select max(a3) from t1 where a2 = 0 and a3 between 'K' and 'Q'; +max(a3) +LAX +explain +select min(a1), max(a1) from t1 where a1 between 'A' and 'P'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(a1), max(a1) from t1 where a1 between 'A' and 'P'; +min(a1) max(a1) +AME KKK +explain +select max(a3) from t1 where a3 < 'SEA' and a2 = 2 and a3 <= 'MIN'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select max(a3) from t1 where a3 < 'SEA' and a2 = 2 and a3 <= 'MIN'; +max(a3) +MIN +explain +select max(a3) from t1 where a3 = 'MIN' and a2 = 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select max(a3) from t1 where a3 = 'MIN' and a2 = 2; +max(a3) +MIN +explain +select max(a3) from t1 where a3 = 'DEN' and a2 = 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row +select max(a3) from t1 where a3 = 'DEN' and a2 = 2; +max(a3) +NULL +explain +select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 = 'CA'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 = 'CA'; +max(t1.a3) min(t2.a2) +CHI Los Angeles +explain +select max(a3) from t1 where a2 is null and a2 = 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +select max(a3) from t1 where a2 is null and a2 = 2; +max(a3) +NULL +explain +select max(a2) from t1 where a2 >= 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select max(a2) from t1 where a2 >= 1; +max(a2) +3 +explain +select min(a3) from t1 where a2 = 2 and a3 < 'SEA'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(a3) from t1 where a2 = 2 and a3 < 'SEA'; +min(a3) +CHI +explain +select min(a3) from t1 where a2 = 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row +select min(a3) from t1 where a2 = 4; +min(a3) +NULL +explain +select min(a3) from t1 where a2 = 2 and a3 > 'SEA'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row +select min(a3) from t1 where a2 = 2 and a3 > 'SEA'; +min(a3) +NULL +explain +select (min(a4)+max(a4))/2 from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select (min(a4)+max(a4))/2 from t1; +(min(a4)+max(a4))/2 +0.085 +explain +select min(a3) from t1 where 2 = a2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(a3) from t1 where 2 = a2; +min(a3) +CHI +explain +select max(a3) from t1 where a2 = 2 and 'SEA' > a3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select max(a3) from t1 where a2 = 2 and 'SEA' > a3; +max(a3) +MIN +explain +select max(a3) from t1 where a2 = 2 and 'SEA' < a3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row +select max(a3) from t1 where a2 = 2 and 'SEA' < a3; +max(a3) +NULL +explain +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI'; +min(a3) +CHI +explain +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 < 'SEA'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 < 'SEA'; +min(a3) +CHI +explain +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 = 'MIN'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 = 'MIN'; +min(a3) +MIN +explain +select min(a3) from t1 where a2 = 2 and a3 >= 'SEA' and a3 = 'MIN'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +select min(a3) from t1 where a2 = 2 and a3 >= 'SEA' and a3 = 'MIN'; +min(a3) +NULL +explain +select min(t1.a1), min(t2.a4) from t1,t2 where t1.a1 < 'KKK' and t2.a4 < 'KKK'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(t1.a1), min(t2.a4) from t1,t2 where t1.a1 < 'KKK' and t2.a4 < 'KKK'; +min(t1.a1) min(t2.a4) +AME AME +explain +select min(a1) from t1 where a1 > 'KKK' or a1 < 'XXX'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 0 NULL 15 Using where; Using index +explain +select min(a1) from t1 where a1 != 'KKK'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 3 NULL 14 Using where; Using index +explain +select max(a3) from t1 where a2 < 2 and a3 < 'SEA'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range k1 k1 3 NULL 5 Using where; Using index +explain +select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 > 'CA'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range k1 k1 7 NULL 1 Using where; Using index +1 SIMPLE t2 range k1 k1 3 NULL 4 Using where; Using index +explain +select min(a4 - 0.01) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL k2 12 NULL 14 Using index +explain +select max(a4 + 0.01) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL k2 12 NULL 14 Using index +explain +select min(a3) from t1 where (a2 +1 ) is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL k1 7 NULL 14 Using where; Using index +explain +select min(a3) from t1 where (a2 + 1) = 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL k1 7 NULL 14 Using where; Using index +explain +select min(a3) from t1 where 2 = (a2 + 1); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL k1 7 NULL 14 Using where; Using index +explain +select min(a2) from t1 where a2 < 2 * a2 - 8; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL k1 7 NULL 14 Using where; Using index +explain +select min(a1) from t1 where a1 between a3 and 'KKK'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 14 Using where +explain +select min(a4) from t1 where (a4 + 0.01) between 0.07 and 0.08; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL k2 12 NULL 14 Using where; Using index +explain +select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 3 NULL 14 Using index +1 SIMPLE t2 index NULL k2 4 NULL 6 Using where; Using index +drop table if exists t1, t2; diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index ba33ee0831d..006dc8abef0 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -1,11 +1,95 @@ drop table if exists t1; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; CREATE TABLE t1 (field char(1)); INSERT INTO t1 VALUES ('A'),(NULL); SELECT * from t1 WHERE field IN (NULL); field SELECT * from t1 WHERE field NOT IN (NULL); field -A SELECT * from t1 where field = field; field A @@ -16,6 +100,7 @@ NULL DELETE FROM t1 WHERE field NOT IN (NULL); SELECT * FROM t1; field +A NULL drop table t1; create table t1 (id int(10) primary key); diff --git a/mysql-test/r/func_set.result b/mysql-test/r/func_set.result index 5305c16c5d9..ab72e42eca9 100644 --- a/mysql-test/r/func_set.result +++ b/mysql-test/r/func_set.result @@ -25,3 +25,20 @@ find_in_set("","a,b,c") find_in_set("","a,b,c,") find_in_set("",",a,b,c") select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc"); find_in_set("abc","abc") find_in_set("ab","abc") find_in_set("abcd","abc") 1 0 0 +drop table if exists t1,t2; +create table t1 (id int(10) not null unique); +create table t2 (id int(10) not null primary key, +val int(10) not null); +insert into t1 values (1),(2),(4); +insert into t2 values (1,1),(2,1),(3,1),(4,2); +select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id; +id elt(two.val,'one','two') +1 one +2 one +4 two +select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id; +id elt(two.val,'one','two') +1 one +2 one +4 two +drop table t1,t2; diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 9e8f2b90f07..b3468586f32 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -80,6 +80,21 @@ this is a REAL test select soundex(''),soundex('he'),soundex('hello all folks'); soundex('') soundex('he') soundex('hello all folks') H000 H4142 +select 'mood' sounds like 'mud'; +'mood' sounds like 'mud' +1 +select 'Glazgo' sounds like 'Liverpool'; +'Glazgo' sounds like 'Liverpool' +0 +select null sounds like 'null'; +null sounds like 'null' +NULL +select 'null' sounds like null; +'null' sounds like null +NULL +select null sounds like null; +null sounds like null +NULL select md5('hello'); md5('hello') 5d41402abc4b2a76b9719d911017c592 @@ -216,14 +231,14 @@ bugstatus int(10) unsigned default NULL, submitter int(10) unsigned default NULL ) TYPE=MyISAM; INSERT INTO t1 VALUES (1,'Link',1,1,1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','2001-02-28 08:40:16',20010228084016,0,4); -SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter), '"') FROM t1; -CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter), '"') +SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"') FROM t1; +CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"') "Link";"1";"1";"1";"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"2001-02-28 08:40:16";"20010228084016";"0";"4" SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"') FROM t1; CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"') "Link";"1";"1";"1";"0";"4" -SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter) FROM t1; -CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter) +SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter) FROM t1; +CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter) Link";"1";"1";"1";"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"2001-02-28 08:40:16";"20010228084016";"0";"4 drop table t1; CREATE TABLE t1 (id int(11) NOT NULL auto_increment, tmp text NOT NULL, KEY id (id)) TYPE=MyISAM; diff --git a/mysql-test/r/func_system.result b/mysql-test/r/func_system.result index 5ea4ed5e4e0..83c2ad6e020 100644 --- a/mysql-test/r/func_system.result +++ b/mysql-test/r/func_system.result @@ -4,3 +4,6 @@ test 1 select version()>="3.23.29"; version()>="3.23.29" 1 +select TRUE,FALSE,NULL; +TRUE FALSE NULL +1 0 NULL diff --git a/mysql-test/r/func_test.result b/mysql-test/r/func_test.result index 8cfae44b9dd..9fcf03db838 100644 --- a/mysql-test/r/func_test.result +++ b/mysql-test/r/func_test.result @@ -46,6 +46,9 @@ select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1; select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL; 1 XOR 1 1 XOR 0 0 XOR 1 0 XOR 0 NULL XOR 1 1 XOR NULL 0 XOR NULL 0 1 1 0 NULL NULL NULL +select 10 % 7, 10 mod 7, 10 div 3; +10 % 7 10 mod 7 10 div 3 +3 3 3 select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1; 5 between 0 and 10 between 0 and 1 (5 between 0 and 10) between 0 and 1 0 1 diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 2941352c776..38fe97a79a6 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -96,6 +96,11 @@ week(19981231,2) week(19981231,3) week(20000101,2) week(20000101,3) select week(20001231,2),week(20001231,3); week(20001231,2) week(20001231,3) 1 52 +set default_week_format = 2; +select week(20001231),week(20001231,2),week(20001231,0); +week(20001231) week(20001231,2) week(20001231,0) +1 1 53 +set default_week_format = 0; select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v'); date_format('1998-12-31','%x-%v') date_format('1999-01-01','%x-%v') 1998-53 1998-53 @@ -392,11 +397,71 @@ CREATE TABLE t3 (ctime1 char(19) NOT NULL, ctime2 char(19) NOT NULL); INSERT INTO t3 VALUES ("2002-10-29 16:51:06","2002-11-05 16:47:31"); select * from t1, t2 where t1.start between t2.ctime1 and t2.ctime2; start ctime1 ctime2 -2002-11-04 00:00:00 20021029165106 20021105164731 +2002-11-04 00:00:00 2002-10-29 16:51:06 2002-11-05 16:47:31 select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2; start ctime1 ctime2 -2002-11-04 00:00:00 20021029165106 20021105164731 +2002-11-04 00:00:00 2002-10-29 16:51:06 2002-11-05 16:47:31 select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2; start ctime1 ctime2 2002-11-04 00:00:00 2002-10-29 16:51:06 2002-11-05 16:47:31 drop table t1,t2,t3; +CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time); +INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08"); +SELECT * from t1; +datetime timestamp date time +2001-01-02 03:04:05 2002-01-02 03:04:05 2003-01-02 06:07:08 +select date_add("1997-12-31",INTERVAL 1 SECOND); +date_add("1997-12-31",INTERVAL 1 SECOND) +1997-12-31 00:00:01 +select date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH); +date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH) +1999-01-31 +select date_add(datetime, INTERVAL 1 SECOND) from t1; +date_add(datetime, INTERVAL 1 SECOND) +2001-01-02 03:04:06 +select date_add(datetime, INTERVAL 1 YEAR) from t1; +date_add(datetime, INTERVAL 1 YEAR) +2002-01-02 03:04:05 +select date_add(date,INTERVAL 1 SECOND) from t1; +date_add(date,INTERVAL 1 SECOND) +2003-01-02 00:00:01 +select date_add(date,INTERVAL 1 MINUTE) from t1; +date_add(date,INTERVAL 1 MINUTE) +2003-01-02 00:01:00 +select date_add(date,INTERVAL 1 HOUR) from t1; +date_add(date,INTERVAL 1 HOUR) +2003-01-02 01:00:00 +select date_add(date,INTERVAL 1 DAY) from t1; +date_add(date,INTERVAL 1 DAY) +2003-01-03 +select date_add(date,INTERVAL 1 MONTH) from t1; +date_add(date,INTERVAL 1 MONTH) +2003-02-02 +select date_add(date,INTERVAL 1 YEAR) from t1; +date_add(date,INTERVAL 1 YEAR) +2004-01-02 +select date_add(date,INTERVAL "1:1" MINUTE_SECOND) from t1; +date_add(date,INTERVAL "1:1" MINUTE_SECOND) +2003-01-02 00:01:01 +select date_add(date,INTERVAL "1:1" HOUR_MINUTE) from t1; +date_add(date,INTERVAL "1:1" HOUR_MINUTE) +2003-01-02 01:01:00 +select date_add(date,INTERVAL "1:1" DAY_HOUR) from t1; +date_add(date,INTERVAL "1:1" DAY_HOUR) +2003-01-03 01:00:00 +select date_add(date,INTERVAL "1 1" YEAR_MONTH) from t1; +date_add(date,INTERVAL "1 1" YEAR_MONTH) +2004-02-02 +select date_add(date,INTERVAL "1:1:1" HOUR_SECOND) from t1; +date_add(date,INTERVAL "1:1:1" HOUR_SECOND) +2003-01-02 01:01:01 +select date_add(date,INTERVAL "1 1:1" DAY_MINUTE) from t1; +date_add(date,INTERVAL "1 1:1" DAY_MINUTE) +2003-01-03 01:01:00 +select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1; +date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) +2003-01-03 01:01:01 +select date_add(time,INTERVAL 1 SECOND) from t1; +date_add(time,INTERVAL 1 SECOND) +2006-07-08 00:00:01 +drop table t1; diff --git a/mysql-test/r/gcc296.result b/mysql-test/r/gcc296.result index 8f78f70cc1f..628bbbf3f93 100644 --- a/mysql-test/r/gcc296.result +++ b/mysql-test/r/gcc296.result @@ -1,5 +1,5 @@ -drop table if exists obory; -CREATE TABLE obory ( +drop table if exists t1; +CREATE TABLE t1 ( kodoboru varchar(10) default NULL, obor tinytext, aobor tinytext, @@ -7,14 +7,14 @@ UNIQUE INDEX kodoboru (kodoboru), FULLTEXT KEY obor (obor), FULLTEXT KEY aobor (aobor) ); -INSERT INTO obory VALUES ('0101000000','aaa','AAA'); -INSERT INTO obory VALUES ('0102000000','bbb','BBB'); -INSERT INTO obory VALUES ('0103000000','ccc','CCC'); -INSERT INTO obory VALUES ('0104000000','xxx','XXX'); -select * from obory; +INSERT INTO t1 VALUES ('0101000000','aaa','AAA'); +INSERT INTO t1 VALUES ('0102000000','bbb','BBB'); +INSERT INTO t1 VALUES ('0103000000','ccc','CCC'); +INSERT INTO t1 VALUES ('0104000000','xxx','XXX'); +select * from t1; kodoboru obor aobor 0101000000 aaa AAA 0102000000 bbb BBB 0103000000 ccc CCC 0104000000 xxx XXX -drop table obory; +drop table t1; diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result new file mode 100644 index 00000000000..25c3d14212b --- /dev/null +++ b/mysql-test/r/gis.result @@ -0,0 +1,325 @@ +DROP TABLE IF EXISTS pt, ls, p, mpt, mls, mp, gc, geo; +CREATE TABLE pt (fid INTEGER NOT NULL PRIMARY KEY, g POINT); +CREATE TABLE ls (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING); +CREATE TABLE p (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON); +CREATE TABLE mpt (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOINT); +CREATE TABLE mls (fid INTEGER NOT NULL PRIMARY KEY, g MULTILINESTRING); +CREATE TABLE mp (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOLYGON); +CREATE TABLE gc (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRYCOLLECTION); +CREATE TABLE geo (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY); +INSERT INTO pt VALUES +(101, PointFromText('POINT(10 10)')), +(102, PointFromText('POINT(20 10)')), +(103, PointFromText('POINT(20 20)')), +(104, PointFromText('POINT(10 20)')); +INSERT INTO ls VALUES +(105, LineFromText('LINESTRING(0 0,0 10,10 0)')), +(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')), +(107, LineString(Point(10, 10), Point(40, 10))); +INSERT INTO p VALUES +(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')), +(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')), +(110, Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))); +INSERT INTO mpt VALUES +(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')), +(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')), +(113, MultiPoint(Point(3, 6), Point(4, 10))); +INSERT INTO mls VALUES +(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')), +(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')), +(116, MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))); +INSERT INTO mp VALUES +(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')), +(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')), +(119, MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))); +INSERT INTO gc VALUES +(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')), +(121, GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))); +INSERT into geo SELECT * FROM pt; +INSERT into geo SELECT * FROM ls; +INSERT into geo SELECT * FROM p; +INSERT into geo SELECT * FROM mpt; +INSERT into geo SELECT * FROM mls; +INSERT into geo SELECT * FROM mp; +INSERT into geo SELECT * FROM gc; +SELECT fid, AsText(g) FROM pt; +fid AsText(g) +101 POINT(10 10) +102 POINT(20 10) +103 POINT(20 20) +104 POINT(10 20) +SELECT fid, AsText(g) FROM ls; +fid AsText(g) +105 LINESTRING(0 0,0 10,10 0) +106 LINESTRING(10 10,20 10,20 20,10 20,10 10) +107 LINESTRING(10 10,40 10) +SELECT fid, AsText(g) FROM p; +fid AsText(g) +108 POLYGON((10 10,20 10,20 20,10 20,10 10)) +109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10)) +110 POLYGON((0 0,30 0,30 30,0 0)) +SELECT fid, AsText(g) FROM mpt; +fid AsText(g) +111 MULTIPOINT(0 0,10 10,10 20,20 20) +112 MULTIPOINT(1 1,11 11,11 21,21 21) +113 MULTIPOINT(3 6,4 10) +SELECT fid, AsText(g) FROM mls; +fid AsText(g) +114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48)) +115 MULTILINESTRING((10 48,10 21,10 0)) +116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7)) +SELECT fid, AsText(g) FROM mp; +fid AsText(g) +117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18))) +118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18))) +119 MULTIPOLYGON(((0 3,3 3,3 0,0 3))) +SELECT fid, AsText(g) FROM gc; +fid AsText(g) +120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10)) +121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9)) +SELECT fid, AsText(g) FROM geo; +fid AsText(g) +101 POINT(10 10) +102 POINT(20 10) +103 POINT(20 20) +104 POINT(10 20) +105 LINESTRING(0 0,0 10,10 0) +106 LINESTRING(10 10,20 10,20 20,10 20,10 10) +107 LINESTRING(10 10,40 10) +108 POLYGON((10 10,20 10,20 20,10 20,10 10)) +109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10)) +110 POLYGON((0 0,30 0,30 30,0 0)) +111 MULTIPOINT(0 0,10 10,10 20,20 20) +112 MULTIPOINT(1 1,11 11,11 21,21 21) +113 MULTIPOINT(3 6,4 10) +114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48)) +115 MULTILINESTRING((10 48,10 21,10 0)) +116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7)) +117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18))) +118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18))) +119 MULTIPOLYGON(((0 3,3 3,3 0,0 3))) +120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10)) +121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9)) +SELECT fid, Dimension(g) FROM geo; +fid Dimension(g) +101 0 +102 0 +103 0 +104 0 +105 1 +106 1 +107 1 +108 2 +109 2 +110 2 +111 0 +112 0 +113 0 +114 1 +115 1 +116 1 +117 2 +118 2 +119 2 +120 1 +121 1 +SELECT fid, GeometryType(g) FROM geo; +fid GeometryType(g) +101 POINT +102 POINT +103 POINT +104 POINT +105 LINESTRING +106 LINESTRING +107 LINESTRING +108 POLYGON +109 POLYGON +110 POLYGON +111 MULTIPOINT +112 MULTIPOINT +113 MULTIPOINT +114 MULTILINESTRING +115 MULTILINESTRING +116 MULTILINESTRING +117 MULTIPOLYGON +118 MULTIPOLYGON +119 MULTIPOLYGON +120 GEOMETRYCOLLECTION +121 GEOMETRYCOLLECTION +SELECT fid, IsEmpty(g) FROM geo; +fid IsEmpty(g) +101 0 +102 0 +103 0 +104 0 +105 0 +106 0 +107 0 +108 0 +109 0 +110 0 +111 0 +112 0 +113 0 +114 0 +115 0 +116 0 +117 0 +118 0 +119 0 +120 0 +121 0 +SELECT fid, AsText(Envelope(g)) FROM geo; +fid AsText(Envelope(g)) +101 POLYGON((10 10,10 10,10 10,10 10,10 10)) +102 POLYGON((20 10,20 10,20 10,20 10,20 10)) +103 POLYGON((20 20,20 20,20 20,20 20,20 20)) +104 POLYGON((10 20,10 20,10 20,10 20,10 20)) +105 POLYGON((0 0,10 0,10 10,0 10,0 0)) +106 POLYGON((10 10,20 10,20 20,10 20,10 10)) +107 POLYGON((10 10,40 10,40 10,10 10,10 10)) +108 POLYGON((10 10,20 10,20 20,10 20,10 10)) +109 POLYGON((0 0,50 0,50 50,0 50,0 0)) +110 POLYGON((0 0,30 0,30 30,0 30,0 0)) +111 POLYGON((0 0,20 0,20 20,0 20,0 0)) +112 POLYGON((1 1,21 1,21 21,1 21,1 1)) +113 POLYGON((3 6,4 6,4 10,3 10,3 6)) +114 POLYGON((10 0,16 0,16 48,10 48,10 0)) +115 POLYGON((10 0,10 0,10 48,10 48,10 0)) +116 POLYGON((1 2,21 2,21 8,1 8,1 2)) +117 POLYGON((28 0,84 0,84 42,28 42,28 0)) +118 POLYGON((28 0,84 0,84 42,28 42,28 0)) +119 POLYGON((0 0,3 0,3 3,0 3,0 0)) +120 POLYGON((0 0,10 0,10 10,0 10,0 0)) +121 POLYGON((3 6,44 6,44 9,3 9,3 6)) +SELECT fid, X(g) FROM pt; +fid X(g) +101 10 +102 20 +103 20 +104 10 +SELECT fid, Y(g) FROM pt; +fid Y(g) +101 10 +102 10 +103 20 +104 20 +SELECT fid, AsText(StartPoint(g)) FROM ls; +fid AsText(StartPoint(g)) +105 POINT(0 0) +106 POINT(10 10) +107 POINT(10 10) +SELECT fid, AsText(EndPoint(g)) FROM ls; +fid AsText(EndPoint(g)) +105 POINT(10 0) +106 POINT(10 10) +107 POINT(40 10) +SELECT fid, GLength(g) FROM ls; +fid GLength(g) +105 24.142135623731 +106 40 +107 30 +SELECT fid, NumPoints(g) FROM ls; +fid NumPoints(g) +105 3 +106 5 +107 2 +SELECT fid, AsText(PointN(g, 2)) FROM ls; +fid AsText(PointN(g, 2)) +105 POINT(0 10) +106 POINT(20 10) +107 POINT(40 10) +SELECT fid, IsClosed(g) FROM ls; +fid IsClosed(g) +105 0 +106 1 +107 0 +SELECT fid, AsText(Centroid(g)) FROM p; +fid AsText(Centroid(g)) +108 POINT(15 15) +109 POINT(25.416666666667 25.416666666667) +110 POINT(20 10) +SELECT fid, Area(g) FROM p; +fid Area(g) +108 100 +109 2400 +110 450 +SELECT fid, AsText(ExteriorRing(g)) FROM p; +fid AsText(ExteriorRing(g)) +108 LINESTRING(10 10,20 10,20 20,10 20,10 10) +109 LINESTRING(0 0,50 0,50 50,0 50,0 0) +110 LINESTRING(0 0,30 0,30 30,0 0) +SELECT fid, NumInteriorRings(g) FROM p; +fid NumInteriorRings(g) +108 0 +109 1 +110 0 +SELECT fid, AsText(InteriorRingN(g, 1)) FROM p; +fid AsText(InteriorRingN(g, 1)) +108 NULL +109 LINESTRING(10 10,20 10,20 20,10 20,10 10) +110 NULL +SELECT fid, IsClosed(g) FROM mls; +fid IsClosed(g) +114 0 +115 0 +116 0 +SELECT fid, AsText(Centroid(g)) FROM mp; +fid AsText(Centroid(g)) +117 POINT(55.588527753042 17.426536064114) +118 POINT(55.588527753042 17.426536064114) +119 POINT(2 2) +SELECT fid, Area(g) FROM mp; +fid Area(g) +117 1684.5 +118 1684.5 +119 4.5 +SELECT fid, NumGeometries(g) from mpt; +fid NumGeometries(g) +111 4 +112 4 +113 2 +SELECT fid, NumGeometries(g) from mls; +fid NumGeometries(g) +114 2 +115 1 +116 2 +SELECT fid, NumGeometries(g) from mp; +fid NumGeometries(g) +117 2 +118 2 +119 1 +SELECT fid, NumGeometries(g) from gc; +fid NumGeometries(g) +120 2 +121 2 +SELECT fid, AsText(GeometryN(g, 2)) from mpt; +fid AsText(GeometryN(g, 2)) +111 POINT(10 10) +112 POINT(11 11) +113 POINT(4 10) +SELECT fid, AsText(GeometryN(g, 2)) from mls; +fid AsText(GeometryN(g, 2)) +114 LINESTRING(16 0,16 23,16 48) +115 NULL +116 LINESTRING(2 5,5 8,21 7) +SELECT fid, AsText(GeometryN(g, 2)) from mp; +fid AsText(GeometryN(g, 2)) +117 POLYGON((59 18,67 18,67 13,59 13,59 18)) +118 POLYGON((59 18,67 18,67 13,59 13,59 18)) +119 NULL +SELECT fid, AsText(GeometryN(g, 2)) from gc; +fid AsText(GeometryN(g, 2)) +120 LINESTRING(0 0,10 10) +121 LINESTRING(3 6,7 9) +SELECT g1.fid as first, g2.fid as second, +Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o, +Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t, +Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r +FROM gc g1, gc g2 ORDER BY first, second; +first second w c o e d t i r +120 120 1 1 0 1 0 0 1 0 +120 121 0 0 0 0 0 0 1 0 +121 120 0 0 1 0 0 0 1 0 +121 121 1 1 0 1 0 0 1 0 +DROP TABLE pt, ls, p, mpt, mls, mp, gc, geo; diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 91f33e0cd9f..d13f31d6bef 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1,4 +1,6 @@ drop table if exists t1,t2,t3; +SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1); +Invalid use of group function CREATE TABLE t1 ( spID int(10) unsigned, userID int(10) unsigned, @@ -49,7 +51,7 @@ SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1 userid MIN(t1.score+0.0) 1 1.0 2 2.0 -drop table test.t1,test.t2; +drop table t1,t2; CREATE TABLE t1 ( PID int(10) unsigned DEFAULT '0' NOT NULL auto_increment, payDate date DEFAULT '0000-00-00' NOT NULL, @@ -244,11 +246,11 @@ key (score) ); INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3); explain select userid,count(*) from t1 group by userid desc; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort explain select userid,count(*) from t1 group by userid desc order by null; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 6 Using temporary +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary select userid,count(*) from t1 group by userid desc; userid count(*) 3 3 @@ -262,14 +264,14 @@ select userid,count(*) from t1 group by userid desc having 3 IN (1,COUNT(*)); userid count(*) 3 3 explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc; -table type possible_keys key key_len ref rows Extra -t1 range spID spID 5 NULL 2 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range spID spID 5 NULL 2 Using where; Using index explain select spid,count(*) from t1 where spid between 1 and 2 group by spid; -table type possible_keys key key_len ref rows Extra -t1 range spID spID 5 NULL 2 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range spID spID 5 NULL 2 Using where; Using index explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null; -table type possible_keys key key_len ref rows Extra -t1 range spID spID 5 NULL 2 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range spID spID 5 NULL 2 Using where; Using index select spid,count(*) from t1 where spid between 1 and 2 group by spid; spid count(*) 1 1 @@ -279,11 +281,11 @@ spid count(*) 2 2 1 1 explain select sql_big_result spid,sum(userid) from t1 group by spid desc; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 6 Using filesort +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort explain select sql_big_result spid,sum(userid) from t1 group by spid desc order by null; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 6 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 select sql_big_result spid,sum(userid) from t1 group by spid desc; spid sum(userid) 5 3 @@ -292,11 +294,11 @@ spid sum(userid) 2 3 1 1 explain select sql_big_result score,count(*) from t1 group by score desc; -table type possible_keys key key_len ref rows Extra -t1 index NULL score 3 NULL 6 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL score 3 NULL 6 Using index explain select sql_big_result score,count(*) from t1 group by score desc order by null; -table type possible_keys key key_len ref rows Extra -t1 index NULL score 3 NULL 6 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL score 3 NULL 6 Using index select sql_big_result score,count(*) from t1 group by score desc; score count(*) 3 3 @@ -416,7 +418,6 @@ CONCAT(a, b) count(*) abcdef 1 hijklm 2 DROP TABLE t1; -drop table if exists t1; create table t1 (One int unsigned, Two int unsigned, Three int unsigned, Four int unsigned); insert into t1 values (1,2,1,4),(1,2,2,4),(1,2,3,4),(1,2,4,4),(1,1,1,4),(1,1,2,4),(1,1,3,4),(1,1,4,4),(1,3,1,4),(1,3,2,4),(1,3,3,4),(1,3,4,4); select One, Two, sum(Four) from t1 group by One,Two; @@ -526,13 +527,13 @@ a b 2 2 1 1 explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort -t2 ALL a NULL NULL NULL 4 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort +1 SIMPLE t2 ALL a NULL NULL NULL 4 Using where explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 6 Using temporary -t2 ALL a NULL NULL NULL 4 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary +1 SIMPLE t2 ALL a NULL NULL NULL 4 Using where drop table t1,t2; create table t1 (a int, b int); insert into t1 values (1, 4); diff --git a/mysql-test/r/handler.result b/mysql-test/r/handler.result index 3be24305e09..d8381ccc626 100644 --- a/mysql-test/r/handler.result +++ b/mysql-test/r/handler.result @@ -5,6 +5,8 @@ insert into t1 values (14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"), (20,"ggg"),(21,"hhh"),(22,"iii"); handler t1 open as t2; +handler t2 read a=(SELECT 1); +You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1)' at line 1 handler t2 read a first; a b 14 aaa diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index a33ce457176..bd1bd523964 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -62,4 +62,8 @@ select Fld1, max(Fld2) from t1 group by Fld1 having std(Fld2) is not null; Fld1 max(Fld2) 1 20 3 50 +select Fld1, max(Fld2) from t1 group by Fld1 having variance(Fld2) is not null; +Fld1 max(Fld2) +1 20 +3 50 drop table t1; diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result index 73642d7f751..ffd62ceabb6 100644 --- a/mysql-test/r/heap.result +++ b/mysql-test/r/heap.result @@ -65,10 +65,10 @@ a 869751 alter table t1 type=myisam; explain select * from t1 where a in (869751,736494,226312,802616); -table type possible_keys key key_len ref rows Extra -t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index drop table t1; -create table t1 (x int not null, y int not null, key x(x), unique y(y)) +create table t1 (x int not null, y int not null, key x (x), unique y (y)) type=heap; insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6); select * from t1 where x=1; @@ -84,9 +84,9 @@ x y x y 2 5 2 2 2 6 2 2 explain select * from t1,t1 as t2 where t1.x=t2.y; -table type possible_keys key key_len ref rows Extra -t1 ALL x NULL NULL NULL 6 -t2 eq_ref y y 4 t1.x 1 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL x NULL NULL NULL 6 +1 SIMPLE t2 eq_ref y y 4 t1.x 1 drop table t1; create table t1 (a int) type=heap; insert into t1 values(1); @@ -158,18 +158,18 @@ drop table t1; create table t1 (btn char(10) not null, key(btn)) type=heap; insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i"); explain select * from t1 where btn like "q%"; -table type possible_keys key key_len ref rows Extra -t1 ALL btn NULL NULL NULL 14 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where select * from t1 where btn like "q%"; btn alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn; update t1 set new_col=btn; explain select * from t1 where btn="a"; -table type possible_keys key key_len ref rows Extra -t1 ALL btn NULL NULL NULL 14 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where explain select * from t1 where btn="a" and new_col="a"; -table type possible_keys key key_len ref rows Extra -t1 ref btn btn 11 const,const 10 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref btn btn 11 const,const 10 Using where drop table t1; CREATE TABLE t1 ( a int default NULL, @@ -181,16 +181,16 @@ INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3); SELECT * FROM t1 WHERE a=NULL; a b explain SELECT * FROM t1 WHERE a IS NULL; -table type possible_keys key key_len ref rows Extra -t1 ref a a 5 const 10 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 5 const 10 Using where SELECT * FROM t1 WHERE a<=>NULL; a b NULL 99 SELECT * FROM t1 WHERE b=NULL; a b explain SELECT * FROM t1 WHERE b IS NULL; -table type possible_keys key key_len ref rows Extra -t1 ref b b 5 const 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref b b 5 const 1 Using where SELECT * FROM t1 WHERE b<=>NULL; a b 99 NULL diff --git a/mysql-test/r/heap_auto_increment.result b/mysql-test/r/heap_auto_increment.result new file mode 100644 index 00000000000..9a5ed57d741 --- /dev/null +++ b/mysql-test/r/heap_auto_increment.result @@ -0,0 +1,41 @@ +drop table if exists t1; +create table t1 (a int not null auto_increment,b int, primary key (a)) type=heap auto_increment=3; +insert into t1 values (1,1),(NULL,3),(NULL,4); +delete from t1 where a=4; +insert into t1 values (NULL,5),(NULL,6); +select * from t1; +a b +1 1 +3 3 +5 5 +6 6 +delete from t1 where a=6; +replace t1 values (3,1); +ALTER TABLE t1 add c int; +replace t1 values (3,3,3); +insert into t1 values (NULL,7,7); +update t1 set a=8,b=b+1,c=c+1 where a=7; +insert into t1 values (NULL,9,9); +select * from t1; +a b c +1 1 NULL +3 3 3 +5 5 NULL +8 8 8 +9 9 9 +drop table t1; +create table t1 ( +skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY, +sval char(20) +) type=heap; +insert into t1 values (NULL, "hello"); +insert into t1 values (NULL, "hey"); +select * from t1; +skey sval +1 hello +2 hey +select _rowid,t1._rowid,skey,sval from t1; +_rowid _rowid skey sval +1 1 1 hello +2 2 2 hey +drop table t1; diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result new file mode 100644 index 00000000000..bf24f78321f --- /dev/null +++ b/mysql-test/r/heap_btree.result @@ -0,0 +1,235 @@ +drop table if exists t1; +create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +delete from t1 where a=1 or a=0; +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 a A NULL NULL NULL BTREE +select * from t1; +a b +2 2 +3 3 +4 4 +select * from t1 where a=4; +a b +4 4 +update t1 set b=5 where a=4; +update t1 set b=b+1 where a>=3; +replace t1 values (3,3); +select * from t1; +a b +2 2 +3 3 +4 6 +alter table t1 add c int not null, add key using BTREE (c,a); +drop table t1; +create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps"; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +delete from t1 where a > 0; +select * from t1; +a b +drop table t1; +create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps"; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table"; +select * from t1; +a b +1 1 +2 2 +3 3 +4 4 +drop table t1; +create table t1 (a int not null) type=heap; +insert into t1 values (869751),(736494),(226312),(802616); +select * from t1 where a > 736494; +a +869751 +802616 +alter table t1 add unique uniq_id using BTREE (a); +select * from t1 where a > 736494; +a +802616 +869751 +select * from t1 where a = 736494; +a +736494 +select * from t1 where a=869751 or a=736494; +a +736494 +869751 +select * from t1 where a in (869751,736494,226312,802616); +a +226312 +736494 +802616 +869751 +alter table t1 type=myisam; +explain select * from t1 where a in (869751,736494,226312,802616); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index +drop table t1; +create table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y)) +type=heap; +insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6); +explain select * from t1 where x=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref x x 4 const 1 Using where +select * from t1 where x=1; +x y +1 1 +1 3 +select * from t1,t1 as t2 where t1.x=t2.y; +x y x y +1 1 1 1 +2 2 2 2 +1 3 1 1 +2 4 2 2 +2 5 2 2 +2 6 2 2 +explain select * from t1,t1 as t2 where t1.x=t2.y; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL x NULL NULL NULL 6 +1 SIMPLE t2 eq_ref y y 4 t1.x 1 +drop table t1; +create table t1 (a int) type=heap; +insert into t1 values(1); +select max(a) from t1; +max(a) +1 +drop table t1; +CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using BTREE (a,b), key using BTREE (b) ) TYPE=HEAP; +insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); +select * from t1 where a=1; +a b +1 1 +1 2 +1 3 +1 4 +1 5 +1 6 +insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); +select * from t1 where a=1; +a b +1 1 +1 1 +1 2 +1 2 +1 3 +1 3 +1 4 +1 4 +1 5 +1 5 +1 6 +1 6 +explain select * from tx where a=x order by a,b; +id select_type table type possible_keys key key_len ref rows Extra +x SIMPLE tx ref a a x const x Using where +explain select * from tx where a=x order by b; +id select_type table type possible_keys key key_len ref rows Extra +x SIMPLE tx ref a a x const x Using where +select * from t1 where b=1; +a b +1 1 +1 1 +explain select * from tx where b=x; +id select_type table type possible_keys key key_len ref rows Extra +x SIMPLE tx ref b b x const x Using where +drop table t1; +create table t1 (id int unsigned not null, primary key using BTREE (id)) type=HEAP; +insert into t1 values(1); +select max(id) from t1; +max(id) +1 +insert into t1 values(2); +select max(id) from t1; +max(id) +2 +replace into t1 values(1); +drop table t1; +create table t1 (n int) type=heap; +drop table t1; +create table t1 (n int) type=heap; +drop table if exists t1; +CREATE table t1(f1 int not null,f2 char(20) not +null,index(f2)) type=heap; +INSERT into t1 set f1=12,f2="bill"; +INSERT into t1 set f1=13,f2="bill"; +INSERT into t1 set f1=14,f2="bill"; +INSERT into t1 set f1=15,f2="bill"; +INSERT into t1 set f1=16,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +delete from t1 where f2="bill"; +select * from t1; +f1 f2 +16 ted +12 ted +12 ted +12 ted +12 ted +drop table t1; +create table t1 (btn char(10) not null, key using BTREE (btn)) type=heap; +insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i"); +explain select * from t1 where btn like "q%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where +select * from t1 where btn like "q%"; +btn +alter table t1 add column new_col char(1) not null, add key using BTREE (btn,new_col), drop key btn; +update t1 set new_col=btn; +explain select * from t1 where btn="a"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref btn btn 10 const 1 Using where +explain select * from t1 where btn="a" and new_col="a"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref btn btn 11 const,const 1 Using where +drop table t1; +CREATE TABLE t1 ( +a int default NULL, +b int default NULL, +KEY a using BTREE (a), +UNIQUE b using BTREE (b) +) type=heap; +INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3); +SELECT * FROM t1 WHERE a=NULL; +a b +explain SELECT * FROM t1 WHERE a IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 5 const 1 Using where +SELECT * FROM t1 WHERE a<=>NULL; +a b +NULL 99 +SELECT * FROM t1 WHERE b=NULL; +a b +explain SELECT * FROM t1 WHERE b IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref b b 5 const 1 Using where +SELECT * FROM t1 WHERE b<=>NULL; +a b +99 NULL +INSERT INTO t1 VALUES (1,3); +Duplicate entry '3' for key 1 +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) type=heap; +INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1); +SELECT * FROM t1 WHERE a=1 and b IS NULL; +a b c +1 NULL NULL +1 NULL 1 +SELECT * FROM t1 WHERE a=1 and c IS NULL; +a b c +1 NULL NULL +1 1 NULL +SELECT * FROM t1 WHERE a=1 and b IS NULL and c IS NULL; +a b c +1 NULL NULL +DROP TABLE t1; +CREATE TABLE t1 (a int not null, primary key using BTREE (a)) type=heap; +INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); +DELETE from t1 where a < 100; +SELECT * from t1; +a +DROP TABLE t1; diff --git a/mysql-test/r/heap_hash.result b/mysql-test/r/heap_hash.result new file mode 100644 index 00000000000..3c2baa645f7 --- /dev/null +++ b/mysql-test/r/heap_hash.result @@ -0,0 +1,205 @@ +drop table if exists t1; +create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +delete from t1 where a=1 or a=0; +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 a NULL NULL NULL NULL HASH +select * from t1; +a b +2 2 +3 3 +4 4 +select * from t1 where a=4; +a b +4 4 +update t1 set b=5 where a=4; +update t1 set b=b+1 where a>=3; +replace t1 values (3,3); +select * from t1; +a b +2 2 +3 3 +4 6 +alter table t1 add c int not null, add key using HASH (c,a); +drop table t1; +create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps"; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +delete from t1 where a > 0; +select * from t1; +a b +drop table t1; +create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps"; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table"; +select * from t1; +a b +1 1 +2 2 +3 3 +4 4 +drop table t1; +create table t1 (a int not null) type=heap; +insert into t1 values (869751),(736494),(226312),(802616); +select * from t1 where a > 736494; +a +869751 +802616 +alter table t1 add unique uniq_id using HASH (a); +select * from t1 where a > 736494; +a +869751 +802616 +select * from t1 where a = 736494; +a +736494 +select * from t1 where a=869751 or a=736494; +a +736494 +869751 +select * from t1 where a in (869751,736494,226312,802616); +a +226312 +736494 +802616 +869751 +alter table t1 type=myisam; +explain select * from t1 where a in (869751,736494,226312,802616); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index +drop table t1; +create table t1 (x int not null, y int not null, key x using HASH (x), unique y using HASH (y)) +type=heap; +insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6); +select * from t1 where x=1; +x y +1 3 +1 1 +select * from t1,t1 as t2 where t1.x=t2.y; +x y x y +1 1 1 1 +2 2 2 2 +1 3 1 1 +2 4 2 2 +2 5 2 2 +2 6 2 2 +explain select * from t1,t1 as t2 where t1.x=t2.y; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL x NULL NULL NULL 6 +1 SIMPLE t2 eq_ref y y 4 t1.x 1 +drop table t1; +create table t1 (a int) type=heap; +insert into t1 values(1); +select max(a) from t1; +max(a) +1 +drop table t1; +CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using HASH (a), key using HASH (b) ) TYPE=HEAP; +insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); +select * from t1 where a=1; +a b +1 6 +1 5 +1 4 +1 3 +1 2 +1 1 +insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); +select * from t1 where a=1; +a b +1 6 +1 5 +1 4 +1 3 +1 2 +1 1 +1 6 +1 5 +1 4 +1 3 +1 2 +1 1 +drop table t1; +create table t1 (id int unsigned not null, primary key using HASH (id)) type=HEAP; +insert into t1 values(1); +select max(id) from t1; +max(id) +1 +insert into t1 values(2); +select max(id) from t1; +max(id) +2 +replace into t1 values(1); +drop table t1; +create table t1 (n int) type=heap; +drop table t1; +create table t1 (n int) type=heap; +drop table if exists t1; +CREATE table t1(f1 int not null,f2 char(20) not +null,index(f2)) type=heap; +INSERT into t1 set f1=12,f2="bill"; +INSERT into t1 set f1=13,f2="bill"; +INSERT into t1 set f1=14,f2="bill"; +INSERT into t1 set f1=15,f2="bill"; +INSERT into t1 set f1=16,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +delete from t1 where f2="bill"; +select * from t1; +f1 f2 +16 ted +12 ted +12 ted +12 ted +12 ted +drop table t1; +create table t1 (btn char(10) not null, key using HASH (btn)) type=heap; +insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i"); +explain select * from t1 where btn like "q%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where +select * from t1 where btn like "q%"; +btn +alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn; +update t1 set new_col=btn; +explain select * from t1 where btn="a"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where +explain select * from t1 where btn="a" and new_col="a"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref btn btn 11 const,const 10 Using where +drop table t1; +CREATE TABLE t1 ( +a int default NULL, +b int default NULL, +KEY a using HASH (a), +UNIQUE b using HASH (b) +) type=heap; +INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3); +SELECT * FROM t1 WHERE a=NULL; +a b +explain SELECT * FROM t1 WHERE a IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 5 const 10 Using where +SELECT * FROM t1 WHERE a<=>NULL; +a b +NULL 99 +SELECT * FROM t1 WHERE b=NULL; +a b +explain SELECT * FROM t1 WHERE b IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref b b 5 const 1 Using where +SELECT * FROM t1 WHERE b<=>NULL; +a b +99 NULL +INSERT INTO t1 VALUES (1,3); +Duplicate entry '3' for key 1 +DROP TABLE t1; +CREATE TABLE t1 (a int not null, primary key using HASH (a)) type=heap; +INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); +DELETE from t1 where a < 100; +SELECT * from t1; +a +DROP TABLE t1; diff --git a/mysql-test/r/help.result b/mysql-test/r/help.result new file mode 100644 index 00000000000..4da4a84d4ad --- /dev/null +++ b/mysql-test/r/help.result @@ -0,0 +1,123 @@ +truncate mysql.help_topic; +truncate mysql.help_category; +truncate mysql.help_relation; +insert into mysql.help_topic(name,description,example)values('impossible_function_1','description of \n impossible_function1','example of \n impossible_function1'); +SELECT @topic1_id:=LAST_INSERT_ID(); +@topic1_id:=LAST_INSERT_ID() +1 +insert into mysql.help_topic(name,description,example)values('impossible_function_2','description of \n impossible_function2','example of \n impossible_function2'); +SELECT @topic2_id:=LAST_INSERT_ID(); +@topic2_id:=LAST_INSERT_ID() +2 +insert into mysql.help_topic(name,description,example)values('impossible_function_3','description of \n impossible_function3','example of \n impossible_function3'); +SELECT @topic3_id:=LAST_INSERT_ID(); +@topic3_id:=LAST_INSERT_ID() +3 +insert into mysql.help_category(name)values('impossible_category_1'); +SELECT @category1_id:=LAST_INSERT_ID(); +@category1_id:=LAST_INSERT_ID() +1 +insert into mysql.help_category(name)values('impossible_category_2'); +SELECT @category2_id:=LAST_INSERT_ID(); +@category2_id:=LAST_INSERT_ID() +2 +insert into mysql.help_relation(help_category_id,help_topic_id)values(@category1_id,@topic1_id); +insert into mysql.help_relation(help_category_id,help_topic_id)values(@category1_id,@topic2_id); +insert into mysql.help_relation(help_category_id,help_topic_id)values(@category2_id,@topic2_id); +insert into mysql.help_relation(help_category_id,help_topic_id)values(@category2_id,@topic3_id); +help 'function_of_my_dream'; +Name Category +impossible_category_1 Y +impossible_category_2 Y +help '%possible_f%'; +Name Category +impossible_function_1 N +impossible_function_2 N +impossible_function_3 N +help 'impossible_func%'; +Name Category +impossible_function_1 N +impossible_function_2 N +impossible_function_3 N +help 'impossible_category%'; +Name Category +impossible_category_1 Y +impossible_category_2 Y +help 'impossible_%'; +Name Category +impossible_function_1 N +impossible_function_2 N +impossible_function_3 N +impossible_category_1 Y +impossible_category_2 Y +help '%function_2'; +Name Category Description Example +impossible_function_2 N description of + impossible_function2 example of + impossible_function2 +help '%category_2'; +Name Category Description Example +impossible_category_2 Y impossible_function_2 +impossible_function_3 + +help 'impossible_function_1'; +Name Category Description Example +impossible_function_1 N description of + impossible_function1 example of + impossible_function1 +help 'impossible_category_1'; +Name Category Description Example +impossible_category_1 Y impossible_function_1 +impossible_function_2 + +alter table mysql.help_topic type=innodb; +alter table mysql.help_category type=innodb; +alter table mysql.help_relation type=innodb; +help 'function_of_my_dream'; +Name Category +impossible_category_1 Y +impossible_category_2 Y +help '%ble_f%'; +Name Category +impossible_function_1 N +impossible_function_2 N +impossible_function_3 N +help 'impossible_func%'; +Name Category +impossible_function_1 N +impossible_function_2 N +impossible_function_3 N +help 'impossible_category%'; +Name Category +impossible_category_1 Y +impossible_category_2 Y +help 'impossible_%'; +Name Category +impossible_function_1 N +impossible_function_2 N +impossible_function_3 N +impossible_category_1 Y +impossible_category_2 Y +help '%function_2'; +Name Category Description Example +impossible_function_2 N description of + impossible_function2 example of + impossible_function2 +help '%category_2'; +Name Category Description Example +impossible_category_2 Y impossible_function_2 +impossible_function_3 + +help 'impossible_function_1'; +Name Category Description Example +impossible_function_1 N description of + impossible_function1 example of + impossible_function1 +help 'impossible_category_1'; +Name Category Description Example +impossible_category_1 Y impossible_function_1 +impossible_function_2 + +alter table mysql.help_topic type=myisam; +alter table mysql.help_category type=myisam; +alter table mysql.help_relation type=myisam; diff --git a/mysql-test/r/innodb-deadlock.result b/mysql-test/r/innodb-deadlock.result index 121bfa8c6cb..e1b3e38b243 100644 --- a/mysql-test/r/innodb-deadlock.result +++ b/mysql-test/r/innodb-deadlock.result @@ -1,4 +1,4 @@ -drop table if exists t1; +drop table if exists t1,t2; create table t1 (id integer, x integer) type=INNODB; insert into t1 values(0, 0); set autocommit=0; @@ -18,3 +18,79 @@ id x 0 2 commit; drop table t1; +create table t1 (id integer, x integer) type=INNODB; +create table t2 (b integer, a integer) type=INNODB; +insert into t1 values(0, 0), (300, 300); +insert into t2 values(0, 10), (1, 20), (2, 30); +commit; +set autocommit=0; +select * from t2; +b a +0 10 +1 20 +2 30 +update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE); +select * from t2; +b a +0 100 +1 20 +2 30 +select * from t1; +id x +0 0 +300 300 +set autocommit=0; +update t1 set x=2 where id = 0; +update t1 set x=1 where id = 0; +select * from t1; +id x +0 1 +300 300 +commit; +commit; +select * from t1; +id x +0 2 +300 300 +commit; +drop table t1, t2; +create table t1 (id integer, x integer) type=INNODB; +create table t2 (b integer, a integer) type=INNODB; +insert into t1 values(0, 0), (300, 300); +insert into t2 values(0, 0), (1, 20), (2, 30); +commit; +select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE; +a b +0 0 +20 1 +30 2 +300 300 +select * from t2; +b a +0 0 +1 20 +2 30 +select * from t1; +id x +0 0 +300 300 +update t2 set a=2 where b = 0; +select * from t2; +b a +0 2 +1 20 +2 30 +update t1 set x=2 where id = 0; +update t1 set x=1 where id = 0; +select * from t1; +id x +0 1 +300 300 +commit; +commit; +select * from t1; +id x +0 2 +300 300 +commit; +drop table t1, t2; diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index caf3e10be80..0021be10d85 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -139,14 +139,14 @@ id parent_id level 1010 102 2 1015 102 2 explain select level from t1 where level=1; -table type possible_keys key key_len ref rows Extra -t1 ref level level 1 const 12 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref level level 1 const 12 Using where; Using index explain select level,id from t1 where level=1; -table type possible_keys key key_len ref rows Extra -t1 ref level level 1 const 12 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref level level 1 const 12 Using where; Using index explain select level,id,parent_id from t1 where level=1; -table type possible_keys key key_len ref rows Extra -t1 ref level level 1 const 12 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref level level 1 const 12 Using where select level,id from t1 where level=1; level id 1 1002 @@ -596,8 +596,8 @@ id parent_id level 1025 102 2 1016 102 2 explain select level from t1 where level=1; -table type possible_keys key key_len ref rows Extra -t1 ref level level 1 const 6 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref level level 1 const 6 Using where; Using index select level,id from t1 where level=1; level id 1 1004 @@ -758,8 +758,8 @@ DROP TABLE t1; create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) type = innodb; insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); explain select * from t1 where a > 0 and a < 50; -table type possible_keys key key_len ref rows Extra -t1 range PRIMARY PRIMARY 4 NULL 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where drop table t1; create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=innodb; insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); @@ -807,7 +807,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` char(20) default NULL, KEY `a` (`a`) -) TYPE=InnoDB +) TYPE=InnoDB CHARSET=latin1 drop table t1; create temporary table t1 (a int not null auto_increment, primary key(a)) type=innodb; insert into t1 values (NULL),(NULL),(NULL); @@ -892,34 +892,34 @@ drop table t1; create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) type=innodb; insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4); explain select * from t1 order by a; -table type possible_keys key key_len ref rows Extra -t1 index NULL PRIMARY 4 NULL 4 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 explain select * from t1 order by b; -table type possible_keys key key_len ref rows Extra -t1 index NULL b 4 NULL 4 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL b 4 NULL 4 explain select * from t1 order by c; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 Using filesort +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort explain select a from t1 order by a; -table type possible_keys key key_len ref rows Extra -t1 index NULL PRIMARY 4 NULL 4 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index explain select b from t1 order by b; -table type possible_keys key key_len ref rows Extra -t1 index NULL b 4 NULL 4 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL b 4 NULL 4 Using index explain select a,b from t1 order by b; -table type possible_keys key key_len ref rows Extra -t1 index NULL b 4 NULL 4 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL b 4 NULL 4 Using index explain select a,b from t1; -table type possible_keys key key_len ref rows Extra -t1 index NULL b 4 NULL 4 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL b 4 NULL 4 Using index explain select a,b,c from t1; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 drop table t1; create table t1 (t int not null default 1, key (t)) type=innodb; desc t1; -Field Type Null Key Default Extra -t int(11) MUL 1 +Field Type Collation Null Key Default Extra +t int(11) binary MUL 1 drop table t1; CREATE TABLE t1 ( number bigint(20) NOT NULL default '0', @@ -959,29 +959,29 @@ INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,0000000000000 INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0); select * from t1; number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status -4077711111 SeanWheeler 90 2 20020111112846 500 00000000000000 -1 2 3 1 -9197722223 berry 90 3 20020111112809 500 20020102114532 501 4 10 0 -650 San Francisco 0 0 20011227111336 342 00000000000000 -1 1 24 1 -302467 Sue's Subshop 90 3 20020109113241 500 20020102115111 501 7 24 0 -6014911113 SudzCarwash 520 1 20020102115234 500 20020102115259 501 33 32768 0 -333 tubs 99 2 20020109113440 501 20020109113440 500 3 10 0 +4077711111 SeanWheeler 90 2 2002-01-11 11:28:46 500 0000-00-00 00:00:00 -1 2 3 1 +9197722223 berry 90 3 2002-01-11 11:28:09 500 2002-01-02 11:45:32 501 4 10 0 +650 San Francisco 0 0 2001-12-27 11:13:36 342 0000-00-00 00:00:00 -1 1 24 1 +302467 Sue's Subshop 90 3 2002-01-09 11:32:41 500 2002-01-02 11:51:11 501 7 24 0 +6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0 +333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0 select * from t2; number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status -4077711111 SeanWheeler 0 2 20020111112853 500 00000000000000 -1 2 3 1 -9197722223 berry 90 3 20020111112818 500 20020102114532 501 4 10 0 -650 San Francisco 90 0 20020109113158 342 00000000000000 -1 1 24 1 -333 tubs 99 2 20020109113453 501 20020109113453 500 3 10 0 +4077711111 SeanWheeler 0 2 2002-01-11 11:28:53 500 0000-00-00 00:00:00 -1 2 3 1 +9197722223 berry 90 3 2002-01-11 11:28:18 500 2002-01-02 11:45:32 501 4 10 0 +650 San Francisco 90 0 2002-01-09 11:31:58 342 0000-00-00 00:00:00 -1 1 24 1 +333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0 delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or (t1.carrier_id=90 and t2.number is null); select * from t1; number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status -6014911113 SudzCarwash 520 1 20020102115234 500 20020102115259 501 33 32768 0 -333 tubs 99 2 20020109113440 501 20020109113440 500 3 10 0 +6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0 +333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0 select * from t2; number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status -333 tubs 99 2 20020109113453 501 20020109113453 500 3 10 0 +333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0 select * from t2; number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status -333 tubs 99 2 20020109113453 501 20020109113453 500 3 10 0 +333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0 drop table t1,t2; create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) type=innodb; BEGIN; @@ -1021,7 +1021,6 @@ id code name 7 4 Matt COMMIT; DROP TABLE t1; -drop table if exists t1,t2; create table t1 (n int(10), d int(10)) type=innodb; create table t2 (n int(10), d int(10)) type=innodb; insert into t1 values(1,1),(1,2); diff --git a/mysql-test/r/innodb_cache.result b/mysql-test/r/innodb_cache.result index 47abcb45fe5..7d351a13e16 100644 --- a/mysql-test/r/innodb_cache.result +++ b/mysql-test/r/innodb_cache.result @@ -1,4 +1,4 @@ -drop table if exists t1, t2, t3; +drop table if exists t1,t2,t3; flush status; set autocommit=0; create table t1 (a int not null) type=innodb; diff --git a/mysql-test/r/innodb_handler.result b/mysql-test/r/innodb_handler.result index 321aedabdc7..4ce104506f1 100644 --- a/mysql-test/r/innodb_handler.result +++ b/mysql-test/r/innodb_handler.result @@ -1,4 +1,4 @@ -drop table if exists t1; +drop table if exists t1,t2; create table t1 (a int, b char(10), key a(a), key b(a,b)) type=innodb; insert into t1 values (17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"), diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result index 69b790ff35b..ebd34dd7668 100644 --- a/mysql-test/r/insert.result +++ b/mysql-test/r/insert.result @@ -58,9 +58,9 @@ skr 2 test 1 test 2 drop table t1; -drop database if exists foo; -create database foo; -use foo; +drop database if exists test_$1; +create database test_$1; +use test_$1; create table t1 (c int); -insert into foo.t1 set foo.t1.c = '1'; -drop database foo; +insert into test_$1.t1 set test_$1.t1.c = '1'; +drop database test_$1; diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index e24c3179a0c..9a65eaee573 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -21,8 +21,7 @@ payoutID 20 22 drop table t1,t2; -DROP TABLE IF EXISTS crash1,crash2; -CREATE TABLE `crash1` ( +CREATE TABLE `t1` ( `numeropost` bigint(20) unsigned NOT NULL default '0', `icone` tinyint(4) unsigned NOT NULL default '0', `numreponse` bigint(20) unsigned NOT NULL auto_increment, @@ -37,7 +36,7 @@ KEY `date` (`date`), KEY `pseudo` (`pseudo`), KEY `numreponse` (`numreponse`) ) TYPE=MyISAM; -CREATE TABLE `crash2` ( +CREATE TABLE `t2` ( `numeropost` bigint(20) unsigned NOT NULL default '0', `icone` tinyint(4) unsigned NOT NULL default '0', `numreponse` bigint(20) unsigned NOT NULL auto_increment, @@ -52,17 +51,17 @@ KEY `date` (`date`), KEY `pseudo` (`pseudo`), KEY `numreponse` (`numreponse`) ) TYPE=MyISAM; -INSERT INTO crash2 +INSERT INTO t2 (numeropost,icone,numreponse,contenu,pseudo,date,ip,signature) VALUES (9,1,56,'test','joce','2001-07-25 13:50:53' ,3649052399,0); -INSERT INTO crash1 (numeropost,icone,contenu,pseudo,date,signature,ip) -SELECT 1618,icone,contenu,pseudo,date,signature,ip FROM crash2 +INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip) +SELECT 1618,icone,contenu,pseudo,date,signature,ip FROM t2 WHERE numeropost=9 ORDER BY numreponse ASC; show variables like '%bulk%'; Variable_name Value bulk_insert_buffer_size 8388608 -INSERT INTO crash1 (numeropost,icone,contenu,pseudo,date,signature,ip) -SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM crash2 +INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip) +SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM t2 WHERE numeropost=9 ORDER BY numreponse ASC; -DROP TABLE IF EXISTS crash1,crash2; +DROP TABLE IF EXISTS t1,t2; diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result new file mode 100644 index 00000000000..8cc79564679 --- /dev/null +++ b/mysql-test/r/insert_update.result @@ -0,0 +1,51 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B)); +INSERT t1 VALUES (1,2,10), (3,4,20); +INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 20 +5 6 30 +INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 20 +5 6 130 +INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE c=c+1000; +SELECT * FROM t1; +a b c +1 2 10 +3 4 1020 +5 6 130 +INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000; +SELECT * FROM t1; +a b c +1 2 10010 +3 4 1020 +5 6 130 +INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4; +Duplicate entry '4' for key 2 +SELECT * FROM t1; +a b c +1 2 10010 +3 4 1020 +5 6 130 +TRUNCATE TABLE t1; +INSERT t1 VALUES (1,2,10), (3,4,20); +INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 120 +5 6 30 +8 9 60 +INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0; +SELECT * FROM t1; +a b c +1 2 10 +3 4 120 +5 0 30 +8 9 60 +DROP TABLE t1; diff --git a/mysql-test/r/isam.result b/mysql-test/r/isam.result index 0f7224f52da..7871e899773 100644 --- a/mysql-test/r/isam.result +++ b/mysql-test/r/isam.result @@ -38,6 +38,8 @@ Incorrect table definition; There can only be one auto column and it must be def create table t1 (ordid int(8), unique (ordid)) type=isam; Column 'ordid' is used with UNIQUE or INDEX but is not defined as NOT NULL drop table if exists t1; +Warnings: +Note 1051 Unknown table 't1' create table t1 (a int not null primary key, b int not null,c int not null, key(b,c)); insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4); create table t2 type=isam select * from t1; @@ -62,15 +64,15 @@ Table Op Msg_type Msg_text test.t2 check error Table 't2' was not locked with LOCK TABLES test.t1 check status OK show columns from t1; -Field Type Null Key Default Extra -a int(11) PRI 0 -b int(11) MUL 0 -c int(11) 0 +Field Type Collation Null Key Default Extra +a int(11) binary PRI 0 +b int(11) binary MUL 0 +c int(11) binary 0 show full columns from t1; -Field Type Null Key Default Extra Privileges -a int(11) PRI 0 select,insert,update,references -b int(11) MUL 0 select,insert,update,references -c int(11) 0 select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +a int(11) binary PRI 0 select,insert,update,references +b int(11) binary MUL 0 select,insert,update,references +c int(11) binary 0 select,insert,update,references show index from t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment t1 0 PRIMARY 1 a A 4 NULL NULL BTREE diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index 9f6a8762325..09b819888eb 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -61,12 +61,12 @@ select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 where t2.id=75 id id NULL 75 explain select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 where t2.id=75 and t1.id is null; -table type possible_keys key key_len ref rows Extra -t1 const PRIMARY NULL NULL NULL 1 Impossible ON condition -t2 ALL NULL NULL NULL NULL 3 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY NULL NULL NULL 1 Impossible ON condition +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where explain select t1.id, t2.id from t1, t2 where t2.id = t1.id and t1.id <0 and t1.id > 0; -Comment -Impossible WHERE noticed after reading const tables +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables drop table t1,t2; CREATE TABLE t1 ( id int(11) NOT NULL auto_increment, diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 37e18b8b304..8abe6d517ee 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -90,12 +90,12 @@ grp a c id a c d 2 3 c NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1; -Comment -Impossible WHERE noticed after reading const tables +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 7 -t2 eq_ref PRIMARY PRIMARY 8 t1.a 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 7 +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 8 t1.a 1 Using where select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a); grp a c id a c d a 1 1 a 1 1 a 1 1 @@ -181,7 +181,6 @@ SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 L usr_id uniq_id increment usr2_id c_amount max 3 4 84676 NULL NULL NULL drop table t1,t2; -drop table if exists t1,t2,t3,t4; CREATE TABLE t1 ( cod_asig int(11) DEFAULT '0' NOT NULL, desc_larga_cat varchar(80) DEFAULT '' NOT NULL, @@ -311,13 +310,13 @@ select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where name name id Lilliana Angelovska NULL NULL explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 3 -t2 ALL NULL NULL NULL NULL 3 Using where; Not exists +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Not exists explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 3 -t2 ALL NULL NULL NULL NULL 3 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where select count(*) from t1 left join t2 on (t1.id = t2.owner); count(*) 4 @@ -331,13 +330,13 @@ select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where name name id Lilliana Angelovska NULL NULL explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 3 -t2 ALL NULL NULL NULL NULL 3 Using where; Not exists +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Not exists explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 3 -t2 ALL NULL NULL NULL NULL 3 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where select count(*) from t2 right join t1 on (t1.id = t2.owner); count(*) 4 @@ -618,9 +617,9 @@ UNIQUE id (id,idx) ); INSERT INTO t2 VALUES (1,1); explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 2 -t2 index id id 8 NULL 1 Using where; Using index; Not exists +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 +1 SIMPLE t2 index id id 8 NULL 1 Using where; Using index; Not exists SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; id name id idx 2 no NULL NULL @@ -638,9 +637,9 @@ create table t2 (fooID smallint unsigned not null, barID smallint unsigned not n insert into t1 (fooID) values (10),(20),(30); insert into t2 values (10,1),(20,2),(30,3); explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; -table type possible_keys key key_len ref rows Extra -t2 index NULL PRIMARY 4 NULL 3 Using index -t1 eq_ref PRIMARY PRIMARY 2 const 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index NULL PRIMARY 4 NULL 3 Using index +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 2 const 1 Using where; Using index select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; fooID barID fooID 10 1 NULL diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result index 1cd9c9dfe79..9e1f743d132 100644 --- a/mysql-test/r/key.result +++ b/mysql-test/r/key.result @@ -147,7 +147,6 @@ t1 0 e 1 e A 0 NULL NULL BTREE t1 0 b 1 b A NULL NULL NULL YES BTREE t1 1 c 1 c A NULL NULL NULL YES BTREE drop table t1; -DROP TABLE IF EXISTS t1; CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT, UNIQUE (c,i)); INSERT INTO t1 (c) VALUES (NULL),(NULL); diff --git a/mysql-test/r/key_diff.result b/mysql-test/r/key_diff.result index 4eaccc696f9..8097186bde1 100644 --- a/mysql-test/r/key_diff.result +++ b/mysql-test/r/key_diff.result @@ -34,9 +34,9 @@ C c a a D E a a a a a a explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B; -table type possible_keys key key_len ref rows Extra -t1 ALL a NULL NULL NULL 5 -t2 ALL b NULL NULL NULL 5 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a NULL NULL NULL 5 +1 SIMPLE t2 ALL b NULL NULL NULL 5 Using where select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a; a b a b A B a a diff --git a/mysql-test/r/key_primary.result b/mysql-test/r/key_primary.result index 87289f1cf54..14ca90b3dd2 100644 --- a/mysql-test/r/key_primary.result +++ b/mysql-test/r/key_primary.result @@ -12,9 +12,9 @@ select * from t1 where t1 like "a_\%"; t1 AB% describe select * from t1 where t1="ABC"; -table type possible_keys key key_len ref rows Extra -t1 const PRIMARY PRIMARY 3 const 1 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 3 const 1 describe select * from t1 where t1="ABCD"; -Comment -Impossible WHERE noticed after reading const tables +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables drop table t1; diff --git a/mysql-test/r/keywords.result b/mysql-test/r/keywords.result index 2ca36425841..c218379110f 100644 --- a/mysql-test/r/keywords.result +++ b/mysql-test/r/keywords.result @@ -3,7 +3,7 @@ create table t1 (time time, date date, timestamp timestamp); insert into t1 values ("12:22:22","97:02:03","1997-01-02"); select * from t1; time date timestamp -12:22:22 1997-02-03 19970102000000 +12:22:22 1997-02-03 1997-01-02 00:00:00 select t1.time+0,t1.date+0,t1.timestamp+0,concat(date," ",time) from t1; t1.time+0 t1.date+0 t1.timestamp+0 concat(date," ",time) 122222 19970203 19970102000000 1997-02-03 12:22:22 diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 0bffc93c284..b28607218d1 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -34,11 +34,11 @@ insert into t2 select NULL,message from t1; insert into t1 select NULL,message from t2; create table t3 (a int not null, b char(20), key(a)) type=MERGE UNION=(test.t1,test.t2); explain select * from t3 where a < 10; -table type possible_keys key key_len ref rows Extra -t3 range a a 4 NULL 18 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range a a 4 NULL 18 Using where explain select * from t3 where a > 10 and a < 20; -table type possible_keys key key_len ref rows Extra -t3 range a a 4 NULL 16 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range a a 4 NULL 16 Using where select * from t3 where a = 10; a b 10 Testing @@ -84,8 +84,8 @@ a b 19 Testing 19 Testing explain select a from t3 order by a desc limit 10; -table type possible_keys key key_len ref rows Extra -t3 index NULL a 4 NULL 1131 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 index NULL a 4 NULL 1131 Using index select a from t3 order by a desc limit 10; a 699 @@ -174,13 +174,15 @@ t3 CREATE TABLE `t3` ( `a` int(11) NOT NULL default '0', `b` char(20) default NULL, KEY `a` (`a`) -) TYPE=MRG_MyISAM UNION=(t1,t2) +) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(t1,t2) create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2); select * from t4; Can't open file: 't4.MRG'. (errno: 143) create table t5 (a int not null, b char(10), key(a)) type=MERGE UNION=(test.t1,test_2.t2); Incorrect table definition; All MERGE tables must be in the same database drop table if exists t5,t4,t3,t1,t2; +Warnings: +Note 1051 Unknown table 't5' create table t1 (c char(10)) type=myisam; create table t2 (c char(10)) type=myisam; create table t3 (c char(10)) union=(t1,t2) type=merge; @@ -249,20 +251,19 @@ t3 CREATE TABLE `t3` ( `incr` int(11) NOT NULL default '0', `othr` int(11) NOT NULL default '0', PRIMARY KEY (`incr`) -) TYPE=MRG_MyISAM UNION=(t1,t2) +) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(t1,t2) alter table t3 drop primary key; show create table t3; Table Create Table t3 CREATE TABLE `t3` ( `incr` int(11) NOT NULL default '0', `othr` int(11) NOT NULL default '0' -) TYPE=MRG_MyISAM UNION=(t1,t2) +) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(t1,t2) drop table t3,t2,t1; create table t1 (a int not null, key(a)) type=merge; select * from t1; a drop table t1; -drop table if exists t3, t2, t1; create table t1 (a int not null, b int not null, key(a,b)); create table t2 (a int not null, b int not null, key(a,b)); create table t3 (a int not null, b int not null, key(a,b)) TYPE=MERGE UNION=(t1,t2); @@ -274,7 +275,6 @@ a b 1 1 1 2 drop table t3,t1,t2; -drop table if exists t6, t5, t4, t3, t2, t1; create table t1 (a int not null, b int not null auto_increment, primary key(a,b)); create table t2 (a int not null, b int not null auto_increment, primary key(a,b)); create table t3 (a int not null, b int not null, key(a,b)) UNION=(t1,t2) INSERT_METHOD=NO; @@ -287,28 +287,28 @@ t3 CREATE TABLE `t3` ( `a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', KEY `a` (`a`,`b`) -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 show create table t4; Table Create Table t4 CREATE TABLE `t4` ( `a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', KEY `a` (`a`,`b`) -) TYPE=MRG_MyISAM UNION=(t1,t2) +) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(t1,t2) show create table t5; Table Create Table t5 CREATE TABLE `t5` ( `a` int(11) NOT NULL default '0', `b` int(11) NOT NULL auto_increment, PRIMARY KEY (`a`,`b`) -) TYPE=MRG_MyISAM INSERT_METHOD=FIRST UNION=(t1,t2) +) TYPE=MRG_MyISAM CHARSET=latin1 INSERT_METHOD=FIRST UNION=(t1,t2) show create table t6; Table Create Table t6 CREATE TABLE `t6` ( `a` int(11) NOT NULL default '0', `b` int(11) NOT NULL auto_increment, PRIMARY KEY (`a`,`b`) -) TYPE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1,t2) +) TYPE=MRG_MyISAM CHARSET=latin1 INSERT_METHOD=LAST UNION=(t1,t2) insert into t1 values (1,NULL),(1,NULL),(1,NULL),(1,NULL); insert into t2 values (2,NULL),(2,NULL),(2,NULL),(2,NULL); select * from t3 order by b,a limit 3; @@ -373,7 +373,7 @@ t4 CREATE TABLE `t4` ( `a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', KEY `a` (`a`,`b`) -) TYPE=MRG_MyISAM UNION=(t1,t2,t3) +) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(t1,t2,t3) select * from t4 order by a,b; a b 1 1 @@ -399,7 +399,7 @@ t4 CREATE TABLE `t4` ( `a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', KEY `a` (`a`,`b`) -) TYPE=MRG_MyISAM INSERT_METHOD=FIRST UNION=(t1,t2,t3) +) TYPE=MRG_MyISAM CHARSET=latin1 INSERT_METHOD=FIRST UNION=(t1,t2,t3) insert into t4 values (4,1),(4,2); select * from t1 order by a,b; a b @@ -533,15 +533,14 @@ CREATE TABLE t1 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default ' INSERT INTO t1 VALUES (1,1), (2,1); CREATE TABLE t2 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) TYPE=MyISAM; INSERT INTO t2 VALUES (1,2), (2,2); -CREATE TABLE t ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) TYPE=MRG_MyISAM UNION=(t1,t2); -select max(b) from t where a = 2; +CREATE TABLE t3 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) TYPE=MRG_MyISAM UNION=(t1,t2); +select max(b) from t3 where a = 2; max(b) 2 select max(b) from t1 where a = 2; max(b) 1 -drop table if exists t,t1,t2; -drop table if exists t1, t2, t3, t4, t5, t6; +drop table if exists t3,t1,t2; create table t1 (a int not null); create table t2 (a int not null); insert into t1 values (1); @@ -560,8 +559,7 @@ select * from t6; a 1 2 -drop table if exists t1, t2, t3, t4, t5, t6; -DROP TABLE IF EXISTS t1, t2; +drop table if exists t6, t3, t1, t2, t4, t5; CREATE TABLE t1 ( fileset_id tinyint(3) unsigned NOT NULL default '0', file_code varchar(32) NOT NULL default '', @@ -581,18 +579,18 @@ KEY files (fileset_id,fileset_root_id) ) TYPE=MRG_MyISAM UNION=(t1); EXPLAIN SELECT * FROM t2 IGNORE INDEX (files) WHERE fileset_id = 2 AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1; -table type possible_keys key key_len ref rows Extra -t2 range PRIMARY PRIMARY 33 NULL 5 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range PRIMARY PRIMARY 33 NULL 5 Using where EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2 AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1; -table type possible_keys key key_len ref rows Extra -t2 range PRIMARY,files PRIMARY 33 NULL 5 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range PRIMARY,files PRIMARY 33 NULL 5 Using where EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2 AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1; -table type possible_keys key key_len ref rows Extra -t1 range PRIMARY,files PRIMARY 33 NULL 5 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY,files PRIMARY 33 NULL 5 Using where EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2 AND file_code = '0000000115' LIMIT 1; -table type possible_keys key key_len ref rows Extra -t2 const PRIMARY,files PRIMARY 33 const,const 1 -DROP TABLE IF EXISTS t1, t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 const PRIMARY,files PRIMARY 33 const,const 1 +DROP TABLE t2, t1; diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index fe028a4cb95..4dbb3c8adb1 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -96,7 +96,7 @@ id mydate 5 2002-05-12 00:00:00 6 2002-06-22 00:00:00 7 2002-07-22 00:00:00 -DROP TABLE IF EXISTS t1,t2,t3; +DROP TABLE t1,t2,t3; CREATE TABLE IF NOT EXISTS `t1` ( `id` int(11) NOT NULL auto_increment, `tst` text, @@ -125,7 +125,7 @@ ID ParId tst tst1 1 1 MySQL MySQL AB 2 2 MSSQL Microsoft 3 3 ORACLE ORACLE -drop table if exists t1, t2 ; +drop table t1, t2 ; create table t1 (n numeric(10)); create table t2 (n numeric(10)); insert into t2 values (1),(2),(4),(8),(16),(32); @@ -235,8 +235,22 @@ select * from t2; n d 1 30 1 30 +UPDATE t1 a ,t2 b SET a.d=b.d,b.d=30 WHERE a.n=b.n; +select * from t1; +n d +1 30 +3 2 +select * from t2; +n d +1 30 +1 30 +DELETE t1, t2 FROM t1 a,t2 b where a.n=b.n; +select * from t1; +n d +3 2 +select * from t2; +n d drop table t1,t2; -drop table if exists t1,t2,t3; CREATE TABLE t1 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM; INSERT INTO t1 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a'),(10,''),(11,''),(12,''),(13,''); CREATE TABLE t2 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM; @@ -245,4 +259,4 @@ CREATE TABLE t3 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT INSERT INTO t3 VALUES (1,'jedan'),(2,'dva'); update t1,t2 set t1.naziv="aaaa" where t1.broj=t2.broj; update t1,t2,t3 set t1.naziv="bbbb", t2.naziv="aaaa" where t1.broj=t2.broj and t2.broj=t3.broj; -drop table if exists t1,t2,t3; +drop table t1,t2,t3; diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 3a3558eedcb..c0914e23992 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1,7 +1,7 @@ drop table if exists t1,t2; CREATE TABLE t1 ( STRING_DATA char(255) default NULL, -KEY STRING_DATA (STRING_DATA) +KEY string_data (STRING_DATA) ) TYPE=MyISAM; INSERT INTO t1 VALUES ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); INSERT INTO t1 VALUES ('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD'); @@ -51,29 +51,29 @@ drop table t1; create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) type=myisam; insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4); explain select * from t1 order by a; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 Using filesort +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort explain select * from t1 order by b; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 Using filesort +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort explain select * from t1 order by c; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 Using filesort +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort explain select a from t1 order by a; -table type possible_keys key key_len ref rows Extra -t1 index NULL PRIMARY 4 NULL 4 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index explain select b from t1 order by b; -table type possible_keys key key_len ref rows Extra -t1 index NULL b 4 NULL 4 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL b 4 NULL 4 Using index explain select a,b from t1 order by b; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 Using filesort +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort explain select a,b from t1; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 explain select a,b,c from t1; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 drop table t1; CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1), (2), (3); @@ -83,7 +83,6 @@ OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status OK DROP TABLE t1; -drop table if exists t1; create table t1 ( t1 char(255), key(t1(250))); insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169'); insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203'); @@ -121,7 +120,6 @@ check table t1; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; -drop table if exists t1; create table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8 int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17 int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int, @@ -286,7 +284,7 @@ insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); -drop table if exists t1; +drop table t1; CREATE TABLE `t1` ( `post_id` mediumint(8) unsigned NOT NULL auto_increment, `topic_id` mediumint(8) unsigned NOT NULL default '0', @@ -334,29 +332,40 @@ t1 1 a 2 b A 5 NULL NULL YES BTREE t1 1 c_2 1 c A 5 NULL NULL YES BTREE t1 1 c_2 2 a A 5 NULL NULL BTREE explain select * from t1,t2 where t1.a=t2.a; -table type possible_keys key key_len ref rows Extra -t1 ALL a NULL NULL NULL 5 -t2 ALL a NULL NULL NULL 2 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a NULL NULL NULL 5 +1 SIMPLE t2 ALL a NULL NULL NULL 2 Using where explain select * from t1,t2 force index(a) where t1.a=t2.a; -table type possible_keys key key_len ref rows Extra -t2 ALL a NULL NULL NULL 2 -t1 ALL a NULL NULL NULL 5 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL a NULL NULL NULL 2 +1 SIMPLE t1 ALL a NULL NULL NULL 5 Using where explain select * from t1 force index(a),t2 force index(a) where t1.a=t2.a; -table type possible_keys key key_len ref rows Extra -t2 ALL a NULL NULL NULL 2 -t1 ref a a 4 t2.a 3 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL a NULL NULL NULL 2 +1 SIMPLE t1 ref a a 4 t2.a 3 explain select * from t1,t2 where t1.b=t2.b; -table type possible_keys key key_len ref rows Extra -t2 ALL b NULL NULL NULL 2 -t1 ref b b 5 t2.b 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL b NULL NULL NULL 2 +1 SIMPLE t1 ref b b 5 t2.b 1 Using where explain select * from t1,t2 force index(c) where t1.a=t2.a; -table type possible_keys key key_len ref rows Extra -t1 ALL a NULL NULL NULL 5 -t2 ALL NULL NULL NULL NULL 2 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a NULL NULL NULL 5 +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where explain select * from t1 where a=0 or a=2; -table type possible_keys key key_len ref rows Extra -t1 ALL a NULL NULL NULL 5 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a NULL NULL NULL 5 Using where explain select * from t1 force index (a) where a=0 or a=2; -table type possible_keys key key_len ref rows Extra -t1 range a a 4 NULL 4 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 4 NULL 4 Using where +explain select * from t1 where c=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref c,c_2 c 5 const 1 Using where +explain select * from t1 use index() where c=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where drop table t1,t2; +CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) TYPE=MyISAM; +This version of MySQL doesn't yet support 'RTREE INDEX' +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index ba2161d3147..08612fa191f 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -1,3 +1,4 @@ +drop table if exists t1; select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null; NULL NULL isnull(null) isnull(1/0) isnull(1/0 = null) ifnull(null,1) ifnull(null,"TRUE") ifnull("TRUE","ERROR") 1/0 is null 1 is not null NULL NULL 1 1 1 1 TRUE TRUE 1 1 @@ -34,7 +35,6 @@ NULL AND 0 0 and NULL select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),inet_aton("122.226."),inet_aton(""); inet_ntoa(null) inet_aton(null) inet_aton("122.256") inet_aton("122.226.") inet_aton("") NULL NULL NULL NULL NULL -drop table if exists t1; create table t1 (x int); insert into t1 values (null); select * from t1 where x != 0; diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result index 236def64b5e..ce3af6c37cd 100644 --- a/mysql-test/r/null_key.result +++ b/mysql-test/r/null_key.result @@ -1,39 +1,39 @@ -drop table if exists t1; +drop table if exists t1,t2; create table t1 (a int, b int not null,unique key (a,b),index(b)) type=myisam; insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); explain select * from t1 where a is null; -table type possible_keys key key_len ref rows Extra -t1 ref a a 5 const 3 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 5 const 3 Using where; Using index explain select * from t1 where a is null and b = 2; -table type possible_keys key key_len ref rows Extra -t1 ref a,b a 9 const,const 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a,b a 9 const,const 1 Using where; Using index explain select * from t1 where a is null and b = 7; -table type possible_keys key key_len ref rows Extra -t1 ref a,b a 9 const,const 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a,b a 9 const,const 1 Using where; Using index explain select * from t1 where a=2 and b = 2; -table type possible_keys key key_len ref rows Extra -t1 const a,b a 9 const,const 1 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const a,b a 9 const,const 1 explain select * from t1 where a<=>b limit 2; -table type possible_keys key key_len ref rows Extra -t1 index NULL a 9 NULL 12 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 9 NULL 12 Using where; Using index explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3; -table type possible_keys key key_len ref rows Extra -t1 range a,b a 9 NULL 3 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a,b a 9 NULL 3 Using where; Using index explain select * from t1 where (a is null or a = 7) and b=7; -table type possible_keys key key_len ref rows Extra -t1 ref a,b b 4 const 2 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a,b b 4 const 2 Using where explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2; -table type possible_keys key key_len ref rows Extra -t1 ref a,b a 5 const 3 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a,b a 5 const 3 Using where; Using index explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3; -table type possible_keys key key_len ref rows Extra -t1 range a,b a 9 NULL 2 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a,b a 9 NULL 2 Using where; Using index explain select * from t1 where a > 1 and a < 3 limit 1; -table type possible_keys key key_len ref rows Extra -t1 range a a 5 NULL 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 5 NULL 1 Using where; Using index explain select * from t1 where a > 8 and a < 9; -table type possible_keys key key_len ref rows Extra -t1 range a a 5 NULL 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 5 NULL 1 Using where; Using index select * from t1 where a is null; a b NULL 7 @@ -65,44 +65,44 @@ NULL 9 NULL 9 alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); explain select * from t1 where a is null and b = 2; -table type possible_keys key key_len ref rows Extra -t1 ref a,b a 5 const 3 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a,b a 5 const 3 Using where explain select * from t1 where a is null and b = 2 and c=0; -table type possible_keys key key_len ref rows Extra -t1 ref a,b a 5 const 3 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a,b a 5 const 3 Using where explain select * from t1 where a is null and b = 7 and c=0; -table type possible_keys key key_len ref rows Extra -t1 ref a,b a 5 const 3 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a,b a 5 const 3 Using where explain select * from t1 where a=2 and b = 2; -table type possible_keys key key_len ref rows Extra -t1 ref a,b a 5 const 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a,b a 5 const 1 Using where explain select * from t1 where a<=>b limit 2; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 12 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 12 Using where explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 and c=0 limit 3; -table type possible_keys key key_len ref rows Extra -t1 range a,b a 5 NULL 5 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a,b a 5 NULL 5 Using where explain select * from t1 where (a is null or a = 7) and b=7 and c=0; -table type possible_keys key key_len ref rows Extra -t1 range a,b a 5 NULL 4 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a,b a 5 NULL 4 Using where explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2; -table type possible_keys key key_len ref rows Extra -t1 ref a,b a 5 const 3 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a,b a 5 const 3 Using where explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3; -table type possible_keys key key_len ref rows Extra -t1 ref a,b a 5 const 3 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a,b a 5 const 3 Using where explain select * from t1 where a > 1 and a < 3 limit 1; -table type possible_keys key key_len ref rows Extra -t1 range a a 5 NULL 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 5 NULL 1 Using where explain select * from t1 where a is null and b=7 or a > 1 and a < 3 limit 1; -table type possible_keys key key_len ref rows Extra -t1 range a,b a 5 NULL 4 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a,b a 5 NULL 4 Using where explain select * from t1 where a > 8 and a < 9; -table type possible_keys key key_len ref rows Extra -t1 range a a 5 NULL 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 5 NULL 1 Using where explain select * from t1 where b like "6%"; -table type possible_keys key key_len ref rows Extra -t1 range b b 12 NULL 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 12 NULL 1 Using where select * from t1 where a is null; a b c NULL 7 0 @@ -136,7 +136,6 @@ select * from t1 where b like "6%"; a b c 6 6 0 drop table t1; -DROP TABLE IF EXISTS t1,t2; CREATE TABLE t1 ( id int(10) unsigned NOT NULL auto_increment, uniq_id int(10) unsigned default NULL, @@ -151,11 +150,11 @@ PRIMARY KEY (id) INSERT INTO t1 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL); INSERT INTO t2 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL); explain select id from t1 where uniq_id is null; -table type possible_keys key key_len ref rows Extra -t1 ref idx1 idx1 5 const 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx1 idx1 5 const 1 Using where explain select id from t1 where uniq_id =1; -table type possible_keys key key_len ref rows Extra -t1 const idx1 idx1 5 const 1 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const idx1 idx1 5 const 1 UPDATE t1 SET id=id+100 where uniq_id is null; UPDATE t2 SET id=id+100 where uniq_id is null; select id from t1 where uniq_id is null; diff --git a/mysql-test/r/odbc.result b/mysql-test/r/odbc.result index 5aa163a663e..c0b2ada0053 100644 --- a/mysql-test/r/odbc.result +++ b/mysql-test/r/odbc.result @@ -1,7 +1,7 @@ +drop table if exists t1; select {fn length("hello")}, { date "1997-10-20" }; {fn length("hello")} 1997-10-20 5 1997-10-20 -drop table if exists t1; create table t1 (a int not null auto_increment,b int not null,primary key (a,b)); insert into t1 SET A=NULL,B=1; insert into t1 SET a=null,b=2; @@ -11,6 +11,6 @@ a b select * from t1 where a is null; a b explain select * from t1 where b is null; -Comment -Impossible WHERE noticed after reading const tables +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables drop table t1; diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 52bd83df5ed..428d1052d19 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -1,6 +1,6 @@ -drop table if exists sales; -create table sales ( product varchar(32), country varchar(32), year int, profit int); -insert into sales values ( 'Computer', 'India',2000, 1200), +drop table if exists t1; +create table t1 ( product varchar(32), country varchar(32), year int, profit int); +insert into t1 values ( 'Computer', 'India',2000, 1200), ( 'TV', 'United States', 1999, 150), ( 'Calculator', 'United States', 1999,50), ( 'Computer', 'United States', 1999,1500), @@ -14,14 +14,14 @@ insert into sales values ( 'Computer', 'India',2000, 1200), ( 'Computer', 'India', 1999,1200), ( 'Computer', 'United States', 2000,1500), ( 'Calculator', 'United States', 2000,75); -select product, country , year, sum(profit) from sales group by product, country, year with cube; +select product, country , year, sum(profit) from t1 group by product, country, year with cube; This version of MySQL doesn't yet support 'CUBE' -explain select product, country , year, sum(profit) from sales group by product, country, year with cube; +explain select product, country , year, sum(profit) from t1 group by product, country, year with cube; This version of MySQL doesn't yet support 'CUBE' -select product, country , year, sum(profit) from sales group by product, country, year with rollup; +select product, country , year, sum(profit) from t1 group by product, country, year with rollup; This version of MySQL doesn't yet support 'ROLLUP' -explain select product, country , year, sum(profit) from sales group by product, country, year with rollup; +explain select product, country , year, sum(profit) from t1 group by product, country, year with rollup; This version of MySQL doesn't yet support 'ROLLUP' -select product, country , year, sum(profit) from sales group by product, country, year with cube union all select product, country , year, sum(profit) from sales group by product, country, year with rollup; +select product, country , year, sum(profit) from t1 group by product, country, year with cube union all select product, country , year, sum(profit) from t1 group by product, country, year with rollup; This version of MySQL doesn't yet support 'CUBE' -drop table sales; +drop table t1; diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 9238d9eafcb..d0d7a954c99 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -222,7 +222,6 @@ DateOfAction TransactionID 1999-07-27 834 1999-07-27 840 drop table t1,t2,t3; -drop table if exists t1; CREATE TABLE t1 ( member_id int(11) NOT NULL auto_increment, inschrijf_datum varchar(20) NOT NULL default '', @@ -263,14 +262,14 @@ drop table t1; create table t1 (a int not null, b int, c varchar(10), key (a, b, c)); insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b'); explain select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc; -table type possible_keys key key_len ref rows Extra -t1 range a a 20 NULL 2 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 20 NULL 2 Using where; Using index select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc; a b c 1 NULL b explain select * from t1 where a >= 1 and a < 3 order by a desc; -table type possible_keys key key_len ref rows Extra -t1 range a a 4 NULL 10 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 4 NULL 10 Using where; Using index select * from t1 where a >= 1 and a < 3 order by a desc; a b c 2 3 c @@ -285,8 +284,8 @@ a b c 1 NULL b 1 NULL NULL explain select * from t1 where a = 1 order by a desc, b desc; -table type possible_keys key key_len ref rows Extra -t1 ref a a 4 const 5 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 4 const 5 Using where; Using index select * from t1 where a = 1 order by a desc, b desc; a b c 1 3 b @@ -296,34 +295,34 @@ a b c 1 NULL b 1 NULL NULL explain select * from t1 where a = 1 and b is null order by a desc, b desc; -table type possible_keys key key_len ref rows Extra -t1 ref a a 9 const,const 2 Using where; Using index; Using filesort +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 9 const,const 2 Using where; Using index; Using filesort select * from t1 where a = 1 and b is null order by a desc, b desc; a b c 1 NULL NULL 1 NULL b explain select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc; -table type possible_keys key key_len ref rows Extra -t1 range a a 9 NULL 8 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 9 NULL 8 Using where; Using index explain select * from t1 where a = 2 and b >0 order by a desc,b desc; -table type possible_keys key key_len ref rows Extra -t1 range a a 9 NULL 5 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index explain select * from t1 where a = 2 and b is null order by a desc,b desc; -table type possible_keys key key_len ref rows Extra -t1 ref a a 9 const,const 1 Using where; Using index; Using filesort +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 9 const,const 1 Using where; Using index; Using filesort explain select * from t1 where a = 2 and (b is null or b > 0) order by a desc,b desc; -table type possible_keys key key_len ref rows Extra -t1 range a a 9 NULL 6 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 9 NULL 6 Using where; Using index explain select * from t1 where a = 2 and b > 0 order by a desc,b desc; -table type possible_keys key key_len ref rows Extra -t1 range a a 9 NULL 5 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index explain select * from t1 where a = 2 and b < 2 order by a desc,b desc; -table type possible_keys key key_len ref rows Extra -t1 range a a 9 NULL 2 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 9 NULL 2 Using where; Using index explain select * from t1 where a = 1 order by b desc; -table type possible_keys key key_len ref rows Extra -t1 ref a a 4 const 5 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 4 const 5 Using where; Using index select * from t1 where a = 1 order by b desc; a b c 1 3 b @@ -334,8 +333,8 @@ a b c 1 NULL NULL alter table t1 modify b int not null, modify c varchar(10) not null; explain select * from t1 order by a, b, c; -table type possible_keys key key_len ref rows Extra -t1 index NULL a 18 NULL 11 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 18 NULL 11 Using index select * from t1 order by a, b, c; a b c 1 0 @@ -350,8 +349,8 @@ a b c 2 2 b 2 3 c explain select * from t1 order by a desc, b desc, c desc; -table type possible_keys key key_len ref rows Extra -t1 index NULL a 18 NULL 11 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 18 NULL 11 Using index select * from t1 order by a desc, b desc, c desc; a b c 2 3 c @@ -366,15 +365,15 @@ a b c 1 0 b 1 0 explain select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc; -table type possible_keys key key_len ref rows Extra -t1 range a a 18 NULL 3 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 18 NULL 3 Using where; Using index select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc; a b c 1 1 b 1 1 b explain select * from t1 where a < 2 and b <= 1 order by a desc, b desc; -table type possible_keys key key_len ref rows Extra -t1 range a a 4 NULL 6 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 4 NULL 6 Using where; Using index select * from t1 where a < 2 and b <= 1 order by a desc, b desc; a b c 1 1 b @@ -397,8 +396,8 @@ a b c 1 1 b 1 1 explain select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc; -table type possible_keys key key_len ref rows Extra -t1 range a a 8 NULL 10 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 8 NULL 10 Using where; Using index select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc; a b c 2 1 b @@ -409,8 +408,8 @@ a b c 1 0 b 1 0 explain select * from t1 where a between 0 and 1 order by a desc, b desc; -table type possible_keys key key_len ref rows Extra -t1 range a a 4 NULL 5 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 4 NULL 5 Using where; Using index select * from t1 where a between 0 and 1 order by a desc, b desc; a b c 1 3 b @@ -460,27 +459,27 @@ gid sid uid 104505 5 117 103853 5 250 EXPLAIN select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t1.gid, t3.uid; -table type possible_keys key key_len ref rows Extra -t1 index PRIMARY PRIMARY 4 NULL 6 Using index -t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1 -t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 6 Using index +1 SIMPLE t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1 +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr; -table type possible_keys key key_len ref rows Extra -t1 index PRIMARY PRIMARY 4 NULL 6 Using index -t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 6 Using index +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 Using where EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid; -table type possible_keys key key_len ref rows Extra -t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort -t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1 -t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort +1 SIMPLE t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1 +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid; -table type possible_keys key key_len ref rows Extra -t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort -t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 t1.gid 1 Using where EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort -t3 eq_ref PRIMARY PRIMARY 2 t1.skr 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 t1.skr 1 Using where drop table t1,t2,t3; CREATE TABLE t1 ( `titre` char(80) NOT NULL default '', @@ -517,3 +516,37 @@ SELECT titre,t1.numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,des titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug drop table t1,t2; +CREATE TABLE t1 ( +FieldKey varchar(36) NOT NULL default '', +LongVal bigint(20) default NULL, +StringVal mediumtext, +KEY FieldKey (FieldKey), +KEY LongField (FieldKey,LongVal), +KEY StringField (FieldKey,StringVal(32)) +); +INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3'); +EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref FieldKey,LongField,StringField LongField 36 const 2 Using where +SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; +FieldKey LongVal StringVal +1 0 2 +1 1 3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range FieldKey,LongField,StringField FieldKey 36 NULL 4 Using where; Using filesort +SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal; +FieldKey LongVal StringVal +3 1 2 +3 2 1 +3 3 3 +EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range FieldKey,LongField,StringField LongField 36 NULL 4 Using where +SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; +FieldKey LongVal StringVal +3 1 2 +3 2 1 +3 3 3 +DROP TABLE t1; diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 41fccc2743c..30a0cd01c51 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -2,6 +2,7 @@ flush query cache; flush query cache; reset query cache; flush status; +drop database if exists mysqltest; drop table if exists t1,t2,t3,t11,t21, mysqltest.t1; create table t1 (a int not null); insert into t1 values (1),(2),(3); @@ -531,6 +532,7 @@ i show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 2 +update t1 set i=(select distinct 1 from (select * from t2) a); drop table t1, t2, t3; use mysql; select * from db; diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index a1d258455dc..86a93398a9f 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -15,8 +15,8 @@ event_date type event_id 1999-07-13 100600 26 1999-07-14 100600 10 explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; -Comment -Impossible WHERE +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099; event_date type event_id 1999-07-10 100100 24 @@ -193,7 +193,7 @@ INSERT INTO t1 (art) VALUES ('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j' ('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'); select count(*) from t1 where upper(art) = 'J'; count(*) -602 +213 select count(*) from t1 where art = 'J' or art = 'j'; count(*) 602 diff --git a/mysql-test/r/rename.result b/mysql-test/r/rename.result index b2bb659502a..e422fbe49c1 100644 --- a/mysql-test/r/rename.result +++ b/mysql-test/r/rename.result @@ -37,3 +37,5 @@ select * from t3; 3 table 3 3 table 3 drop table if exists t1,t2,t3,t4; +Warnings: +Note 1051 Unknown table 't4' diff --git a/mysql-test/r/replace.result b/mysql-test/r/replace.result index 0aa80e18ccc..4a71428b2f4 100644 --- a/mysql-test/r/replace.result +++ b/mysql-test/r/replace.result @@ -12,15 +12,17 @@ replace into t1 (gesuchnr,benutzer_id) values (1,1); alter table t1 type=heap; replace into t1 (gesuchnr,benutzer_id) values (1,1); drop table t1; -create table t1 (a tinyint not null auto_increment primary key, b char(20)); -insert into t1 values (126,"first"),(0,"last"); +create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value"); +insert into t1 values (126,"first"),(63, "middle"),(0,"last"); insert into t1 values (0,"error"); Duplicate entry '127' for key 1 replace into t1 values (0,"error"); Duplicate entry '127' for key 1 replace into t1 values (126,"first updated"); +replace into t1 values (63,default); select * from t1; a b 126 first updated +63 default_value 127 last drop table t1; diff --git a/mysql-test/r/rollback.result b/mysql-test/r/rollback.result index a5eb6f8729f..d87aa68dce4 100644 --- a/mysql-test/r/rollback.result +++ b/mysql-test/r/rollback.result @@ -4,9 +4,26 @@ begin work; insert into t1 values (4); insert into t1 values (5); rollback; -Warning: Some non-transactional changed tables couldn't be rolled back +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +select @@warning_count; +@@warning_count +1 +select @@error_count; +@@error_count +0 +show warnings; +Level Code Message +Warning 1196 Some non-transactional changed tables couldn't be rolled back +show errors; +Level Code Message select * from t1; n 4 5 +select @@warning_count; +@@warning_count +0 +show warnings; +Level Code Message drop table t1; diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result new file mode 100644 index 00000000000..79eb6cc7e59 --- /dev/null +++ b/mysql-test/r/row.result @@ -0,0 +1,167 @@ +drop table if exists t1; +select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3)); +(1,2,3) IN ((3,2,3), (1,2,3), (1,3,3)) +1 +select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3)); +row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3)) +0 +select row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); +row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)) +1 +select row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); +row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)) +0 +select row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a')); +row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a')) +1 +select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3)); +row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3)) +1 +select row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3)); +row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3)) +1 +select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); +row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)) +1 +select row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); +row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)) +0 +select row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3)); +row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3)) +NULL +select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3)); +row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3)) +0 +select (1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4))); +(1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4))) +1 +select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4)); +Cardinality error (more/less than 2 columns) +select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))); +row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))) +NULL +SELECT (1,2,3)=(0,NULL,3); +(1,2,3)=(0,NULL,3) +0 +SELECT (1,2,3)=(1,NULL,3); +(1,2,3)=(1,NULL,3) +NULL +SELECT (1,2,3)=(1,NULL,0); +(1,2,3)=(1,NULL,0) +NULL +SELECT ROW(1,2,3)=ROW(1,2,3); +ROW(1,2,3)=ROW(1,2,3) +1 +SELECT ROW(2,2,3)=ROW(1+1,2,3); +ROW(2,2,3)=ROW(1+1,2,3) +1 +SELECT ROW(1,2,3)=ROW(1+1,2,3); +ROW(1,2,3)=ROW(1+1,2,3) +0 +SELECT ROW(1,2,3)<ROW(1+1,2,3); +ROW(1,2,3)<ROW(1+1,2,3) +1 +SELECT ROW(1,2,3)>ROW(1+1,2,3); +ROW(1,2,3)>ROW(1+1,2,3) +0 +SELECT ROW(1,2,3)<=ROW(1+1,2,3); +ROW(1,2,3)<=ROW(1+1,2,3) +1 +SELECT ROW(1,2,3)>=ROW(1+1,2,3); +ROW(1,2,3)>=ROW(1+1,2,3) +0 +SELECT ROW(1,2,3)<>ROW(1+1,2,3); +ROW(1,2,3)<>ROW(1+1,2,3) +1 +SELECT ROW(NULL,2,3)=ROW(NULL,2,3); +ROW(NULL,2,3)=ROW(NULL,2,3) +NULL +SELECT ROW(NULL,2,3)<=>ROW(NULL,2,3); +ROW(NULL,2,3)<=>ROW(NULL,2,3) +1 +SELECT ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5)); +ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5)) +1 +SELECT ROW('test',2,3.33)=ROW('test',2,3.33); +ROW('test',2,3.33)=ROW('test',2,3.33) +1 +SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4); +Cardinality error (more/less than 3 columns) +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33)); +ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33)) +1 +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3)); +ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3)) +0 +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL)); +ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL)) +NULL +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,4); +Cardinality error (more/less than 2 columns) +create table t1 ( a int, b int, c int); +insert into t1 values (1,2,3), (2,3,1), (3,2,1), (1,2,NULL); +select * from t1 where ROW(1,2,3)=ROW(a,b,c); +a b c +1 2 3 +select * from t1 where ROW(0,2,3)=ROW(a,b,c); +a b c +select * from t1 where ROW(1,2,3)<ROW(a,b,c); +a b c +2 3 1 +3 2 1 +select ROW(a,2,3) IN(row(1,b,c), row(2,3,1)) from t1; +ROW(a,2,3) IN(row(1,b,c), row(2,3,1)) +1 +0 +0 +NULL +select ROW(c,2,3) IN(row(1,b,a), row(2,3,1)) from t1; +ROW(c,2,3) IN(row(1,b,a), row(2,3,1)) +0 +0 +1 +NULL +select ROW(a,b,c) IN(row(1,2,3), row(3,2,1)) from t1; +ROW(a,b,c) IN(row(1,2,3), row(3,2,1)) +1 +0 +1 +NULL +select ROW(1,2,3) IN(row(a,b,c), row(1,2,3)) from t1; +ROW(1,2,3) IN(row(a,b,c), row(1,2,3)) +1 +1 +1 +1 +drop table t1; +select ROW(1,1); +Cardinality error (more/less than 1 columns) +create table t1 (i int); +select 1 from t1 where ROW(1,1); +Cardinality error (more/less than 1 columns) +select count(*) from t1 order by ROW(1,1); +Cardinality error (more/less than 1 columns) +select count(*) from t1 having (1,1) order by i; +Cardinality error (more/less than 1 columns) +drop table t1; +create table t1 (a int, b int); +insert into t1 values (1, 4); +insert into t1 values (10, 40); +insert into t1 values (1, 4); +insert into t1 values (10, 43); +insert into t1 values (1, 4); +insert into t1 values (10, 41); +insert into t1 values (1, 4); +insert into t1 values (10, 43); +insert into t1 values (1, 4); +select a, MAX(b), (1, MAX(b)) = (1, 4) from t1 group by a; +a MAX(b) (1, MAX(b)) = (1, 4) +1 4 1 +10 43 0 +drop table t1; +SELECT ROW(2,10) <=> ROW(3,4); +ROW(2,10) <=> ROW(3,4) +0 +SELECT ROW(NULL,10) <=> ROW(3,NULL); +ROW(NULL,10) <=> ROW(3,NULL) +0 diff --git a/mysql-test/r/rpl000001.result b/mysql-test/r/rpl000001.result index f3b52b43b19..8aa667df063 100644 --- a/mysql-test/r/rpl000001.result +++ b/mysql-test/r/rpl000001.result @@ -1,10 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop table if exists t1,t2,t3; +start slave; create table t1 (word char(20) not null); load data infile '../../std_data/words.dat' into table t1; load data local infile 'MYSQL_TEST_DIR/std_data/words.dat' into table t1; @@ -20,9 +19,9 @@ abandoned abandoning abandonment abandons -slave stop; +stop slave; set password for root@"localhost" = password('foo'); -slave start; +start slave; set password for root@"localhost" = password(''); create table t3(n int); insert into t3 values(1),(2); @@ -35,13 +34,13 @@ sum(length(word)) 1022 drop table t1,t3; reset master; -slave stop; +stop slave; reset slave; create table t1(n int); select get_lock("hold_slave",10); get_lock("hold_slave",10) 1 -slave start; +start slave; select release_lock("hold_slave"); release_lock("hold_slave") 1 @@ -58,7 +57,7 @@ kill @id; drop table t2; Server shutdown in progress set global sql_slave_skip_counter=1; -slave start; +start slave; select count(*) from t1; count(*) 5000 diff --git a/mysql-test/r/rpl000002.result b/mysql-test/r/rpl000002.result index 4c2b3bdfde6..56e34b4874f 100644 --- a/mysql-test/r/rpl000002.result +++ b/mysql-test/r/rpl000002.result @@ -1,10 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop table if exists t1; +start slave; create table t1 (n int auto_increment primary key); set insert_id = 2000; insert into t1 values (NULL),(NULL),(NULL); @@ -17,15 +16,14 @@ show slave hosts; Server_id Host Port Rpl_recovery_rank Master_id 2 127.0.0.1 9999 2 1 drop table t1; -slave stop; -drop table if exists t2; +stop slave; create table t2(id int auto_increment primary key, created datetime); set timestamp=12345; insert into t2 set created=now(); select * from t2; id created 1 1970-01-01 06:25:45 -slave start; +start slave; select * from t2; id created 1 1970-01-01 06:25:45 diff --git a/mysql-test/r/rpl000003.result b/mysql-test/r/rpl000003.result deleted file mode 100644 index b123b3d98c5..00000000000 --- a/mysql-test/r/rpl000003.result +++ /dev/null @@ -1,17 +0,0 @@ -slave stop; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -reset master; -reset slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop table if exists t1; -create table t1(n int primary key); -insert into t1 values (1),(2),(2); -Duplicate entry '2' for key 1 -insert into t1 values (3); -select * from t1; -n -1 -2 -3 -drop table t1; diff --git a/mysql-test/r/rpl000004.result b/mysql-test/r/rpl000004.result index 3142adc50d6..9abb4db7974 100644 --- a/mysql-test/r/rpl000004.result +++ b/mysql-test/r/rpl000004.result @@ -1,22 +1,17 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; set SQL_LOG_BIN=0; -drop table if exists t1; create table t1 (word char(20) not null, index(word)); load data infile '../../std_data/words.dat' into table t1; -drop table if exists t2; create table t2 (word char(20) not null); load data infile '../../std_data/words.dat' into table t2; create table t3 (word char(20) not null primary key); -drop table if exists t1; load table t1 from master; -drop table if exists t2; load table t2 from master; -drop table if exists t3; load table t3 from master; check table t1; Table Op Msg_type Msg_text diff --git a/mysql-test/r/rpl000005.result b/mysql-test/r/rpl000005.result index 3e9028bf2cf..0202e43dcb2 100644 --- a/mysql-test/r/rpl000005.result +++ b/mysql-test/r/rpl000005.result @@ -1,10 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop table if exists t1; +start slave; CREATE TABLE t1 (name varchar(64), age smallint(3)); INSERT INTO t1 SET name='Andy', age=31; INSERT t1 SET name='Jacob', age=2; diff --git a/mysql-test/r/rpl000006.result b/mysql-test/r/rpl000006.result index e7fc5151ac4..7209ec3c3d1 100644 --- a/mysql-test/r/rpl000006.result +++ b/mysql-test/r/rpl000006.result @@ -1,17 +1,15 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; set SQL_LOG_BIN=0,timestamp=200006; -drop table if exists t1; create table t1(t timestamp not null,a char(1)); insert into t1 ( a) values ('F'); select unix_timestamp(t) from t1; unix_timestamp(t) 200006 -drop table if exists t1; load table t1 from master; select unix_timestamp(t) from t1; unix_timestamp(t) diff --git a/mysql-test/r/rpl000008.result b/mysql-test/r/rpl000008.result index a0230d55702..a88a3c690ed 100644 --- a/mysql-test/r/rpl000008.result +++ b/mysql-test/r/rpl000008.result @@ -1,25 +1,23 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; use test; -drop table if exists foo; -create table foo (n int); -insert into foo values(4); +drop table if exists mysqltest_foo; +drop table if exists mysqltest_bar; +create table mysqltest_foo (n int); +insert into mysqltest_foo values(4); use test; -drop table if exists foo; -create table foo (n int); -insert into foo values(5); -drop table if exists bar; -create table bar (m int); -insert into bar values(15); -drop table if exists choo; -create table choo (k int); -insert into choo values(55); -select foo.n,bar.m,choo.k from foo,bar,choo; +create table mysqltest_foo (n int); +insert into mysqltest_foo values(5); +create table mysqltest_bar (m int); +insert into mysqltest_bar values(15); +create table t1 (k int); +insert into t1 values(55); +select mysqltest_foo.n,mysqltest_bar.m,t1.k from mysqltest_foo,mysqltest_bar,t1; n m k 4 15 55 -drop table if exists foo,bar,choo; -drop table if exists foo,bar,choo; +drop table mysqltest_foo,mysqltest_bar,t1; +drop table mysqltest_foo,mysqltest_bar,t1; diff --git a/mysql-test/r/rpl000009.result b/mysql-test/r/rpl000009.result index 002f6843953..06f34842577 100644 --- a/mysql-test/r/rpl000009.result +++ b/mysql-test/r/rpl000009.result @@ -1,85 +1,85 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop database if exists foo; -create database foo; -drop database if exists bar; -create database bar; -create database foo; -drop table if exists foo.foo; -create table foo.foo (n int); -insert into foo.foo values(4); -drop table if exists foo.foo; -create table foo.foo (n int); -insert into foo.foo values(5); -drop table if exists bar.bar; -create table bar.bar (m int); -insert into bar.bar values(15); -select foo.foo.n,bar.bar.m from foo.foo,bar.bar; +start slave; +drop database if exists mysqltest2; +create database mysqltest2; +drop database if exists mysqltest; +create database mysqltest; +create database mysqltest2; +create table mysqltest2.foo (n int); +insert into mysqltest2.foo values(4); +create table mysqltest2.foo (n int); +insert into mysqltest2.foo values(5); +create table mysqltest.bar (m int); +insert into mysqltest.bar values(15); +select mysqltest2.foo.n,mysqltest.bar.m from mysqltest2.foo,mysqltest.bar; n m 4 15 -drop database bar; -drop database if exists foo; -drop database bar; -Can't drop database 'bar'. Database doesn't exist -drop database foo; +drop database mysqltest; +drop database if exists mysqltest2; +drop database mysqltest; +Can't drop database 'mysqltest'. Database doesn't exist +drop database mysqltest2; set sql_log_bin = 0; -create database foo; -create database bar; +create database mysqltest2; +create database mysqltest; show databases; Database -bar -foo mysql +mysqltest +mysqltest2 test -create table foo.t1(n int, s char(20)); -create table foo.t2(n int, s text); -insert into foo.t1 values (1, 'one'), (2, 'two'), (3, 'three'); -insert into foo.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen'); -create table bar.t1(n int, s char(20)); -create table bar.t2(n int, s text); -insert into bar.t1 values (1, 'one bar'), (2, 'two bar'), (3, 'three bar'); -insert into bar.t2 values (11, 'eleven bar'), (12, 'twelve bar'), -(13, 'thirteen bar'); +create table mysqltest2.t1(n int, s char(20)); +create table mysqltest2.t2(n int, s text); +insert into mysqltest2.t1 values (1, 'one'), (2, 'two'), (3, 'three'); +insert into mysqltest2.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen'); +create table mysqltest.t1(n int, s char(20)); +create table mysqltest.t2(n int, s text); +insert into mysqltest.t1 values (1, 'one test'), (2, 'two test'), (3, 'three test'); +insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'), +(13, 'thirteen test'); set sql_log_bin = 1; show databases; Database mysql test load data from master; +Warnings: +Note 1008 Can't drop database 'mysqltest'. Database doesn't exist +Note 1008 Can't drop database 'mysqltest2'. Database doesn't exist show databases; Database -bar -foo mysql +mysqltest +mysqltest2 test -use foo; +use mysqltest2; show tables; -Tables_in_foo -use bar; +Tables_in_mysqltest2 +use mysqltest; show tables; -Tables_in_bar +Tables_in_mysqltest t1 t2 -select * from bar.t1; +select * from mysqltest.t1; n s -1 one bar -2 two bar -3 three bar -select * from bar.t2; +1 one test +2 two test +3 three test +select * from mysqltest.t2; n s -11 eleven bar -12 twelve bar -13 thirteen bar -insert into bar.t1 values (4, 'four bar'); -select * from bar.t1; +11 eleven test +12 twelve test +13 thirteen test +insert into mysqltest.t1 values (4, 'four test'); +select * from mysqltest.t1; n s -1 one bar -2 two bar -3 three bar -4 four bar -drop database bar; -drop database foo; +1 one test +2 two test +3 three test +4 four test +drop database mysqltest; +drop database mysqltest2; diff --git a/mysql-test/r/rpl000010.result b/mysql-test/r/rpl000010.result index 49538ed148e..65191ea411f 100644 --- a/mysql-test/r/rpl000010.result +++ b/mysql-test/r/rpl000010.result @@ -1,11 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop table if exists t1; -drop table if exists t1; +start slave; create table t1 (n int not null auto_increment primary key); insert into t1 values(NULL); insert into t1 values(2); diff --git a/mysql-test/r/rpl000011.result b/mysql-test/r/rpl000011.result index 5d22c29bdba..dd0fa2fbe74 100644 --- a/mysql-test/r/rpl000011.result +++ b/mysql-test/r/rpl000011.result @@ -1,14 +1,13 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop table if exists t1; +start slave; create table t1 (n int); insert into t1 values(1); -slave stop; -slave start; +stop slave; +start slave; insert into t1 values(2); select * from t1; n diff --git a/mysql-test/r/rpl000012.result b/mysql-test/r/rpl000012.result index 45de6502bbd..17fb53010ab 100644 --- a/mysql-test/r/rpl000012.result +++ b/mysql-test/r/rpl000012.result @@ -1,21 +1,19 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop table if exists t1,t2,t3; +start slave; create table t2 (n int); create temporary table t1 (n int); insert into t1 values(1),(2),(3); insert into t2 select * from t1; -drop table if exists test.t3; -create temporary table test.t3 (n int not null); -alter table test.t3 add primary key(n); +create temporary table t3 (n int not null); +alter table t3 add primary key(n); flush logs; insert into t3 values (100); insert into t2 select * from t3; -drop table if exists test.t3; +drop table if exists t3; insert into t2 values (101); create temporary table t1 (n int); insert into t1 values (4),(5); @@ -35,3 +33,5 @@ show status like 'Slave_open_temp_tables'; Variable_name Value Slave_open_temp_tables 0 drop table if exists t1,t2; +Warnings: +Note 1051 Unknown table 't1' diff --git a/mysql-test/r/rpl000013.result b/mysql-test/r/rpl000013.result index 9e802da59c5..37838bb88e0 100644 --- a/mysql-test/r/rpl000013.result +++ b/mysql-test/r/rpl000013.result @@ -1,10 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop table if exists t2; +start slave; create table t2(n int); create temporary table t1 (n int); insert into t1 values(1),(2),(3); @@ -25,3 +24,5 @@ show status like 'Slave_open_temp_tables'; Variable_name Value Slave_open_temp_tables 0 drop table if exists t1,t2; +Warnings: +Note 1051 Unknown table 't1' diff --git a/mysql-test/r/rpl000015.result b/mysql-test/r/rpl000015.result index 7010349e5ff..349365e17ad 100644 --- a/mysql-test/r/rpl000015.result +++ b/mysql-test/r/rpl000015.result @@ -1,23 +1,23 @@ reset master; show master status; File Position Binlog_do_db Binlog_ignore_db -master-bin.001 79 +master-bin.000001 79 reset slave; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space change master to master_host='127.0.0.1'; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 test MASTER_PORT 7 4 slave-relay-bin.001 4 No No 0 0 0 4 +127.0.0.1 test MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=MASTER_PORT; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 7 4 slave-relay-bin.001 4 No No 0 0 0 4 -slave start; +127.0.0.1 root MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 +start slave; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 7 master-bin.001 79 slave-relay-bin.001 120 master-bin.001 Yes Yes 0 0 79 120 +127.0.0.1 root MASTER_PORT 7 master-bin.000001 79 slave-relay-bin.000001 123 master-bin.000001 Yes Yes 0 0 79 123 drop table if exists t1; create table t1 (n int); insert into t1 values (10),(45),(90); diff --git a/mysql-test/r/rpl000017.result b/mysql-test/r/rpl000017.result index bac0573165d..64e13042e9c 100644 --- a/mysql-test/r/rpl000017.result +++ b/mysql-test/r/rpl000017.result @@ -1,7 +1,7 @@ reset master; grant replication slave on *.* to replicate@localhost identified by 'aaaaaaaaaaaaaaab'; grant replication slave on *.* to replicate@127.0.0.1 identified by 'aaaaaaaaaaaaaaab'; -slave start; +start slave; drop table if exists t1; create table t1(n int); insert into t1 values(24); diff --git a/mysql-test/r/rpl000018.result b/mysql-test/r/rpl000018.result index ba51406bba0..7211d440524 100644 --- a/mysql-test/r/rpl000018.result +++ b/mysql-test/r/rpl000018.result @@ -1,9 +1,9 @@ reset slave; -slave start; -show master logs; +start slave; +show binary logs; Log_name -master-bin.001 -master-bin.002 +master-bin.000001 +master-bin.000002 drop table if exists t1; create table t1(n int); insert into t1 values (3351); diff --git a/mysql-test/r/rpl_alter.result b/mysql-test/r/rpl_alter.result index 1dc73c6524a..e7abc3b3b48 100644 --- a/mysql-test/r/rpl_alter.result +++ b/mysql-test/r/rpl_alter.result @@ -1,21 +1,21 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop database if exists d1; -create database d1; -create table d1.t1 ( n int); -alter table d1.t1 add m int; -insert into d1.t1 values (1,2); -create table d1.t2 (n int); -insert into d1.t2 values (45); -rename table d1.t2 to d1.t3, d1.t1 to d1.t2; -select * from d1.t2; +start slave; +drop database if exists test_$1; +create database test_$1; +create table test_$1.t1 ( n int); +alter table test_$1.t1 add m int; +insert into test_$1.t1 values (1,2); +create table test_$1.t2 (n int); +insert into test_$1.t2 values (45); +rename table test_$1.t2 to test_$1.t3, test_$1.t1 to test_$1.t2; +select * from test_$1.t2; n m 1 2 -select * from d1.t3; +select * from test_$1.t3; n 45 -drop database d1; +drop database test_$1; diff --git a/mysql-test/r/rpl_empty_master_crash.result b/mysql-test/r/rpl_empty_master_crash.result index 19e2bf28dcd..8818029ab99 100644 --- a/mysql-test/r/rpl_empty_master_crash.result +++ b/mysql-test/r/rpl_empty_master_crash.result @@ -1,10 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop table if exists t1; +start slave; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space load table t1 from master; diff --git a/mysql-test/r/rpl_failsafe.result b/mysql-test/r/rpl_failsafe.result index 7e8aeea64f7..956555f9318 100644 --- a/mysql-test/r/rpl_failsafe.result +++ b/mysql-test/r/rpl_failsafe.result @@ -1,9 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; show variables like 'rpl_recovery_rank'; Variable_name Value rpl_recovery_rank 1 @@ -18,14 +18,14 @@ rpl_recovery_rank 2 show status like 'Rpl_status'; Variable_name Value Rpl_status ACTIVE_SLAVE -slave start; +start slave; show variables like 'rpl_recovery_rank'; Variable_name Value rpl_recovery_rank 3 show status like 'Rpl_status'; Variable_name Value Rpl_status ACTIVE_SLAVE -slave start; +start slave; show variables like 'rpl_recovery_rank'; Variable_name Value rpl_recovery_rank 4 diff --git a/mysql-test/r/rpl_flush_log_loop.result b/mysql-test/r/rpl_flush_log_loop.result index da2930f30c3..98d661e9af2 100644 --- a/mysql-test/r/rpl_flush_log_loop.result +++ b/mysql-test/r/rpl_flush_log_loop.result @@ -1,17 +1,17 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=MASTER_PORT; -slave start; -slave stop; +start slave; +stop slave; change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=SLAVE_PORT; -slave start; +start slave; flush logs; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root SLAVE_PORT 60 slave-bin.001 79 relay-log.001 119 slave-bin.001 Yes Yes 0 0 79 119 +127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 79 relay-log.000001 122 slave-bin.000001 Yes Yes 0 0 79 122 diff --git a/mysql-test/r/rpl_get_lock.result b/mysql-test/r/rpl_get_lock.result index a8e602be03f..369fde7ef8f 100644 --- a/mysql-test/r/rpl_get_lock.result +++ b/mysql-test/r/rpl_get_lock.result @@ -1,9 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; create table t1(n int); insert into t1 values(get_lock("lock",2)); select get_lock("lock",2); diff --git a/mysql-test/r/rpl_insert_id.result b/mysql-test/r/rpl_insert_id.result index d524818985e..82015bdf538 100644 --- a/mysql-test/r/rpl_insert_id.result +++ b/mysql-test/r/rpl_insert_id.result @@ -1,10 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop table if exists t1; +start slave; create table t1(a int auto_increment, key(a)); create table t2(b int auto_increment, c int, key(b)); insert into t1 values (1),(2),(3); diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index 27f3d185f63..8735cae47d5 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -1,9 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; create table t1(a int not null auto_increment, b int, primary key(a) ); load data infile '../../std_data/rpl_loaddata.dat' into table t1; select * from t1; diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index 5415a153a98..6f438c6c34a 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -1,10 +1,10 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -slave stop; +start slave; +stop slave; reset master; reset slave; reset master; @@ -16,77 +16,77 @@ load data infile '../../std_data/words.dat' into table t1; drop table t1; show binlog events; Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3 -master-bin.001 79 Query 1 79 use test; create table t1(n int not null auto_increment primary key) -master-bin.001 172 Intvar 1 172 INSERT_ID=1 -master-bin.001 200 Query 1 200 use test; insert into t1 values (NULL) -master-bin.001 263 Query 1 263 use test; drop table t1 -master-bin.001 311 Query 1 311 use test; create table t1 (word char(20) not null) -master-bin.001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581 -master-bin.001 1056 Exec_load 1 1056 ;file_id=1 -master-bin.001 1079 Query 1 1079 use test; drop table t1 +master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3 +master-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 172 Intvar 1 172 INSERT_ID=1 +master-bin.000001 200 Query 1 200 use `test`; insert into t1 values (NULL) +master-bin.000001 263 Query 1 263 use `test`; drop table t1 +master-bin.000001 311 Query 1 311 use `test`; create table t1 (word char(20) not null) +master-bin.000001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581 +master-bin.000001 1056 Exec_load 1 1056 ;file_id=1 +master-bin.000001 1079 Query 1 1079 use `test`; drop table t1 show binlog events from 79 limit 1; Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.001 79 Query 1 79 use test; create table t1(n int not null auto_increment primary key) +master-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key) show binlog events from 79 limit 2; Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.001 79 Query 1 79 use test; create table t1(n int not null auto_increment primary key) -master-bin.001 172 Intvar 1 172 INSERT_ID=1 +master-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 172 Intvar 1 172 INSERT_ID=1 show binlog events from 79 limit 2,1; Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.001 200 Query 1 200 use test; insert into t1 values (NULL) +master-bin.000001 200 Query 1 200 use `test`; insert into t1 values (NULL) flush logs; -slave start; +start slave; flush logs; -slave stop; +stop slave; create table t1 (n int); insert into t1 values (1); drop table t1; show binlog events; Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3 -master-bin.001 79 Query 1 79 use test; create table t1(n int not null auto_increment primary key) -master-bin.001 172 Intvar 1 172 INSERT_ID=1 -master-bin.001 200 Query 1 200 use test; insert into t1 values (NULL) -master-bin.001 263 Query 1 263 use test; drop table t1 -master-bin.001 311 Query 1 311 use test; create table t1 (word char(20) not null) -master-bin.001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581 -master-bin.001 1056 Exec_load 1 1056 ;file_id=1 -master-bin.001 1079 Query 1 1079 use test; drop table t1 -master-bin.001 1127 Rotate 1 1127 master-bin.002;pos=4 -show binlog events in 'master-bin.002'; +master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3 +master-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 172 Intvar 1 172 INSERT_ID=1 +master-bin.000001 200 Query 1 200 use `test`; insert into t1 values (NULL) +master-bin.000001 263 Query 1 263 use `test`; drop table t1 +master-bin.000001 311 Query 1 311 use `test`; create table t1 (word char(20) not null) +master-bin.000001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581 +master-bin.000001 1056 Exec_load 1 1056 ;file_id=1 +master-bin.000001 1079 Query 1 1079 use `test`; drop table t1 +master-bin.000001 1127 Rotate 1 1127 master-bin.000002;pos=4 +show binlog events in 'master-bin.000002'; Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.002 4 Query 1 4 use test; create table t1 (n int) -master-bin.002 62 Query 1 62 use test; insert into t1 values (1) -master-bin.002 122 Query 1 122 use test; drop table t1 -show master logs; +master-bin.000002 4 Query 1 4 use `test`; create table t1 (n int) +master-bin.000002 62 Query 1 62 use `test`; insert into t1 values (1) +master-bin.000002 122 Query 1 122 use `test`; drop table t1 +show binary logs; Log_name -master-bin.001 -master-bin.002 -slave start; -show master logs; +master-bin.000001 +master-bin.000002 +start slave; +show binary logs; Log_name -slave-bin.001 -slave-bin.002 -show binlog events in 'slave-bin.001' from 4; +slave-bin.000001 +slave-bin.000002 +show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id Orig_log_pos Info -slave-bin.001 4 Start 2 4 Server ver: VERSION, Binlog ver: 3 -slave-bin.001 79 Query 1 79 use test; create table t1(n int not null auto_increment primary key) -slave-bin.001 172 Intvar 1 172 INSERT_ID=1 -slave-bin.001 200 Query 1 200 use test; insert into t1 values (NULL) -slave-bin.001 263 Query 1 263 use test; drop table t1 -slave-bin.001 311 Query 1 311 use test; create table t1 (word char(20) not null) -slave-bin.001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581 -slave-bin.001 1065 Exec_load 1 1056 ;file_id=1 -slave-bin.001 1088 Query 1 1079 use test; drop table t1 -slave-bin.001 1136 Rotate 2 1136 slave-bin.002;pos=4 -show binlog events in 'slave-bin.002' from 4; +slave-bin.000001 4 Start 2 4 Server ver: VERSION, Binlog ver: 3 +slave-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key) +slave-bin.000001 172 Intvar 1 172 INSERT_ID=1 +slave-bin.000001 200 Query 1 200 use `test`; insert into t1 values (NULL) +slave-bin.000001 263 Query 1 263 use `test`; drop table t1 +slave-bin.000001 311 Query 1 311 use `test`; create table t1 (word char(20) not null) +slave-bin.000001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581 +slave-bin.000001 1065 Exec_load 1 1056 ;file_id=1 +slave-bin.000001 1088 Query 1 1079 use `test`; drop table t1 +slave-bin.000001 1136 Rotate 2 1136 slave-bin.000002;pos=4 +show binlog events in 'slave-bin.000002' from 4; Log_name Pos Event_type Server_id Orig_log_pos Info -slave-bin.002 4 Query 1 4 use test; create table t1 (n int) -slave-bin.002 62 Query 1 62 use test; insert into t1 values (1) -slave-bin.002 122 Query 1 122 use test; drop table t1 +slave-bin.000002 4 Query 1 4 use `test`; create table t1 (n int) +slave-bin.000002 62 Query 1 62 use `test`; insert into t1 values (1) +slave-bin.000002 122 Query 1 122 use `test`; drop table t1 show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 1 master-bin.002 170 slave-relay-bin.002 1457 master-bin.002 Yes Yes 0 0 170 1461 -show binlog events in 'slave-bin.005' from 4; +127.0.0.1 root MASTER_PORT 1 master-bin.000002 170 slave-relay-bin.000002 1469 master-bin.000002 Yes Yes 0 0 170 1473 +show binlog events in 'slave-bin.000005' from 4; Error when executing command SHOW BINLOG EVENTS: Could not find target log diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result index e76b565813f..fa38e42ae73 100644 --- a/mysql-test/r/rpl_log_pos.result +++ b/mysql-test/r/rpl_log_pos.result @@ -1,43 +1,43 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; show master status; File Position Binlog_do_db Binlog_ignore_db -master-bin.001 79 +master-bin.000001 79 show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 1 master-bin.001 79 slave-relay-bin.002 120 master-bin.001 Yes Yes 0 0 79 124 -slave stop; +127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 127 +stop slave; change master to master_log_pos=73; -slave start; -slave stop; +start slave; +stop slave; change master to master_log_pos=73; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 1 master-bin.001 73 slave-relay-bin.001 4 master-bin.001 No No 0 0 73 4 -slave start; +127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 73 4 +start slave; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 1 master-bin.001 73 slave-relay-bin.001 4 master-bin.001 No Yes 0 0 73 4 -slave stop; +127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 4 master-bin.000001 No Yes 0 0 73 4 +stop slave; change master to master_log_pos=173; -slave start; +start slave; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 1 master-bin.001 173 slave-relay-bin.001 4 master-bin.001 No Yes 0 0 173 4 +127.0.0.1 root MASTER_PORT 1 master-bin.000001 173 slave-relay-bin.000001 4 master-bin.000001 No Yes 0 0 173 4 show master status; File Position Binlog_do_db Binlog_ignore_db -master-bin.001 79 +master-bin.000001 79 create table if not exists t1 (n int); drop table if exists t1; create table t1 (n int); insert into t1 values (1),(2),(3); -slave stop; +stop slave; change master to master_log_pos=79; -slave start; +start slave; select * from t1; n 1 diff --git a/mysql-test/r/rpl_master_pos_wait.result b/mysql-test/r/rpl_master_pos_wait.result index 22c7aef621c..801ffad6975 100644 --- a/mysql-test/r/rpl_master_pos_wait.result +++ b/mysql-test/r/rpl_master_pos_wait.result @@ -1,9 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; select master_pos_wait('master-bin.999999',0,10); master_pos_wait('master-bin.999999',0,10) -1 diff --git a/mysql-test/r/rpl_mystery22.result b/mysql-test/r/rpl_mystery22.result index 5dd665fe9d5..348b3211cd5 100644 --- a/mysql-test/r/rpl_mystery22.result +++ b/mysql-test/r/rpl_mystery22.result @@ -1,20 +1,20 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; create table t1(n int auto_increment primary key); insert into t1 values (2); insert into t1 values(NULL); insert into t1 values(NULL); delete from t1 where n = 2; -slave start; -slave stop; +start slave; +stop slave; create table t2(n int); drop table t2; insert into t1 values(NULL); -slave start; +start slave; select * from t1; n 1 diff --git a/mysql-test/r/rpl_redirect.result b/mysql-test/r/rpl_redirect.result index 6103a075684..3807479fb54 100644 --- a/mysql-test/r/rpl_redirect.result +++ b/mysql-test/r/rpl_redirect.result @@ -1,15 +1,14 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; SHOW SLAVE STATUS; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space SHOW SLAVE HOSTS; Server_id Host Port Rpl_recovery_rank Master_id 2 127.0.0.1 SLAVE_PORT 2 1 -drop table if exists t1; create table t1 ( n int); insert into t1 values (1),(2),(3),(4); insert into t1 values(5); diff --git a/mysql-test/r/rpl_replicate_do.result b/mysql-test/r/rpl_replicate_do.result index 372d8c07f64..9ae292c2709 100644 --- a/mysql-test/r/rpl_replicate_do.result +++ b/mysql-test/r/rpl_replicate_do.result @@ -1,9 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; drop table if exists t11; drop table if exists t11; create table t2 (n int); @@ -25,4 +25,4 @@ n 4 select * from t11; Table 'test.t11' doesn't exist -drop table if exists t1,t2,t3,t11; +drop table if exists t1,t2,t11; diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index 741c53fe52b..c4023832921 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -1,36 +1,35 @@ drop table if exists t1, t2, t3, t4; drop table if exists t1, t2, t3, t4; -slave start; +start slave; Could not initialize master info structure, check permisions on master.info -slave start; +start slave; Could not initialize master info structure, check permisions on master.info change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root'; Could not initialize master info reset slave; change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root'; reset master; -slave start; +start slave; create temporary table temp_table (a char(80) not null); insert into temp_table values ("testing temporary tables"); create table t1 (s text); insert into t1 values('Could not break slave'),('Tried hard'); show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 60 master-bin.001 417 slave-relay-bin.001 458 master-bin.001 Yes Yes 0 0 417 458 +127.0.0.1 root MASTER_PORT 60 master-bin.000001 417 slave-relay-bin.000001 461 master-bin.000001 Yes Yes 0 0 417 461 select * from t1; s Could not break slave Tried hard flush logs; -drop table if exists t2; create table t2(m int not null auto_increment primary key); insert into t2 values (34),(67),(123); flush logs; -show master logs; +show binary logs; Log_name -master-bin.001 -master-bin.002 -master-bin.003 +master-bin.000001 +master-bin.000002 +master-bin.000003 create table t3 select * from temp_table; select * from t3; a @@ -40,15 +39,20 @@ insert into t2 values(1234); set insert_id=1234; insert into t2 values(NULL); set global sql_slave_skip_counter=1; -slave start; -purge master logs to 'master-bin.003'; -show master logs; +start slave; +purge master logs to 'master-bin.000002'; +show binary logs; Log_name -master-bin.003 +master-bin.000002 +master-bin.000003 +purge logs before now(); +show binary logs; +Log_name +master-bin.000003 insert into t2 values (65); show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 60 master-bin.003 290 slave-relay-bin.001 1073 master-bin.003 Yes Yes 0 0 290 1073 +127.0.0.1 root MASTER_PORT 60 master-bin.000003 290 slave-relay-bin.000001 1088 master-bin.000003 Yes Yes 0 0 290 1088 select * from t2; m 34 @@ -58,24 +62,23 @@ m 1234 create temporary table temp_table (a char(80) not null); insert into temp_table values ("testing temporary tables part 2"); -drop table if exists t3; create table t3 (n int); create table t4 select * from temp_table; -show master logs; +show binary logs; Log_name -master-bin.003 -master-bin.004 -master-bin.005 -master-bin.006 +master-bin.000003 +master-bin.000004 +master-bin.000005 +master-bin.000006 show master status; File Position Binlog_do_db Binlog_ignore_db -master-bin.006 838 +master-bin.000006 838 select * from t4; a testing temporary tables part 2 show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 60 master-bin.006 838 slave-relay-bin.001 8034 master-bin.006 Yes Yes 0 0 838 8034 +127.0.0.1 root MASTER_PORT 60 master-bin.000006 838 slave-relay-bin.000001 8067 master-bin.000006 Yes Yes 0 0 838 8067 lock tables t3 read; select count(*) from t3 where n >= 4; count(*) diff --git a/mysql-test/r/rpl_skip_error.result b/mysql-test/r/rpl_skip_error.result index 946d64ad7c5..e52426c381c 100644 --- a/mysql-test/r/rpl_skip_error.result +++ b/mysql-test/r/rpl_skip_error.result @@ -1,10 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; -drop table if exists t1; +start slave; create table t1 (n int not null primary key); insert into t1 values (1); insert into t1 values (1); diff --git a/mysql-test/r/rpl_sporadic_master.result b/mysql-test/r/rpl_sporadic_master.result index a6a58515f0a..789c3bf2b2b 100644 --- a/mysql-test/r/rpl_sporadic_master.result +++ b/mysql-test/r/rpl_sporadic_master.result @@ -1,16 +1,16 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; create table t2(n int); create table t1(n int not null auto_increment primary key); insert into t1 values (NULL),(NULL); truncate table t1; insert into t1 values (4),(NULL); -slave stop; -slave start; +stop slave; +start slave; insert into t1 values (NULL),(NULL); flush logs; truncate table t1; diff --git a/mysql-test/r/rpl_temporary.result b/mysql-test/r/rpl_temporary.result new file mode 100644 index 00000000000..3d811aeb09c --- /dev/null +++ b/mysql-test/r/rpl_temporary.result @@ -0,0 +1,74 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +reset master; +drop table if exists t1,t2; +create table t1(f int); +create table t2(f int); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +create temporary table t3(f int); +insert into t3 select * from t1 where f<6; +create temporary table t3(f int); +insert into t2 select count(*) from t3; +insert into t3 select * from t1 where f>=4; +drop temporary table t3; +insert into t2 select count(*) from t3; +drop temporary table t3; +select * from t2; +f +5 +7 +show binlog events; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3 +master-bin.000001 79 Query 1 79 use `test`; create table t1(f int) +master-bin.000001 136 Query 1 136 use `test`; create table t2(f int) +master-bin.000001 193 Query 1 193 use `test`; insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10) +master-bin.000001 290 Query 1 290 use `test`; create temporary table t3(f int) +master-bin.000001 357 Query 1 357 use `test`; insert into t3 select * from t1 where f<6 +master-bin.000001 433 Query 1 433 use `test`; create temporary table t3(f int) +master-bin.000001 500 Query 1 500 use `test`; insert into t2 select count(*) from t3 +master-bin.000001 573 Query 1 573 use `test`; insert into t3 select * from t1 where f>=4 +master-bin.000001 650 Query 1 650 use `test`; drop temporary table t3 +master-bin.000001 708 Query 1 708 use `test`; insert into t2 select count(*) from t3 +master-bin.000001 781 Query 1 781 use `test`; drop temporary table t3 +drop table t1, t2; +use test; +SET TIMESTAMP=1040323920; +create table t1(f int); +SET TIMESTAMP=1040323931; +create table t2(f int); +SET TIMESTAMP=1040323938; +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +SET TIMESTAMP=1040323945; +SET @@session.pseudo_thread_id=1; +create temporary table t3(f int); +SET TIMESTAMP=1040323952; +SET @@session.pseudo_thread_id=1; +insert into t3 select * from t1 where f<6; +SET TIMESTAMP=1040324145; +SET @@session.pseudo_thread_id=2; +create temporary table t3(f int); +SET TIMESTAMP=1040324186; +SET @@session.pseudo_thread_id=1; +insert into t2 select count(*) from t3; +SET TIMESTAMP=1040324200; +SET @@session.pseudo_thread_id=2; +insert into t3 select * from t1 where f>=4; +SET TIMESTAMP=1040324211; +SET @@session.pseudo_thread_id=1; +drop temporary table t3; +SET TIMESTAMP=1040324219; +SET @@session.pseudo_thread_id=2; +insert into t2 select count(*) from t3; +SET TIMESTAMP=1040324224; +SET @@session.pseudo_thread_id=2; +drop temporary table t3; +select * from t2; +f +5 +7 +drop table t1,t2; diff --git a/mysql-test/r/rpl_user_variables.result b/mysql-test/r/rpl_user_variables.result new file mode 100644 index 00000000000..2feef3dd4e3 --- /dev/null +++ b/mysql-test/r/rpl_user_variables.result @@ -0,0 +1,75 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +reset master; +create table t1(n char(30)); +set @i1:=12345678901234, @i2:=-12345678901234, @i3:=0, @i4:=-1; +set @s1:='This is a test', @r1:=12.5, @r2:=-12.5; +set @n1:=null; +set @s2:='', @s3:='abc\'def', @s4:= 'abc\\def', @s5:= 'abc''def'; +insert into t1 values (@i1), (@i2), (@i3), (@i4); +insert into t1 values (@r1), (@r2); +insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5); +insert into t1 values (@n1); +insert into t1 values (@n2); +insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1); +insert into t1 values (@a+(@b:=@a+1)); +set @q:='abc'; +insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2')); +set @a:=5; +insert into t1 values (@a),(@a); +select * from t1; +n +12345678901234 +-12345678901234 +0 +-1 +12.5 +-12.5 +This is a test + +abc'def +abc\def +abc'def +NULL +NULL +0 +1 +2 +5 +abc +abcn1 +abcn1n2 +5 +5 +show binlog events from 141; +Log_name Pos Event_type Server_id Orig_log_pos Info +slave-bin.000001 141 User var 2 141 @i1=12345678901234 +slave-bin.000001 184 User var 2 184 @i2=-12345678901234 +slave-bin.000001 227 User var 2 227 @i3=0 +slave-bin.000001 270 User var 2 270 @i4=-1 +slave-bin.000001 313 Query 1 313 use `test`; insert into t1 values (@i1), (@i2), (@i3), (@i4) +slave-bin.000001 396 User var 2 396 @r1=12.5 +slave-bin.000001 439 User var 2 439 @r2=-12.5 +slave-bin.000001 482 Query 1 482 use `test`; insert into t1 values (@r1), (@r2) +slave-bin.000001 551 User var 2 551 @s1='This is a test' +slave-bin.000001 600 User var 2 600 @s2='' +slave-bin.000001 635 User var 2 635 @s3='abc'def' +slave-bin.000001 677 User var 2 677 @s4='abc\def' +slave-bin.000001 719 User var 2 719 @s5='abc'def' +slave-bin.000001 761 Query 1 761 use `test`; insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5) +slave-bin.000001 851 User var 2 851 @n1=NULL +slave-bin.000001 877 Query 1 877 use `test`; insert into t1 values (@n1) +slave-bin.000001 939 Query 1 939 use `test`; insert into t1 values (@n2) +slave-bin.000001 1001 Query 1 1001 use `test`; insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1) +slave-bin.000001 1089 User var 2 1089 @a='2' +slave-bin.000001 1124 Query 1 1124 use `test`; insert into t1 values (@a+(@b:=@a+1)) +slave-bin.000001 1196 User var 2 1196 @q='abc' +slave-bin.000001 1233 Query 1 1233 use `test`; insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2')) +slave-bin.000001 1337 User var 2 1337 @a=5 +slave-bin.000001 1379 Query 1 1379 use `test`; insert into t1 values (@a),(@a) +drop table t1; +stop slave; diff --git a/mysql-test/r/sel000001.result b/mysql-test/r/sel000001.result deleted file mode 100644 index 28f6d3d1d5a..00000000000 --- a/mysql-test/r/sel000001.result +++ /dev/null @@ -1,7 +0,0 @@ -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 (s CHAR(20) PRIMARY KEY, id INT); -INSERT INTO t1 VALUES ('cat', 1), ('mouse', 3), ('dog', 2), ('snake', 77); -SELECT s, id FROM t1 WHERE s = 'mouse'; -s id -mouse 3 -drop table t1; diff --git a/mysql-test/r/sel000002.result b/mysql-test/r/sel000002.result deleted file mode 100644 index b824de8de4a..00000000000 --- a/mysql-test/r/sel000002.result +++ /dev/null @@ -1,9 +0,0 @@ -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 (n INT); -INSERT INTO t1 VALUES (1), (2), (3); -SELECT * FROM t1; -n -1 -2 -3 -drop table t1; diff --git a/mysql-test/r/sel000003.result b/mysql-test/r/sel000003.result deleted file mode 100644 index c3853832f87..00000000000 --- a/mysql-test/r/sel000003.result +++ /dev/null @@ -1,8 +0,0 @@ -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 (name CHAR(20) NOT NULL PRIMARY KEY, score SMALLINT NOT NULL, KEY(score)); -INSERT INTO t1 VALUES ('Sasha', 20), ('Matt', 20), ('Monty', 10), ('David', 10), ('Tim', 10), ('Jeremy', 10); -SELECT COUNT(*) as n, score FROM t1 GROUP BY score; -n score -4 10 -2 20 -drop table t1; diff --git a/mysql-test/r/sel000031.result b/mysql-test/r/sel000031.result deleted file mode 100644 index d3f01ab687f..00000000000 --- a/mysql-test/r/sel000031.result +++ /dev/null @@ -1,12 +0,0 @@ -drop table if exists t1,t2; -create table t1 (id int(10) not null unique); -create table t2 (id int(10) not null primary key, -val int(10) not null); -insert into t1 values (1),(2),(4); -insert into t2 values (1,1),(2,1),(3,1),(4,2); -select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id; -id elt(two.val,'one','two') -1 one -2 one -4 two -drop table t1,t2; diff --git a/mysql-test/r/sel000032.result b/mysql-test/r/sel000032.result deleted file mode 100644 index 4cca245d75b..00000000000 --- a/mysql-test/r/sel000032.result +++ /dev/null @@ -1,12 +0,0 @@ -drop table if exists t1,t2; -create table t1 (id int(10) not null unique); -create table t2 (id int(10) not null primary key, -val int(10) not null); -insert into t1 values (1),(2),(4); -insert into t2 values (1,1),(2,1),(3,1),(4,2); -select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id; -id elt(two.val,'one','two') -1 one -2 one -4 two -drop table t1,t2; diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 1ad3043b4b2..a2bf24cad54 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -1326,20 +1326,20 @@ fld3 select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; fld3 explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; -table type possible_keys key key_len ref rows Extra -t2 ref fld3 fld3 30 const 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; -table type possible_keys key key_len ref rows Extra -t2 ALL NULL NULL NULL NULL 1199 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; -table type possible_keys key key_len ref rows Extra -t2 ALL NULL NULL NULL NULL 1199 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; -table type possible_keys key key_len ref rows Extra -t2 ref fld3 fld3 30 const 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; -table type possible_keys key key_len ref rows Extra -t2 ref fld3 fld3 30 const 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index explain select fld3 from t2 ignore index (fld3,not_used); Key column 'not_used' doesn't exist in table explain select fld3 from t2 use index (not_used); @@ -1349,8 +1349,8 @@ fld3 honeysuckle honoring explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; -table type possible_keys key key_len ref rows Extra -t2 range fld3 fld3 30 NULL 2 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range fld3 fld3 30 NULL 2 Using where; Using index select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; fld1 fld3 148504 Colombo @@ -1369,8 +1369,8 @@ fld1 250501 250502 explain select fld1 from t2 where fld1=250501 or fld1="250502"; -table type possible_keys key key_len ref rows Extra -t2 range fld1 fld1 4 NULL 2 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range fld1 fld1 4 NULL 2 Using where; Using index select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; fld1 250501 @@ -1378,8 +1378,8 @@ fld1 250505 250601 explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; -table type possible_keys key key_len ref rows Extra -t2 range fld1 fld1 4 NULL 4 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range fld1 fld1 4 NULL 4 Using where; Using index select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; fld1 fld3 218401 faithful @@ -1805,21 +1805,21 @@ companynr rtrim(space(512+companynr)) select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; fld3 explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; -table type possible_keys key key_len ref rows Extra -t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort -t3 eq_ref PRIMARY PRIMARY 4 t2.fld1 1 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 t2.fld1 1 Using where; Using index explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; -table type possible_keys key key_len ref rows Extra -t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort -t3 ref period period 4 t1.period 4181 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort +1 SIMPLE t3 ref period period 4 t1.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; -table type possible_keys key key_len ref rows Extra -t3 index period period 4 NULL 41810 -t1 ref period period 4 t3.period 4181 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 index period period 4 NULL 41810 +1 SIMPLE t1 ref period period 4 t3.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; -table type possible_keys key key_len ref rows Extra -t1 index period period 4 NULL 41810 -t3 ref period period 4 t1.period 4181 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index period period 4 NULL 41810 +1 SIMPLE t3 ref period period 4 t1.period 4181 select period from t1; period 9410 @@ -1832,9 +1832,9 @@ select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3. fld3 period breaking 1001 explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; -table type possible_keys key key_len ref rows Extra -t2 const fld1 fld1 4 const 1 -t3 const PRIMARY,period PRIMARY 4 const 1 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 const fld1 fld1 4 const 1 +1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1 select fld3,period from t2,t1 where companynr*10 = 37*10; fld3 period breaking 9410 @@ -2492,7 +2492,6 @@ fld1 fld3 period price price2 018601 vacuuming 1001 5987435 234724 018801 inch 1001 5987435 234724 018811 repetitions 1001 5987435 234724 -drop table if exists company; create table t4 ( companynr tinyint(2) unsigned zerofill NOT NULL default '00', companyname char(30) NOT NULL default '', @@ -2572,21 +2571,21 @@ fld1 fld1 select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; companynr companyname explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; -table type possible_keys key key_len ref rows Extra -t2 ALL NULL NULL NULL NULL 1199 -t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not exists +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 +1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not exists explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; -table type possible_keys key key_len ref rows Extra -t4 ALL NULL NULL NULL NULL 12 -t2 ALL NULL NULL NULL NULL 1199 Using where; Not exists +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 ALL NULL NULL NULL NULL 12 +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Not exists select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; companynr companynr 37 36 41 40 explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; -table type possible_keys key key_len ref rows Extra -t2 ALL NULL NULL NULL NULL 1199 Using temporary -t4 index NULL PRIMARY 1 NULL 12 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using temporary +1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using where; Using index select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; fld1 companynr fld3 period 038008 37 reporters 1008 @@ -2655,14 +2654,14 @@ companynr count(*) 58 23 53 4 50 11 -select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1) from t2 where companynr = 34 and fld4<>""; -count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) -70 absentee vest 17788966 254128.0857 3272.5940 -select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1) from t2 group by companynr limit 3; -companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) -00 82 Anthony windmills 10355753 126289.6707 115550.9757 -29 95 abut wetness 14473298 152350.5053 8368.5480 -34 70 absentee vest 17788966 254128.0857 3272.5940 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087 +29 95 abut wetness 14473298 152350.5053 8368.5480 70032594.9026 +34 70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10; companynr t2nr count(price) sum(price) min(price) max(price) avg(price) 37 1 1 5987435 5987435 5987435 5987435.0000 @@ -3095,11 +3094,11 @@ select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = fld1 sum(price) 038008 234298 explain select fld3 from t2 where 1>2 or 2>3; -Comment -Impossible WHERE +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE explain select fld3 from t2 where fld1=fld1; -table type possible_keys key key_len ref rows Extra -t2 ALL NULL NULL NULL NULL 1199 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; companynr fld1 34 250501 @@ -3150,8 +3149,8 @@ select count(*) from t3 where companynr=512 and price2=76234234; count(*) 4181 explain select min(fld1),max(fld1),count(*) from t2; -Comment -Select tables optimized away +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away select min(fld1),max(fld1),count(*) from t2; min(fld1) max(fld1) count(*) 0 1232609 1199 @@ -3218,23 +3217,23 @@ Tables_in_test (s%) show tables from test like "t?"; Tables_in_test (t?) show full columns from t2; -Field Type Null Key Default Extra Privileges -auto int(11) PRI NULL auto_increment select,insert,update,references -fld1 int(6) unsigned zerofill UNI 000000 select,insert,update,references -companynr tinyint(2) unsigned zerofill 00 select,insert,update,references -fld3 char(30) MUL select,insert,update,references -fld4 char(35) select,insert,update,references -fld5 char(35) select,insert,update,references -fld6 char(4) select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +auto int(11) binary PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill binary UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill binary 00 select,insert,update,references +fld3 char(30) latin1 MUL select,insert,update,references +fld4 char(35) latin1 select,insert,update,references +fld5 char(35) latin1 select,insert,update,references +fld6 char(4) latin1 select,insert,update,references show full columns from t2 from test like 'f%'; -Field Type Null Key Default Extra Privileges -fld1 int(6) unsigned zerofill UNI 000000 select,insert,update,references -fld3 char(30) MUL select,insert,update,references -fld4 char(35) select,insert,update,references -fld5 char(35) select,insert,update,references -fld6 char(4) select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill binary UNI 000000 select,insert,update,references +fld3 char(30) latin1 MUL select,insert,update,references +fld4 char(35) latin1 select,insert,update,references +fld5 char(35) latin1 select,insert,update,references +fld6 char(4) latin1 select,insert,update,references show full columns from t2 from test like 's%'; -Field Type Null Key Default Extra Privileges +Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE @@ -3276,6 +3275,16 @@ select wss_type from t1 where wss_type =102935229216544093; wss_type 102935229216544093 drop table t1; +select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +select @a; +@a +3 +select @b; +@b +aaaa +select @c; +@c +6.26 create table t1 (a int not null auto_increment primary key); insert into t1 values (); insert into t1 values (); diff --git a/mysql-test/r/select_found.result b/mysql-test/r/select_found.result index 0a7f464cf7b..c8991696b5e 100644 --- a/mysql-test/r/select_found.result +++ b/mysql-test/r/select_found.result @@ -168,4 +168,24 @@ test2 2 2 SELECT FOUND_ROWS(); FOUND_ROWS() 2 +SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) as a LIMIT 0; +1 +SELECT FOUND_ROWS(); +FOUND_ROWS() +1 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1 LIMIT 0; +titre numeropost maxnumrep +SELECT FOUND_ROWS(); +FOUND_ROWS() +2 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 0; +titre numeropost maxnumrep +SELECT FOUND_ROWS(); +FOUND_ROWS() +3 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 ORDER BY numeropost LIMIT 0; +titre numeropost maxnumrep +SELECT FOUND_ROWS(); +FOUND_ROWS() +3 drop table t1; diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index fa2f381d905..de652b05154 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -43,7 +43,7 @@ wait_timeout 28800 show variables like "this_doesn't_exists%"; Variable_name Value show table status from test like "this_doesn't_exists%"; -Name Type Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Create_options Comment +Name Type Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Charset Create_options Comment show databases; Database mysql @@ -77,24 +77,31 @@ show create table t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( `a` int(11) NOT NULL default '0' -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 alter table t1 rename t2; show create table t2; Table Create Table t2 CREATE TEMPORARY TABLE `t2` ( `a` int(11) NOT NULL default '0' -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 drop table t2; create table t1 ( test_set set( 'val1', 'val2', 'val3' ) not null default '', -name char(20) default 'O''Brien' +name char(20) default 'O''Brien' comment 'O''Brien as default', +c int not null comment 'int column' ) comment = 'it\'s a table' ; show create table t1 ; Table Create Table t1 CREATE TABLE `t1` ( `test_set` set('val1','val2','val3') NOT NULL default '', - `name` char(20) default 'O''Brien' -) TYPE=MyISAM COMMENT='it''s a table' + `name` char(20) default 'O''Brien' COMMENT 'O''Brien as default', + `c` int(11) NOT NULL default '0' COMMENT 'int column' +) TYPE=MyISAM CHARSET=latin1 COMMENT='it''s a table' +show full columns from t1; +Field Type Collation Null Key Default Extra Privileges Comment +test_set set('val1','val2','val3') latin1 select,insert,update,references +name char(20) latin1 YES O'Brien select,insert,update,references O'Brien as default +c int(11) binary 0 select,insert,update,references int column drop table t1; create table t1 (a int not null, unique aa (a)); show create table t1; @@ -102,7 +109,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', UNIQUE KEY `aa` (`a`) -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 drop table t1; create table t1 (a int not null, primary key (a)); show create table t1; @@ -110,7 +117,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', PRIMARY KEY (`a`) -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 drop table t1; flush tables; show open tables; @@ -128,7 +135,7 @@ t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', `b` char(10) default NULL, KEY `b` (`b`) -) TYPE=MyISAM MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test' +) TYPE=MyISAM CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test' alter table t1 MAX_ROWS=200 ROW_FORMAT=dynamic PACK_KEYS=0; show create table t1; Table Create Table @@ -136,7 +143,7 @@ t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', `b` varchar(10) default NULL, KEY `b` (`b`) -) TYPE=MyISAM MIN_ROWS=10 MAX_ROWS=200 AVG_ROW_LENGTH=10 PACK_KEYS=0 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='test' +) TYPE=MyISAM CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=200 AVG_ROW_LENGTH=10 PACK_KEYS=0 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='test' ALTER TABLE t1 AVG_ROW_LENGTH=0 CHECKSUM=0 COMMENT="" MIN_ROWS=0 MAX_ROWS=0 PACK_KEYS=DEFAULT DELAY_KEY_WRITE=0 ROW_FORMAT=default; show create table t1; Table Create Table @@ -144,17 +151,25 @@ t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', `b` varchar(10) default NULL, KEY `b` (`b`) -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 drop table t1; create table t1 (a decimal(9,2), b decimal (9,0), e double(9,2), f double(5,0), h float(3,2), i float(3,0)); show columns from t1; -Field Type Null Key Default Extra -a decimal(9,2) YES NULL -b decimal(9,0) YES NULL -e double(9,2) YES NULL -f double(5,0) YES NULL -h float(3,2) YES NULL -i float(3,0) YES NULL +Field Type Collation Null Key Default Extra +a decimal(9,2) binary YES NULL +b decimal(9,0) binary YES NULL +e double(9,2) binary YES NULL +f double(5,0) binary YES NULL +h float(3,2) binary YES NULL +i float(3,0) binary YES NULL +show full columns from t1; +Field Type Collation Null Key Default Extra Privileges Comment +a decimal(9,2) binary YES NULL select,insert,update,references +b decimal(9,0) binary YES NULL select,insert,update,references +e double(9,2) binary YES NULL select,insert,update,references +f double(5,0) binary YES NULL select,insert,update,references +h float(3,2) binary YES NULL select,insert,update,references +i float(3,0) binary YES NULL select,insert,update,references drop table t1; create table t1 ( type_bool bool not null, @@ -193,7 +208,7 @@ t1 CREATE TABLE `t1` ( `empty_char` char(0) default NULL, `type_char` char(2) default NULL, `type_varchar` varchar(10) default NULL, - `type_timestamp` timestamp(14) NOT NULL, + `type_timestamp` timestamp NOT NULL, `type_date` date NOT NULL default '0000-00-00', `type_time` time NOT NULL default '00:00:00', `type_datetime` datetime NOT NULL default '0000-00-00 00:00:00', @@ -206,24 +221,24 @@ t1 CREATE TABLE `t1` ( `type_long_blob` longblob, PRIMARY KEY (`type_tiny`), KEY `type_short` (`type_short`) -) TYPE=MyISAM MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test' +) TYPE=MyISAM CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test' insert into t1 (type_timestamp) values ("2003-02-07 10:00:01"); select * from t1; type_bool type_tiny type_short type_mediumint type_bigint type_decimal type_numeric empty_char type_char type_varchar type_timestamp type_date type_time type_datetime type_year type_enum type_set type_tinyblob type_blob type_medium_blob type_long_blob -0 1 NULL NULL NULL NULL NULL NULL NULL NULL 20030207100001 0000-00-00 00:00:00 0000-00-00 00:00:00 NULL NULL NULL NULL NULL NULL NULL +0 1 NULL NULL NULL NULL NULL NULL NULL NULL 2003-02-07 10:00:01 0000-00-00 00:00:00 0000-00-00 00:00:00 NULL NULL NULL NULL NULL NULL NULL drop table t1; create table t1 (c decimal, d double, f float, r real); show columns from t1; -Field Type Null Key Default Extra -c decimal(10,0) YES NULL -d double YES NULL -f float YES NULL -r double YES NULL +Field Type Collation Null Key Default Extra +c decimal(10,0) binary YES NULL +d double binary YES NULL +f float binary YES NULL +r double binary YES NULL drop table t1; create table t1 (c decimal(3,3), d double(3,3), f float(3,3)); show columns from t1; -Field Type Null Key Default Extra -c decimal(4,3) YES NULL -d double(4,3) YES NULL -f float(4,3) YES NULL +Field Type Collation Null Key Default Extra +c decimal(4,3) binary YES NULL +d double(4,3) binary YES NULL +f float(4,3) binary YES NULL drop table t1; diff --git a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result new file mode 100644 index 00000000000..8ded3daf114 --- /dev/null +++ b/mysql-test/r/sql_mode.result @@ -0,0 +1,87 @@ +drop table if exists t1; +CREATE TABLE `t1` ( +a int not null auto_increment, +`pseudo` varchar(35) character set latin2 NOT NULL default '', +`email` varchar(60) character set latin2 NOT NULL default '', +PRIMARY KEY (a), +UNIQUE KEY `email` USING BTREE (`email`) +) TYPE=HEAP CHARSET=latin1 ROW_FORMAT DYNAMIC; +set @@sql_mode=""; +show variables like 'sql_mode'; +Variable_name Value +sql_mode +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL auto_increment, + `pseudo` varchar(35) character set latin2 NOT NULL default '', + `email` varchar(60) character set latin2 NOT NULL default '', + PRIMARY KEY (`a`), + UNIQUE KEY `email` TYPE BTREE (`email`) +) TYPE=HEAP CHARSET=latin1 ROW_FORMAT=DYNAMIC +set @@sql_mode="ansi_quotes"; +show variables like 'sql_mode'; +Variable_name Value +sql_mode ANSI_QUOTES +show create table t1; +Table Create Table +t1 CREATE TABLE "t1" ( + "a" int(11) NOT NULL auto_increment, + "pseudo" varchar(35) character set latin2 NOT NULL default '', + "email" varchar(60) character set latin2 NOT NULL default '', + PRIMARY KEY ("a"), + UNIQUE KEY "email" TYPE BTREE ("email") +) TYPE=HEAP CHARSET=latin1 ROW_FORMAT=DYNAMIC +set @@sql_mode="no_table_options"; +show variables like 'sql_mode'; +Variable_name Value +sql_mode NO_TABLE_OPTIONS +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL auto_increment, + `pseudo` varchar(35) character set latin2 NOT NULL default '', + `email` varchar(60) character set latin2 NOT NULL default '', + PRIMARY KEY (`a`), + UNIQUE KEY `email` TYPE BTREE (`email`) +) +set @@sql_mode="no_key_options"; +show variables like 'sql_mode'; +Variable_name Value +sql_mode NO_KEY_OPTIONS +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL auto_increment, + `pseudo` varchar(35) character set latin2 NOT NULL default '', + `email` varchar(60) character set latin2 NOT NULL default '', + PRIMARY KEY (`a`), + UNIQUE KEY `email` (`email`) +) TYPE=HEAP CHARSET=latin1 ROW_FORMAT=DYNAMIC +set @@sql_mode="no_field_options,mysql323,mysql40"; +show variables like 'sql_mode'; +Variable_name Value +sql_mode NO_FIELD_OPTIONS,MYSQL323,MYSQL40 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL auto_increment, + `pseudo` varchar(35) NOT NULL default '', + `email` varchar(60) NOT NULL default '', + PRIMARY KEY (`a`), + UNIQUE KEY `email` (`email`) +) TYPE=HEAP ROW_FORMAT=DYNAMIC +set @@sql_mode="postgresql,oracle,mssql,db2,sapdb"; +show variables like 'sql_mode'; +Variable_name Value +sql_mode POSTGRESQL,ORACLE,MSSQL,DB2,SAPDB +show create table t1; +Table Create Table +t1 CREATE TABLE "t1" ( + "a" int(11) NOT NULL, + "pseudo" varchar(35) NOT NULL default '', + "email" varchar(60) NOT NULL default '', + PRIMARY KEY ("a"), + UNIQUE KEY "email" ("email") +) +drop table t1; diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result new file mode 100644 index 00000000000..795348f1897 --- /dev/null +++ b/mysql-test/r/subselect.result @@ -0,0 +1,1084 @@ +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12; +select (select 2); +(select 2) +2 +explain select (select 2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1247 Select 2 was reduced during optimisation +SELECT (SELECT 1) UNION SELECT (SELECT 2); +(SELECT 1) +1 +2 +explain SELECT (SELECT 1) UNION SELECT (SELECT 2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1247 Select 2 was reduced during optimisation +Note 1247 Select 4 was reduced during optimisation +SELECT (SELECT (SELECT 0 UNION SELECT 0)); +(SELECT (SELECT 0 UNION SELECT 0)) +0 +explain SELECT (SELECT (SELECT 0 UNION SELECT 0)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +3 SUBSELECT NULL NULL NULL NULL NULL NULL NULL No tables used +4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1247 Select 2 was reduced during optimisation +SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a; +Reference 'a' not supported (forward reference in item list) +SELECT (SELECT 1 FROM (SELECT 1) as b HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) as c HAVING a=1) as b; +Reference 'b' not supported (forward reference in item list) +SELECT (SELECT 1),MAX(1) FROM (SELECT 1) as a; +(SELECT 1) MAX(1) +1 1 +SELECT (SELECT a) as a; +Reference 'a' not supported (forward reference in item list) +EXPLAIN SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> system NULL NULL NULL NULL 1 +3 DEPENDENT SUBSELECT NULL NULL NULL NULL NULL NULL NULL No tables used +2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used +SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; +1 +1 +SELECT (SELECT 1), a; +Unknown column 'a' in 'field list' +SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1; +a +1 +SELECT 1 FROM (SELECT (SELECT a) b) c; +Unknown column 'a' in 'field list' +SELECT * FROM (SELECT 1 as id) b WHERE id IN (SELECT * FROM (SELECT 1 as id) c ORDER BY id); +id +1 +SELECT * FROM (SELECT 1) a WHERE 1 IN (SELECT 1,1); +Cardinality error (more/less than 1 columns) +SELECT 1 IN (SELECT 1); +1 IN (SELECT 1) +1 +SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); +1 +1 +select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); +Wrong usage of PROCEDURE and subquery +SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); +Incorrect parameters to procedure 'ANALYSE' +SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; +a +SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL; +a +1 +SELECT (SELECT 1,2,3) = ROW(1,2,3); +(SELECT 1,2,3) = ROW(1,2,3) +1 +SELECT (SELECT 1,2,3) = ROW(1,2,1); +(SELECT 1,2,3) = ROW(1,2,1) +0 +SELECT (SELECT 1,2,3) < ROW(1,2,1); +(SELECT 1,2,3) < ROW(1,2,1) +0 +SELECT (SELECT 1,2,3) > ROW(1,2,1); +(SELECT 1,2,3) > ROW(1,2,1) +1 +SELECT (SELECT 1,2,3) = ROW(1,2,NULL); +(SELECT 1,2,3) = ROW(1,2,NULL) +NULL +SELECT ROW(1,2,3) = (SELECT 1,2,3); +ROW(1,2,3) = (SELECT 1,2,3) +1 +SELECT ROW(1,2,3) = (SELECT 1,2,1); +ROW(1,2,3) = (SELECT 1,2,1) +0 +SELECT ROW(1,2,3) < (SELECT 1,2,1); +ROW(1,2,3) < (SELECT 1,2,1) +0 +SELECT ROW(1,2,3) > (SELECT 1,2,1); +ROW(1,2,3) > (SELECT 1,2,1) +1 +SELECT ROW(1,2,3) = (SELECT 1,2,NULL); +ROW(1,2,3) = (SELECT 1,2,NULL) +NULL +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a'); +(SELECT 1.5,2,'a') = ROW(1.5,2,'a') +1 +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b'); +(SELECT 1.5,2,'a') = ROW(1.5,2,'b') +0 +SELECT (SELECT 1.5,2,'a') = ROW('b',2,'b'); +(SELECT 1.5,2,'a') = ROW('b',2,'b') +0 +SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); +(SELECT 'b',2,'a') = ROW(1.5,2,'a') +0 +SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a'); +(SELECT 1.5,2,'a') = ROW(1.5,'c','a') +0 +SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); +(SELECT 1.5,'c','a') = ROW(1.5,2,'a') +0 +SELECT (SELECT * FROM (SELECT 'test' a,'test' b) a); +Cardinality error (more/less than 1 columns) +SELECT 1 as a,(SELECT a+a) b,(SELECT b); +a b (SELECT b) +1 2 2 +create table t1 (a int); +create table t2 (a int, b int); +create table t3 (a int); +create table t4 (a int, b int); +insert into t1 values (2); +insert into t2 values (1,7),(2,7); +insert into t4 values (4,8),(3,8),(5,9); +select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1; +Reference 'a1' not supported (forward reference in item list) +select (select a from t1 where t1.a=t2.a), a from t2; +(select a from t1 where t1.a=t2.a) a +NULL 1 +2 2 +select (select a from t1 where t1.a=t2.b), a from t2; +(select a from t1 where t1.a=t2.b) a +NULL 1 +NULL 2 +select (select a from t1), a from t2; +(select a from t1) a +2 1 +2 2 +select (select a from t3), a from t2; +(select a from t3) a +NULL 1 +NULL 2 +select * from t2 where t2.a=(select a from t1); +a b +2 7 +insert into t3 values (6),(7),(3); +select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1); +a b +1 7 +2 7 +(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 order by a limit 2) limit 3; +a b +1 7 +2 7 +3 8 +(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a); +a b +1 7 +2 7 +3 8 +4 8 +explain (select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 SUBSELECT t3 ALL NULL NULL NULL NULL 3 Using filesort +3 UNION t4 ALL NULL NULL NULL NULL 3 Using where; Using filesort +4 SUBSELECT t2 ALL NULL NULL NULL NULL 2 +select (select a from t3 where a<t2.a*4 order by 1 desc limit 1), a from t2; +(select a from t3 where a<t2.a*4 order by 1 desc limit 1) a +3 1 +7 2 +select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from +(select * from t2 where a>1) as tt; +(select t3.a from t3 where a<8 order by 1 desc limit 1) a +7 2 +explain select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from +(select * from t2 where a>1) as tt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived3> system NULL NULL NULL NULL 1 +3 DERIVED t2 ALL NULL NULL NULL NULL 2 Using where +2 SUBSELECT t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort +select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1); +a +2 +select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a > t1.a) order by 1 desc limit 1); +a +2 +select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1); +a +select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; +b (select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) +8 7.5000 +8 4.5000 +9 7.5000 +explain select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 +2 DEPENDENT SUBSELECT t2 ALL NULL NULL NULL NULL 2 +3 DEPENDENT SUBSELECT t3 ALL NULL NULL NULL NULL 3 Using where +select * from t3 where exists (select * from t2 where t2.b=t3.a); +a +7 +select * from t3 where not exists (select * from t2 where t2.b=t3.a); +a +6 +3 +select * from t3 where a in (select b from t2); +a +7 +select * from t3 where a not in (select b from t2); +a +6 +3 +select * from t3 where a = some (select b from t2); +a +7 +select * from t3 where a <> any (select b from t2); +a +6 +3 +select * from t3 where a = all (select b from t2); +a +7 +select * from t3 where a <> all (select b from t2); +a +6 +3 +insert into t2 values (100, 5); +select * from t3 where a < any (select b from t2); +a +6 +3 +select * from t3 where a < all (select b from t2); +a +3 +select * from t3 where a >= any (select b from t2); +a +6 +7 +select * from t3 where a >= all (select b from t2); +a +7 +delete from t2 where a=100; +select * from t3 where a in (select a,b from t2); +Cardinality error (more/less than 1 columns) +select * from t3 where a in (select * from t2); +Cardinality error (more/less than 1 columns) +insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9); +select b,max(a) as ma from t4 group by b having b < (select max(t2.a) +from t2 where t2.b=t4.b); +b ma +select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) +from t2 where t2.b=t4.b); +b ma +7 12 +create table t5 (a int); +select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +NULL 1 +2 2 +insert into t5 values (5); +select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +NULL 1 +2 2 +insert into t5 values (2); +select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +NULL 1 +2 2 +explain select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 +2 DEPENDENT SUBSELECT t1 system NULL NULL NULL NULL 1 +3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where +select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; +Subselect returns more than 1 record +create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); +create table t7( uq int primary key, name char(25)); +insert into t7 values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta"); +insert into t6 values (1,1),(1,2),(2,2),(1,3); +select * from t6 where exists (select * from t7 where uq = clinic_uq); +patient_uq clinic_uq +1 1 +1 2 +2 2 +select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); +Column: 'a' in field list is ambiguous +drop table if exists t1,t2,t3; +CREATE TABLE t3 (a varchar(20),b char(1) NOT NULL default '0'); +INSERT INTO t3 VALUES ('W','a'),('A','c'),('J','b'); +CREATE TABLE t2 (a varchar(20),b int NOT NULL default '0'); +INSERT INTO t2 VALUES ('W','1'),('A','3'),('J','2'); +CREATE TABLE t1 (a varchar(20),b date NOT NULL default '0000-00-00'); +INSERT INTO t1 VALUES ('W','1732-02-22'),('A','1735-10-30'),('J','1743-04-13'); +SELECT * FROM t1 WHERE b = (SELECT MIN(b) FROM t1); +a b +W 1732-02-22 +SELECT * FROM t2 WHERE b = (SELECT MIN(b) FROM t2); +a b +W 1 +SELECT * FROM t3 WHERE b = (SELECT MIN(b) FROM t3); +a b +W a +CREATE TABLE `t8` ( +`pseudo` varchar(35) character set latin1 NOT NULL default '', +`email` varchar(60) character set latin1 NOT NULL default '', +PRIMARY KEY (`pseudo`), +UNIQUE KEY `email` (`email`) +) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC; +INSERT INTO t8 (pseudo,email) VALUES ('joce','test'); +INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1'); +INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1'); +EXPLAIN SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t8 const PRIMARY PRIMARY 35 const 1 +4 SUBSELECT t8 const PRIMARY PRIMARY 35 1 +2 SUBSELECT t8 const PRIMARY PRIMARY 35 const 1 +3 SUBSELECT t8 const PRIMARY PRIMARY 35 1 +SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM +t8 WHERE pseudo='joce'); +Cardinality error (more/less than 1 columns) +SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE +pseudo='joce'); +Cardinality error (more/less than 1 columns) +SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); +pseudo +joce +SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%joce%'); +Subselect returns more than 1 record +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8; +CREATE TABLE `t1` ( +`topic` mediumint(8) unsigned NOT NULL default '0', +`date` date NOT NULL default '0000-00-00', +`pseudo` varchar(35) character set latin1 NOT NULL default '', +PRIMARY KEY (`pseudo`,`date`,`topic`), +KEY `topic` (`topic`) +) TYPE=MyISAM ROW_FORMAT=DYNAMIC; +INSERT INTO t1 (topic,date,pseudo) VALUES +('43506','2002-10-02','joce'),('40143','2002-08-03','joce'); +EXPLAIN SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 41 NULL 2 Using where; Using index +EXPLAIN SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 SUBSELECT t1 index NULL PRIMARY 41 NULL 2 Using where; Using index +SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'; +date +2002-08-03 +SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'); +(SELECT DISTINCT date FROM t1 WHERE date='2002-08-03') +2002-08-03 +SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1; +1 +1 +1 +1 +SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1; +Subselect returns more than 1 record +EXPLAIN SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index NULL topic 3 NULL 2 Using index +2 SUBSELECT NULL NULL NULL NULL NULL NULL NULL No tables used +3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used +drop table t1; +CREATE TABLE `t1` ( +`numeropost` mediumint(8) unsigned NOT NULL auto_increment, +`maxnumrep` int(10) unsigned NOT NULL default '0', +PRIMARY KEY (`numeropost`), +UNIQUE KEY `maxnumrep` (`maxnumrep`) +) TYPE=MyISAM ROW_FORMAT=FIXED; +INSERT INTO t1 (numeropost,maxnumrep) VALUES (40143,1),(43506,2); +CREATE TABLE `t2` ( +`mot` varchar(30) NOT NULL default '', +`topic` mediumint(8) unsigned NOT NULL default '0', +`date` date NOT NULL default '0000-00-00', +`pseudo` varchar(35) NOT NULL default '', +PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`) +) TYPE=MyISAM ROW_FORMAT=DYNAMIC; +INSERT INTO t2 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce'); +select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1); +a +40143 +SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND date >= '2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20; +numeropost maxnumrep +43506 2 +40143 1 +SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) b; +Unknown column 'a' in 'having clause' +SELECT 1 IN (SELECT 1 FROM t2 HAVING a); +Unknown column 'a' in 'having clause' +SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic); +mot topic date pseudo +joce 40143 2002-10-22 joce +joce 43506 2002-10-22 joce +SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100); +mot topic date pseudo +SELECT * from t2 where topic IN (SELECT SUM(topic) FROM t1); +mot topic date pseudo +SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic); +mot topic date pseudo +joce 40143 2002-10-22 joce +joce 43506 2002-10-22 joce +SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100); +mot topic date pseudo +SELECT * from t2 where topic = any (SELECT SUM(topic) FROM t1); +mot topic date pseudo +SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic); +mot topic date pseudo +SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100); +mot topic date pseudo +joce 40143 2002-10-22 joce +joce 43506 2002-10-22 joce +SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2; +mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) +joce 40143 2002-10-22 joce 1 +joce 43506 2002-10-22 joce 1 +SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2); +mot topic date pseudo +SELECT * from t2 where topic <> any (SELECT SUM(topic) FROM t2); +mot topic date pseudo +joce 40143 2002-10-22 joce +joce 43506 2002-10-22 joce +SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); +mot topic date pseudo +joce 40143 2002-10-22 joce +SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); +mot topic date pseudo +joce 40143 2002-10-22 joce +SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); +mot topic date pseudo +joce 40143 2002-10-22 joce +SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2; +mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) +joce 40143 2002-10-22 joce 1 +joce 43506 2002-10-22 joce 0 +drop table t1,t2; +CREATE TABLE `t1` ( +`numeropost` mediumint(8) unsigned NOT NULL auto_increment, +`maxnumrep` int(10) unsigned NOT NULL default '0', +PRIMARY KEY (`numeropost`), +UNIQUE KEY `maxnumrep` (`maxnumrep`) +) TYPE=MyISAM ROW_FORMAT=FIXED; +INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1); +select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1); +Subselect returns more than 1 record +select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1); +Subselect returns more than 1 record +drop table t1; +CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b'); +INSERT INTO t1 VALUES (); +SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b'); +Subselect returns more than 1 record +drop table t1; +CREATE TABLE `t1` ( +`numeropost` mediumint(8) unsigned NOT NULL default '0', +`numreponse` int(10) unsigned NOT NULL auto_increment, +`pseudo` varchar(35) NOT NULL default '', +PRIMARY KEY (`numeropost`,`numreponse`), +UNIQUE KEY `numreponse` (`numreponse`), +KEY `pseudo` (`pseudo`,`numeropost`) +) TYPE=MyISAM; +SELECT (SELECT numeropost FROM t1 HAVING numreponse=a),numreponse FROM (SELECT * FROM t1) as a; +Reference 'numreponse' not supported (forward reference in item list) +SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=a) FROM (SELECT * FROM t1) as a; +Unknown column 'a' in 'having clause' +SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT * FROM t1) as a; +numreponse (SELECT numeropost FROM t1 HAVING numreponse=1) +INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); +EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); +Subselect returns more than 1 record +EXPLAIN SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 +2 SUBSELECT NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +drop table t1; +CREATE TABLE t1 (a int(1)); +INSERT INTO t1 VALUES (1); +SELECT 1 FROM (SELECT a FROM t1) b HAVING (SELECT b.a)=1; +1 +1 +drop table t1; +create table t1 (a int NOT NULL, b int, primary key (a)); +create table t2 (a int NOT NULL, b int, primary key (a)); +insert into t1 values (0, 10),(1, 11),(2, 12); +insert into t2 values (1, 21),(2, 22),(3, 23); +select * from t1; +a b +0 10 +1 11 +2 12 +update t1 set b= (select b from t1); +You can't specify target table 't1' for update in FROM clause +update t1 set b= (select b from t2); +Subselect returns more than 1 record +update t1 set b= (select b from t2 where t1.a = t2.a); +select * from t1; +a b +0 NULL +1 21 +2 22 +drop table t1, t2; +create table t1 (a int NOT NULL, b int, primary key (a)); +create table t2 (a int NOT NULL, b int, primary key (a)); +insert into t1 values (0, 10),(1, 11),(2, 12); +insert into t2 values (1, 21),(2, 12),(3, 23); +select * from t1; +a b +0 10 +1 11 +2 12 +select * from t1 where b = (select b from t2 where t1.a = t2.a); +a b +2 12 +delete from t1 where b = (select b from t1); +You can't specify target table 't1' for update in FROM clause +delete from t1 where b = (select b from t2); +Subselect returns more than 1 record +delete from t1 where b = (select b from t2 where t1.a = t2.a); +select * from t1; +a b +0 10 +1 11 +drop table t1, t2; +create table t11 (a int NOT NULL, b int, primary key (a)); +create table t12 (a int NOT NULL, b int, primary key (a)); +create table t2 (a int NOT NULL, b int, primary key (a)); +insert into t11 values (0, 10),(1, 11),(2, 12); +insert into t12 values (33, 10),(22, 11),(2, 12); +insert into t2 values (1, 21),(2, 12),(3, 23); +select * from t11; +a b +0 10 +1 11 +2 12 +select * from t12; +a b +33 10 +22 11 +2 12 +delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a); +You can't specify target table 't12' for update in FROM clause +delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2); +Subselect returns more than 1 record +delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a); +select * from t11; +a b +0 10 +1 11 +select * from t12; +a b +33 10 +22 11 +drop table t11, t12, t2; +CREATE TABLE t1 (x int); +create table t2 (a int); +create table t3 (a int); +insert into t2 values (1); +insert into t3 values (1),(2); +INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); +You can't specify target table 't1' for update in FROM clause +INSERT INTO t1 (x) VALUES ((SELECT a FROM t3)); +Subselect returns more than 1 record +INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); +select * from t1; +x +1 +insert into t2 values (1); +INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); +select * from t1; +x +1 +2 +INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; +select * from t1; +x +1 +2 +3 +3 +INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; +You can't specify target table 't1' for update in FROM clause +INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); +select * from t1; +x +1 +2 +3 +3 +0 +drop table t1, t2, t3; +CREATE TABLE t1 (x int not null, y int, primary key (x)); +create table t2 (a int); +create table t3 (a int); +insert into t2 values (1); +insert into t3 values (1),(2); +select * from t1; +x y +replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); +You can't specify target table 't1' for update in FROM clause +replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); +Subselect returns more than 1 record +replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); +select * from t1; +x y +1 2 +replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+2 FROM t2)); +select * from t1; +x y +1 3 +replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a FROM t2)); +select * from t1; +x y +1 3 +4 1 +replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a+1 FROM t2)); +select * from t1; +x y +1 3 +4 2 +replace LOW_PRIORITY into t1 (x, y) VALUES ((SELECT a+1 FROM t2), (SELECT a FROM t2)); +select * from t1; +x y +1 3 +4 2 +2 1 +drop table t1, t2, t3; +SELECT * FROM (SELECT 1) b WHERE 1 IN (SELECT *); +No tables used +CREATE TABLE t2 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t2 VALUES (1),(2); +SELECT * FROM t2 WHERE id IN (SELECT 1); +id +1 +EXPLAIN SELECT * FROM t2 WHERE id IN (SELECT 1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ref id id 5 const 1 Using where; Using index +Warnings: +Note 1247 Select 2 was reduced during optimisation +SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); +id +1 +SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1)); +id +2 +EXPLAIN SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ref id id 5 const 1 Using where; Using index +3 SUBSELECT NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1247 Select 3 was reduced during optimisation +Note 1247 Select 2 was reduced during optimisation +EXPLAIN SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 index NULL id 5 NULL 2 Using where; Using index +2 DEPENDENT SUBSELECT NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3); +id +SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); +id +2 +INSERT INTO t2 VALUES ((SELECT * FROM t2)); +You can't specify target table 't2' for update in FROM clause +SELECT * FROM t2; +id +1 +2 +CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 values (1),(1); +UPDATE t2 SET id=(SELECT * FROM t1); +Subselect returns more than 1 record +drop table t2, t1; +create table t1 (a int); +insert into t1 values (1),(2),(3); +select 1 IN (SELECT * from t1); +1 IN (SELECT * from t1) +1 +select 10 IN (SELECT * from t1); +10 IN (SELECT * from t1) +0 +select NULL IN (SELECT * from t1); +NULL IN (SELECT * from t1) +NULL +update t1 set a=NULL where a=2; +select 1 IN (SELECT * from t1); +1 IN (SELECT * from t1) +1 +select 3 IN (SELECT * from t1); +3 IN (SELECT * from t1) +1 +select 10 IN (SELECT * from t1); +10 IN (SELECT * from t1) +NULL +select 1 > ALL (SELECT * from t1); +1 > ALL (SELECT * from t1) +0 +select 10 > ALL (SELECT * from t1); +10 > ALL (SELECT * from t1) +NULL +select 1 > ANY (SELECT * from t1); +1 > ANY (SELECT * from t1) +NULL +select 10 > ANY (SELECT * from t1); +10 > ANY (SELECT * from t1) +1 +drop table t1; +create table t1 (a varchar(20)); +insert into t1 values ('A'),('BC'),('DEF'); +select 'A' IN (SELECT * from t1); +'A' IN (SELECT * from t1) +1 +select 'XYZS' IN (SELECT * from t1); +'XYZS' IN (SELECT * from t1) +0 +select NULL IN (SELECT * from t1); +NULL IN (SELECT * from t1) +NULL +update t1 set a=NULL where a='BC'; +select 'A' IN (SELECT * from t1); +'A' IN (SELECT * from t1) +1 +select 'DEF' IN (SELECT * from t1); +'DEF' IN (SELECT * from t1) +1 +select 'XYZS' IN (SELECT * from t1); +'XYZS' IN (SELECT * from t1) +NULL +select 'A' > ALL (SELECT * from t1); +'A' > ALL (SELECT * from t1) +0 +select 'XYZS' > ALL (SELECT * from t1); +'XYZS' > ALL (SELECT * from t1) +NULL +select 'A' > ANY (SELECT * from t1); +'A' > ANY (SELECT * from t1) +NULL +select 'XYZS' > ANY (SELECT * from t1); +'XYZS' > ANY (SELECT * from t1) +1 +drop table t1; +create table t1 (a float); +insert into t1 values (1.5),(2.5),(3.5); +select 1.5 IN (SELECT * from t1); +1.5 IN (SELECT * from t1) +1 +select 10.5 IN (SELECT * from t1); +10.5 IN (SELECT * from t1) +0 +select NULL IN (SELECT * from t1); +NULL IN (SELECT * from t1) +NULL +update t1 set a=NULL where a=2.5; +select 1.5 IN (SELECT * from t1); +1.5 IN (SELECT * from t1) +1 +select 3.5 IN (SELECT * from t1); +3.5 IN (SELECT * from t1) +1 +select 10.5 IN (SELECT * from t1); +10.5 IN (SELECT * from t1) +NULL +select 1.5 > ALL (SELECT * from t1); +1.5 > ALL (SELECT * from t1) +0 +select 10.5 > ALL (SELECT * from t1); +10.5 > ALL (SELECT * from t1) +NULL +select 1.5 > ANY (SELECT * from t1); +1.5 > ANY (SELECT * from t1) +NULL +select 10.5 > ANY (SELECT * from t1); +10.5 > ANY (SELECT * from t1) +1 +explain select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 +Warnings: +Note 1247 Select 2 was reduced during optimisation +select (select a+1) from t1; +(select a+1) +2.5 +NULL +4.5 +drop table t1; +CREATE TABLE t1 (a int(11) NOT NULL default '0', PRIMARY KEY (a)); +CREATE TABLE t2 (a int(11) default '0', INDEX (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t2 VALUES (1),(2),(3); +SELECT t1.a, t1.a in (select t2.a from t2) FROM t1; +a t1.a in (select t2.a from t2) +1 1 +2 1 +3 1 +4 0 +explain SELECT t1.a, t1.a in (select t2.a from t2) FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 Using index +2 DEPENDENT SUBSELECT t2 index NULL a 5 NULL 3 Using where; Using index +drop table t1,t2; +create table t1 (a float); +select 10.5 IN (SELECT * from t1 LIMIT 1); +This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' +select 10.5 IN (SELECT * from t1 LIMIT 1 UNION SELECT 1.5); +This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' +drop table t1; +create table t1 (a int, b int, c varchar(10)); +create table t2 (a int); +insert into t1 values (1,2,'a'),(2,3,'b'),(3,4,'c'); +insert into t2 values (1),(2),(NULL); +select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,2,'a'),(select c from t1 where a=t2.a) from t2; +a (select a,b,c from t1 where t1.a=t2.a) = ROW(a,2,'a') (select c from t1 where a=t2.a) +1 1 a +2 0 b +NULL NULL NULL +select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b'),(select c from t1 where a=t2.a) from t2; +a (select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b') (select c from t1 where a=t2.a) +1 0 a +2 1 b +NULL NULL NULL +select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,4,'c'),(select c from t1 where a=t2.a) from t2; +a (select a,b,c from t1 where t1.a=t2.a) = ROW(a,4,'c') (select c from t1 where a=t2.a) +1 0 a +2 0 b +NULL NULL NULL +drop table t1,t2; +create table t1 (a int, b real, c varchar(10)); +insert into t1 values (1, 1, 'a'), (2,2,'b'), (NULL, 2, 'b'); +select ROW(1, 1, 'a') IN (select a,b,c from t1); +ROW(1, 1, 'a') IN (select a,b,c from t1) +1 +select ROW(1, 2, 'a') IN (select a,b,c from t1); +ROW(1, 2, 'a') IN (select a,b,c from t1) +NULL +select ROW(1, 1, 'a') IN (select b,a,c from t1); +ROW(1, 1, 'a') IN (select b,a,c from t1) +1 +select ROW(1, 1, 'a') IN (select a,b,c from t1 where a is not null); +ROW(1, 1, 'a') IN (select a,b,c from t1 where a is not null) +1 +select ROW(1, 2, 'a') IN (select a,b,c from t1 where a is not null); +ROW(1, 2, 'a') IN (select a,b,c from t1 where a is not null) +0 +select ROW(1, 1, 'a') IN (select b,a,c from t1 where a is not null); +ROW(1, 1, 'a') IN (select b,a,c from t1 where a is not null) +1 +select ROW(1, 1, 'a') IN (select a,b,c from t1 where c='b' or c='a'); +ROW(1, 1, 'a') IN (select a,b,c from t1 where c='b' or c='a') +1 +select ROW(1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a'); +ROW(1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a') +NULL +select ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a'); +ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a') +1 +select ROW(1, 1, 'a') IN (select b,a,c from t1 limit 2); +This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' +drop table t1; +create table t1 (a int); +insert into t1 values (1); +do @a:=(SELECT a from t1); +select @a; +@a +1 +set @a:=2; +set @a:=(SELECT a from t1); +select @a; +@a +1 +drop table t1; +do (SELECT a from t1); +Table 'test.t1' doesn't exist +set @a:=(SELECT a from t1); +Table 'test.t1' doesn't exist +CREATE TABLE t1 (a int, KEY(a)); +HANDLER t1 OPEN; +HANDLER t1 READ a=((SELECT 1)); +You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use +HANDLER t1 CLOSE; +drop table t1; +create table t1 (a int); +create table t2 (b int); +insert into t1 values (1),(2); +insert into t2 values (1); +select a from t1 where a in (select a from t1 where a in (select b from t2)); +a +1 +drop table t1, t2; +create table t1 (a int, b int); +create table t2 like t1; +insert into t1 values (1,2),(1,3),(1,4),(1,5); +insert into t2 values (1,2),(1,3); +select * from t1 where row(a,b) in (select a,b from t2); +a b +1 2 +1 3 +drop table t1, t2; +CREATE TABLE `t1` (`i` int(11) NOT NULL default '0',PRIMARY KEY (`i`)) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 VALUES (1); +UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i)); +Invalid use of group function +drop table t1; +CREATE TABLE t1 (a int(1)); +EXPLAIN SELECT (SELECT RAND() FROM t1) FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found +2 UNCACHEABLE SUBSELECT t1 system NULL NULL NULL NULL 0 const row not found +EXPLAIN SELECT (SELECT ENCRYPT('test') FROM t1) FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found +2 UNCACHEABLE SUBSELECT t1 system NULL NULL NULL NULL 0 const row not found +EXPLAIN SELECT (SELECT BENCHMARK(1,1) FROM t1) FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found +2 UNCACHEABLE SUBSELECT t1 system NULL NULL NULL NULL 0 const row not found +drop table t1; +CREATE TABLE `t1` ( +`mot` varchar(30) character set latin1 NOT NULL default '', +`topic` mediumint(8) unsigned NOT NULL default '0', +`date` date NOT NULL default '0000-00-00', +`pseudo` varchar(35) character set latin1 NOT NULL default '', +PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`), +KEY `pseudo` (`pseudo`,`date`,`topic`), +KEY `topic` (`topic`) +) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC; +CREATE TABLE `t2` ( +`mot` varchar(30) character set latin1 NOT NULL default '', +`topic` mediumint(8) unsigned NOT NULL default '0', +`date` date NOT NULL default '0000-00-00', +`pseudo` varchar(35) character set latin1 NOT NULL default '', +PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`), +KEY `pseudo` (`pseudo`,`date`,`topic`), +KEY `topic` (`topic`) +) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC; +CREATE TABLE `t3` ( +`numeropost` mediumint(8) unsigned NOT NULL auto_increment, +`maxnumrep` int(10) unsigned NOT NULL default '0', +PRIMARY KEY (`numeropost`), +UNIQUE KEY `maxnumrep` (`maxnumrep`) +) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 VALUES ('joce','1','','joce'),('test','2','','test'); +INSERT INTO t2 VALUES ('joce','1','','joce'),('test','2','','test'); +INSERT INTO t3 VALUES (1,1); +SELECT DISTINCT topic FROM t2 WHERE NOT EXISTS(SELECT * FROM t3 WHERE +numeropost=topic); +topic +2 +select * from t1; +mot topic date pseudo +joce 1 0000-00-00 joce +test 2 0000-00-00 test +DELETE FROM t1 WHERE topic IN (SELECT DISTINCT topic FROM t2 WHERE NOT +EXISTS(SELECT * FROM t3 WHERE numeropost=topic)); +select * from t1; +mot topic date pseudo +joce 1 0000-00-00 joce +drop table t1, t2, t3; +SELECT * FROM (SELECT 1 as a,(SELECT a)) a; +a (SELECT a) +1 1 +CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT 1)) a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(1) NOT NULL default '0', + `(SELECT 1)` bigint(1) NOT NULL default '0' +) TYPE=MyISAM CHARSET=latin1 +drop table t1; +CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT a)) a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(1) NOT NULL default '0', + `(SELECT a)` bigint(1) NOT NULL default '0' +) TYPE=MyISAM CHARSET=latin1 +drop table t1; +CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT a+0)) a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(1) NOT NULL default '0', + `(SELECT a+0)` bigint(17) NOT NULL default '0' +) TYPE=MyISAM CHARSET=latin1 +drop table t1; +CREATE TABLE t1 SELECT (SELECT 1 as a UNION SELECT 1+1 limit 1,1) as a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(1) NOT NULL default '0' +) TYPE=MyISAM CHARSET=latin1 +drop table t1; +create table t1 (a int); +insert into t1 values (1), (2), (3); +explain select a,(select (select rand() from t1 limit 1) from t1 limit 1) +from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 +2 UNCACHEABLE SUBSELECT t1 ALL NULL NULL NULL NULL 3 +3 UNCACHEABLE SUBSELECT t1 ALL NULL NULL NULL NULL 3 +drop table t1; +select t1.Continent, t2.Name, t2.Population from t1 LEFT JOIN t2 ON t1.Code = t2.Country where t2.Population IN (select max(t2.Population) AS Population from t2, t1 where t2.Country = t1.Code group by Continent); +Table 'test.t1' doesn't exist +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +name char(35) NOT NULL default '', +t2 char(3) NOT NULL default '', +District char(20) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID) +) TYPE=MyISAM; +INSERT INTO t1 VALUES (130,'Sydney','AUS','New South Wales',3276207); +INSERT INTO t1 VALUES (131,'Melbourne','AUS','Victoria',2865329); +INSERT INTO t1 VALUES (132,'Brisbane','AUS','Queensland',1291117); +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL default 'Asia', +Region char(26) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +IndepYear smallint(6) default NULL, +Population int(11) NOT NULL default '0', +LifeExpectancy float(3,1) default NULL, +GNP float(10,2) default NULL, +GNPOld float(10,2) default NULL, +LocalName char(45) NOT NULL default '', +GovernmentForm char(45) NOT NULL default '', +HeadOfState char(60) default NULL, +Capital int(11) default NULL, +Code2 char(2) NOT NULL default '', +PRIMARY KEY (Code) +) TYPE=MyISAM; +INSERT INTO t2 VALUES ('AUS','Australia','Oceania','Australia and New Zealand',7741220.00,1901,18886000,79.8,351182.00,392911.00,'Australia','Constitutional Monarchy, Federation','Elisabeth II',135,'AU'); +INSERT INTO t2 VALUES ('AZE','Azerbaijan','Asia','Middle East',86600.00,1991,7734000,62.9,4127.00,4100.00,'Azärbaycan','Federal Republic','Heydär Äliyev',144,'AZ'); +select t2.Continent, t1.Name, t1.Population from t2 LEFT JOIN t1 ON t2.Code = t1.t2 where t1.Population IN (select max(t1.Population) AS Population from t1, t2 where t1.t2 = t2.Code group by Continent); +Continent Name Population +Oceania Sydney 3276207 +drop table t1, t2; +CREATE TABLE `t1` ( +`id` mediumint(8) unsigned NOT NULL auto_increment, +`pseudo` varchar(35) character set latin1 NOT NULL default '', +PRIMARY KEY (`id`), +UNIQUE KEY `pseudo` (`pseudo`), +) TYPE=MyISAM PACK_KEYS=1 ROW_FORMAT=DYNAMIC; +INSERT INTO t1 (pseudo) VALUES ('test'); +SELECT 0 IN (SELECT 1 FROM t1 a); +0 IN (SELECT 1 FROM t1 a) +0 +EXPLAIN SELECT 0 IN (SELECT 1 FROM t1 a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT SUBSELECT NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +INSERT INTO t1 (pseudo) VALUES ('test1'); +SELECT 0 IN (SELECT 1 FROM t1 a); +0 IN (SELECT 1 FROM t1 a) +0 +EXPLAIN SELECT 0 IN (SELECT 1 FROM t1 a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT SUBSELECT NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +drop table t1; +CREATE TABLE `t1` ( +`i` int(11) NOT NULL default '0', +PRIMARY KEY (`i`) +) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 VALUES (1); +UPDATE t1 SET i=i+(SELECT MAX(i) FROM (SELECT 1) t) WHERE i=(SELECT MAX(i)); +Invalid use of group function +UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i)); +Invalid use of group function +drop table t1; diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index 5626bc0fe11..1eb595eb2a9 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -36,10 +36,10 @@ show create table t9; Table Create Table t9 CREATE TABLE `t9` ( `a` int(11) NOT NULL auto_increment, - `b` char(16) NOT NULL default '', + `b` char(16) character set latin1 NOT NULL default '', `c` int(11) NOT NULL default '0', PRIMARY KEY (`a`) -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 alter table t9 rename t8, add column d int not null; alter table t8 rename t7; rename table t7 to t9; @@ -57,9 +57,9 @@ show create table test_mysqltest.t9; Table Create Table t9 CREATE TABLE `t9` ( `a` int(11) NOT NULL auto_increment, - `b` char(16) NOT NULL default '', + `b` char(16) character set latin1 NOT NULL default '', `c` int(11) NOT NULL default '0', `d` int(11) NOT NULL default '0', PRIMARY KEY (`a`) -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 drop database test_mysqltest; diff --git a/mysql-test/r/temp_table.result b/mysql-test/r/temp_table.result index 7c8d10cf0a6..5568e5b25d8 100644 --- a/mysql-test/r/temp_table.result +++ b/mysql-test/r/temp_table.result @@ -48,7 +48,6 @@ c d e 3 b 2 drop table t1; drop table t1; -drop table if exists t1; CREATE TABLE t1 (pkCrash INTEGER PRIMARY KEY,strCrash VARCHAR(255)); INSERT INTO t1 ( pkCrash, strCrash ) VALUES ( 1, '1'); SELECT CONCAT_WS(pkCrash, strCrash) FROM t1; @@ -77,7 +76,6 @@ insert into t1 values (1),(1); alter table t1 add primary key (a); Duplicate entry '1' for key 1 drop table t1; -drop table if exists t1; CREATE TABLE t1 ( d datetime default NULL ) TYPE=MyISAM; diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index ab4723457d1..2126fadba58 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -1,4 +1,36 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7; +CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000)); +show columns from t1; +Field Type Collation Null Key Default Extra +a blob binary YES NULL +b text latin1 YES NULL +c blob binary YES NULL +d mediumtext latin1 YES NULL +e longtext latin1 YES NULL +CREATE TABLE t2 (a char(257), b varchar(70000) binary, c varchar(70000000)); +Warnings: +Warning 1244 Converting column 'a' from CHAR to TEXT +Warning 1244 Converting column 'b' from CHAR to BLOB +Warning 1244 Converting column 'c' from CHAR to TEXT +show columns from t2; +Field Type Collation Null Key Default Extra +a text latin1 YES NULL +b mediumblob binary YES NULL +c longtext latin1 YES NULL +create table t3 (a long, b long byte); +show create TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` mediumtext, + `b` mediumblob +) TYPE=MyISAM CHARSET=latin1 +drop table t1,t2,t3 +#; +CREATE TABLE t1 (a char(257) default "hello"); +Too big column length for column 'a' (max = 255). Use BLOB instead +CREATE TABLE t2 (a blob default "hello"); +BLOB column 'a' can't have a default value +drop table if exists t1,t2; create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr)); insert into t1 values (null,"a","A"); insert into t1 values (null,"bbb","BBB"); @@ -37,18 +69,18 @@ insert into t1 values (NULL,NULL,NULL,NULL); update t1 set c="",b=null where c="1"; lock tables t1 READ; show full fields from t1; -Field Type Null Key Default Extra Privileges -t text YES NULL select,insert,update,references -c varchar(10) YES NULL select,insert,update,references -b blob YES NULL select,insert,update,references -d varchar(10) binary YES NULL select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +t text latin1 YES NULL select,insert,update,references +c varchar(10) latin1 YES NULL select,insert,update,references +b blob binary YES NULL select,insert,update,references +d varchar(10) binary binary YES NULL select,insert,update,references lock tables t1 WRITE; show full fields from t1; -Field Type Null Key Default Extra Privileges -t text YES NULL select,insert,update,references -c varchar(10) YES NULL select,insert,update,references -b blob YES NULL select,insert,update,references -d varchar(10) binary YES NULL select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +t text latin1 YES NULL select,insert,update,references +c varchar(10) latin1 YES NULL select,insert,update,references +b blob binary YES NULL select,insert,update,references +d varchar(10) binary binary YES NULL select,insert,update,references unlock tables; select t from t1 where t like "hello"; t @@ -98,6 +130,10 @@ select d from t1 having d like "%HELLO%"; d HELLO HELLO MY +select d from t1 having d like "%HE%LLO%"; +d +HELLO +HELLO MY select t from t1 order by t; t NULL diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index 214328eab47..cf6533eef67 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -1,3 +1,4 @@ +drop table if exists t1,t2; create table t1 (a char(16), b date, c datetime); insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01'; select * from t1 where c = '2000-01-01'; @@ -7,7 +8,6 @@ select * from t1 where b = '2000-01-01'; a b c test 2000-01-01 2000-01-01 2000-01-01 00:00:00 drop table t1; -drop table if exists t1,t2; CREATE TABLE t1 (name char(6),cdate date); INSERT INTO t1 VALUES ('name1','1998-01-01'); INSERT INTO t1 VALUES ('name2','1998-01-01'); diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 4785f790069..5a9a8699d06 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -41,8 +41,8 @@ t drop table t1; CREATE TABLE t1 (a timestamp, b date, c time, d datetime); insert into t1 (b,c,d) values(now(),curtime(),now()); -select date_format(a,"%Y-%m-%d")=b,right(a,6)=c+0,a=d+0 from t1; -date_format(a,"%Y-%m-%d")=b right(a,6)=c+0 a=d+0 +select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1; +date_format(a,"%Y-%m-%d")=b right(a+0,6)=c+0 a=d+0 1 1 1 drop table t1; CREATE TABLE t1 (a datetime not null); @@ -75,8 +75,8 @@ date numfacture expedition 0000-00-00 00:00:00 0 0001-00-00 00:00:00 0000-00-00 00:00:00 1212 0001-00-00 00:00:00 EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00'; -table type possible_keys key key_len ref rows Extra -t1 ref expedition expedition 8 const 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref expedition expedition 8 const 1 Using where drop table t1; create table t1 (a datetime not null, b datetime not null); insert into t1 values (now(), now()); diff --git a/mysql-test/r/type_enum.result b/mysql-test/r/type_enum.result index ee3bd077798..c0f0be246c9 100644 --- a/mysql-test/r/type_enum.result +++ b/mysql-test/r/type_enum.result @@ -1627,12 +1627,12 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` enum('','a','b') NOT NULL default '' -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 drop table t1; create table t1 (a enum (' ','a','b ') not null default 'b '); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` enum('','a','b') NOT NULL default 'b' -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 drop table t1; diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index e85bced353a..3914114d92c 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -1,3 +1,4 @@ +drop table if exists t1; SELECT 10,10.0,10.,.1e+2,100.0e-1; 10 10.0 10. .1e+2 100.0e-1 10 10.0 10 10 10 @@ -7,12 +8,11 @@ SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000; SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1; 1e1 1.e1 1.0e1 1e+1 1.e+1 1.0e+1 1e-1 1.e-1 1.0e-1 10 10 10 10 10 10 0.1 0.1 0.1 -drop table if exists t1; create table t1 (f1 float(24),f2 float(52)); show full columns from t1; -Field Type Null Key Default Extra Privileges -f1 float YES NULL select,insert,update,references -f2 double YES NULL select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +f1 float binary YES NULL select,insert,update,references +f2 double binary YES NULL select,insert,update,references insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150); insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150); select * from t1; @@ -69,19 +69,19 @@ min(a) drop table t1; create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6)); show full columns from t1; -Field Type Null Key Default Extra Privileges -f float YES NULL select,insert,update,references -f2 float YES NULL select,insert,update,references -f3 float(6,2) YES NULL select,insert,update,references -d double YES NULL select,insert,update,references -d2 double YES NULL select,insert,update,references -d3 double(10,3) YES NULL select,insert,update,references -de decimal(10,0) YES NULL select,insert,update,references -de2 decimal(6,0) YES NULL select,insert,update,references -de3 decimal(5,2) YES NULL select,insert,update,references -n decimal(10,0) YES NULL select,insert,update,references -n2 decimal(8,0) YES NULL select,insert,update,references -n3 decimal(7,6) YES NULL select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +f float binary YES NULL select,insert,update,references +f2 float binary YES NULL select,insert,update,references +f3 float(6,2) binary YES NULL select,insert,update,references +d double binary YES NULL select,insert,update,references +d2 double binary YES NULL select,insert,update,references +d3 double(10,3) binary YES NULL select,insert,update,references +de decimal(10,0) binary YES NULL select,insert,update,references +de2 decimal(6,0) binary YES NULL select,insert,update,references +de3 decimal(5,2) binary YES NULL select,insert,update,references +n decimal(10,0) binary YES NULL select,insert,update,references +n2 decimal(8,0) binary YES NULL select,insert,update,references +n3 decimal(7,6) binary YES NULL select,insert,update,references drop table t1; create table t1 (a decimal(7,3) not null, key (a)); insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1"); diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index fc7cc5255cf..1b2c775509e 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -38,31 +38,31 @@ KEY (ulonglong,ulong), KEY (options,flags) ); show full fields from t1; -Field Type Null Key Default Extra Privileges -auto int(5) unsigned PRI NULL auto_increment select,insert,update,references -string varchar(10) YES hello select,insert,update,references -tiny tinyint(4) MUL 0 select,insert,update,references -short smallint(6) MUL 1 select,insert,update,references -medium mediumint(8) MUL 0 select,insert,update,references -long_int int(11) 0 select,insert,update,references -longlong bigint(13) MUL 0 select,insert,update,references -real_float float(13,1) MUL 0.0 select,insert,update,references -real_double double(16,4) YES NULL select,insert,update,references -utiny tinyint(3) unsigned MUL 0 select,insert,update,references -ushort smallint(5) unsigned zerofill MUL 00000 select,insert,update,references -umedium mediumint(8) unsigned MUL 0 select,insert,update,references -ulong int(11) unsigned MUL 0 select,insert,update,references -ulonglong bigint(13) unsigned MUL 0 select,insert,update,references -time_stamp timestamp(14) YES NULL select,insert,update,references -date_field date YES NULL select,insert,update,references -time_field time YES NULL select,insert,update,references -date_time datetime YES NULL select,insert,update,references -blob_col blob YES NULL select,insert,update,references -tinyblob_col tinyblob YES NULL select,insert,update,references -mediumblob_col mediumblob select,insert,update,references -longblob_col longblob select,insert,update,references -options enum('one','two','tree') MUL one select,insert,update,references -flags set('one','two','tree') select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +auto int(5) unsigned binary PRI NULL auto_increment select,insert,update,references +string varchar(10) latin1 YES hello select,insert,update,references +tiny tinyint(4) binary MUL 0 select,insert,update,references +short smallint(6) binary MUL 1 select,insert,update,references +medium mediumint(8) binary MUL 0 select,insert,update,references +long_int int(11) binary 0 select,insert,update,references +longlong bigint(13) binary MUL 0 select,insert,update,references +real_float float(13,1) binary MUL 0.0 select,insert,update,references +real_double double(16,4) binary YES NULL select,insert,update,references +utiny tinyint(3) unsigned binary MUL 0 select,insert,update,references +ushort smallint(5) unsigned zerofill binary MUL 00000 select,insert,update,references +umedium mediumint(8) unsigned binary MUL 0 select,insert,update,references +ulong int(11) unsigned binary MUL 0 select,insert,update,references +ulonglong bigint(13) unsigned binary MUL 0 select,insert,update,references +time_stamp timestamp latin1 YES NULL select,insert,update,references +date_field date latin1 YES NULL select,insert,update,references +time_field time latin1 YES NULL select,insert,update,references +date_time datetime latin1 YES NULL select,insert,update,references +blob_col blob binary YES NULL select,insert,update,references +tinyblob_col tinyblob binary YES NULL select,insert,update,references +mediumblob_col mediumblob binary select,insert,update,references +longblob_col longblob binary select,insert,update,references +options enum('one','two','tree') latin1 MUL one select,insert,update,references +flags set('one','two','tree') latin1 select,insert,update,references show keys from t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment t1 0 PRIMARY 1 auto A 0 NULL NULL BTREE @@ -85,7 +85,7 @@ CREATE INDEX test3 on t1 ( medium ) ; DROP INDEX test ON t1; insert into t1 values (10, 1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one'); insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,NULL,2,2,'two','two,one'); -insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303 101010','','','','3',3,3); +insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303101010','','','','3',3,3); insert into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1); insert into t1 values (0,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,NULL,0,0,0,-4294967295,-4294967295,-4294967295,'-4294967295',0,"one,two,tree"); insert into t1 values (0,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,NULL,0,0,0,4294967295,4294967295,4294967295,'4294967295',0,0); @@ -168,57 +168,57 @@ drop table t2; create table t2 select * from t1; update t2 set string="changed" where auto=16; show full columns from t1; -Field Type Null Key Default Extra Privileges -auto int(5) unsigned MUL NULL auto_increment select,insert,update,references -string varchar(10) YES new defaul select,insert,update,references -tiny tinyint(4) MUL 0 select,insert,update,references -short smallint(6) MUL 0 select,insert,update,references -medium mediumint(8) MUL 0 select,insert,update,references -long_int int(11) 0 select,insert,update,references -longlong bigint(13) MUL 0 select,insert,update,references -real_float float(13,1) MUL 0.0 select,insert,update,references -real_double double(16,4) YES NULL select,insert,update,references -utiny tinyint(3) unsigned 0 select,insert,update,references -ushort smallint(5) unsigned zerofill 00000 select,insert,update,references -umedium mediumint(8) unsigned MUL 0 select,insert,update,references -ulong int(11) unsigned MUL 0 select,insert,update,references -ulonglong bigint(13) unsigned MUL 0 select,insert,update,references -time_stamp timestamp(14) YES NULL select,insert,update,references -date_field varchar(10) YES NULL select,insert,update,references -time_field time YES NULL select,insert,update,references -date_time datetime YES NULL select,insert,update,references -new_blob_col varchar(20) YES NULL select,insert,update,references -tinyblob_col tinyblob YES NULL select,insert,update,references -mediumblob_col mediumblob select,insert,update,references -options enum('one','two','tree') MUL one select,insert,update,references -flags set('one','two','tree') select,insert,update,references -new_field varchar(10) new select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +auto int(5) unsigned binary MUL NULL auto_increment select,insert,update,references +string varchar(10) latin1 YES new defaul select,insert,update,references +tiny tinyint(4) binary MUL 0 select,insert,update,references +short smallint(6) binary MUL 0 select,insert,update,references +medium mediumint(8) binary MUL 0 select,insert,update,references +long_int int(11) binary 0 select,insert,update,references +longlong bigint(13) binary MUL 0 select,insert,update,references +real_float float(13,1) binary MUL 0.0 select,insert,update,references +real_double double(16,4) binary YES NULL select,insert,update,references +utiny tinyint(3) unsigned binary 0 select,insert,update,references +ushort smallint(5) unsigned zerofill binary 00000 select,insert,update,references +umedium mediumint(8) unsigned binary MUL 0 select,insert,update,references +ulong int(11) unsigned binary MUL 0 select,insert,update,references +ulonglong bigint(13) unsigned binary MUL 0 select,insert,update,references +time_stamp timestamp latin1 YES NULL select,insert,update,references +date_field varchar(10) latin1 YES NULL select,insert,update,references +time_field time latin1 YES NULL select,insert,update,references +date_time datetime latin1 YES NULL select,insert,update,references +new_blob_col varchar(20) latin1 YES NULL select,insert,update,references +tinyblob_col tinyblob binary YES NULL select,insert,update,references +mediumblob_col mediumblob binary select,insert,update,references +options enum('one','two','tree') latin1 MUL one select,insert,update,references +flags set('one','two','tree') latin1 select,insert,update,references +new_field varchar(10) latin1 new select,insert,update,references show full columns from t2; -Field Type Null Key Default Extra Privileges -auto int(5) unsigned 0 select,insert,update,references -string varchar(10) YES new defaul select,insert,update,references -tiny tinyint(4) 0 select,insert,update,references -short smallint(6) 0 select,insert,update,references -medium mediumint(8) 0 select,insert,update,references -long_int int(11) 0 select,insert,update,references -longlong bigint(13) 0 select,insert,update,references -real_float float(13,1) 0.0 select,insert,update,references -real_double double(16,4) YES NULL select,insert,update,references -utiny tinyint(3) unsigned 0 select,insert,update,references -ushort smallint(5) unsigned zerofill 00000 select,insert,update,references -umedium mediumint(8) unsigned 0 select,insert,update,references -ulong int(11) unsigned 0 select,insert,update,references -ulonglong bigint(13) unsigned 0 select,insert,update,references -time_stamp timestamp(14) YES NULL select,insert,update,references -date_field varchar(10) YES NULL select,insert,update,references -time_field time YES NULL select,insert,update,references -date_time datetime YES NULL select,insert,update,references -new_blob_col varchar(20) YES NULL select,insert,update,references -tinyblob_col tinyblob YES NULL select,insert,update,references -mediumblob_col mediumblob select,insert,update,references -options enum('one','two','tree') one select,insert,update,references -flags set('one','two','tree') select,insert,update,references -new_field varchar(10) new select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +auto int(5) unsigned binary 0 select,insert,update,references +string varchar(10) latin1 YES new defaul select,insert,update,references +tiny tinyint(4) binary 0 select,insert,update,references +short smallint(6) binary 0 select,insert,update,references +medium mediumint(8) binary 0 select,insert,update,references +long_int int(11) binary 0 select,insert,update,references +longlong bigint(13) binary 0 select,insert,update,references +real_float float(13,1) binary 0.0 select,insert,update,references +real_double double(16,4) binary YES NULL select,insert,update,references +utiny tinyint(3) unsigned binary 0 select,insert,update,references +ushort smallint(5) unsigned zerofill binary 00000 select,insert,update,references +umedium mediumint(8) unsigned binary 0 select,insert,update,references +ulong int(11) unsigned binary 0 select,insert,update,references +ulonglong bigint(13) unsigned binary 0 select,insert,update,references +time_stamp timestamp latin1 YES NULL select,insert,update,references +date_field varchar(10) latin1 YES NULL select,insert,update,references +time_field time latin1 YES NULL select,insert,update,references +date_time datetime latin1 YES NULL select,insert,update,references +new_blob_col varchar(20) latin1 YES NULL select,insert,update,references +tinyblob_col tinyblob binary YES NULL select,insert,update,references +mediumblob_col mediumblob binary select,insert,update,references +options enum('one','two','tree') latin1 one select,insert,update,references +flags set('one','two','tree') latin1 select,insert,update,references +new_field varchar(10) latin1 new select,insert,update,references select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null))); auto auto 16 16 @@ -228,12 +228,12 @@ auto auto drop table t2; create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, "a" as t2, repeat("a",256) as t3, binary repeat("b",256) as t4 from t1; show full columns from t2; -Field Type Null Key Default Extra Privileges -auto bigint(17) unsigned PRI 0 select,insert,update,references -t1 bigint(1) 0 select,insert,update,references -t2 char(1) select,insert,update,references -t3 mediumtext select,insert,update,references -t4 mediumblob select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +auto bigint(17) unsigned binary PRI 0 select,insert,update,references +t1 bigint(1) binary 0 select,insert,update,references +t2 char(1) latin1 select,insert,update,references +t3 mediumtext latin1 select,insert,update,references +t4 mediumtext character set latin1 latin1_bin select,insert,update,references select * from t2; auto t1 t2 t3 t4 11 1 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb @@ -251,10 +251,10 @@ create table t3 select * from t1, t2; Duplicate column name 'c' create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2; show full columns from t3; -Field Type Null Key Default Extra Privileges -c1 int(11) YES NULL select,insert,update,references -c2 int(11) YES NULL select,insert,update,references -const bigint(1) 0 select,insert,update,references +Field Type Collation Null Key Default Extra Privileges Comment +c1 int(11) binary YES NULL select,insert,update,references +c2 int(11) binary YES NULL select,insert,update,references +const bigint(1) binary 0 select,insert,update,references drop table t1,t2,t3; create table t1 ( myfield INT NOT NULL, UNIQUE INDEX (myfield), unique (myfield), index(myfield)); drop table t1; diff --git a/mysql-test/r/type_set.result b/mysql-test/r/type_set.result index 59f8744e2ec..b0ea1b69e59 100644 --- a/mysql-test/r/type_set.result +++ b/mysql-test/r/type_set.result @@ -4,12 +4,12 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` set('','a','b') NOT NULL default '' -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 drop table t1; create table t1 (a set (' ','a','b ') not null default 'b '); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` set('','a','b') NOT NULL default 'b' -) TYPE=MyISAM +) TYPE=MyISAM CHARSET=latin1 drop table t1; diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index 3d5d74709c1..959c69ff6e7 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -15,26 +15,26 @@ SET TIMESTAMP=1238; insert into t1 (a) select a+1 from t2 where a=8; select * from t1; a t -1 19700101032034 -2 20020303000000 -3 19700101032035 -4 19700101032036 -5 20020304000000 -6 19700101032037 -7 20020305000000 -8 00000000000000 -9 19700101032038 +1 1970-01-01 03:20:34 +2 2002-03-03 00:00:00 +3 1970-01-01 03:20:35 +4 1970-01-01 03:20:36 +5 2002-03-04 00:00:00 +6 1970-01-01 03:20:37 +7 2002-03-05 00:00:00 +8 0000-00-00 00:00:00 +9 1970-01-01 03:20:38 drop table t1,t2; SET TIMESTAMP=1234; CREATE TABLE t1 (value TEXT NOT NULL, id VARCHAR(32) NOT NULL, stamp timestamp, PRIMARY KEY (id)); INSERT INTO t1 VALUES ("my value", "myKey","1999-04-02 00:00:00"); SELECT stamp FROM t1 WHERE id="myKey"; stamp -19990402000000 +1999-04-02 00:00:00 UPDATE t1 SET value="my value" WHERE id="myKey"; SELECT stamp FROM t1 WHERE id="myKey"; stamp -19990402000000 +1999-04-02 00:00:00 drop table t1; create table t1 (a timestamp); insert into t1 values (now()); @@ -44,8 +44,8 @@ date_format(a,"%Y %y") year(a) year(now()) drop table t1; create table t1 (ix timestamp); insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000); -select * from t1; -ix +select ix+0 from t1; +ix+0 19991101000000 19990102030405 19990630232922 @@ -71,18 +71,18 @@ INSERT INTO t1 VALUES ("2005-01-01","2005-01-01 00:00:00",20050101000000); INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000); SELECT * FROM t1; date date_time time_stamp -1998-12-31 1998-12-31 23:59:59 19981231235959 -1999-01-01 1999-01-01 00:00:00 19990101000000 -1999-09-09 1999-09-09 23:59:59 19990909235959 -2000-01-01 2000-01-01 00:00:00 20000101000000 -2000-02-28 2000-02-28 00:00:00 20000228000000 -2000-02-29 2000-02-29 00:00:00 20000229000000 -2000-03-01 2000-03-01 00:00:00 20000301000000 -2000-12-31 2000-12-31 23:59:59 20001231235959 -2001-01-01 2001-01-01 00:00:00 20010101000000 -2004-12-31 2004-12-31 23:59:59 20041231235959 -2005-01-01 2005-01-01 00:00:00 20050101000000 -2030-01-01 2030-01-01 00:00:00 20300101000000 +1998-12-31 1998-12-31 23:59:59 1998-12-31 23:59:59 +1999-01-01 1999-01-01 00:00:00 1999-01-01 00:00:00 +1999-09-09 1999-09-09 23:59:59 1999-09-09 23:59:59 +2000-01-01 2000-01-01 00:00:00 2000-01-01 00:00:00 +2000-02-28 2000-02-28 00:00:00 2000-02-28 00:00:00 +2000-02-29 2000-02-29 00:00:00 2000-02-29 00:00:00 +2000-03-01 2000-03-01 00:00:00 2000-03-01 00:00:00 +2000-12-31 2000-12-31 23:59:59 2000-12-31 23:59:59 +2001-01-01 2001-01-01 00:00:00 2001-01-01 00:00:00 +2004-12-31 2004-12-31 23:59:59 2004-12-31 23:59:59 +2005-01-01 2005-01-01 00:00:00 2005-01-01 00:00:00 +2030-01-01 2030-01-01 00:00:00 2030-01-01 00:00:00 drop table t1; show variables like 'new'; Variable_name Value diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 2af9d5a3584..0edf5df7ae1 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -84,37 +84,34 @@ a b 3 c 2 b 1 a +(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b; +Table 't1' from one of SELECT's can not be used in global ORDER clause explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 -t2 ALL NULL NULL NULL NULL 4 Using filesort -t1 ALL NULL NULL NULL NULL 4 -(select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2; -a b -1 a -2 b +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 +2 UNION t2 ALL NULL NULL NULL NULL 4 Using filesort select found_rows(); found_rows() -6 +0 explain select a,b from t1 union all select a,b from t2; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 -t2 ALL NULL NULL NULL NULL 4 +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 +2 UNION t2 ALL NULL NULL NULL NULL 4 explain select xx from t1 union select 1; Unknown column 'xx' in 'field list' explain select a,b from t1 union select 1; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 - 0 0 No tables used +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 +2 UNION NULL NULL NULL NULL NULL NULL NULL No tables used explain select 1 union select a,b from t1 union select 1; -table type possible_keys key key_len ref rows Extra - 0 0 No tables used -t1 ALL NULL NULL NULL NULL 4 - 0 0 No tables used +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION t1 ALL NULL NULL NULL NULL 4 +3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used explain select a,b from t1 union select 1 limit 0; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 - 0 0 Impossible WHERE +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 UNION NULL NULL NULL NULL NULL NULL NULL Impossible WHERE select a,b from t1 into outfile 'skr' union select a,b from t2; Wrong usage of UNION and INTO select a,b from t1 order by a union select a,b from t2; @@ -173,7 +170,6 @@ testtt tsestset 1 drop table t1; -drop table if exists t1,t2; create table t1 (a int); create table t2 (a int); insert into t1 values (1),(2),(3),(4),(5); @@ -202,3 +198,78 @@ a 11 set SQL_SELECT_LIMIT=DEFAULT; drop table t1,t2; +select * union select 1; +No tables used +select 1 as a,(select a union select a); +a (select a union select a) +1 1 +drop table if exists t1,t2; +CREATE TABLE t1 ( id int(3) unsigned default '0') TYPE=MyISAM; +INSERT INTO t1 (id) VALUES("1"); +CREATE TABLE t2 ( id int(3) unsigned default '0', id_master int(5) default '0', text1 varchar(5) default NULL, text2 varchar(5) default NULL) TYPE=MyISAM; +INSERT INTO t2 (id, id_master, text1, text2) VALUES("1", "1", +"foo1", "bar1"); +INSERT INTO t2 (id, id_master, text1, text2) VALUES("2", "1", +"foo2", "bar2"); +INSERT INTO t2 (id, id_master, text1, text2) VALUES("3", "1", NULL, +"bar3"); +INSERT INTO t2 (id, id_master, text1, text2) VALUES("4", "1", +"foo4", "bar4"); +SELECT 1 AS id_master, 1 AS id, NULL AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master; +id_master id text1 text2 +1 1 NULL ABCDE +1 1 bar1 +1 2 bar2 +1 3 NULL bar3 +1 4 bar4 +SELECT 1 AS id_master, 1 AS id, 'ABCDE' AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master; +id_master id text1 text2 +1 1 ABCDE ABCDE +1 1 foo1 bar1 +1 2 foo2 bar2 +1 3 NULL bar3 +1 4 foo4 bar4 +drop table if exists t1,t2; +(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2); +1 3 +1 3 +2 1 +create table t1 (a int not null primary key auto_increment, b int, key(b)); +create table t2 (a int not null primary key auto_increment, b int); +insert into t1 (b) values (1),(2),(2),(3); +insert into t2 (b) values (10),(11),(12),(13); +explain (select * from t1 where a=1) union (select * from t2 where a=1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 +2 UNION t2 const PRIMARY PRIMARY 4 const 1 +(select * from t1 where a=5) union (select * from t2 where a=1); +a b +1 10 +(select * from t1 where a=5 and a=6) union (select * from t2 where a=1); +a b +1 10 +(select t1.a,t1.b from t1,t2 where t1.a=5) union (select * from t2 where a=1); +a b +1 10 +(select * from t1 where a=1) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a); +a b +1 1 +2 2 +3 3 +4 4 +explain (select * from t1 where a=1 and b=10) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 UNION t1 index PRIMARY PRIMARY 4 NULL 4 Using index +2 UNION t2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index +explain (select * from t1 where a=1) union (select * from t1 where b=1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 +2 UNION t1 ref b b 5 const 1 Using where +drop table t1,t2; +(select 1) union (select 2) order by 0; +Unknown column '0' in 'order clause' +SELECT @a:=1 UNION SELECT @a:=@a+1; +@a:=1 +1 +2 diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index ba5c1c6e28f..159b971440b 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -1,4 +1,4 @@ -drop table if exists t1; +drop table if exists t1,t2; create table t1 (a int auto_increment , primary key (a)); insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); update t1 set a=a+10 where a > 34; @@ -106,9 +106,12 @@ create table t1 (a int not null, b int not null); insert into t1 values (1,1),(1,2),(1,3); update t1 set b=4 where a=1 order by b asc limit 1; update t1 set b=4 where a=1 order by b desc limit 1; +create table t2 (a int not null, b int not null); +insert into t2 values (1,1),(1,2),(1,3); select * from t1; a b 1 4 1 2 1 4 -drop table t1; +update t1 set b=(select distinct 1 from (select * from t2) a); +drop table t1,t2; diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 5e9f3a720c2..6e3b9309351 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -1,10 +1,10 @@ +drop table if exists t1,t2; set @a := foo; Unknown column 'foo' in 'field list' set @a := connection_id() + 3; select @a - connection_id(); @a - connection_id() 3 -drop table if exists t1,t2; CREATE TABLE t1 ( i int not null, v int not null,index (i)); insert into t1 values (1,1),(1,3),(2,1); create table t2 (i int not null, unique (i)); @@ -18,15 +18,15 @@ i @vv1:=if(sv1.i,1,0) @vv2:=if(sv2.i,1,0) @vv3:=if(sv3.i,1,0) @vv1+@vv2+@vv3 1 1 0 1 2 2 1 0 0 1 explain select * from t1 where i=@vv1; -table type possible_keys key key_len ref rows Extra -t1 ref i i 4 const 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref i i 4 const 1 Using where explain select * from t1 where @vv1:=@vv1+1 and i=@vv1; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 3 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where explain select @vv1:=i from t1 where i=@vv1; -table type possible_keys key key_len ref rows Extra -t1 index NULL i 4 NULL 3 Using where; Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL i 4 NULL 3 Using where; Using index explain select * from t1 where i=@vv1; -table type possible_keys key key_len ref rows Extra -t1 ref i i 4 const 1 Using where +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref i i 4 const 1 Using where drop table t1,t2; diff --git a/mysql-test/r/varbinary.result b/mysql-test/r/varbinary.result index 4eb34ebfd63..2d04da31caa 100644 --- a/mysql-test/r/varbinary.result +++ b/mysql-test/r/varbinary.result @@ -1,3 +1,4 @@ +drop table if exists t1; select 0x41,0x41+0,0x41 | 0x7fffffffffffffff | 0,0xffffffffffffffff | 0 ; 0x41 0x41+0 0x41 | 0x7fffffffffffffff | 0 0xffffffffffffffff | 0 A 65 9223372036854775807 18446744073709551615 @@ -7,13 +8,12 @@ select 0x31+1,concat(0x31)+1,-0xf; select x'31',X'ffff'+0; x'31' X'ffff'+0 1 65535 -drop table if exists t1; create table t1 (ID int(8) unsigned zerofill not null auto_increment,UNIQ bigint(21) unsigned zerofill not null,primary key (ID),unique (UNIQ) ); insert into t1 set UNIQ=0x38afba1d73e6a18a; insert into t1 set UNIQ=123; explain select * from t1 where UNIQ=0x38afba1d73e6a18a; -table type possible_keys key key_len ref rows Extra -t1 const UNIQ UNIQ 8 const 1 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const UNIQ UNIQ 8 const 1 drop table t1; select x'hello'; You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'x'hello'' at line 1 diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index ed477a8519b..b66d75e2b3a 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -1,4 +1,4 @@ -drop table if exists t1; +drop table if exists t1,t2; set @`test`=1,@TEST=3,@select=2,@t5=1.23456; select @test,@`select`,@TEST,@not_used; @test @`select` @TEST @not_used @@ -315,7 +315,6 @@ set tmp_table_size=100; set tx_isolation="READ-COMMITTED"; set wait_timeout=100; set log_warnings=1; -DROP TABLE IF EXISTS t1,t2; create table t1 (a int not null auto_increment, primary key(a)); create table t2 (a int not null auto_increment, primary key(a)); insert into t1 values(null),(null),(null); diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index e5713718db0..f2a105827da 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -1,4 +1,6 @@ drop table if exists t1; +Warnings: +Note 1051 Unknown table 't1' create table t1 (a int); insert into t1 values (1); insert into t1 values ("hej"); @@ -8,3 +10,23 @@ insert into t1 values ("hej"); insert into t1 values ("hej"),("då"); drop table t1; set SQL_WARNINGS=0; +drop temporary table if exists not_exists; +Warnings: +Note 1051 Unknown table 'not_exists' +drop table if exists not_exists_table; +Warnings: +Note 1051 Unknown table 'not_exists_table' +show warnings limit 1; +Level Code Message +Note 1051 Unknown table 'not_exists_table' +drop database if exists not_exists_db; +Warnings: +Note 1008 Can't drop database 'not_exists_db'. Database doesn't exist +show count(*) warnings; +@@session.warning_count +1 +create table t1(id int); +create table if not exists t1(id int); +select @@warning_count; +@@warning_count +0 diff --git a/mysql-test/std_data/master-bin.001 b/mysql-test/std_data/master-bin.000001 Binary files differindex 2ec2397acdd..2ec2397acdd 100644 --- a/mysql-test/std_data/master-bin.001 +++ b/mysql-test/std_data/master-bin.000001 diff --git a/mysql-test/t/README b/mysql-test/t/README deleted file mode 100644 index e69de29bb2d..00000000000 --- a/mysql-test/t/README +++ /dev/null diff --git a/mysql-test/t/alias.test b/mysql-test/t/alias.test index 5c6813d93aa..64dd481d37d 100644 --- a/mysql-test/t/alias.test +++ b/mysql-test/t/alias.test @@ -1,4 +1,7 @@ +--disable_warnings DROP TABLE IF EXISTS t1; +--enable_warnings + CREATE TABLE t1 ( cont_nr int(11) NOT NULL auto_increment, ver_nr int(11) NOT NULL default '0', diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 1c3987e2a31..64b657f1146 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -1,8 +1,10 @@ # # Test of alter table # - +--disable_warnings drop table if exists t1,t2; +--enable_warnings + create table t1 ( col1 int not null auto_increment primary key, col2 varchar(30) not null, diff --git a/mysql-test/t/analyse.test b/mysql-test/t/analyse.test index 9bf737c9515..6aca345b282 100644 --- a/mysql-test/t/analyse.test +++ b/mysql-test/t/analyse.test @@ -2,12 +2,16 @@ # Test of procedure analyse # +--disable_warnings drop table if exists t1,t2; +--enable_warnings create table t1 (i int, j int, empty_string char(10), bool char(1), d date); insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6,"","Y","2002-03-04"), (7,8,"","N","2002-03-05"); +select count(*) from t1 procedure analyse(); select * from t1 procedure analyse(); select * from t1 procedure analyse(2); create table t2 select * from t1 procedure analyse(); select * from t2; drop table t1,t2; +EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(); diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index 5fba4bb9234..d7f67fe80d4 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -1,8 +1,10 @@ # # Test of auto_increment; The test for BDB tables is in bdb.test # - +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (a int not null auto_increment,b int, primary key (a)) type=myisam auto_increment=3; insert into t1 values (1,1),(NULL,3),(NULL,4); delete from t1 where a=4; diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test index 0346e6ba456..a66c07fd27f 100644 --- a/mysql-test/t/backup.test +++ b/mysql-test/t/backup.test @@ -6,6 +6,9 @@ connect (con1,localhost,root,,); connect (con2,localhost,root,,); connection con1; set SQL_LOG_BIN=0; +--disable_warnings +drop table if exists t1, t2, t3; +--enable_warnings create table t4(n int); --replace_result "errno: 2" "errno: X" "errno: 22" "errno: X" "errno: 23" "errno: X" backup table t4 to '../bogus'; diff --git a/mysql-test/t/bdb-alter-table-1.test b/mysql-test/t/bdb-alter-table-1.test index 5861c2fe0bf..7537cc358e8 100644 --- a/mysql-test/t/bdb-alter-table-1.test +++ b/mysql-test/t/bdb-alter-table-1.test @@ -2,7 +2,10 @@ # Test of problem when shutting down mysqld at once after ALTER TABLE # -- source include/have_bdb.inc +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1(objid BIGINT not null, tablename varchar(64), oid BIGINT not null, test BIGINT, PRIMARY KEY (objid), UNIQUE(tablename)) type=BDB; insert into t1 values(1, 't1',4,9); insert into t1 values(2, 'metatable',1,9); diff --git a/mysql-test/t/bdb-crash.test b/mysql-test/t/bdb-crash.test index 0005b631a46..956645b1188 100644 --- a/mysql-test/t/bdb-crash.test +++ b/mysql-test/t/bdb-crash.test @@ -2,7 +2,9 @@ # test for bug reported by Mark Steele +--disable_warnings drop table if exists t1; +--enable_warnings CREATE TABLE t1 ( ChargeID int(10) unsigned DEFAULT '0' NOT NULL auto_increment, ServiceID int(10) unsigned DEFAULT '0' NOT NULL, diff --git a/mysql-test/t/bdb-deadlock.test b/mysql-test/t/bdb-deadlock.test index b32b50c715b..2453c42e49a 100644 --- a/mysql-test/t/bdb-deadlock.test +++ b/mysql-test/t/bdb-deadlock.test @@ -11,7 +11,9 @@ connect (con1,localhost,root,,); connect (con2,localhost,root,,); +--disable_warnings drop table if exists t1,t2; +--enable_warnings connection con1; create table t1 (id integer, x integer) type=BDB; create table t2 (id integer, x integer) type=BDB; @@ -30,13 +32,19 @@ select x from t1 where id = 0; connection con1; # This should generate a deadlock as we are trying to access a locked row ---error 1213 +--send select x from t2 where id = 0; -commit; connection con2; +--error 1213 reap; commit; + +connection con1; +reap; +commit; + +connection con2; select * from t1; select * from t2; commit; @@ -45,4 +53,5 @@ connection con1; select * from t1; select * from t2; commit; + drop table t1,t2; diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test index 608d4bf5042..27755e51b7f 100644 --- a/mysql-test/t/bdb.test +++ b/mysql-test/t/bdb.test @@ -4,7 +4,9 @@ # Small basic test with ignore # +--disable_warnings drop table if exists t1,t2,t3,t4,t5,t6,t7,t8; +--enable_warnings create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) type=bdb; insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt'); @@ -441,7 +443,6 @@ drop table t1; # This gave a wrong result because the row information was freed too early # -drop table if exists t1, t2, t3, t4, t5, t6, t7; create table t1 ( branch_id int auto_increment primary key, @@ -451,7 +452,6 @@ create table t1 unique branch_name(branch_name), index branch_active(branch_active) ) type=bdb; -drop table if exists t2 ; create table t2 ( target_id int auto_increment primary key, @@ -461,7 +461,6 @@ create table t2 unique target_name(target_name), index target_active(target_active) ) type=bdb; -drop table if exists t3 ; create table t3 ( platform_id int auto_increment primary key, @@ -471,7 +470,6 @@ create table t3 unique platform_name(platform_name), index platform_active(platform_active) ) type=bdb; -drop table if exists t4 ; create table t4 ( product_id int auto_increment primary key, @@ -482,7 +480,6 @@ create table t4 unique product_name(product_name), index product_active(product_active) ) type=bdb; -drop table if exists t5 ; create table t5 ( product_file_id int auto_increment primary key, @@ -496,7 +493,6 @@ create table t5 unique product_file(product_id,file_name), index file_included(file_included) ) type=bdb; -drop table if exists t6 ; create table t6 ( file_platform_id int auto_increment primary key, @@ -510,7 +506,6 @@ create table t6 unique file_platform(product_file_id,platform_id,branch_id) ) type=bdb; -drop table if exists t8 ; create table t8 ( archive_id int auto_increment primary key, @@ -523,7 +518,6 @@ create table t8 unique archive(branch_id,target_id,platform_id,product_id), index status_id(status_id) ) type=bdb; -drop table if exists t7 ; create table t7 ( build_id int auto_increment primary key, @@ -727,7 +721,6 @@ DROP TABLE t1,t2; # Test problem with joining table to itself on a multi-part unique key # -drop table if exists t1; create table t1 (a int(11) not null, b int(11) not null, unique (a,b)) type=bdb; insert into t1 values (1,1), (1,2); select * from t1 where a = 1; diff --git a/mysql-test/t/bdb_cache.test b/mysql-test/t/bdb_cache.test index aa5572886c5..0d7de75ccf6 100644 --- a/mysql-test/t/bdb_cache.test +++ b/mysql-test/t/bdb_cache.test @@ -4,7 +4,9 @@ # # Without auto_commit. # +--disable_warnings drop table if exists t1, t2, t3; +--enable_warnings flush status; set autocommit=0; create table t1 (a int not null) type=bdb; @@ -47,4 +49,5 @@ select * from t3; show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; commit; -show status like "Qcache_queries_in_cache";
\ No newline at end of file +show status like "Qcache_queries_in_cache"; +drop table if exists t1, t2, t3; diff --git a/mysql-test/t/bench_count_distinct.test b/mysql-test/t/bench_count_distinct.test index 9059428bea4..c1adeab2c44 100644 --- a/mysql-test/t/bench_count_distinct.test +++ b/mysql-test/t/bench_count_distinct.test @@ -1,4 +1,10 @@ +# +# Test of count(distinct ..) +# + +--disable_warnings drop table if exists t1; +--enable_warnings create table t1(n int not null, key(n)) delay_key_write = 1; let $1=100; disable_query_log; diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index c5691a760c7..060d45c29a4 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -1,4 +1,11 @@ # +# Initialize + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# # Test of reading of bigint values # select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296; @@ -12,7 +19,6 @@ select 9223372036854775808+1; # This will work on 4.0 as we then have internal handling of bigint variables. # -drop table if exists t1; create table t1 (a bigint unsigned not null, primary key(a)); insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE); select * from t1; diff --git a/mysql-test/t/binary.test b/mysql-test/t/binary.test index 95815cda60f..48912a390ed 100644 --- a/mysql-test/t/binary.test +++ b/mysql-test/t/binary.test @@ -1,8 +1,10 @@ # # test sort,min and max on binary fields # - +--disable_warnings drop table if exists t1,t2; +--enable_warnings + create table t1 (name char(20) not null, primary key (name)); create table t2 (name char(20) binary not null, primary key (name)); insert into t1 values ("å"); @@ -28,16 +30,16 @@ drop table t1,t2; create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b)); insert into t1 values ("hello ","hello "),("hello2 ","hello2 "); -select * from t1 where a="hello"; -select * from t1 where a="hello "; -select * from t1 ignore index (a) where a="hello "; -select * from t1 where b="hello"; -select * from t1 where b="hello "; -select * from t1 ignore index (b) where b="hello "; +select concat("-",a,"-",b,"-") from t1 where a="hello"; +select concat("-",a,"-",b,"-") from t1 where a="hello "; +select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello "; +select concat("-",a,"-",b,"-") from t1 where b="hello"; +select concat("-",a,"-",b,"-") from t1 where b="hello "; +select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello "; # blob test alter table t1 modify b tinytext not null, drop key b, add key (b(100)); -select * from t1 where b="hello "; -select * from t1 ignore index (b) where b="hello "; +select concat("-",a,"-",b,"-") from t1 where b="hello "; +select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello "; drop table t1; # diff --git a/mysql-test/t/bool.test b/mysql-test/t/bool.test index 10f97fefb73..c001973baeb 100644 --- a/mysql-test/t/bool.test +++ b/mysql-test/t/bool.test @@ -2,7 +2,9 @@ # Test of boolean operations with NULL # +--disable_warnings DROP TABLE IF EXISTS t1; +--enable_warnings SELECT IF(NULL AND 1, 1, 2), IF(1 AND NULL, 1, 2); SELECT NULL AND 1, 1 AND NULL, 0 AND NULL, NULL and 0; @@ -33,19 +35,17 @@ DROP TABLE t1; # Read nA as !A, AB as A && B, AoB as A || B # Result table makes ANSI happy -drop table if exists t; -create table t(a int, b int); -insert into t values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1); +create table t1 (a int, b int); +insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1); # Below test is valid untill we have True/False implemented as 1/0 # To comply to all rules it must show that: n(AB) = nAonB, n(AoB) = nAnB -select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t; +select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1; # This should work with any internal representation of True/False # Result must be same as above -select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t; +select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t1; - -drop table t; +drop table t1; diff --git a/mysql-test/t/bulk_replace.test b/mysql-test/t/bulk_replace.test index d366004c16f..755d34083f8 100644 --- a/mysql-test/t/bulk_replace.test +++ b/mysql-test/t/bulk_replace.test @@ -1,11 +1,10 @@ # # this is a test of bulk-insert code -# as used by REPLACE -# -# by Monty # +--disable_warnings drop table if exists t1; +--enable_warnings CREATE TABLE t1 (a int, unique (a), b int not null, unique(b), c int not null, index(c)); replace into t1 values (1,1,1),(2,2,2),(3,1,3); select * from t1; diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test index 3ba3a292c77..6131d1500de 100644 --- a/mysql-test/t/case.test +++ b/mysql-test/t/case.test @@ -2,7 +2,9 @@ # Testing of CASE # +--disable_warnings drop table if exists t1; +--enable_warnings select CASE "b" when "a" then 1 when "b" then 2 END; select CASE "c" when "a" then 1 when "b" then 2 END; diff --git a/mysql-test/t/check.test b/mysql-test/t/check.test index 947566e725b..bc61aea2d66 100644 --- a/mysql-test/t/check.test +++ b/mysql-test/t/check.test @@ -1,8 +1,11 @@ connect (con1,localhost,root,,); connect (con2,localhost,root,,); connection con1; +--disable_warnings drop table if exists t1; -#add a lot of keys to slow down check +--enable_warnings + +# Add a lot of keys to slow down check create table t1(n int not null, key(n), key(n), key(n), key(n)); let $1=10000; disable_query_log; diff --git a/mysql-test/t/compare.test b/mysql-test/t/compare.test index 450d9c0961c..e5a2e310866 100644 --- a/mysql-test/t/compare.test +++ b/mysql-test/t/compare.test @@ -2,7 +2,10 @@ # Bug when using comparions of strings and integers. # +--disable_warnings drop table if exists t1; +--enable_warnings + CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id)); insert into t1 values ('000000000001'),('000000000002'); explain select * from t1 where id=000000000001; diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test new file mode 100644 index 00000000000..7b441ee5f7b --- /dev/null +++ b/mysql-test/t/connect.test @@ -0,0 +1,64 @@ +# This test is to check various cases of connections +# with right and wrong password, with and without database +# Unfortunately the check is incomplete as we can't handle errors on connect +# Also we can't connect without database + +#connect (con1,localhost,root,,""); +#show tables; +connect (con1,localhost,root,,mysql); +show tables; +connect (con1,localhost,root,,test); +show tables; + +# Re enable this one day if error handling on connect will take place + +#connect (con1,localhost,root,z,test2); +#--error 1045 +#connect (con1,localhost,root,z,); +#--error 1045 + +grant ALL on *.* to test@localhost identified by "gambling"; +grant ALL on *.* to test@127.0.0.1 identified by "gambling"; + +# Now check this user with different databases + +#connect (con1,localhost,test,gambling,""); +#show tables; +connect (con1,localhost,test,gambling,mysql); +show tables; +connect (con1,localhost,test,gambling,test); +show tables; + +# Re enable this one day if error handling on connect will take place + +#connect (con1,localhost,test,,test2); +#--error 1045 +#connect (con1,localhost,test,,""); +#--error 1045 +#connect (con1,localhost,test,zorro,test2); +#--error 1045 +#connect (con1,localhost,test,zorro,); +#--error 1045 + + +# check if old password version also works +update mysql.user set password=old_password("gambling2") where user="test"; +flush privileges; + +#connect (con1,localhost,test,gambling2,""); +#show tables; +connect (con1,localhost,test,gambling2,mysql); +show tables; +connect (con1,localhost,test,gambling2,test); +show tables; + +# Re enable this one day if error handling on connect will take place + +#connect (con1,localhost,test,,test2); +#--error 1045 +#connect (con1,localhost,test,,); +#--error 1045 +#connect (con1,localhost,test,zorro,test2); +#--error 1045 +#connect (con1,localhost,test,zorro,); +#--error 1045 diff --git a/mysql-test/t/constraints.test b/mysql-test/t/constraints.test index 8682cdc42a2..cc796e0abd2 100644 --- a/mysql-test/t/constraints.test +++ b/mysql-test/t/constraints.test @@ -2,7 +2,9 @@ # Testing of constraints # Currently MySQL only ignores the syntax. # +--disable_warnings drop table if exists t1; +--enable_warnings create table t1 (a int check (a>0)); insert into t1 values (1); diff --git a/mysql-test/t/count_distinct.test b/mysql-test/t/count_distinct.test index cb84d0211d7..1f0404876cb 100644 --- a/mysql-test/t/count_distinct.test +++ b/mysql-test/t/count_distinct.test @@ -2,7 +2,10 @@ # Problem with count(distinct) # +--disable_warnings drop table if exists t1,t2,t3; +--enable_warnings + create table t1 (libname varchar(21) not null, city text, primary key (libname)); create table t2 (isbn varchar(21) not null, author text, title text, primary key (isbn)); create table t3 (isbn varchar(21) not null, libname varchar(21) not null, quantity int ,primary key (isbn,libname)); diff --git a/mysql-test/t/count_distinct2.test b/mysql-test/t/count_distinct2.test index d1bea7614c8..9100f622dec 100644 --- a/mysql-test/t/count_distinct2.test +++ b/mysql-test/t/count_distinct2.test @@ -1,4 +1,6 @@ +--disable_warnings drop table if exists t1; +--enable_warnings create table t1(n1 int, n2 int, s char(20), vs varchar(20), t text); insert into t1 values (1,11, 'one','eleven', 'eleven'), diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 7d566cb89ac..98d76bf2883 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -2,7 +2,10 @@ # Check some special create statements. # -drop table if exists t1,t2; +--disable_warnings +drop table if exists t1,t2,t3; +--enable_warnings + create table t1 (b char(0)); insert into t1 values (""),(null); select * from t1; @@ -12,7 +15,7 @@ create table t1 (b char(0) not null); create table if not exists t1 (b char(0) not null); insert into t1 values (""),(null); select * from t1; -drop table if exists t1; +drop table t1; # # Test of some CREATE TABLE'S that should fail @@ -22,12 +25,12 @@ drop table if exists t1; !$1146 create table t2 select auto+1 from t1; drop table if exists t1,t2; !$1167 create table t1 (b char(0) not null, index(b)); -!$1164 create table t1 (a int not null auto_increment,primary key (a)) type=heap; +create table t1 (a int not null auto_increment,primary key (a)) type=heap; !$1163 create table t1 (a int not null,b text) type=heap; !$1171 create table t1 (a int ,primary key(a)) type=heap; drop table if exists t1; -!$1164 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap; +!$1075 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap; !$1171 create table t1 (ordid int(8), primary key (ordid)); -- error 1044,1 @@ -91,6 +94,25 @@ describe t2; drop table t1,t2; # +# Test of CREATE ... SELECT with duplicate fields +# + +create table t1 (a tinyint); +create table t2 (a int) select * from t1; +describe t1; +describe t2; +drop table if exists t2; +--error 1060 +create table t2 (a int, a float) select * from t1; +drop table if exists t2; +--error 1060 +create table t2 (a int) select a as b, a+1 as b from t1; +drop table if exists t2; +--error 1060 +create table t2 (b int) select a as b, a+1 as b from t1; +drop table if exists t1,t2; + +# # Test of primary key with 32 index # @@ -102,3 +124,46 @@ drop table t1; create table t1 select if('2002'='2002','Y','N'); select * from t1; drop table if exists t1; +create table t1 (a int, key(a)); +create table t2 (b int, foreign key(b) references t1(a), key(b)); +drop table if exists t1,t2; + +# +# Test for CREATE TABLE .. LIKE .. +# + +create table t1(id int not null, name char(20)); +insert into t1 values(10,'mysql'),(20,'monty- the creator'); +create table t2(id int not null); +insert into t2 values(10),(20); +create table t3 like t1; +show create table t3; +select * from t3; +create table if not exists t3 like t1; +select @@warning_count; +create temporary table t3 like t2; +show create table t3; +select * from t3; +drop table t3; +show create table t3; +select * from t3; +drop table t2, t3; +drop database if exists test_$1; +create database test_$1; +create table test_$1.t3 like t1; +create temporary table t3 like test_$1.t3; +show create table t3; +create table t2 like t3; +show create table t2; +select * from t2; +create table t3 like t1; +!$1050 create table t3 like test_$1.t3; +--error 1044,1 +create table non_existing_database.t1 like t1; +!$1051 create table t3 like non_existing_table; +!$1050 create temporary table t3 like t1; +!$1103 create table t3 like `a/a`; +drop table t1, t2, t3; +drop table t3; +drop database test_$1; + diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test new file mode 100644 index 00000000000..c2ebf39170e --- /dev/null +++ b/mysql-test/t/ctype_collate.test @@ -0,0 +1,161 @@ +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings + +CREATE TABLE t1 ( + latin1_f CHAR(32) CHARACTER SET latin1 NOT NULL +); + +--error 1251 +CREATE TABLE t2 ( + latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r NOT NULL +); + + +INSERT INTO t1 (latin1_f) VALUES (_latin1'A'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'a'); + +INSERT INTO t1 (latin1_f) VALUES (_latin1'AD'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ad'); + +INSERT INTO t1 (latin1_f) VALUES (_latin1'AE'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ae'); + +INSERT INTO t1 (latin1_f) VALUES (_latin1'AF'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'af'); + +INSERT INTO t1 (latin1_f) VALUES (_latin1'Ä'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ä'); + +INSERT INTO t1 (latin1_f) VALUES (_latin1'Å'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'å'); + +INSERT INTO t1 (latin1_f) VALUES (_latin1'B'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'b'); + +INSERT INTO t1 (latin1_f) VALUES (_latin1'U'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'u'); + +INSERT INTO t1 (latin1_f) VALUES (_latin1'UE'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ue'); + +INSERT INTO t1 (latin1_f) VALUES (_latin1'Ü'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ü'); + +INSERT INTO t1 (latin1_f) VALUES (_latin1'SS'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ss'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ß'); + +INSERT INTO t1 (latin1_f) VALUES (_latin1'Y'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'y'); + +INSERT INTO t1 (latin1_f) VALUES (_latin1'Z'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'z'); + + +-- ORDER BY + +SELECT latin1_f FROM t1 ORDER BY latin1_f; +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1; +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_de; +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_ci_as; +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_bin; +--error 1251 +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r; + +--SELECT latin1_f COLLATE koi8r FROM t1 ; + +-- AS + ORDER BY +SELECT latin1_f COLLATE latin1 AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +SELECT latin1_f COLLATE latin1_de AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +SELECT latin1_f COLLATE latin1_ci_as AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +SELECT latin1_f COLLATE latin1_bin AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +--error 1251 +SELECT latin1_f COLLATE koi8r AS latin1_f_as FROM t1 ORDER BY latin1_f_as; + + +-- GROUP BY + +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f; +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1; +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_de; +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_ci_as; +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_bin; +--error 1251 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r; + + +-- DISTINCT + +SELECT DISTINCT latin1_f FROM t1; +SELECT DISTINCT latin1_f COLLATE latin1 FROM t1; +SELECT DISTINCT latin1_f COLLATE latin1_de FROM t1; +SELECT DISTINCT latin1_f COLLATE latin1_ci_as FROM t1; +SELECT DISTINCT latin1_f COLLATE latin1_bin FROM t1; +--error 1251 +SELECT DISTINCT latin1_f COLLATE koi8r FROM t1; + + +-- Aggregates +--SELECT MAX(k COLLATE latin1_de) +--FROM t1 + + +-- WHERE +--SELECT * +--FROM t1 +--WHERE (_latin1'Mu"ller' COLLATE latin1_de) = k + +--HAVING +--SELECT * +--FROM t1 +--HAVING (_latin1'Mu"ller' COLLATE latin1_de) = k + + +# +# Check that SHOW displays COLLATE clause +# + +SHOW CREATE TABLE t1; +SHOW FIELDS FROM t1; +ALTER TABLE t1 CHANGE latin1_f +latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin; +SHOW CREATE TABLE t1; +SHOW FIELDS FROM t1; +ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin; +SHOW CREATE TABLE t1; +SHOW FIELDS FROM t1; + +SET NAMES 'latin1'; +SHOW VARIABLES LIKE 'client_collation'; +SET NAMES latin1; +SHOW VARIABLES LIKE 'client_collation'; +SHOW VARIABLES LIKE 'client_collation'; +SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +SET NAMES latin1 COLLATE latin1_bin; +SHOW VARIABLES LIKE 'client_collation'; +SET NAMES LATIN1 COLLATE Latin1_Bin; +SHOW VARIABLES LIKE 'client_collation'; +SET NAMES 'latin1' COLLATE 'latin1_bin'; +SHOW VARIABLES LIKE 'client_collation'; +SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +SET NAMES koi8r; +SHOW VARIABLES LIKE 'client_collation'; +SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +SET COLLATION koi8r_bin; +SHOW VARIABLES LIKE 'client_collation'; +SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +SET COLLATION DEFAULT; +SHOW VARIABLES LIKE 'client_collation'; +SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +SET NAMES DEFAULT; +SHOW VARIABLES LIKE 'client_collation'; +SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +--error 1251 +SET NAMES latin1 COLLATE koi8r; +--error 1115 +SET NAMES 'DEFAULT'; + + +DROP TABLE t1; diff --git a/mysql-test/t/ctype_latin1_de.test b/mysql-test/t/ctype_latin1_de.test index 4b96f5f5867..e0591913f68 100644 --- a/mysql-test/t/ctype_latin1_de.test +++ b/mysql-test/t/ctype_latin1_de.test @@ -1,7 +1,9 @@ # # Test latin_de character set # +--disable_warnings drop table if exists t1; +--enable_warnings create table t1 (a char (20) not null, b int not null auto_increment, index (a,b)); insert into t1 (a) values ('ä'),('ac'),('ae'),('ad'),('Äc'),('aeb'); insert into t1 (a) values ('üc'),('uc'),('ue'),('ud'),('Ü'),('ueb'),('uf'); diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test new file mode 100644 index 00000000000..1f9f9cf99cc --- /dev/null +++ b/mysql-test/t/ctype_many.test @@ -0,0 +1,197 @@ +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 ( + comment CHAR(32) ASCII NOT NULL, + koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL +) CHARSET=latin5; + +SHOW CREATE TABLE t1; +ALTER TABLE t1 CHANGE comment comment CHAR(32) CHARACTER SET latin2 NOT NULL; +SHOW CREATE TABLE t1; +ALTER TABLE t1 ADD latin5_f CHAR(32) NOT NULL; +SHOW CREATE TABLE t1; +ALTER TABLE t1 CHARSET=latin2; +ALTER TABLE t1 ADD latin2_f CHAR(32) NOT NULL; +SHOW CREATE TABLE t1; +ALTER TABLE t1 DROP latin2_f, DROP latin5_f; +SHOW CREATE TABLE t1; + +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('a','LAT SMALL A'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('b','LAT SMALL B'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('c','LAT SMALL C'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('d','LAT SMALL D'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('e','LAT SMALL E'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('f','LAT SMALL F'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('g','LAT SMALL G'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('h','LAT SMALL H'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('i','LAT SMALL I'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('j','LAT SMALL J'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('k','LAT SMALL K'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('l','LAT SMALL L'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('m','LAT SMALL M'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('n','LAT SMALL N'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('o','LAT SMALL O'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('p','LAT SMALL P'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('q','LAT SMALL Q'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('r','LAT SMALL R'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('s','LAT SMALL S'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('t','LAT SMALL T'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('u','LAT SMALL U'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('v','LAT SMALL V'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('w','LAT SMALL W'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('x','LAT SMALL X'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('y','LAT SMALL Y'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('z','LAT SMALL Z'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('A','LAT CAPIT A'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('B','LAT CAPIT B'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('C','LAT CAPIT C'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('D','LAT CAPIT D'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('E','LAT CAPIT E'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('F','LAT CAPIT F'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('G','LAT CAPIT G'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('H','LAT CAPIT H'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('I','LAT CAPIT I'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('J','LAT CAPIT J'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('K','LAT CAPIT K'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('L','LAT CAPIT L'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('M','LAT CAPIT M'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('N','LAT CAPIT N'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('O','LAT CAPIT O'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('P','LAT CAPIT P'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Q','LAT CAPIT Q'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('R','LAT CAPIT R'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('S','LAT CAPIT S'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('T','LAT CAPIT T'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('U','LAT CAPIT U'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('V','LAT CAPIT V'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('W','LAT CAPIT W'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('X','LAT CAPIT X'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Y','LAT CAPIT Y'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Z','LAT CAPIT Z'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Á','CYR SMALL A'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Â','CYR SMALL BE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'×','CYR SMALL VE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ç','CYR SMALL GE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ä','CYR SMALL DE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Å','CYR SMALL IE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'£','CYR SMALL IO'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ö','CYR SMALL ZHE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ú','CYR SMALL ZE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'É','CYR SMALL I'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ë','CYR SMALL KA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ì','CYR SMALL EL'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Í','CYR SMALL EM'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Î','CYR SMALL EN'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ï','CYR SMALL O'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ð','CYR SMALL PE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ò','CYR SMALL ER'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ó','CYR SMALL ES'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ô','CYR SMALL TE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Õ','CYR SMALL U'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Æ','CYR SMALL EF'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'È','CYR SMALL HA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ã','CYR SMALL TSE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Þ','CYR SMALL CHE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Û','CYR SMALL SHA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ý','CYR SMALL SCHA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ß','CYR SMALL HARD SIGN'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ù','CYR SMALL YERU'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ø','CYR SMALL SOFT SIGN'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ü','CYR SMALL E'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'À','CYR SMALL YU'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ñ','CYR SMALL YA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'á','CYR CAPIT A'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'â','CYR CAPIT BE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'÷','CYR CAPIT VE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ç','CYR CAPIT GE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ä','CYR CAPIT DE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'å','CYR CAPIT IE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'³','CYR CAPIT IO'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ö','CYR CAPIT ZHE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ú','CYR CAPIT ZE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'é','CYR CAPIT I'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ë','CYR CAPIT KA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ì','CYR CAPIT EL'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'í','CYR CAPIT EM'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'î','CYR CAPIT EN'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ï','CYR CAPIT O'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ð','CYR CAPIT PE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ò','CYR CAPIT ER'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ó','CYR CAPIT ES'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ô','CYR CAPIT TE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'õ','CYR CAPIT U'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'æ','CYR CAPIT EF'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'è','CYR CAPIT HA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ã','CYR CAPIT TSE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'þ','CYR CAPIT CHE'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'û','CYR CAPIT SHA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ý','CYR CAPIT SCHA'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ÿ','CYR CAPIT HARD SIGN'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ù','CYR CAPIT YERU'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ø','CYR CAPIT SOFT SIGN'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ü','CYR CAPIT E'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'à','CYR CAPIT YU'); +INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ñ','CYR CAPIT YA'); + +SELECT CONVERT(koi8_ru_f USING utf8),MIN(comment),COUNT(*) FROM t1 GROUP BY 1; + +ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL; +UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8); +SELECT * FROM t1; + +ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL; +UPDATE t1 SET bin_f=koi8_ru_f; +SELECT COUNT(DISTINCT bin_f),COUNT(DISTINCT koi8_ru_f),COUNT(DISTINCT utf8_f) FROM t1; + +SELECT koi8_ru_f,MIN(comment) FROM t1 GROUP BY 1; +SELECT utf8_f,MIN(comment) FROM t1 GROUP BY 1; +SELECT DISTINCT koi8_ru_f FROM t1; +SELECT DISTINCT utf8_f FROM t1; +SELECT lower(koi8_ru_f) FROM t1 ORDER BY 1 DESC; +SELECT lower(utf8_f) FROM t1 ORDER BY 1 DESC; + +SELECT t11.comment,t12.comment +FROM t1 t11,t1 t12 WHERE CONVERT(t11.koi8_ru_f USING utf8)=t12.utf8_f +ORDER BY t11.koi8_ru_f,t11.comment,t12.comment; + +SELECT t11.comment,t12.comment +FROM t1 t11,t1 t12 +WHERE t11.koi8_ru_f=CONVERT(t12.utf8_f USING koi8r) +ORDER BY t12.utf8_f,t11.comment,t12.comment; + +ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2; +ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL; + +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0391,'GREEK CAPIT ALPHA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0392,'GREEK CAPIT BETA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0393,'GREEK CAPIT GAMMA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0394,'GREEK CAPIT DELTA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0395,'GREEK CAPIT EPSILON'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B1,'GREEK SMALL ALPHA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B2,'GREEK SMALL BETA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B3,'GREEK SMALL GAMMA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B4,'GREEK SMALL DELTA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B5,'GREEK SMALL EPSILON'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0531,'ARMENIAN CAPIT AYB'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0532,'ARMENIAN CAPIT BEN'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0533,'ARMENIAN CAPIT GIM'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0534,'ARMENIAN CAPIT DA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0535,'ARMENIAN CAPIT ECH'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0536,'ARMENIAN CAPIT ZA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0561,'ARMENIAN SMALL YAB'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0562,'ARMENIAN SMALL BEN'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0563,'ARMENIAN SMALL GIM'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0564,'ARMENIAN SMALL DA'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0565,'ARMENIAN SMALL ECH'); +INSERT INTO t1 (ucs2_f,comment) VALUES (0x0566,'ARMENIAN SMALL ZA'); + +ALTER TABLE t1 ADD armscii8_f CHAR(32) CHARACTER SET armscii8 NOT NULL; +ALTER TABLE t1 ADD greek_f CHAR(32) CHARACTER SET greek NOT NULL; +UPDATE t1 SET greek_f=CONVERT(ucs2_f USING greek) WHERE comment LIKE 'GRE%'; +UPDATE t1 SET armscii8_f=CONVERT(ucs2_f USING armscii8) WHERE comment LIKE 'ARM%'; +UPDATE t1 SET utf8_f=CONVERT(ucs2_f USING utf8) WHERE utf8_f=''; +UPDATE t1 SET ucs2_f=CONVERT(utf8_f USING ucs2) WHERE ucs2_f=''; +SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f; +DROP TABLE t1; diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 67111ea1734..4cf26b330c6 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -3,7 +3,9 @@ # (Can't be tested with purify :( ) # +--disable_warnings drop table if exists t1; +--enable_warnings create table t1 (a char(10), tmsp timestamp); insert into t1 set a = 1; insert delayed into t1 set a = 2; diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 13fa617b3cf..af047db04bd 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -2,7 +2,9 @@ # Check for problems with delete # +--disable_warnings drop table if exists t1; +--enable_warnings CREATE TABLE t1 (a tinyint(3), b tinyint(5)); INSERT INTO t1 VALUES (1,1); INSERT LOW_PRIORITY INTO t1 VALUES (1,2); @@ -36,6 +38,15 @@ insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(2 delete from t1 where a=27; drop table t1; +CREATE TABLE `t` ( + `i` int(10) NOT NULL default '0', + `i2` int(10) NOT NULL default '0', + PRIMARY KEY (`i`) +) TYPE=MyISAM CHARSET=latin1; +-- error 1054 +DELETE FROM t USING t WHERE post='1'; +drop table if exists t; + # # CHAR(0) bug - not actually DELETE bug, but anyway... # @@ -54,4 +65,3 @@ delete from t1 where misc > 5 and bool is null; select * from t1 where misc > 5 and bool is null; drop table t1; - diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test new file mode 100644 index 00000000000..8b8d9e4d1a2 --- /dev/null +++ b/mysql-test/t/derived.test @@ -0,0 +1,66 @@ +# Initialize +--disable_warnings +drop table if exists t1,t2,t3; +--enable_warnings + +select * from (select 2 from DUAL) b; +-- error 1054 +SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b; +-- error 1054 +SELECT 1 as a FROM (SELECT a UNION SELECT 1) b; +CREATE TABLE t1 (a int not null, b char (10) not null); +insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); +CREATE TABLE t2 (a int not null, b char (10) not null); +insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e'); +select t1.a,t3.y from t1,(select a as y from t2 where b='c') as t3 where t1.a = t3.y; +select t1.a,t3.a from t1,(select * from t2 where b='c') as t3 where t1.a = t3.a; +CREATE TABLE t3 (a int not null, b char (10) not null); +insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c'); +select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y; +--error 1054 +SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b; +--error 1052 +SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1; +SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2; +SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1; +--error 1054 +SELECT 1 FROM (SELECT 1) a WHERE a=2; +--error 1054 +SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a; +select * from t1 as x1, (select * from t1) as x2; +explain select * from t1 as x1, (select * from t1) as x2; +drop table if exists t2,t3; +select * from (select 1) as a; +select a from (select 1 as a) as b; +select 1 from (select 1) as a; +select * from (select * from t1 union select * from t1) a; +select * from (select * from t1 union all select * from t1) a; +explain select * from (select * from t1 union select * from t1) a; +explain select * from (select * from t1 union all select * from t1) a; +CREATE TABLE t2 (a int not null); +insert into t2 values(1); +select * from (select * from t1 where t1.a=(select a from t2 where t2.a=t1.a)) a; +select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a; +drop table t1, t2; +create table t1(a int not null, t char(8), index(a)); +disable_query_log; +let $1 = 10000; +while ($1) + { + eval insert into t1 values ($1,'$1'); + dec $1; + } +enable_query_log; +SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20; +explain select count(*) from t1 as tt1, (select * from t1) as tt2; +drop table t1; +SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b; +select * from (select 1 as a) b left join (select 2 as a) c using(a); +--error 1054 +SELECT * FROM (SELECT 1 UNION SELECT a) b; +--error 1054 +SELECT 1 as a FROM (SELECT a UNION SELECT 1) b; +--error 1054 +SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b; +--error 1054 +select 1 from (select 2) a order by 0; diff --git a/mysql-test/t/dirty_close.test b/mysql-test/t/dirty_close.test index 3ed22f26d5b..f965df8cfea 100644 --- a/mysql-test/t/dirty_close.test +++ b/mysql-test/t/dirty_close.test @@ -3,7 +3,11 @@ connect (con2,localhost,root,,); connection con1; dirty_close con1; connection con2; + +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (n int); insert into t1 values (1),(2),(3); select * from t1; diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index 7f75b6b1687..859c4042b1d 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -3,7 +3,9 @@ # Bug with group by and not used fields # +--disable_warnings drop table if exists t1,t2,t3; +--enable_warnings CREATE TABLE t1 (id int,facility char(20)); CREATE TABLE t2 (facility char(20)); @@ -198,7 +200,6 @@ drop table t1,t2,t3; # This also test the case when one doesn't use all fields in GROUP BY. # -drop table if exists t1; create table t1 (a int not null, b int not null, t time); insert into t1 values (1,1,"00:06:15"),(1,2,"00:06:15"),(1,2,"00:30:15"),(1,3,"00:06:15"),(1,3,"00:30:15"); select a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b; @@ -261,7 +262,7 @@ INSERT INTO t1 VALUES (128,0,33,33,8,':D','',996121863,1,0,2,996122850,2,0,0); CREATE TABLE t2 (userid int(10) unsigned NOT NULL auto_increment, usergroupid smallint(5) unsigned NOT NULL default '0', username varchar(50) NOT NULL default '', password varchar(50) NOT NULL default '', email varchar(50) NOT NULL default '', styleid smallint(5) unsigned NOT NULL default '0', parentemail varchar(50) NOT NULL default '', coppauser smallint(6) NOT NULL default '0', homepage varchar(100) NOT NULL default '', icq varchar(20) NOT NULL default '', aim varchar(20) NOT NULL default '', yahoo varchar(20) NOT NULL default '', signature mediumtext NOT NULL, adminemail smallint(6) NOT NULL default '0', showemail smallint(6) NOT NULL default '0', invisible smallint(6) NOT NULL default '0', usertitle varchar(250) NOT NULL default '', customtitle smallint(6) NOT NULL default '0', joindate int(10) unsigned NOT NULL default '0', cookieuser smallint(6) NOT NULL default '0', daysprune smallint(6) NOT NULL default '0', lastvisit int(10) unsigned NOT NULL default '0', lastactivity int(10) unsigned NOT NULL default '0', lastpost int(10) unsigned NOT NULL default '0', posts smallint(5) unsigned NOT NULL default '0', timezoneoffset varchar(4) NOT NULL default '', emailnotification smallint(6) NOT NULL default '0', buddylist mediumtext NOT NULL, ignorelist mediumtext NOT NULL, pmfolders mediumtext NOT NULL, receivepm smallint(6) NOT NULL default '0', emailonpm smallint(6) NOT NULL default '0', pmpopup smallint(6) NOT NULL default '0', avatarid smallint(6) NOT NULL default '0', avatarrevision int(6) unsigned NOT NULL default '0', options smallint(6) NOT NULL default '15', birthday date NOT NULL default '0000-00-00', maxposts smallint(6) NOT NULL default '-1', startofweek smallint(6) NOT NULL default '1', ipaddress varchar(20) NOT NULL default '', referrerid int(10) unsigned NOT NULL default '0', nosessionhash smallint(6) NOT NULL default '0', autorefresh smallint(6) NOT NULL default '-1', messagepopup tinyint(2) NOT NULL default '0', inforum smallint(5) unsigned NOT NULL default '0', ratenum smallint(5) unsigned NOT NULL default '0', ratetotal smallint(5) unsigned NOT NULL default '0', allowrate smallint(5) unsigned NOT NULL default '1', PRIMARY KEY (userid), KEY usergroupid (usergroupid), KEY username (username), KEY inforum (inforum)) TYPE=MyISAM; INSERT INTO t2 VALUES (33,6,'Kevin','0','kevin@stileproject.com',1,'',0,'http://www.stileproject.com','','','','',1,1,0,'Administrator',0,996120694,1,-1,1030996168,1031027028,1030599436,36,'-6',0,'','','',1,0,1,0,0,15,'0000-00-00',-1,1,'64.0.0.0',0,1,-1,0,0,4,19,1); SELECT DISTINCT t1.*, t2.* FROM t1 LEFT JOIN t2 ON (t2.userid = t1.touserid); -DROP TABLE IF EXISTS t1,t2; +DROP TABLE t1,t2; # # test with const_item in ORDER BY @@ -272,5 +273,4 @@ INSERT t1 VALUES (1,2,3); CREATE TABLE t2 (a int primary key, b int, c int); INSERT t2 VALUES (3,4,5); SELECT DISTINCT t1.a, t2.b FROM t1, t2 WHERE t1.a=1 ORDER BY t2.c; -DROP TABLE IF EXISTS t1,t2; - +DROP TABLE t1,t2; diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index c92f2b1f3b9..307dd45654d 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -1,5 +1,8 @@ +# Initialise +--disable_warnings drop table if exists t1; -drop table if exists t1; +--enable_warnings + --error 1051; drop table t1; create table t1(n int); diff --git a/mysql-test/t/empty_table.test b/mysql-test/t/empty_table.test index 9ea79ee157f..db0a8e6a247 100644 --- a/mysql-test/t/empty_table.test +++ b/mysql-test/t/empty_table.test @@ -2,7 +2,10 @@ # Some special cases with empty tables # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr)); select count(*) from t1; select * from t1; diff --git a/mysql-test/t/err000001.test b/mysql-test/t/err000001.test index d9898054a83..b558c90b0c6 100644 --- a/mysql-test/t/err000001.test +++ b/mysql-test/t/err000001.test @@ -2,18 +2,30 @@ # Test some error conditions # +--disable_warnings drop table if exists t1; -!$1146 insert into t1 values(1); -!$1146 delete from t1; -!$1146 update t1 set a=1; +--enable_warnings +--error 1146 +insert into t1 values(1); +--error 1146 +delete from t1; +--error 1146 +update t1 set a=1; create table t1 (a int); -!$1054 select count(test.t1.b) from t1; -!$1109 select count(not_existing_database.t1) from t1; -!$1109 select count(not_existing_database.t1.a) from t1; +--error 1054 +select count(test.t1.b) from t1; +--error 1109 +select count(not_existing_database.t1) from t1; +--error 1109 +select count(not_existing_database.t1.a) from t1; --error 1044,1146 select count(not_existing_database.t1.a) from not_existing_database.t1; -!$1054 select 1 from t1 order by 2; -!$1054 select 1 from t1 group by 2; -!$1054 select 1 from t1 order by t1.b; -!$1054 select count(*),b from t1; +--error 1054 +select 1 from t1 order by 2; +--error 1054 +select 1 from t1 group by 2; +--error 1054 +select 1 from t1 order by t1.b; +--error 1054 +select count(*),b from t1; drop table t1; diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index 045598e97df..ff1803368b9 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -1,7 +1,9 @@ # # Test of different EXPLAIN's +--disable_warnings drop table if exists t1; +--enable_warnings create table t1 (id int not null, str char(10), unique(str)); explain select * from t1; insert into t1 values (1, null),(2, null),(3, "foo"),(4, "bar"); diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index 540aa4235cc..44a821b63c2 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -9,9 +9,13 @@ connect (con1,localhost,root,,); connect (con2,localhost,root,,); connection con1; -drop table if exists t1; + +--disable_warnings +drop table if exists t1,t2; +drop database if exists mysqltest; +--enable_warnings + create temporary table t1(n int not null primary key); -drop table if exists t2; create table t2(n int); insert into t2 values(3); let $1=100; @@ -44,7 +48,6 @@ reap; #test if drop database will wait until we release the global read lock connection con1; -drop database if exists mysqltest; create database mysqltest; create table mysqltest.t1(n int); insert into mysqltest.t1 values (23); diff --git a/mysql-test/t/foreign_key.test b/mysql-test/t/foreign_key.test index 1afcb546f6a..8c35fd65f74 100644 --- a/mysql-test/t/foreign_key.test +++ b/mysql-test/t/foreign_key.test @@ -2,7 +2,10 @@ # Test syntax of foreign keys # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 ( a int not null references t2, b int not null references t2 (c), diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 5a64f2614aa..214236268fa 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -2,7 +2,9 @@ # Test of fulltext index # +--disable_warnings drop table if exists t1,t2,t3; +--enable_warnings CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)); INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'), @@ -16,6 +18,7 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'), select * from t1 where MATCH(a,b) AGAINST ("collections"); select * from t1 where MATCH(a,b) AGAINST ("indexes"); select * from t1 where MATCH(a,b) AGAINST ("indexes collections"); +select * from t1 where MATCH(a,b) AGAINST ("only"); # UNION of fulltext's select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes"); @@ -166,7 +169,6 @@ drop table t1; # ERROR 1030: Got error 127 from table handler # -drop table if exists t1; create table t1 (a text, fulltext key (a)); insert into t1 values ('aaaa'); repair table t1; diff --git a/mysql-test/t/fulltext2.test b/mysql-test/t/fulltext2.test new file mode 100644 index 00000000000..2c0d352a870 --- /dev/null +++ b/mysql-test/t/fulltext2.test @@ -0,0 +1,96 @@ +# +# test of new fulltext search features +# + +# +# two-level tree +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 ( + i int(10) unsigned not null auto_increment primary key, + a varchar(255) not null, + FULLTEXT KEY (a) +) TYPE=MyISAM; + +# two-level entry, second-level tree with depth 2 +let $1=260; +while ($1) +{ + eval insert t1 (a) values ('aaaxxx'); + dec $1; +} + +# two-level entry, second-level tree has only one page +let $1=255; +while ($1) +{ + eval insert t1 (a) values ('aaazzz'); + dec $1; +} + +# one-level entry (entries) +let $1=250; +while ($1) +{ + eval insert t1 (a) values ('aaayyy'); + dec $1; +} + +# converting to two-level +repair table t1 quick; + +select count(*) from t1 where match a against ('aaaxxx'); +select count(*) from t1 where match a against ('aaayyy'); +select count(*) from t1 where match a against ('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz'); +select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode); + +select count(*) from t1 where match a against ('aaax*' in boolean mode); +select count(*) from t1 where match a against ('aaay*' in boolean mode); +select count(*) from t1 where match a against ('aaa*' in boolean mode); + +# mi_write: + +insert t1 (a) values ('aaaxxx'),('aaayyy'); +# call to enlarge_root() below +insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx'); +select count(*) from t1 where match a against ('aaayyy'); +select count(*) from t1 where match a against ('aaazzz'); + +# mi_delete +insert t1 (a) values ('aaaxxx 000000'); +select count(*) from t1 where match a against ('000000'); +delete from t1 where match a against ('000000'); +select count(*) from t1 where match a against ('000000'); +select count(*) from t1 where match a against ('aaaxxx'); +delete from t1 where match a against ('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +# double-check without index +select count(*) from t1 where a = 'aaaxxx'; +select count(*) from t1 where a = 'aaayyy'; +select count(*) from t1 where a = 'aaazzz'; + +# update +insert t1 (a) values ('aaaxxx 000000'); +select count(*) from t1 where match a against ('000000'); +update t1 set a='aaazzz' where match a against ('000000'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +update t1 set a='aaazzz' where a = 'aaaxxx'; +update t1 set a='aaaxxx' where a = 'aaayyy'; +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +select count(*) from t1 where match a against ('aaazzz' in boolean mode); + +DROP TABLE IF EXISTS t1; + diff --git a/mysql-test/t/fulltext_cache.test b/mysql-test/t/fulltext_cache.test index 0b15e57a97b..15f32fdb5a0 100644 --- a/mysql-test/t/fulltext_cache.test +++ b/mysql-test/t/fulltext_cache.test @@ -2,7 +2,10 @@ # Bugreport due to Roy Nasser <roy@vem.ca> # +--disable_warnings drop table if exists t1, t2; +--enable_warnings + CREATE TABLE t1 ( id int(10) unsigned NOT NULL auto_increment, q varchar(255) default NULL, diff --git a/mysql-test/t/fulltext_distinct.test b/mysql-test/t/fulltext_distinct.test index 86e2f7ca1b4..2ccfb94c819 100644 --- a/mysql-test/t/fulltext_distinct.test +++ b/mysql-test/t/fulltext_distinct.test @@ -3,7 +3,10 @@ # bug reported by Tibor Simko <tibor.simko@cern.ch> # +--disable_warnings DROP TABLE IF EXISTS t1, t2; +--enable_warnings + CREATE TABLE t1 ( id mediumint unsigned NOT NULL auto_increment, tag char(6) NOT NULL default '', diff --git a/mysql-test/t/fulltext_left_join.test b/mysql-test/t/fulltext_left_join.test index bcf7cbcc505..4fce8ee287e 100644 --- a/mysql-test/t/fulltext_left_join.test +++ b/mysql-test/t/fulltext_left_join.test @@ -2,7 +2,10 @@ # Test for bug from Jean-Cédric COSTA <jean-cedric.costa@ensmp.fr> # +--disable_warnings drop table if exists t1, t2; +--enable_warnings + CREATE TABLE t1 ( id VARCHAR(255) NOT NULL PRIMARY KEY, sujet VARCHAR(255), diff --git a/mysql-test/t/fulltext_multi.test b/mysql-test/t/fulltext_multi.test index 233c243146e..c312a5938b2 100644 --- a/mysql-test/t/fulltext_multi.test +++ b/mysql-test/t/fulltext_multi.test @@ -1,6 +1,8 @@ # several FULLTEXT indexes in one table test -use test; +--disable_warnings DROP TABLE IF EXISTS t1; +--enable_warnings + CREATE TABLE t1 ( a int(11) NOT NULL auto_increment, b text, diff --git a/mysql-test/t/fulltext_order_by.test b/mysql-test/t/fulltext_order_by.test index 3b60ee77db2..f8afe49d95d 100644 --- a/mysql-test/t/fulltext_order_by.test +++ b/mysql-test/t/fulltext_order_by.test @@ -1,5 +1,7 @@ -use test; +--disable_warnings DROP TABLE IF EXISTS t1; +--enable_warnings + CREATE TABLE t1 ( a INT AUTO_INCREMENT PRIMARY KEY, message CHAR(20), diff --git a/mysql-test/t/fulltext_update.test b/mysql-test/t/fulltext_update.test index 9e2ce3ccba5..a1d133ba3fe 100644 --- a/mysql-test/t/fulltext_update.test +++ b/mysql-test/t/fulltext_update.test @@ -2,7 +2,9 @@ # Test for bug by voi@ims.at # +--disable_warnings drop table if exists test; +--enable_warnings CREATE TABLE test ( gnr INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, url VARCHAR(80) DEFAULT '' NOT NULL, diff --git a/mysql-test/t/func_concat.test b/mysql-test/t/func_concat.test index d6da1d6a603..147367a6d27 100644 --- a/mysql-test/t/func_concat.test +++ b/mysql-test/t/func_concat.test @@ -2,7 +2,10 @@ # Test of problem with CONCAT_WS() and long separators. # +--disable_warnings DROP TABLE IF EXISTS t1; +--enable_warnings + CREATE TABLE t1 ( number INT NOT NULL, alpha CHAR(6) NOT NULL ); INSERT INTO t1 VALUES (1413006,'idlfmv'), (1413065,'smpsfz'),(1413127,'sljrhx'),(1413304,'qerfnd'); diff --git a/mysql-test/t/func_crypt.test b/mysql-test/t/func_crypt.test index f403d96e885..c72356bda1a 100644 --- a/mysql-test/t/func_crypt.test +++ b/mysql-test/t/func_crypt.test @@ -2,5 +2,9 @@ select length(encrypt('foo', 'ff')) <> 0; --replace_result $1$aa$4OSUA5cjdx0RUQ08opV27/ aaqPiZY5xR5l. -select old_password('test'), password('test'); -select length(encrypt('test')), encrypt('test','aa'); + +# Test new and old password handling functions +select password("a",""), password("a",NULL), password("","a"), password(NULL,"a"); +select password("aaaaaaaaaaaaaaaa","a"), password("a","aaaaaaaaaaaaaaaa"); +select old_password('test'), length(password("1")), length(encrypt('test')), encrypt('test','aa'); +select old_password(""), old_password(NULL), password(""), password(NULL); diff --git a/mysql-test/t/func_date_add.test b/mysql-test/t/func_date_add.test index c0250c6ece4..35acfe84bee 100644 --- a/mysql-test/t/func_date_add.test +++ b/mysql-test/t/func_date_add.test @@ -2,7 +2,10 @@ # Test of DATE_ADD # +--disable_warnings drop table if exists t1; +--enable_warnings + CREATE TABLE t1 ( visitor_id int(10) unsigned DEFAULT '0' NOT NULL, group_id int(10) unsigned DEFAULT '0' NOT NULL, diff --git a/mysql-test/t/func_encrypt.test b/mysql-test/t/func_encrypt.test index 3b6acc54ec9..fbb71f850e2 100644 --- a/mysql-test/t/func_encrypt.test +++ b/mysql-test/t/func_encrypt.test @@ -1,6 +1,9 @@ -- source include/have_openssl.inc +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (x blob); insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','The quick red fox jumped over the lazy brown dog')); insert into t1 values (des_encrypt('a','The quick red fox jumped over the lazy brown dog')); diff --git a/mysql-test/t/func_equal.test b/mysql-test/t/func_equal.test index 0d7a4ed9778..cbf589ffcc2 100644 --- a/mysql-test/t/func_equal.test +++ b/mysql-test/t/func_equal.test @@ -1,3 +1,8 @@ +# Initialise +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + # # Testing of the <=> operator # @@ -15,7 +20,6 @@ select "A"<=>"B","A"<=>NULL,NULL<=>"A"; # Test with tables # -drop table if exists t1,t2; create table t1 (id int, value int); create table t2 (id int, value int); diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 1915c2172ad..c78509d3869 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -2,7 +2,10 @@ # simple test of all group functions # +--disable_warnings drop table if exists t1,t2; +--enable_warnings + create table t1 (grp int, a bigint unsigned, c char(10) not null); insert into t1 values (1,1,"a"); insert into t1 values (2,2,"b"); @@ -21,9 +24,9 @@ select count(distinct a),count(distinct grp) from t1; insert into t1 values (null,null,''); select count(distinct a),count(distinct grp) from t1; -select sum(all a),count(all a),avg(all a),std(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1; -select grp, sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp; -select grp, sum(a)+count(a)+avg(a)+std(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp; +select sum(all a),count(all a),avg(all a),std(all a),variance(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1; +select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp; +select grp, sum(a)+count(a)+avg(a)+std(a)+variance(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp; create table t2 (grp int, a bigint unsigned, c char(10)); insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp; @@ -40,8 +43,8 @@ CREATE TABLE t1 (id int(11),value1 float(10,2)); INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00); CREATE TABLE t2 (id int(11),name char(20)); INSERT INTO t2 VALUES (1,'Set One'),(2,'Set Two'); -select id, avg(value1), std(value1) from t1 group by id; -select name, avg(value1), std(value1) from t1, t2 where t1.id = t2.id group by t1.id; +select id, avg(value1), std(value1), variance(value1) from t1 group by id; +select name, avg(value1), std(value1), variance(value1) from t1, t2 where t1.id = t2.id group by t1.id; drop table t1,t2; # @@ -118,11 +121,211 @@ explain select min(a2) from t1; explain select max(t1.a1), max(t2.a2) from t1, t2; insert into t2 values('AAA', 10, 0.5); +insert into t2 values('BBB', 20, 1.0); +select t1.a1, t1.a2, t2.a1, t2.a2 from t1,t2; + select max(t1.a1), max(t2.a1) from t1, t2 where t2.a2=9; select max(t2.a1), max(t1.a1) from t1, t2 where t2.a2=9; select t1.a1, t1.a2, t2.a1, t2.a2 from t1 left outer join t2 on t1.a1=10; select max(t1.a2) from t1 left outer join t2 on t1.a1=10; -select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=20; -select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=10; +select max(t2.a1) from t2 left outer join t1 on t2.a2=10 where t2.a2=20; +select max(t2.a1) from t2 left outer join t1 on t2.a2=10 where t2.a2=10; select max(t2.a1) from t1 left outer join t2 on t1.a2=t2.a1 and 1=0 where t2.a1='AAA'; +select max(t1.a2),max(t2.a1) from t1 left outer join t2 on t1.a1=10; drop table t1,t2; + + +# +# Tests to check MIN/MAX query optimization +# + +# Create database schema +create table t1( + a1 char(3) primary key, + a2 smallint, + a3 char(3), + a4 real, + a5 date, + key k1(a2,a3), + key k2(a4 desc,a1), + key k3(a5,a1) +); +create table t2( + a1 char(3) primary key, + a2 char(17), + a3 char(2), + a4 char(3), + key k1(a3, a2), + key k2(a4) +); + +# Populate table t1 +insert into t1 values('AME',0,'SEA',0.100,date'1942-02-19'); +insert into t1 values('HBR',1,'SEA',0.085,date'1948-03-05'); +insert into t1 values('BOT',2,'SEA',0.085,date'1951-11-29'); +insert into t1 values('BMC',3,'SEA',0.085,date'1958-09-08'); +insert into t1 values('TWU',0,'LAX',0.080,date'1969-10-05'); +insert into t1 values('BDL',0,'DEN',0.080,date'1960-11-27'); +insert into t1 values('DTX',1,'NYC',0.080,date'1961-05-04'); +insert into t1 values('PLS',1,'WDC',0.075,date'1949-01-02'); +insert into t1 values('ZAJ',2,'CHI',0.075,date'1960-06-15'); +insert into t1 values('VVV',2,'MIN',0.075,date'1959-06-28'); +insert into t1 values('GTM',3,'DAL',0.070,date'1977-09-23'); +insert into t1 values('SSJ',null,'CHI',null,date'1974-03-19'); +insert into t1 values('KKK',3,'ATL',null,null); +insert into t1 values('XXX',null,'MIN',null,null); + +# Populate table t2 +insert into t2 values('TKF','Seattle','WA','AME'); +insert into t2 values('LCC','Los Angeles','CA','TWU'); +insert into t2 values('DEN','Denver','CO','BDL'); +insert into t2 values('SDC','San Diego','CA','TWU'); +insert into t2 values('NOL','New Orleans','LA','GTM'); +insert into t2 values('LAK','Los Angeles','CA','TWU'); + +# Show the table contents +select * from t1; +select * from t2; + +# Queries with min/max functions +# which regular min/max optimization are applied to + +explain +select min(a1) from t1; +select min(a1) from t1; +explain +select max(a4) from t1; +select max(a4) from t1; +explain +select min(a5), max(a5) from t1; +select min(a5), max(a5) from t1; +explain +select min(a3) from t1 where a2 = 2; +select min(a3) from t1 where a2 = 2; +explain +select min(a1), max(a1) from t1 where a4 = 0.080; +select min(a1), max(a1) from t1 where a4 = 0.080; + +explain +select min(t1.a5), max(t2.a3) from t1, t2; +select min(t1.a5), max(t2.a3) from t1, t2; +explain +select min(t1.a3), max(t2.a2) from t1, t2 where t1.a2 = 0 and t2.a3 = 'CA'; +select min(t1.a3), max(t2.a2) from t1, t2 where t1.a2 = 0 and t2.a3 = 'CA'; + +# Queries with min/max functions +# which extended min/max optimization are applied to + +explain +select min(a1) from t1 where a1 > 'KKK'; +select min(a1) from t1 where a1 > 'KKK'; +explain +select min(a1) from t1 where a1 >= 'KKK'; +select min(a1) from t1 where a1 >= 'KKK'; +explain +select max(a3) from t1 where a2 = 2 and a3 < 'SEA'; +select max(a3) from t1 where a2 = 2 and a3 < 'SEA'; +explain +select max(a5) from t1 where a5 < date'1970-01-01'; +select max(a5) from t1 where a5 < date'1970-01-01'; +explain +select max(a3) from t1 where a2 is null; +select max(a3) from t1 where a2 is null; +explain +select max(a3) from t1 where a2 = 0 and a3 between 'K' and 'Q'; +select max(a3) from t1 where a2 = 0 and a3 between 'K' and 'Q'; +explain +select min(a1), max(a1) from t1 where a1 between 'A' and 'P'; +select min(a1), max(a1) from t1 where a1 between 'A' and 'P'; +explain +select max(a3) from t1 where a3 < 'SEA' and a2 = 2 and a3 <= 'MIN'; +select max(a3) from t1 where a3 < 'SEA' and a2 = 2 and a3 <= 'MIN'; +explain +select max(a3) from t1 where a3 = 'MIN' and a2 = 2; +select max(a3) from t1 where a3 = 'MIN' and a2 = 2; +explain +select max(a3) from t1 where a3 = 'DEN' and a2 = 2; +select max(a3) from t1 where a3 = 'DEN' and a2 = 2; + +explain +select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 = 'CA'; +select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 = 'CA'; + +explain +select max(a3) from t1 where a2 is null and a2 = 2; +select max(a3) from t1 where a2 is null and a2 = 2; + +explain +select max(a2) from t1 where a2 >= 1; +select max(a2) from t1 where a2 >= 1; +explain +select min(a3) from t1 where a2 = 2 and a3 < 'SEA'; +select min(a3) from t1 where a2 = 2 and a3 < 'SEA'; + +explain +select min(a3) from t1 where a2 = 4; +select min(a3) from t1 where a2 = 4; +explain +select min(a3) from t1 where a2 = 2 and a3 > 'SEA'; +select min(a3) from t1 where a2 = 2 and a3 > 'SEA'; +explain +select (min(a4)+max(a4))/2 from t1; +select (min(a4)+max(a4))/2 from t1; +explain +select min(a3) from t1 where 2 = a2; +select min(a3) from t1 where 2 = a2; +explain +select max(a3) from t1 where a2 = 2 and 'SEA' > a3; +select max(a3) from t1 where a2 = 2 and 'SEA' > a3; +explain +select max(a3) from t1 where a2 = 2 and 'SEA' < a3; +select max(a3) from t1 where a2 = 2 and 'SEA' < a3; +explain +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI'; +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI'; +explain +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 < 'SEA'; +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 < 'SEA'; +explain +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 = 'MIN'; +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 = 'MIN'; +explain +select min(a3) from t1 where a2 = 2 and a3 >= 'SEA' and a3 = 'MIN'; +select min(a3) from t1 where a2 = 2 and a3 >= 'SEA' and a3 = 'MIN'; + +explain +select min(t1.a1), min(t2.a4) from t1,t2 where t1.a1 < 'KKK' and t2.a4 < 'KKK'; +select min(t1.a1), min(t2.a4) from t1,t2 where t1.a1 < 'KKK' and t2.a4 < 'KKK'; + +# Queries to which max/min optimization is not applied + +explain +select min(a1) from t1 where a1 > 'KKK' or a1 < 'XXX'; +explain +select min(a1) from t1 where a1 != 'KKK'; +explain +select max(a3) from t1 where a2 < 2 and a3 < 'SEA'; +explain +select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 > 'CA'; + +explain +select min(a4 - 0.01) from t1; +explain +select max(a4 + 0.01) from t1; +explain +select min(a3) from t1 where (a2 +1 ) is null; +explain +select min(a3) from t1 where (a2 + 1) = 2; +explain +select min(a3) from t1 where 2 = (a2 + 1); +explain +select min(a2) from t1 where a2 < 2 * a2 - 8; +explain +select min(a1) from t1 where a1 between a3 and 'KKK'; +explain +select min(a4) from t1 where (a4 + 0.01) between 0.07 and 0.08; +explain +select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME'; + +# Clean up +drop table if exists t1, t2;
\ No newline at end of file diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index 85553d1a2fd..21e5836c781 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -1,7 +1,9 @@ # # Init section # +--disable_warnings drop table if exists t1; +--enable_warnings # # Simple IF tests diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index e5d42ec25c4..723f1707a42 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -1,8 +1,44 @@ +# Initialise +--disable_warnings +drop table if exists t1; +--enable_warnings # # test of IN (NULL) # -drop table if exists t1; +select 1 in (1,2,3); +select 10 in (1,2,3); +select NULL in (1,2,3); +select 1 in (1,NULL,3); +select 3 in (1,NULL,3); +select 10 in (1,NULL,3); +select 1.5 in (1.5,2.5,3.5); +select 10.5 in (1.5,2.5,3.5); +select NULL in (1.5,2.5,3.5); +select 1.5 in (1.5,NULL,3.5); +select 3.5 in (1.5,NULL,3.5); +select 10.5 in (1.5,NULL,3.5); + +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +select 3 in (a,b,c) from t1; +select 10 in (a,b,c) from t1; +select NULL in (a,b,c) from t1; +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +select 3.5 in (a,b,c) from t1; +select 10.5 in (a,b,c) from t1; +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +select 'EFD' in (a,b,c) from t1; +select 'XSFGGHF' in (a,b,c) from t1; +drop table t1; + CREATE TABLE t1 (field char(1)); INSERT INTO t1 VALUES ('A'),(NULL); SELECT * from t1 WHERE field IN (NULL); diff --git a/mysql-test/t/func_isnull.test b/mysql-test/t/func_isnull.test index bd3bcd8d04c..506efada0eb 100644 --- a/mysql-test/t/func_isnull.test +++ b/mysql-test/t/func_isnull.test @@ -2,7 +2,10 @@ # test of ISNULL() # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (id int auto_increment primary key not null, mydate date not null); insert into t1 values (0,"2002-05-01"),(0,"2002-05-01"),(0,"2002-05-01"); flush tables; diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test index a5d1193fd74..90b376e34df 100644 --- a/mysql-test/t/func_like.test +++ b/mysql-test/t/func_like.test @@ -2,7 +2,10 @@ # Test of like # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (a varchar(10), key(a)); insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); explain select * from t1 where a like 'abc%'; diff --git a/mysql-test/t/func_regexp.test b/mysql-test/t/func_regexp.test index 7fbe4000cfc..6e5d601844e 100644 --- a/mysql-test/t/func_regexp.test +++ b/mysql-test/t/func_regexp.test @@ -2,7 +2,10 @@ # Some regexp tests # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (s1 char(64),s2 char(64)); insert into t1 values('aaa','aaa'); diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test index cb1aa543d43..60d67a77562 100644 --- a/mysql-test/t/func_set.test +++ b/mysql-test/t/func_set.test @@ -15,3 +15,21 @@ select export_set(9,"Y","N","-",5),export_set(9,"Y","N"),export_set(9,"Y","N","" select elt(2,1),field(NULL,"a","b","c"); select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c"); select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc"); + +# +# test for a bug with elt() +# + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +create table t1 (id int(10) not null unique); +create table t2 (id int(10) not null primary key, +val int(10) not null); +insert into t1 values (1),(2),(4); +insert into t2 values (1,1),(2,1),(3,1),(4,2); + +select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id; +select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id; +drop table t1,t2; diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index f95cd901dfb..a87707746ba 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -4,7 +4,9 @@ # ----------- # Testing string functions +--disable_warnings drop table if exists t1; +--enable_warnings select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo'; select 'hello' 'monty'; @@ -36,6 +38,11 @@ select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es'); select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c'); select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ; select soundex(''),soundex('he'),soundex('hello all folks'); +select 'mood' sounds like 'mud'; +select 'Glazgo' sounds like 'Liverpool'; +select null sounds like 'null'; +select 'null' sounds like null; +select null sounds like null; select md5('hello'); select sha('abc'); select sha1('abc'); @@ -111,9 +118,9 @@ CREATE TABLE t1 ( ) TYPE=MyISAM; INSERT INTO t1 VALUES (1,'Link',1,1,1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','2001-02-28 08:40:16',20010228084016,0,4); -SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter), '"') FROM t1; +SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"') FROM t1; SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"') FROM t1; -SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter) FROM t1; +SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter) FROM t1; drop table t1; # diff --git a/mysql-test/t/func_system.test b/mysql-test/t/func_system.test index 052e0530cf6..c69526644f4 100644 --- a/mysql-test/t/func_system.test +++ b/mysql-test/t/func_system.test @@ -4,3 +4,4 @@ select database(),user() like "%@%"; select version()>="3.23.29"; +select TRUE,FALSE,NULL; diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test index f5ad2e21c73..8810aefc20f 100644 --- a/mysql-test/t/func_test.test +++ b/mysql-test/t/func_test.test @@ -17,6 +17,7 @@ select 2 in (3,2,5,9,5,1),"monty" in ("david","monty","allan"), 1.2 in (1.4,1.2, select -1.49 or -1.49,0.6 or 0.6; select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1; select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL; +select 10 % 7, 10 mod 7, 10 div 3; # # Wrong usage of functions diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index dd589ff2e66..af222b0b3cc 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1,7 +1,9 @@ # # time functions # +--disable_warnings drop table if exists t1,t2,t3; +--enable_warnings select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29"); select period_add("9602",-12),period_diff(199505,"9404") ; @@ -39,6 +41,10 @@ select yearweek("2000-01-06",1) as '2000', yearweek("2001-01-06",1) as '2001', y select week(19981231,2), week(19981231,3), week(20000101,2), week(20000101,3); select week(20001231,2),week(20001231,3); +set default_week_format = 2; +select week(20001231),week(20001231,2),week(20001231,0); +set default_week_format = 0; + select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v'); select date_format('1999-12-31','%x-%v'),date_format('2000-01-01','%x-%v'); @@ -183,3 +189,34 @@ select * from t1, t2 where t1.start between t2.ctime1 and t2.ctime2; select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2; select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2; drop table t1,t2,t3; + +# +# Test types from + INTERVAL +# + +CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time); +INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08"); +SELECT * from t1; +select date_add("1997-12-31",INTERVAL 1 SECOND); +select date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH); + +select date_add(datetime, INTERVAL 1 SECOND) from t1; +select date_add(datetime, INTERVAL 1 YEAR) from t1; + +select date_add(date,INTERVAL 1 SECOND) from t1; +select date_add(date,INTERVAL 1 MINUTE) from t1; +select date_add(date,INTERVAL 1 HOUR) from t1; +select date_add(date,INTERVAL 1 DAY) from t1; +select date_add(date,INTERVAL 1 MONTH) from t1; +select date_add(date,INTERVAL 1 YEAR) from t1; +select date_add(date,INTERVAL "1:1" MINUTE_SECOND) from t1; +select date_add(date,INTERVAL "1:1" HOUR_MINUTE) from t1; +select date_add(date,INTERVAL "1:1" DAY_HOUR) from t1; +select date_add(date,INTERVAL "1 1" YEAR_MONTH) from t1; +select date_add(date,INTERVAL "1:1:1" HOUR_SECOND) from t1; +select date_add(date,INTERVAL "1 1:1" DAY_MINUTE) from t1; +select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1; + +# The following is not as one would expect... +select date_add(time,INTERVAL 1 SECOND) from t1; +drop table t1; diff --git a/mysql-test/t/func_timestamp.test b/mysql-test/t/func_timestamp.test index 74e541f782d..8583c16073d 100644 --- a/mysql-test/t/func_timestamp.test +++ b/mysql-test/t/func_timestamp.test @@ -2,7 +2,10 @@ # Tests that depend on the timestamp and the TZ variable # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (Zeit time, Tag tinyint not null, Monat tinyint not null, Jahr smallint not null, index(Tag), index(Monat), index(Jahr) ); insert into t1 values ("09:26:00",16,9,1998),("09:26:00",16,9,1998); diff --git a/mysql-test/t/gcc296.test b/mysql-test/t/gcc296.test index 7c72b57ca54..ebca4dbc897 100644 --- a/mysql-test/t/gcc296.test +++ b/mysql-test/t/gcc296.test @@ -1,6 +1,9 @@ #try to crash gcc 2.96 -drop table if exists obory; -CREATE TABLE obory ( +--disable_warnings +drop table if exists t1; +--enable_warnings + +CREATE TABLE t1 ( kodoboru varchar(10) default NULL, obor tinytext, aobor tinytext, @@ -8,10 +11,10 @@ CREATE TABLE obory ( FULLTEXT KEY obor (obor), FULLTEXT KEY aobor (aobor) ); -INSERT INTO obory VALUES ('0101000000','aaa','AAA'); -INSERT INTO obory VALUES ('0102000000','bbb','BBB'); -INSERT INTO obory VALUES ('0103000000','ccc','CCC'); -INSERT INTO obory VALUES ('0104000000','xxx','XXX'); +INSERT INTO t1 VALUES ('0101000000','aaa','AAA'); +INSERT INTO t1 VALUES ('0102000000','bbb','BBB'); +INSERT INTO t1 VALUES ('0103000000','ccc','CCC'); +INSERT INTO t1 VALUES ('0104000000','xxx','XXX'); -select * from obory; -drop table obory; +select * from t1; +drop table t1; diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test new file mode 100644 index 00000000000..35bb682f732 --- /dev/null +++ b/mysql-test/t/gis.test @@ -0,0 +1,113 @@ +# +# Spatial objects +# + +--disable_warnings +DROP TABLE IF EXISTS pt, ls, p, mpt, mls, mp, gc, geo; +--enable_warnings + +CREATE TABLE pt (fid INTEGER NOT NULL PRIMARY KEY, g POINT); +CREATE TABLE ls (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING); +CREATE TABLE p (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON); +CREATE TABLE mpt (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOINT); +CREATE TABLE mls (fid INTEGER NOT NULL PRIMARY KEY, g MULTILINESTRING); +CREATE TABLE mp (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOLYGON); +CREATE TABLE gc (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRYCOLLECTION); +CREATE TABLE geo (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY); + +INSERT INTO pt VALUES +(101, PointFromText('POINT(10 10)')), +(102, PointFromText('POINT(20 10)')), +(103, PointFromText('POINT(20 20)')), +(104, PointFromText('POINT(10 20)')); + +INSERT INTO ls VALUES +(105, LineFromText('LINESTRING(0 0,0 10,10 0)')), +(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')), +(107, LineString(Point(10, 10), Point(40, 10))); + +INSERT INTO p VALUES +(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')), +(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')), +(110, Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))); + +INSERT INTO mpt VALUES +(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')), +(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')), +(113, MultiPoint(Point(3, 6), Point(4, 10))); + +INSERT INTO mls VALUES +(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')), +(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')), +(116, MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))); + + +INSERT INTO mp VALUES +(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')), +(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')), +(119, MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))); + +INSERT INTO gc VALUES +(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')), +(121, GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))); + +INSERT into geo SELECT * FROM pt; +INSERT into geo SELECT * FROM ls; +INSERT into geo SELECT * FROM p; +INSERT into geo SELECT * FROM mpt; +INSERT into geo SELECT * FROM mls; +INSERT into geo SELECT * FROM mp; +INSERT into geo SELECT * FROM gc; + +SELECT fid, AsText(g) FROM pt; +SELECT fid, AsText(g) FROM ls; +SELECT fid, AsText(g) FROM p; +SELECT fid, AsText(g) FROM mpt; +SELECT fid, AsText(g) FROM mls; +SELECT fid, AsText(g) FROM mp; +SELECT fid, AsText(g) FROM gc; +SELECT fid, AsText(g) FROM geo; + +SELECT fid, Dimension(g) FROM geo; +SELECT fid, GeometryType(g) FROM geo; +SELECT fid, IsEmpty(g) FROM geo; +SELECT fid, AsText(Envelope(g)) FROM geo; + +SELECT fid, X(g) FROM pt; +SELECT fid, Y(g) FROM pt; + +SELECT fid, AsText(StartPoint(g)) FROM ls; +SELECT fid, AsText(EndPoint(g)) FROM ls; +SELECT fid, GLength(g) FROM ls; +SELECT fid, NumPoints(g) FROM ls; +SELECT fid, AsText(PointN(g, 2)) FROM ls; +SELECT fid, IsClosed(g) FROM ls; + +SELECT fid, AsText(Centroid(g)) FROM p; +SELECT fid, Area(g) FROM p; +SELECT fid, AsText(ExteriorRing(g)) FROM p; +SELECT fid, NumInteriorRings(g) FROM p; +SELECT fid, AsText(InteriorRingN(g, 1)) FROM p; + +SELECT fid, IsClosed(g) FROM mls; + +SELECT fid, AsText(Centroid(g)) FROM mp; +SELECT fid, Area(g) FROM mp; + +SELECT fid, NumGeometries(g) from mpt; +SELECT fid, NumGeometries(g) from mls; +SELECT fid, NumGeometries(g) from mp; +SELECT fid, NumGeometries(g) from gc; + +SELECT fid, AsText(GeometryN(g, 2)) from mpt; +SELECT fid, AsText(GeometryN(g, 2)) from mls; +SELECT fid, AsText(GeometryN(g, 2)) from mp; +SELECT fid, AsText(GeometryN(g, 2)) from gc; + +SELECT g1.fid as first, g2.fid as second, +Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o, +Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t, +Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r +FROM gc g1, gc g2 ORDER BY first, second; + +DROP TABLE pt, ls, p, mpt, mls, mp, gc, geo; diff --git a/mysql-test/t/grant_cache.test b/mysql-test/t/grant_cache.test index 7dfbb3b8d83..2d704a770aa 100644 --- a/mysql-test/t/grant_cache.test +++ b/mysql-test/t/grant_cache.test @@ -3,12 +3,17 @@ # # Test grants with query cache # +--disable_warnings drop table if exists test.t1,mysqltest.t1,mysqltest.t2; +--enable_warnings + reset query cache; flush status; connect (root,localhost,root,,test,$MASTER_MYPORT,master.sock); connection root; +--disable_warnings create database if not exists mysqltest; +--enable_warnings create table mysqltest.t1 (a int,b int,c int); create table mysqltest.t2 (a int,b int,c int); diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index ab5d6062daf..85ec680b3a2 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1,8 +1,18 @@ +# Initialise +--disable_warnings +drop table if exists t1,t2,t3; +--enable_warnings + +# +# Simple test without tables + +-- error 1111 +SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1); + # # Test of group (Failed for Lars Hoss <lh@pbm.de>) # -drop table if exists t1,t2,t3; CREATE TABLE t1 ( spID int(10) unsigned, userID int(10) unsigned, @@ -40,7 +50,7 @@ SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid; SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid; SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL; -drop table test.t1,test.t2; +drop table t1,t2; # # Bug in GROUP BY, by Nikki Chumakov <nikki@saddam.cityline.ru> @@ -302,7 +312,6 @@ SELECT 1 FROM t1 GROUP BY CONCAT(a, b); INSERT INTO t1 values ('hij','klm'); SELECT CONCAT(a, b),count(*) FROM t1 GROUP BY 1; DROP TABLE t1; -drop table if exists t1; # # Test problem with ORDER BY on a SUM() column diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test index 7020a4ab3d3..30746f10c62 100644 --- a/mysql-test/t/handler.test +++ b/mysql-test/t/handler.test @@ -2,13 +2,18 @@ # test of HANDLER ... # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (a int, b char(10), key a(a), key b(a,b)); insert into t1 values (17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"), (14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"), (20,"ggg"),(21,"hhh"),(22,"iii"); handler t1 open as t2; +-- error 1064 +handler t2 read a=(SELECT 1); handler t2 read a first; handler t2 read a next; handler t2 read a next; diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index 8dd7606d82b..4bd56400f98 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -1,7 +1,10 @@ # test of problems with having (Reported by Mark Rogers) # +--disable_warnings drop table if exists t1,t2; +--enable_warnings + create table t1 (a int); select count(a) as b from t1 where a=0 having b > 0; insert into t1 values (null); @@ -59,4 +62,5 @@ select Fld1, max(Fld2) as q from t1 group by Fld1 having q is not null; select Fld1, max(Fld2) from t1 group by Fld1 having max(Fld2) is not null; select Fld1, max(Fld2) from t1 group by Fld1 having avg(Fld2) is not null; select Fld1, max(Fld2) from t1 group by Fld1 having std(Fld2) is not null; +select Fld1, max(Fld2) from t1 group by Fld1 having variance(Fld2) is not null; drop table t1; diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index ef7e3239a96..cd5dbd5afbe 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -2,7 +2,10 @@ # Test of heap tables. # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (a int not null,b int not null, primary key (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; insert into t1 values(1,1),(2,2),(3,3),(4,4); delete from t1 where a=1 or a=0; @@ -42,7 +45,7 @@ alter table t1 type=myisam; explain select * from t1 where a in (869751,736494,226312,802616); drop table t1; -create table t1 (x int not null, y int not null, key x(x), unique y(y)) +create table t1 (x int not null, y int not null, key x (x), unique y (y)) type=heap; insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6); select * from t1 where x=1; diff --git a/mysql-test/t/heap_auto_increment.test b/mysql-test/t/heap_auto_increment.test new file mode 100644 index 00000000000..6f392f6830d --- /dev/null +++ b/mysql-test/t/heap_auto_increment.test @@ -0,0 +1,33 @@ +# +# Test of auto_increment; The test for BDB tables is in bdb.test +# + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (a int not null auto_increment,b int, primary key (a)) type=heap auto_increment=3; +insert into t1 values (1,1),(NULL,3),(NULL,4); +delete from t1 where a=4; +insert into t1 values (NULL,5),(NULL,6); +select * from t1; +delete from t1 where a=6; +#show table status like "t1"; +replace t1 values (3,1); +ALTER TABLE t1 add c int; +replace t1 values (3,3,3); +insert into t1 values (NULL,7,7); +update t1 set a=8,b=b+1,c=c+1 where a=7; +insert into t1 values (NULL,9,9); +select * from t1; +drop table t1; + +create table t1 ( + skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY, + sval char(20) +) type=heap; +insert into t1 values (NULL, "hello"); +insert into t1 values (NULL, "hey"); +select * from t1; +select _rowid,t1._rowid,skey,sval from t1; +drop table t1; diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test new file mode 100644 index 00000000000..3c2ff249415 --- /dev/null +++ b/mysql-test/t/heap_btree.test @@ -0,0 +1,158 @@ +# +# Test of heap tables. +# + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +delete from t1 where a=1 or a=0; +#show table status like "t1"; +show keys from t1; +select * from t1; +select * from t1 where a=4; +update t1 set b=5 where a=4; +update t1 set b=b+1 where a>=3; +replace t1 values (3,3); +select * from t1; +alter table t1 add c int not null, add key using BTREE (c,a); +drop table t1; + +create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps"; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +delete from t1 where a > 0; +select * from t1; +drop table t1; + +create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps"; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table"; +#show table status like "t1"; +select * from t1; +drop table t1; + +create table t1 (a int not null) type=heap; +insert into t1 values (869751),(736494),(226312),(802616); +select * from t1 where a > 736494; +alter table t1 add unique uniq_id using BTREE (a); +select * from t1 where a > 736494; +select * from t1 where a = 736494; +select * from t1 where a=869751 or a=736494; +select * from t1 where a in (869751,736494,226312,802616); +alter table t1 type=myisam; +explain select * from t1 where a in (869751,736494,226312,802616); +drop table t1; + +create table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y)) +type=heap; +insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6); +explain select * from t1 where x=1; +select * from t1 where x=1; +select * from t1,t1 as t2 where t1.x=t2.y; +explain select * from t1,t1 as t2 where t1.x=t2.y; +drop table t1; + +create table t1 (a int) type=heap; +insert into t1 values(1); +select max(a) from t1; +drop table t1; + +CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using BTREE (a,b), key using BTREE (b) ) TYPE=HEAP; +insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); +select * from t1 where a=1; +insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); +select * from t1 where a=1; +--replace_result 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x +explain select * from t1 where a=1 order by a,b; +--replace_result 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x +explain select * from t1 where a=1 order by b; +select * from t1 where b=1; +--replace_result 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x +explain select * from t1 where b=1; +drop table t1; + +create table t1 (id int unsigned not null, primary key using BTREE (id)) type=HEAP; +insert into t1 values(1); +select max(id) from t1; +insert into t1 values(2); +select max(id) from t1; +replace into t1 values(1); +drop table t1; + +create table t1 (n int) type=heap; +drop table t1; + +create table t1 (n int) type=heap; +drop table if exists t1; + +# Test of non unique index + +CREATE table t1(f1 int not null,f2 char(20) not +null,index(f2)) type=heap; +INSERT into t1 set f1=12,f2="bill"; +INSERT into t1 set f1=13,f2="bill"; +INSERT into t1 set f1=14,f2="bill"; +INSERT into t1 set f1=15,f2="bill"; +INSERT into t1 set f1=16,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +delete from t1 where f2="bill"; +select * from t1; +drop table t1; + +# +# Test when using part key searches +# + +create table t1 (btn char(10) not null, key using BTREE (btn)) type=heap; +insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i"); +explain select * from t1 where btn like "q%"; +select * from t1 where btn like "q%"; +alter table t1 add column new_col char(1) not null, add key using BTREE (btn,new_col), drop key btn; +update t1 set new_col=btn; +explain select * from t1 where btn="a"; +explain select * from t1 where btn="a" and new_col="a"; +drop table t1; + +# +# Test of NULL keys +# + +CREATE TABLE t1 ( + a int default NULL, + b int default NULL, + KEY a using BTREE (a), + UNIQUE b using BTREE (b) +) type=heap; +INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3); +SELECT * FROM t1 WHERE a=NULL; +explain SELECT * FROM t1 WHERE a IS NULL; +SELECT * FROM t1 WHERE a<=>NULL; +SELECT * FROM t1 WHERE b=NULL; +explain SELECT * FROM t1 WHERE b IS NULL; +SELECT * FROM t1 WHERE b<=>NULL; + +--error 1062 +INSERT INTO t1 VALUES (1,3); +DROP TABLE t1; + +CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) type=heap; +INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1); +SELECT * FROM t1 WHERE a=1 and b IS NULL; +SELECT * FROM t1 WHERE a=1 and c IS NULL; +SELECT * FROM t1 WHERE a=1 and b IS NULL and c IS NULL; +DROP TABLE t1; + +# +# Test when deleting all rows +# + +CREATE TABLE t1 (a int not null, primary key using BTREE (a)) type=heap; +INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); +DELETE from t1 where a < 100; +SELECT * from t1; +DROP TABLE t1; diff --git a/mysql-test/t/heap_hash.test b/mysql-test/t/heap_hash.test new file mode 100644 index 00000000000..7b375fdfa3c --- /dev/null +++ b/mysql-test/t/heap_hash.test @@ -0,0 +1,143 @@ +# +# Test of heap tables. +# + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +delete from t1 where a=1 or a=0; +#show table status like "t1"; +show keys from t1; +select * from t1; +select * from t1 where a=4; +update t1 set b=5 where a=4; +update t1 set b=b+1 where a>=3; +replace t1 values (3,3); +select * from t1; +alter table t1 add c int not null, add key using HASH (c,a); +drop table t1; + +create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps"; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +delete from t1 where a > 0; +select * from t1; +drop table t1; + +create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps"; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table"; +#show table status like "t1"; +select * from t1; +drop table t1; + +create table t1 (a int not null) type=heap; +insert into t1 values (869751),(736494),(226312),(802616); +select * from t1 where a > 736494; +alter table t1 add unique uniq_id using HASH (a); +select * from t1 where a > 736494; +select * from t1 where a = 736494; +select * from t1 where a=869751 or a=736494; +select * from t1 where a in (869751,736494,226312,802616); +alter table t1 type=myisam; +explain select * from t1 where a in (869751,736494,226312,802616); +drop table t1; + +create table t1 (x int not null, y int not null, key x using HASH (x), unique y using HASH (y)) +type=heap; +insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6); +select * from t1 where x=1; +select * from t1,t1 as t2 where t1.x=t2.y; +explain select * from t1,t1 as t2 where t1.x=t2.y; +drop table t1; + +create table t1 (a int) type=heap; +insert into t1 values(1); +select max(a) from t1; +drop table t1; + +CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using HASH (a), key using HASH (b) ) TYPE=HEAP; +insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); +select * from t1 where a=1; +insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); +select * from t1 where a=1; +drop table t1; + +create table t1 (id int unsigned not null, primary key using HASH (id)) type=HEAP; +insert into t1 values(1); +select max(id) from t1; +insert into t1 values(2); +select max(id) from t1; +replace into t1 values(1); +drop table t1; + +create table t1 (n int) type=heap; +drop table t1; + +create table t1 (n int) type=heap; +drop table if exists t1; + +# Test of non unique index + +CREATE table t1(f1 int not null,f2 char(20) not +null,index(f2)) type=heap; +INSERT into t1 set f1=12,f2="bill"; +INSERT into t1 set f1=13,f2="bill"; +INSERT into t1 set f1=14,f2="bill"; +INSERT into t1 set f1=15,f2="bill"; +INSERT into t1 set f1=16,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +delete from t1 where f2="bill"; +select * from t1; +drop table t1; + +# +# Test when using part key searches +# + +create table t1 (btn char(10) not null, key using HASH (btn)) type=heap; +insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i"); +explain select * from t1 where btn like "q%"; +select * from t1 where btn like "q%"; +alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn; +update t1 set new_col=btn; +explain select * from t1 where btn="a"; +explain select * from t1 where btn="a" and new_col="a"; +drop table t1; + +# +# Test of NULL keys +# + +CREATE TABLE t1 ( + a int default NULL, + b int default NULL, + KEY a using HASH (a), + UNIQUE b using HASH (b) +) type=heap; +INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3); +SELECT * FROM t1 WHERE a=NULL; +explain SELECT * FROM t1 WHERE a IS NULL; +SELECT * FROM t1 WHERE a<=>NULL; +SELECT * FROM t1 WHERE b=NULL; +explain SELECT * FROM t1 WHERE b IS NULL; +SELECT * FROM t1 WHERE b<=>NULL; + +--error 1062 +INSERT INTO t1 VALUES (1,3); +DROP TABLE t1; + +# +# Test when deleting all rows +# + +CREATE TABLE t1 (a int not null, primary key using HASH (a)) type=heap; +INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); +DELETE from t1 where a < 100; +SELECT * from t1; +DROP TABLE t1; diff --git a/mysql-test/t/help.test b/mysql-test/t/help.test new file mode 100644 index 00000000000..c36b670c6b3 --- /dev/null +++ b/mysql-test/t/help.test @@ -0,0 +1,50 @@ +-- source include/have_innodb.inc + +truncate mysql.help_topic; +truncate mysql.help_category; +truncate mysql.help_relation; + +insert into mysql.help_topic(name,description,example)values('impossible_function_1','description of \n impossible_function1','example of \n impossible_function1'); +SELECT @topic1_id:=LAST_INSERT_ID(); +insert into mysql.help_topic(name,description,example)values('impossible_function_2','description of \n impossible_function2','example of \n impossible_function2'); +SELECT @topic2_id:=LAST_INSERT_ID(); +insert into mysql.help_topic(name,description,example)values('impossible_function_3','description of \n impossible_function3','example of \n impossible_function3'); +SELECT @topic3_id:=LAST_INSERT_ID(); + +insert into mysql.help_category(name)values('impossible_category_1'); +SELECT @category1_id:=LAST_INSERT_ID(); +insert into mysql.help_category(name)values('impossible_category_2'); +SELECT @category2_id:=LAST_INSERT_ID(); + +insert into mysql.help_relation(help_category_id,help_topic_id)values(@category1_id,@topic1_id); +insert into mysql.help_relation(help_category_id,help_topic_id)values(@category1_id,@topic2_id); +insert into mysql.help_relation(help_category_id,help_topic_id)values(@category2_id,@topic2_id); +insert into mysql.help_relation(help_category_id,help_topic_id)values(@category2_id,@topic3_id); + +help 'function_of_my_dream'; +help '%possible_f%'; +help 'impossible_func%'; +help 'impossible_category%'; +help 'impossible_%'; +help '%function_2'; +help '%category_2'; +help 'impossible_function_1'; +help 'impossible_category_1'; + +alter table mysql.help_topic type=innodb; +alter table mysql.help_category type=innodb; +alter table mysql.help_relation type=innodb; + +help 'function_of_my_dream'; +help '%ble_f%'; +help 'impossible_func%'; +help 'impossible_category%'; +help 'impossible_%'; +help '%function_2'; +help '%category_2'; +help 'impossible_function_1'; +help 'impossible_category_1'; + +alter table mysql.help_topic type=myisam; +alter table mysql.help_category type=myisam; +alter table mysql.help_relation type=myisam; diff --git a/mysql-test/t/innodb-deadlock.test b/mysql-test/t/innodb-deadlock.test index bc2839bfb3a..ba4ec4a9ae4 100644 --- a/mysql-test/t/innodb-deadlock.test +++ b/mysql-test/t/innodb-deadlock.test @@ -2,7 +2,10 @@ connect (con1,localhost,root,,); connect (con2,localhost,root,,); -drop table if exists t1; + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings # # Testing of FOR UPDATE @@ -36,3 +39,75 @@ select * from t1; commit; drop table t1; +# +# Testing of FOR UPDATE +# + +connection con1; +create table t1 (id integer, x integer) type=INNODB; +create table t2 (b integer, a integer) type=INNODB; +insert into t1 values(0, 0), (300, 300); +insert into t2 values(0, 10), (1, 20), (2, 30); +commit; +set autocommit=0; +select * from t2; +update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE); +select * from t2; +select * from t1; + +connection con2; +set autocommit=0; + +# The following query should hang because con1 is locking the page +--send +update t1 set x=2 where id = 0; +--sleep 2; + +connection con1; +update t1 set x=1 where id = 0; +select * from t1; +commit; + +connection con2; +reap; +commit; + +connection con1; +select * from t1; +commit; + +drop table t1, t2; +create table t1 (id integer, x integer) type=INNODB; +create table t2 (b integer, a integer) type=INNODB; +insert into t1 values(0, 0), (300, 300); +insert into t2 values(0, 0), (1, 20), (2, 30); +commit; + +connection con1; +select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE; +select * from t2; +select * from t1; + +connection con2; + +# The following query should hang because con1 is locking the page +update t2 set a=2 where b = 0; +select * from t2; +--send +update t1 set x=2 where id = 0; +--sleep 2; + +connection con1; +update t1 set x=1 where id = 0; +select * from t1; +commit; + +connection con2; +reap; +commit; + +connection con1; +select * from t1; +commit; + +drop table t1, t2; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 556822ab51d..95a690e56b7 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -4,7 +4,10 @@ # Small basic test with ignore # +--disable_warnings drop table if exists t1,t2; +--enable_warnings + create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) type=innodb; insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt'); @@ -664,7 +667,6 @@ DROP TABLE t1; # # Test of multi-table-update # -drop table if exists t1,t2; create table t1 (n int(10), d int(10)) type=innodb; create table t2 (n int(10), d int(10)) type=innodb; insert into t1 values(1,1),(1,2); diff --git a/mysql-test/t/innodb_cache.test b/mysql-test/t/innodb_cache.test index 9066a5f19ba..8a08c19703d 100644 --- a/mysql-test/t/innodb_cache.test +++ b/mysql-test/t/innodb_cache.test @@ -1,10 +1,14 @@ -- source include/have_innodb.inc -- source include/have_query_cache.inc +# Initialise +--disable_warnings +drop table if exists t1,t2,t3; +--enable_warnings + # # Without auto_commit. # -drop table if exists t1, t2, t3; flush status; set autocommit=0; create table t1 (a int not null) type=innodb; diff --git a/mysql-test/t/innodb_handler.test b/mysql-test/t/innodb_handler.test index c6448eba3ef..32c8741577c 100644 --- a/mysql-test/t/innodb_handler.test +++ b/mysql-test/t/innodb_handler.test @@ -4,7 +4,10 @@ # test of HANDLER ... # -drop table if exists t1; +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + create table t1 (a int, b char(10), key a(a), key b(a,b)) type=innodb; insert into t1 values (17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"), diff --git a/mysql-test/t/ins000001.test b/mysql-test/t/ins000001.test index 4d75b4e7fe3..afcd27ebfca 100644 --- a/mysql-test/t/ins000001.test +++ b/mysql-test/t/ins000001.test @@ -1,5 +1,8 @@ use test; +--disable_warnings drop table if exists t1,t2; +--enable_warnings + create table t1 (email varchar(50)); insert into t1 values ('sasha@mysql.com'),('monty@mysql.com'), ('foo@hotmail.com'),('foo@aol.com'),('bar@aol.com'); diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index 9b06b522028..bfa8aac7a1f 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -2,7 +2,10 @@ # Test of refering to old values # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (a int not null); insert into t1 values (1); insert into t1 values (a+2); @@ -54,9 +57,11 @@ drop table t1; # Test of mysqld crash with fully qualified column names # -drop database if exists foo; -create database foo; -use foo; +--disable_warnings +drop database if exists test_$1; +--enable_warnings +create database test_$1; +use test_$1; create table t1 (c int); -insert into foo.t1 set foo.t1.c = '1'; -drop database foo; +insert into test_$1.t1 set test_$1.t1.c = '1'; +drop database test_$1; diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 42f65858d77..8fcb22e4684 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -2,7 +2,10 @@ # Problem with INSERT ... SELECT # +--disable_warnings drop table if exists t1,t2; +--enable_warnings + create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL); insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12); create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY); @@ -12,13 +15,13 @@ insert into t2 (payoutID) SELECT payoutID+10 FROM t1; insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1; select * from t2; drop table t1,t2; + # # bug in bulk insert optimization # test case by Fournier Jocelyn <joc@presence-pc.com> # -DROP TABLE IF EXISTS crash1,crash2; -CREATE TABLE `crash1` ( +CREATE TABLE `t1` ( `numeropost` bigint(20) unsigned NOT NULL default '0', `icone` tinyint(4) unsigned NOT NULL default '0', `numreponse` bigint(20) unsigned NOT NULL auto_increment, @@ -34,7 +37,7 @@ CREATE TABLE `crash1` ( KEY `numreponse` (`numreponse`) ) TYPE=MyISAM; -CREATE TABLE `crash2` ( +CREATE TABLE `t2` ( `numeropost` bigint(20) unsigned NOT NULL default '0', `icone` tinyint(4) unsigned NOT NULL default '0', `numreponse` bigint(20) unsigned NOT NULL auto_increment, @@ -50,21 +53,21 @@ CREATE TABLE `crash2` ( KEY `numreponse` (`numreponse`) ) TYPE=MyISAM; -INSERT INTO crash2 +INSERT INTO t2 (numeropost,icone,numreponse,contenu,pseudo,date,ip,signature) VALUES (9,1,56,'test','joce','2001-07-25 13:50:53' ,3649052399,0); -INSERT INTO crash1 (numeropost,icone,contenu,pseudo,date,signature,ip) -SELECT 1618,icone,contenu,pseudo,date,signature,ip FROM crash2 +INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip) +SELECT 1618,icone,contenu,pseudo,date,signature,ip FROM t2 WHERE numeropost=9 ORDER BY numreponse ASC; show variables like '%bulk%'; -INSERT INTO crash1 (numeropost,icone,contenu,pseudo,date,signature,ip) -SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM crash2 +INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip) +SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM t2 WHERE numeropost=9 ORDER BY numreponse ASC; -DROP TABLE IF EXISTS crash1,crash2; +DROP TABLE IF EXISTS t1,t2; diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test new file mode 100644 index 00000000000..f40391554cc --- /dev/null +++ b/mysql-test/t/insert_update.test @@ -0,0 +1,24 @@ +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B)); +INSERT t1 VALUES (1,2,10), (3,4,20); +INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE c=c+1000; +SELECT * FROM t1; +INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000; +SELECT * FROM t1; +-- error 1062 +INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4; +SELECT * FROM t1; +TRUNCATE TABLE t1; +INSERT t1 VALUES (1,2,10), (3,4,20); +INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0; +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/t/isam.test b/mysql-test/t/isam.test index c7308c4b999..fc2dbac439c 100644 --- a/mysql-test/t/isam.test +++ b/mysql-test/t/isam.test @@ -1,6 +1,8 @@ -- source include/have_isam.inc +--disable_warnings drop table if exists t1,t2; +--enable_warnings # # Test possible problem with rows that are about 65535 bytes long @@ -41,10 +43,14 @@ drop table t1; # # Test of some CREATE TABLE's that should fail # -!$1121 create table t1 (a int,b text, index(a)) type=isam; -!$1073 create table t1 (a int,b text, index(b)) type=isam; -!$1075 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=isam; -!$1121 create table t1 (ordid int(8), unique (ordid)) type=isam; +--error 1121 +create table t1 (a int,b text, index(a)) type=isam; +--error 1073 +create table t1 (a int,b text, index(b)) type=isam; +--error 1075 +create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=isam; +--error 1121 +create table t1 (ordid int(8), unique (ordid)) type=isam; drop table if exists t1; # diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 63ec90f854c..7840e128ac7 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -1,6 +1,8 @@ # # Initialization +--disable_warnings drop table if exists t1,t2,t3; +--enable_warnings # # Test different join syntaxes @@ -25,7 +27,6 @@ drop table t1,t2; # This failed for lia Perminov # - create table t1 (id int primary key); create table t2 (id int); insert into t1 values (75); diff --git a/mysql-test/t/join_crash.test b/mysql-test/t/join_crash.test index 4606b23f726..ada6e56e664 100644 --- a/mysql-test/t/join_crash.test +++ b/mysql-test/t/join_crash.test @@ -2,7 +2,10 @@ # This test gave a core dump # +--disable_warnings DROP TABLE IF EXISTS t1,t2,t3,t4; +--enable_warnings + CREATE TABLE t1 ( project_id int(11) NOT NULL auto_increment, project_row_lock int(11) NOT NULL default '0', diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index af5f377afb5..bfeb5bbb06b 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -2,7 +2,9 @@ # test of left outer join # +--disable_warnings drop table if exists t1,t2,t3,t4,t5; +--enable_warnings CREATE TABLE t1 ( grp int(11) default NULL, @@ -109,7 +111,6 @@ drop table t1,t2; # Test of LEFT JOIN with const tables (failed for frankie@etsetb.upc.es) # -drop table if exists t1,t2,t3,t4; CREATE TABLE t1 ( cod_asig int(11) DEFAULT '0' NOT NULL, desc_larga_cat varchar(80) DEFAULT '' NOT NULL, diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test index 1996c793880..4fd8cc86dd5 100644 --- a/mysql-test/t/key.test +++ b/mysql-test/t/key.test @@ -2,7 +2,10 @@ # This failed for Elizabeth Mattijsen # +--disable_warnings drop table if exists t1,t2,t3; +--enable_warnings + CREATE TABLE t1 ( ID CHAR(32) NOT NULL, name CHAR(32) NOT NULL, @@ -173,7 +176,6 @@ drop table t1; # Problem with UNIQUE() with NULL parts and auto increment # -DROP TABLE IF EXISTS t1; CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT, UNIQUE (c,i)); INSERT INTO t1 (c) VALUES (NULL),(NULL); diff --git a/mysql-test/t/key_diff.test b/mysql-test/t/key_diff.test index 60afb5f81a4..b4e4339ae33 100644 --- a/mysql-test/t/key_diff.test +++ b/mysql-test/t/key_diff.test @@ -1,7 +1,10 @@ # # Check on condition on different length keys. +--disable_warnings drop table if exists t1; +--enable_warnings + CREATE TABLE t1 ( a char(5) NOT NULL, b char(4) NOT NULL, diff --git a/mysql-test/t/key_primary.test b/mysql-test/t/key_primary.test index 2cdb117128f..816365c517c 100644 --- a/mysql-test/t/key_primary.test +++ b/mysql-test/t/key_primary.test @@ -2,7 +2,10 @@ # test of primary key conversions # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (t1 char(3) primary key); insert into t1 values("ABC"); insert into t1 values("ABA"); diff --git a/mysql-test/t/keywords.test b/mysql-test/t/keywords.test index 3bd757aa069..e7ec63afe54 100644 --- a/mysql-test/t/keywords.test +++ b/mysql-test/t/keywords.test @@ -2,7 +2,10 @@ # Test keywords as fields # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (time time, date date, timestamp timestamp); insert into t1 values ("12:22:22","97:02:03","1997-01-02"); select * from t1; diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index 6bcc43ac916..65d4f27059f 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -11,7 +11,10 @@ connect (con2, localhost, root,,); #remember id of con1 connection con1; +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (kill_id int); insert into t1 values(connection_id()); diff --git a/mysql-test/t/limit.test b/mysql-test/t/limit.test index d4f6ce186cf..88a9831aa68 100644 --- a/mysql-test/t/limit.test +++ b/mysql-test/t/limit.test @@ -2,7 +2,10 @@ # Test of update and delete with limit # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (a int primary key, b int not null); insert into t1 () values (); -- Testing default values insert into t1 values (1,1),(2,1),(3,1); diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test index 385713174d2..0868cf2c4b1 100644 --- a/mysql-test/t/lock.test +++ b/mysql-test/t/lock.test @@ -2,7 +2,9 @@ # Testing of table locking # +--disable_warnings drop table if exists t1,t2; +--enable_warnings CREATE TABLE t1 ( `id` int(11) NOT NULL default '0', `id2` int(11) NOT NULL default '0', `id3` int(11) NOT NULL default '0', `dummy1` char(30) default NULL, PRIMARY KEY (`id`,`id2`), KEY `index_id3` (`id3`)) TYPE=MyISAM; insert into t1 (id,id2) values (1,1),(1,2),(1,3); LOCK TABLE t1 WRITE; diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index 0295fca29e7..fa095275182 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -6,9 +6,11 @@ # -- source include/not_embedded.inc +--disable_warnings drop table if exists t1,t2; +--enable_warnings -# test to see if select will get the lock ahead of low priority update +# Test to see if select will get the lock ahead of low priority update connect (locker,localhost,root,,); connect (reader,localhost,root,,); diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test index 0d04e6c7df7..f3a747c4d61 100644 --- a/mysql-test/t/lowercase_table.test +++ b/mysql-test/t/lowercase_table.test @@ -2,7 +2,10 @@ # Test of --lower-case-table-names # +--disable_warnings drop table if exists t1,t2,t3; +--enable_warnings + create table T1 (id int primary key, Word varchar(40) not null, Index(Word)); INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c'); SELECT * FROM t1; diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index e2cd8b57b7e..7a7678afca1 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -2,7 +2,10 @@ # test of MERGE TABLES # +--disable_warnings drop table if exists t1,t2,t3,t4,t5,t6; +--enable_warnings + create table t1 (a int not null primary key auto_increment, message char(20)); create table t2 (a int not null primary key auto_increment, message char(20)); INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1"); @@ -49,6 +52,7 @@ select * from t4; create table t5 (a int not null, b char(10), key(a)) type=MERGE UNION=(test.t1,test_2.t2); # Because of windows, it's important that we drop the merge tables first! +# This should give a warning on table t5 drop table if exists t5,t4,t3,t1,t2; create table t1 (c char(10)) type=myisam; @@ -110,10 +114,9 @@ select * from t1; drop table t1; # -# Bug found by Monty. +# Bug in flush tables combined with MERGE tables # -drop table if exists t3, t2, t1; create table t1 (a int not null, b int not null, key(a,b)); create table t2 (a int not null, b int not null, key(a,b)); create table t3 (a int not null, b int not null, key(a,b)) TYPE=MERGE UNION=(t1,t2); @@ -127,7 +130,6 @@ drop table t3,t1,t2; # [phi] testing INSERT_METHOD stuff # -drop table if exists t6, t5, t4, t3, t2, t1; # first testing of common stuff with new parameters create table t1 (a int not null, b int not null auto_increment, primary key(a,b)); create table t2 (a int not null, b int not null auto_increment, primary key(a,b)); @@ -181,15 +183,14 @@ CREATE TABLE t1 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default ' INSERT INTO t1 VALUES (1,1), (2,1); CREATE TABLE t2 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) TYPE=MyISAM; INSERT INTO t2 VALUES (1,2), (2,2); -CREATE TABLE t ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) TYPE=MRG_MyISAM UNION=(t1,t2); -select max(b) from t where a = 2; +CREATE TABLE t3 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) TYPE=MRG_MyISAM UNION=(t1,t2); +select max(b) from t3 where a = 2; select max(b) from t1 where a = 2; -drop table if exists t,t1,t2; +drop table if exists t3,t1,t2; # # temporary merge tables # -drop table if exists t1, t2, t3, t4, t5, t6; create table t1 (a int not null); create table t2 (a int not null); insert into t1 values (1); @@ -202,13 +203,12 @@ insert into t4 values (1); insert into t5 values (2); create temporary table t6 (a int not null) TYPE=MERGE UNION=(t4,t5); select * from t6; -drop table if exists t1, t2, t3, t4, t5, t6; +drop table if exists t6, t3, t1, t2, t4, t5; # # testing merge::records_in_range and optimizer # -DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1 ( fileset_id tinyint(3) unsigned NOT NULL default '0', file_code varchar(32) NOT NULL default '', @@ -235,5 +235,5 @@ EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2 AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1; EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2 AND file_code = '0000000115' LIMIT 1; -DROP TABLE IF EXISTS t1, t2; +DROP TABLE t2, t1; diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 088b355a17c..6156da82ec0 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -2,7 +2,10 @@ # Test of update statement that uses many tables. # +--disable_warnings drop table if exists t1,t2,t3; +--enable_warnings + create table t1(id1 int not null auto_increment primary key, t char(12)); create table t2(id2 int not null, t char(12)); create table t3(id3 int not null, t char(12), index(id3)); @@ -99,7 +102,7 @@ INSERT INTO t3 VALUES (1,'2002-02-04 00:00:00'),(3,'2002-05-12 00:00:00'),(5,'20 00:00:00'),(7,'2002-07-22 00:00:00'); delete t1,t2,t3 from t1,t2,t3 where to_days(now())-to_days(t3.mydate)>=30 and t3.id=t1.id and t3.id=t2.id; select * from t3; -DROP TABLE IF EXISTS t1,t2,t3; +DROP TABLE t1,t2,t3; CREATE TABLE IF NOT EXISTS `t1` ( `id` int(11) NOT NULL auto_increment, @@ -127,8 +130,7 @@ select * from t2; UPDATE t2, t1 SET t2.tst = t1.tst, t2.tst1 = t1.tst1 WHERE t2.ParId = t1.Id; select * from t2; - -drop table if exists t1, t2 ; +drop table t1, t2 ; create table t1 (n numeric(10)); create table t2 (n numeric(10)); @@ -213,8 +215,14 @@ insert into t2 values(1,10),(1,20); UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n; select * from t1; select * from t2; +UPDATE t1 a ,t2 b SET a.d=b.d,b.d=30 WHERE a.n=b.n; +select * from t1; +select * from t2; +DELETE t1, t2 FROM t1 a,t2 b where a.n=b.n; +select * from t1; +select * from t2; drop table t1,t2; -drop table if exists t1,t2,t3; + CREATE TABLE t1 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM; INSERT INTO t1 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a'),(10,''),(11,''),(12,''),(13,''); CREATE TABLE t2 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM; @@ -223,4 +231,4 @@ CREATE TABLE t3 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT INSERT INTO t3 VALUES (1,'jedan'),(2,'dva'); update t1,t2 set t1.naziv="aaaa" where t1.broj=t2.broj; update t1,t2,t3 set t1.naziv="bbbb", t2.naziv="aaaa" where t1.broj=t2.broj and t2.broj=t3.broj; -drop table if exists t1,t2,t3; +drop table t1,t2,t3; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index c96a21e73dd..3cce93840e0 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -3,7 +3,9 @@ # # Initialise +--disable_warnings drop table if exists t1,t2; +--enable_warnings # # Test problem with CHECK TABLE; @@ -11,7 +13,7 @@ drop table if exists t1,t2; CREATE TABLE t1 ( STRING_DATA char(255) default NULL, - KEY STRING_DATA (STRING_DATA) + KEY string_data (STRING_DATA) ) TYPE=MyISAM; INSERT INTO t1 VALUES ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); @@ -88,7 +90,6 @@ DROP TABLE t1; # in ha_myisam::repair, and index size is changed (decreased). # -drop table if exists t1; create table t1 ( t1 char(255), key(t1(250))); insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169'); insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203'); @@ -127,7 +128,6 @@ drop table t1; # test of myisam with huge number of packed fields # -drop table if exists t1; create table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8 int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17 int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int, @@ -292,7 +292,7 @@ insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); -drop table if exists t1; +drop table t1; # # Test of REPAIR that once failed @@ -349,4 +349,15 @@ explain select * from t1,t2 where t1.b=t2.b; explain select * from t1,t2 force index(c) where t1.a=t2.a; explain select * from t1 where a=0 or a=2; explain select * from t1 force index (a) where a=0 or a=2; +explain select * from t1 where c=1; +explain select * from t1 use index() where c=1; drop table t1,t2; + +# +# Test RTREE index +# +--error 1235 +CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) TYPE=MyISAM; +# INSERT INTO t1 VALUES (1,1),(1,1); +# DELETE FROM rt WHERE a<1; +DROP TABLE IF EXISTS t1; diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index 6fea7f0d10d..fa36249dce0 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -1,3 +1,8 @@ +# Initialise +--disable_warnings +drop table if exists t1; +--enable_warnings + # # Testing of NULL in a lot of different places # @@ -15,7 +20,6 @@ SELECT (NULL OR NULL) IS NULL; select NULL AND 0, 0 and NULL; select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),inet_aton("122.226."),inet_aton(""); -drop table if exists t1; create table t1 (x int); insert into t1 values (null); select * from t1 where x != 0; diff --git a/mysql-test/t/null_key.test b/mysql-test/t/null_key.test index b1cbd5cdfb0..18d0d368891 100644 --- a/mysql-test/t/null_key.test +++ b/mysql-test/t/null_key.test @@ -1,7 +1,10 @@ # # Check null keys -drop table if exists t1; +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + create table t1 (a int, b int not null,unique key (a,b),index(b)) type=myisam; insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); explain select * from t1 where a is null; @@ -51,7 +54,6 @@ drop table t1; # The following failed for Matt Loschert # -DROP TABLE IF EXISTS t1,t2; CREATE TABLE t1 ( id int(10) unsigned NOT NULL auto_increment, uniq_id int(10) unsigned default NULL, diff --git a/mysql-test/t/odbc.test b/mysql-test/t/odbc.test index 3e0fc214d3e..9aac5948359 100644 --- a/mysql-test/t/odbc.test +++ b/mysql-test/t/odbc.test @@ -1,3 +1,8 @@ +# Initialise +--disable_warnings +drop table if exists t1; +--enable_warnings + # # Test some ODBC compatibility # @@ -8,7 +13,6 @@ select {fn length("hello")}, { date "1997-10-20" }; # Test retreiving row with last insert_id value. # -drop table if exists t1; create table t1 (a int not null auto_increment,b int not null,primary key (a,b)); insert into t1 SET A=NULL,B=1; insert into t1 SET a=null,b=2; diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 8fe547db615..99bb2656001 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -1,6 +1,9 @@ -drop table if exists sales; -create table sales ( product varchar(32), country varchar(32), year int, profit int); -insert into sales values ( 'Computer', 'India',2000, 1200), +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 ( product varchar(32), country varchar(32), year int, profit int); +insert into t1 values ( 'Computer', 'India',2000, 1200), ( 'TV', 'United States', 1999, 150), ( 'Calculator', 'United States', 1999,50), ( 'Computer', 'United States', 1999,1500), @@ -15,13 +18,14 @@ insert into sales values ( 'Computer', 'India',2000, 1200), ( 'Computer', 'United States', 2000,1500), ( 'Calculator', 'United States', 2000,75); --error 1235 -select product, country , year, sum(profit) from sales group by product, country, year with cube; +select product, country , year, sum(profit) from t1 group by product, country, year with cube; --error 1235 -explain select product, country , year, sum(profit) from sales group by product, country, year with cube; +explain select product, country , year, sum(profit) from t1 group by product, country, year with cube; --error 1235 -select product, country , year, sum(profit) from sales group by product, country, year with rollup; +select product, country , year, sum(profit) from t1 group by product, country, year with rollup; --error 1235 -explain select product, country , year, sum(profit) from sales group by product, country, year with rollup; +explain select product, country , year, sum(profit) from t1 group by product, country, year with rollup; --error 1235 -select product, country , year, sum(profit) from sales group by product, country, year with cube union all select product, country , year, sum(profit) from sales group by product, country, year with rollup; -drop table sales; +select product, country , year, sum(profit) from t1 group by product, country, year with cube union all select product, country , year, sum(profit) from t1 group by product, country, year with rollup; +drop table t1; + diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 8291a475d5e..f7677709ca4 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -2,7 +2,9 @@ # Bug with order by # +--disable_warnings drop table if exists t1,t2,t3; +--enable_warnings CREATE TABLE t1 ( id int(6) DEFAULT '0' NOT NULL, @@ -168,7 +170,6 @@ drop table t1,t2,t3; #bug reported by Wouter de Jong -drop table if exists t1; CREATE TABLE t1 ( member_id int(11) NOT NULL auto_increment, inschrijf_datum varchar(20) NOT NULL default '', @@ -331,3 +332,24 @@ INSERT INTO t2 (numeropost,pseudo) VALUES (1,'joce'),(1,'bug'); SELECT titre,t1.numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; SELECT titre,t1.numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; drop table t1,t2; + +# +# Test of test_if_subkey() function +# + +CREATE TABLE t1 ( + FieldKey varchar(36) NOT NULL default '', + LongVal bigint(20) default NULL, + StringVal mediumtext, + KEY FieldKey (FieldKey), + KEY LongField (FieldKey,LongVal), + KEY StringField (FieldKey,StringVal(32)) +); +INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3'); +EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; +SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; +EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal; +SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal; +EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; +SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; +DROP TABLE t1; diff --git a/mysql-test/t/order_fill_sortbuf.test b/mysql-test/t/order_fill_sortbuf.test index 6419f2a93df..37620ebe331 100644 --- a/mysql-test/t/order_fill_sortbuf.test +++ b/mysql-test/t/order_fill_sortbuf.test @@ -3,7 +3,10 @@ # rows MySQL needs to use a merge during the sort phase. # +--disable_warnings drop table if exists t1,t2; +--enable_warnings + CREATE TABLE `t1` ( `id` int(11) NOT NULL default '0', `id2` int(11) NOT NULL default '0', diff --git a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test index c126d221bd2..a944df01051 100644 --- a/mysql-test/t/outfile.test +++ b/mysql-test/t/outfile.test @@ -21,3 +21,8 @@ #select * into dumpfile "/tmp/select-test.99" from t1; #select load_file("/tmp/select-test.not-exist"); #drop table t1; +#drop table if exists t; +#CREATE TABLE t ( t timestamp NOT NULL, c char(200) character set latin1 NOT NULL default '', i int(11), v varchar(200), b blob, KEY t (t)) TYPE=MyISAM; +#INSERT INTO t VALUES ('2002-12-20 12:01:20','',1,"aaa","bbb"); +#select * from t into outfile "check"; +#drop table if exists t; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index dd092866e44..47ea2d06d0a 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -10,7 +10,10 @@ flush query cache; # This crashed in some versions flush query cache; # This crashed in some versions reset query cache; flush status; +--disable_warnings +drop database if exists mysqltest; drop table if exists t1,t2,t3,t11,t21, mysqltest.t1; +--enable_warnings # # First simple test @@ -368,6 +371,7 @@ select * from t2; show status like "Qcache_queries_in_cache"; select * from t3; show status like "Qcache_queries_in_cache"; +update t1 set i=(select distinct 1 from (select * from t2) a); drop table t1, t2, t3; # diff --git a/mysql-test/t/raid.test b/mysql-test/t/raid.test index 8b608c1069f..38c740201bc 100644 --- a/mysql-test/t/raid.test +++ b/mysql-test/t/raid.test @@ -5,7 +5,10 @@ show variables like "have_raid"; # Test of raided tables # +--disable_warnings DROP TABLE IF EXISTS t1,t2; +--enable_warnings + CREATE TABLE t1 ( id int unsigned not null auto_increment primary key, c char(255) not null diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 278807eeea4..31b3ced6cc6 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -2,7 +2,10 @@ # Problem med range optimizer # +--disable_warnings drop table if exists t1; +--enable_warnings + CREATE TABLE t1 ( event_date date DEFAULT '0000-00-00' NOT NULL, type int(11) DEFAULT '0' NOT NULL, diff --git a/mysql-test/t/rename.test b/mysql-test/t/rename.test index ce4651d8de3..48a9cb401d9 100644 --- a/mysql-test/t/rename.test +++ b/mysql-test/t/rename.test @@ -2,7 +2,10 @@ # Test of rename table # +--disable_warnings drop table if exists t0,t1,t2,t3,t4; +--enable_warnings + create table t0 SELECT 1,"table 1"; create table t2 SELECT 2,"table 2"; create table t3 SELECT 3,"table 3"; @@ -29,4 +32,6 @@ rename table t3 to t4, t5 to t3, t1 to t2, t4 to t1; select * from t1; select * from t2; select * from t3; + +# This should give a warning for t4 drop table if exists t1,t2,t3,t4; diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair.test index 6d79014b23d..bdc5a57a07c 100644 --- a/mysql-test/t/repair.test +++ b/mysql-test/t/repair.test @@ -2,7 +2,10 @@ # Test of repair table # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 SELECT 1,"table 1"; repair table t1 use_frm; drop table if exists t1; diff --git a/mysql-test/t/replace.test b/mysql-test/t/replace.test index e9e01615a62..2afce2fcc84 100644 --- a/mysql-test/t/replace.test +++ b/mysql-test/t/replace.test @@ -4,7 +4,9 @@ # Test of REPLACE with ISAM and MyISAM and HEAP # +--disable_warnings drop table if exists t1; +--enable_warnings CREATE TABLE t1 ( gesuchnr int(11) DEFAULT '0' NOT NULL, @@ -25,12 +27,13 @@ drop table t1; # Test when using replace on a key that has used up it's whole range # -create table t1 (a tinyint not null auto_increment primary key, b char(20)); -insert into t1 values (126,"first"),(0,"last"); +create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value"); +insert into t1 values (126,"first"),(63, "middle"),(0,"last"); --error 1062 insert into t1 values (0,"error"); --error 1062 replace into t1 values (0,"error"); replace into t1 values (126,"first updated"); +replace into t1 values (63,default); select * from t1; drop table t1; diff --git a/mysql-test/t/rollback.test b/mysql-test/t/rollback.test index 6ea2cca887f..1673f1648d3 100644 --- a/mysql-test/t/rollback.test +++ b/mysql-test/t/rollback.test @@ -2,13 +2,20 @@ # This test should fail as MyISAM doesn't have rollback # +--disable_warnings drop table if exists t1; +--enable_warnings create table t1 (n int not null primary key) type=myisam; begin work; insert into t1 values (4); insert into t1 values (5); -# Should give an error -!$1196 rollback; +rollback; +select @@warning_count; +select @@error_count; +show warnings; +show errors; select * from t1; +select @@warning_count; +show warnings; drop table t1; diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test new file mode 100644 index 00000000000..fb5fff86b11 --- /dev/null +++ b/mysql-test/t/row.test @@ -0,0 +1,83 @@ +# Initialise +--disable_warnings +drop table if exists t1; +--enable_warnings + +select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3)); +select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3)); +select row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); +select row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); +select row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a')); +select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3)); +select row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3)); +select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); +select row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); +select row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3)); +select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3)); +select (1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4))); +-- error 1239 +select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4)); +select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))); + +SELECT (1,2,3)=(0,NULL,3); +SELECT (1,2,3)=(1,NULL,3); +# here's something for Sanja to fix :) +SELECT (1,2,3)=(1,NULL,0); + +SELECT ROW(1,2,3)=ROW(1,2,3); +SELECT ROW(2,2,3)=ROW(1+1,2,3); +SELECT ROW(1,2,3)=ROW(1+1,2,3); +SELECT ROW(1,2,3)<ROW(1+1,2,3); +SELECT ROW(1,2,3)>ROW(1+1,2,3); +SELECT ROW(1,2,3)<=ROW(1+1,2,3); +SELECT ROW(1,2,3)>=ROW(1+1,2,3); +SELECT ROW(1,2,3)<>ROW(1+1,2,3); +SELECT ROW(NULL,2,3)=ROW(NULL,2,3); +SELECT ROW(NULL,2,3)<=>ROW(NULL,2,3); +SELECT ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5)); +SELECT ROW('test',2,3.33)=ROW('test',2,3.33); +-- error 1239 +SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4); +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33)); +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3)); +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL)); +-- error 1239 +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,4); + +create table t1 ( a int, b int, c int); +insert into t1 values (1,2,3), (2,3,1), (3,2,1), (1,2,NULL); +select * from t1 where ROW(1,2,3)=ROW(a,b,c); +select * from t1 where ROW(0,2,3)=ROW(a,b,c); +select * from t1 where ROW(1,2,3)<ROW(a,b,c); +select ROW(a,2,3) IN(row(1,b,c), row(2,3,1)) from t1; +select ROW(c,2,3) IN(row(1,b,a), row(2,3,1)) from t1; +select ROW(a,b,c) IN(row(1,2,3), row(3,2,1)) from t1; +select ROW(1,2,3) IN(row(a,b,c), row(1,2,3)) from t1; +drop table t1; + +-- error 1239 +select ROW(1,1); + +create table t1 (i int); +-- error 1239 +select 1 from t1 where ROW(1,1); +-- error 1239 +select count(*) from t1 order by ROW(1,1); +-- error 1239 +select count(*) from t1 having (1,1) order by i; +drop table t1; + +create table t1 (a int, b int); +insert into t1 values (1, 4); +insert into t1 values (10, 40); +insert into t1 values (1, 4); +insert into t1 values (10, 43); +insert into t1 values (1, 4); +insert into t1 values (10, 41); +insert into t1 values (1, 4); +insert into t1 values (10, 43); +insert into t1 values (1, 4); +select a, MAX(b), (1, MAX(b)) = (1, 4) from t1 group by a; +drop table t1; +SELECT ROW(2,10) <=> ROW(3,4); +SELECT ROW(NULL,10) <=> ROW(3,NULL); diff --git a/mysql-test/t/rpl000001.test b/mysql-test/t/rpl000001.test index 4ffd7d1d78e..d562a47ef90 100644 --- a/mysql-test/t/rpl000001.test +++ b/mysql-test/t/rpl000001.test @@ -1,5 +1,5 @@ source include/master-slave.inc; -drop table if exists t1,t2,t3; + create table t1 (word char(20) not null); load data infile '../../std_data/words.dat' into table t1; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR @@ -12,11 +12,11 @@ select * from t1 limit 10; save_master_pos; connection slave; sync_with_master; -slave stop; +stop slave; connection master; set password for root@"localhost" = password('foo'); connection slave; -slave start; +start slave; connection master; # # Give slave time to do at last one failed connect retry @@ -43,7 +43,7 @@ sync_with_master; connection master; reset master; connection slave; -slave stop; +stop slave; reset slave; connection master; @@ -62,7 +62,7 @@ enable_query_log; # Try to cause a large relay log lag on the slave connection slave; select get_lock("hold_slave",10); -slave start; +start slave; #hope this is long enough for I/O thread to fetch over 16K relay log data sleep 3; select release_lock("hold_slave"); @@ -100,7 +100,7 @@ wait_for_slave_to_stop; # show slave status; set global sql_slave_skip_counter=1; -slave start; +start slave; select count(*) from t1; connection master1; drop table t1; diff --git a/mysql-test/t/rpl000002.test b/mysql-test/t/rpl000002.test index caf0b4ef6d8..803eb069b66 100644 --- a/mysql-test/t/rpl000002.test +++ b/mysql-test/t/rpl000002.test @@ -1,33 +1,26 @@ source include/master-slave.inc; -drop table if exists t1; + create table t1 (n int auto_increment primary key); set insert_id = 2000; insert into t1 values (NULL),(NULL),(NULL); -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; select * from t1; connection master; --replace_result $SLAVE_MYPORT 9999 show slave hosts; drop table t1; -save_master_pos; -connection slave; -sync_with_master; -slave stop; +sync_slave_with_master; +stop slave; connection master; -drop table if exists t2; create table t2(id int auto_increment primary key, created datetime); set timestamp=12345; insert into t2 set created=now(); select * from t2; save_master_pos; connection slave; -slave start; +start slave; sync_with_master; select * from t2; connection master; drop table t2; -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; diff --git a/mysql-test/t/rpl000003.test b/mysql-test/t/rpl000003.test deleted file mode 100644 index f994ed94371..00000000000 --- a/mysql-test/t/rpl000003.test +++ /dev/null @@ -1,14 +0,0 @@ -source include/master-slave.inc; -drop table if exists t1; -create table t1(n int primary key); -!insert into t1 values (1),(2),(2); -insert into t1 values (3); -save_master_pos; -connection slave; -sync_with_master; -select * from t1; -connection master; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; diff --git a/mysql-test/t/rpl000004.test b/mysql-test/t/rpl000004.test index 705e0d51b7b..8fc2977faab 100644 --- a/mysql-test/t/rpl000004.test +++ b/mysql-test/t/rpl000004.test @@ -1,18 +1,14 @@ source include/master-slave.inc; + set SQL_LOG_BIN=0; -drop table if exists t1; create table t1 (word char(20) not null, index(word)); load data infile '../../std_data/words.dat' into table t1; -drop table if exists t2; create table t2 (word char(20) not null); load data infile '../../std_data/words.dat' into table t2; create table t3 (word char(20) not null primary key); connection slave; -drop table if exists t1; load table t1 from master; -drop table if exists t2; load table t2 from master; -drop table if exists t3; load table t3 from master; check table t1; select count(*) from t2; diff --git a/mysql-test/t/rpl000005.test b/mysql-test/t/rpl000005.test index 1cfea242b69..ae713633df3 100644 --- a/mysql-test/t/rpl000005.test +++ b/mysql-test/t/rpl000005.test @@ -1,5 +1,5 @@ source include/master-slave.inc; -drop table if exists t1; + CREATE TABLE t1 (name varchar(64), age smallint(3)); INSERT INTO t1 SET name='Andy', age=31; INSERT t1 SET name='Jacob', age=2; diff --git a/mysql-test/t/rpl000006.test b/mysql-test/t/rpl000006.test index ad8622c2a81..c6438062bb7 100644 --- a/mysql-test/t/rpl000006.test +++ b/mysql-test/t/rpl000006.test @@ -5,12 +5,10 @@ source include/master-slave.inc; # Don't log table creating to the slave as we want to test LOAD TABLE set SQL_LOG_BIN=0,timestamp=200006; -drop table if exists t1; create table t1(t timestamp not null,a char(1)); insert into t1 ( a) values ('F'); select unix_timestamp(t) from t1; connection slave; -drop table if exists t1; load table t1 from master; select unix_timestamp(t) from t1; diff --git a/mysql-test/t/rpl000008-slave.opt b/mysql-test/t/rpl000008-slave.opt index 79b3bf6174b..177f89e0910 100644 --- a/mysql-test/t/rpl000008-slave.opt +++ b/mysql-test/t/rpl000008-slave.opt @@ -1 +1 @@ ---replicate-ignore-table=test.foo +--replicate-ignore-table=test.mysqltest_foo diff --git a/mysql-test/t/rpl000008.test b/mysql-test/t/rpl000008.test index 12760008b6d..ea782b99d28 100644 --- a/mysql-test/t/rpl000008.test +++ b/mysql-test/t/rpl000008.test @@ -1,29 +1,36 @@ -#this one assumes we are ignoring updates on table foo, but doing -#the ones on all other tables +# This one assumes we are ignoring updates on table mysqltest_foo, but doing +# the ones on all other tables + source include/master-slave.inc; connection slave; + +# +# For this test we must be in the test database +# use test; -drop table if exists foo; -create table foo (n int); -insert into foo values(4); + +--disable_warnings +drop table if exists mysqltest_foo; +drop table if exists mysqltest_bar; +--enable_warnings + +create table mysqltest_foo (n int); +insert into mysqltest_foo values(4); connection master; use test; -drop table if exists foo; -create table foo (n int); -insert into foo values(5); -drop table if exists bar; -create table bar (m int); -insert into bar values(15); -drop table if exists choo; -create table choo (k int); -insert into choo values(55); +create table mysqltest_foo (n int); +insert into mysqltest_foo values(5); +create table mysqltest_bar (m int); +insert into mysqltest_bar values(15); +create table t1 (k int); +insert into t1 values(55); save_master_pos; connection slave; sync_with_master; -select foo.n,bar.m,choo.k from foo,bar,choo; +select mysqltest_foo.n,mysqltest_bar.m,t1.k from mysqltest_foo,mysqltest_bar,t1; connection master; -drop table if exists foo,bar,choo; +drop table mysqltest_foo,mysqltest_bar,t1; save_master_pos; connection slave; sync_with_master; -drop table if exists foo,bar,choo; +drop table mysqltest_foo,mysqltest_bar,t1; diff --git a/mysql-test/t/rpl000009-slave.opt b/mysql-test/t/rpl000009-slave.opt index 245e310c5d8..c015c02ba78 100644 --- a/mysql-test/t/rpl000009-slave.opt +++ b/mysql-test/t/rpl000009-slave.opt @@ -1 +1 @@ ---replicate-wild-do-table=bar.% +--replicate-wild-do-table=mysqltest.% diff --git a/mysql-test/t/rpl000009.test b/mysql-test/t/rpl000009.test index 5f55355271a..ffec20c793e 100644 --- a/mysql-test/t/rpl000009.test +++ b/mysql-test/t/rpl000009.test @@ -1,38 +1,38 @@ -# This one assumes we are ignoring updates on tables in database foo, but doing -# the ones in database bar +# This one assumes we are ignoring updates on tables in database mysqltest2, +# but doing the ones in database mysqltest source include/master-slave.inc; -drop database if exists foo; -create database foo; -drop database if exists bar; -create database bar; +--disable_warnings +drop database if exists mysqltest2; +create database mysqltest2; +drop database if exists mysqltest; +create database mysqltest; +--enable_warnings + save_master_pos; connection slave; sync_with_master; -create database foo; -drop table if exists foo.foo; -create table foo.foo (n int); -insert into foo.foo values(4); +create database mysqltest2; +create table mysqltest2.foo (n int); +insert into mysqltest2.foo values(4); connection master; -drop table if exists foo.foo; -create table foo.foo (n int); -insert into foo.foo values(5); -drop table if exists bar.bar; -create table bar.bar (m int); -insert into bar.bar values(15); +create table mysqltest2.foo (n int); +insert into mysqltest2.foo values(5); +create table mysqltest.bar (m int); +insert into mysqltest.bar values(15); save_master_pos; connection slave; sync_with_master; -select foo.foo.n,bar.bar.m from foo.foo,bar.bar; +select mysqltest2.foo.n,mysqltest.bar.m from mysqltest2.foo,mysqltest.bar; connection master; -drop database bar; -drop database if exists foo; +drop database mysqltest; +drop database if exists mysqltest2; save_master_pos; connection slave; sync_with_master; --error 1008 -drop database bar; -drop database foo; +drop database mysqltest; +drop database mysqltest2; # Now let's test load data from master @@ -40,19 +40,19 @@ drop database foo; connection master; set sql_log_bin = 0; -create database foo; -create database bar; +create database mysqltest2; +create database mysqltest; show databases; -create table foo.t1(n int, s char(20)); -create table foo.t2(n int, s text); -insert into foo.t1 values (1, 'one'), (2, 'two'), (3, 'three'); -insert into foo.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen'); +create table mysqltest2.t1(n int, s char(20)); +create table mysqltest2.t2(n int, s text); +insert into mysqltest2.t1 values (1, 'one'), (2, 'two'), (3, 'three'); +insert into mysqltest2.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen'); -create table bar.t1(n int, s char(20)); -create table bar.t2(n int, s text); -insert into bar.t1 values (1, 'one bar'), (2, 'two bar'), (3, 'three bar'); -insert into bar.t2 values (11, 'eleven bar'), (12, 'twelve bar'), - (13, 'thirteen bar'); +create table mysqltest.t1(n int, s char(20)); +create table mysqltest.t2(n int, s text); +insert into mysqltest.t1 values (1, 'one test'), (2, 'two test'), (3, 'three test'); +insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'), + (13, 'thirteen test'); set sql_log_bin = 1; save_master_pos; connection slave; @@ -64,26 +64,25 @@ load data from master; # Now let's check if we have the right tables and the right data in them show databases; -use foo; +use mysqltest2; show tables; -use bar; +use mysqltest; show tables; -select * from bar.t1; -select * from bar.t2; +select * from mysqltest.t1; +select * from mysqltest.t2; # Now let's see if replication works connection master; -insert into bar.t1 values (4, 'four bar'); +insert into mysqltest.t1 values (4, 'four test'); save_master_pos; connection slave; sync_with_master; -select * from bar.t1; +select * from mysqltest.t1; # Now time for cleanup connection master; -drop database bar; -drop database foo; +drop database mysqltest; +drop database mysqltest2; save_master_pos; connection slave; sync_with_master; - diff --git a/mysql-test/t/rpl000010.test b/mysql-test/t/rpl000010.test index 05a211fbd85..0725214694a 100644 --- a/mysql-test/t/rpl000010.test +++ b/mysql-test/t/rpl000010.test @@ -1,10 +1,8 @@ -#this tests the offset off by 22 mystery bug -#must run slave with --disconnect-slave-event-count=1 --master-connect-retry=1 +# This tests the offset off by 22 mystery bug +# Must run slave with --disconnect-slave-event-count=1 --master-connect-retry=1 + source include/master-slave.inc; -connection slave; -drop table if exists t1; -connection master; -drop table if exists t1; + create table t1 (n int not null auto_increment primary key); insert into t1 values(NULL); insert into t1 values(2); diff --git a/mysql-test/t/rpl000011.test b/mysql-test/t/rpl000011.test index d75937e3f81..3b00afe10e4 100644 --- a/mysql-test/t/rpl000011.test +++ b/mysql-test/t/rpl000011.test @@ -1,21 +1,15 @@ source include/master-slave.inc; -drop table if exists t1; + create table t1 (n int); insert into t1 values(1); -save_master_pos; -connection slave; -sync_with_master; -slave stop; -slave start; +sync_slave_with_master; +stop slave; +start slave; connection master; insert into t1 values(2); -save_master_pos; -connection slave; #let slave catch up -sync_with_master; +sync_slave_with_master; select * from t1; connection master; drop table t1; -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; diff --git a/mysql-test/t/rpl000012.test b/mysql-test/t/rpl000012.test index 9f8ba9a4f91..7f440eaaa13 100644 --- a/mysql-test/t/rpl000012.test +++ b/mysql-test/t/rpl000012.test @@ -1,18 +1,16 @@ source include/master-slave.inc; connection master; -drop table if exists t1,t2,t3; create table t2 (n int); create temporary table t1 (n int); insert into t1 values(1),(2),(3); insert into t2 select * from t1; -drop table if exists test.t3; -create temporary table test.t3 (n int not null); -alter table test.t3 add primary key(n); +create temporary table t3 (n int not null); +alter table t3 add primary key(n); flush logs; insert into t3 values (100); insert into t2 select * from t3; -drop table if exists test.t3; +drop table if exists t3; insert into t2 values (101); connection master1; create temporary table t1 (n int); diff --git a/mysql-test/t/rpl000013.test b/mysql-test/t/rpl000013.test index 14619796e01..94d5feb3925 100644 --- a/mysql-test/t/rpl000013.test +++ b/mysql-test/t/rpl000013.test @@ -3,7 +3,7 @@ save_master_pos; connection slave; sync_with_master; connection master; -drop table if exists t2; + create table t2(n int); create temporary table t1 (n int); insert into t1 values(1),(2),(3); @@ -31,6 +31,10 @@ show status like 'Slave_open_temp_tables'; # connect (master2,localhost,root,,); connection master2; + +# We will get a warning for t1 as this is a temporary table that doesn't +# exist in this connection. + drop table if exists t1,t2; save_master_pos; connection slave; diff --git a/mysql-test/t/rpl000015.test b/mysql-test/t/rpl000015.test index 26d32ea3e11..b5234373355 100644 --- a/mysql-test/t/rpl000015.test +++ b/mysql-test/t/rpl000015.test @@ -18,20 +18,18 @@ eval change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=$MASTER_MYPORT; --replace_result $MASTER_MYPORT MASTER_PORT show slave status; -slave start; +start slave; sync_with_master; --replace_result $MASTER_MYPORT MASTER_PORT show slave status; connection master; +--disable_warnings drop table if exists t1; +--enable_warnings create table t1 (n int); insert into t1 values (10),(45),(90); -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; select * from t1; connection master; drop table t1; -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; diff --git a/mysql-test/t/rpl000016-slave.opt b/mysql-test/t/rpl000016-slave.opt deleted file mode 100644 index f27601e0d7d..00000000000 --- a/mysql-test/t/rpl000016-slave.opt +++ /dev/null @@ -1 +0,0 @@ --O max_binlog_size=2048 diff --git a/mysql-test/t/rpl000017-slave.sh b/mysql-test/t/rpl000017-slave.sh index 066b4880cc1..4dbbaec31ce 100755 --- a/mysql-test/t/rpl000017-slave.sh +++ b/mysql-test/t/rpl000017-slave.sh @@ -1,11 +1,11 @@ rm -f $MYSQL_TEST_DIR/var/log/*relay* rm -f $MYSQL_TEST_DIR/var/slave-data/relay-log.info cat > $MYSQL_TEST_DIR/var/slave-data/master.info <<EOF -master-bin.001 +master-bin.000001 4 127.0.0.1 replicate -aaaaaaaaaaaaaaabthispartofthepasswordisnotused +aaaaaaaaaaaaaaab $MASTER_MYPORT 1 0 diff --git a/mysql-test/t/rpl000017.test b/mysql-test/t/rpl000017.test index d4f41f1e374..cf808a2cbc0 100644 --- a/mysql-test/t/rpl000017.test +++ b/mysql-test/t/rpl000017.test @@ -5,17 +5,15 @@ reset master; grant replication slave on *.* to replicate@localhost identified by 'aaaaaaaaaaaaaaab'; grant replication slave on *.* to replicate@127.0.0.1 identified by 'aaaaaaaaaaaaaaab'; connection slave; -slave start; +start slave; connection master; +--disable_warnings drop table if exists t1; +--enable_warnings create table t1(n int); insert into t1 values(24); -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; select * from t1; connection master; drop table t1; -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; diff --git a/mysql-test/t/rpl000018.test b/mysql-test/t/rpl000018.test index 291b482b912..b8c09ed431d 100644 --- a/mysql-test/t/rpl000018.test +++ b/mysql-test/t/rpl000018.test @@ -10,18 +10,16 @@ server_stop master; server_start master; connection slave; reset slave; -slave start; +start slave; connection master; -show master logs; +show binary logs; +--disable_warnings drop table if exists t1; +--enable_warnings create table t1(n int); insert into t1 values (3351); -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; select * from t1; connection master; drop table t1; -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_alter.test b/mysql-test/t/rpl_alter.test index 710dd2d09d6..6b8cf773150 100644 --- a/mysql-test/t/rpl_alter.test +++ b/mysql-test/t/rpl_alter.test @@ -1,19 +1,22 @@ source include/master-slave.inc; -drop database if exists d1; -create database d1; -create table d1.t1 ( n int); -alter table d1.t1 add m int; -insert into d1.t1 values (1,2); -create table d1.t2 (n int); -insert into d1.t2 values (45); -rename table d1.t2 to d1.t3, d1.t1 to d1.t2; +--disable_warnings +drop database if exists test_$1; +--enable_warnings +create database test_$1; + +create table test_$1.t1 ( n int); +alter table test_$1.t1 add m int; +insert into test_$1.t1 values (1,2); +create table test_$1.t2 (n int); +insert into test_$1.t2 values (45); +rename table test_$1.t2 to test_$1.t3, test_$1.t1 to test_$1.t2; save_master_pos; connection slave; sync_with_master; -select * from d1.t2; -select * from d1.t3; +select * from test_$1.t2; +select * from test_$1.t3; connection master; -drop database d1; +drop database test_$1; save_master_pos; connection slave; sync_with_master; diff --git a/mysql-test/t/rpl_empty_master_crash.test b/mysql-test/t/rpl_empty_master_crash.test index afa76ce10bb..9d5a7a173b0 100644 --- a/mysql-test/t/rpl_empty_master_crash.test +++ b/mysql-test/t/rpl_empty_master_crash.test @@ -1,6 +1,7 @@ source include/master-slave.inc; -drop table if exists t1; + show slave status; + # # Load table should not succeed on the master as this is not a slave # diff --git a/mysql-test/t/rpl_failsafe.test b/mysql-test/t/rpl_failsafe.test index 866efbce5bf..ae61b061153 100644 --- a/mysql-test/t/rpl_failsafe.test +++ b/mysql-test/t/rpl_failsafe.test @@ -7,18 +7,16 @@ show variables like 'rpl_recovery_rank'; show status like 'Rpl_status'; create table t1(n int); drop table t1; -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; show variables like 'rpl_recovery_rank'; show status like 'Rpl_status'; connection slave_sec; -slave start; +start slave; sync_with_master; show variables like 'rpl_recovery_rank'; show status like 'Rpl_status'; connection slave_ter; -slave start; +start slave; sync_with_master; show variables like 'rpl_recovery_rank'; show status like 'Rpl_status'; diff --git a/mysql-test/t/rpl_flush_log_loop.test b/mysql-test/t/rpl_flush_log_loop.test index c68fbb7111a..62bcf2c8b33 100644 --- a/mysql-test/t/rpl_flush_log_loop.test +++ b/mysql-test/t/rpl_flush_log_loop.test @@ -7,13 +7,13 @@ connection slave; --replace_result $MASTER_MYPORT MASTER_PORT eval change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=$MASTER_MYPORT; -slave start; +start slave; connection master; -slave stop; +stop slave; --replace_result $SLAVE_MYPORT SLAVE_PORT eval change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=$SLAVE_MYPORT; -slave start; +start slave; flush logs; sleep 5; --replace_result $SLAVE_MYPORT SLAVE_PORT diff --git a/mysql-test/t/rpl_insert_id.test b/mysql-test/t/rpl_insert_id.test index 3f3636d3082..93062f39c20 100644 --- a/mysql-test/t/rpl_insert_id.test +++ b/mysql-test/t/rpl_insert_id.test @@ -1,9 +1,7 @@ -#see if queries that use both -#auto_increment and LAST_INSERT_ID() -#are replicated well +# See if queries that use both auto_increment and LAST_INSERT_ID() +# are replicated well source include/master-slave.inc; connection master; -drop table if exists t1; create table t1(a int auto_increment, key(a)); create table t2(b int auto_increment, c int, key(b)); insert into t1 values (1),(2),(3); diff --git a/mysql-test/t/rpl_log.test b/mysql-test/t/rpl_log.test index 85782e78142..faca1a6c339 100644 --- a/mysql-test/t/rpl_log.test +++ b/mysql-test/t/rpl_log.test @@ -1,8 +1,18 @@ source include/master-slave.inc; -#clean up slave binlogs +# Clean up old slave's binlogs. +# The slave is started with --log-slave-updates +# and this test does SHOW BINLOG EVENTS on the slave's +# binlog. But previous tests can influence the current test's +# binlog (e.g. a temporary table in the previous test has not +# been explicitly deleted, and at the beginning of the current +# test the slave immediately writes DROP TEMPORARY TABLE this_old_table). +# We wait for the slave to have written all he wants to the binlog +# (otherwise RESET MASTER may come too early). +save_master_pos; connection slave; -slave stop; +sync_with_master; +stop slave; reset master; reset slave; let $VERSION=`select version()`; @@ -26,10 +36,10 @@ flush logs; save_master_pos; connection slave; -slave start; +start slave; sync_with_master; flush logs; -slave stop; +stop slave; connection master; # Create some entries for second log @@ -39,27 +49,27 @@ insert into t1 values (1); drop table t1; --replace_result $VERSION VERSION show binlog events; -show binlog events in 'master-bin.002'; -show master logs; +show binlog events in 'master-bin.000002'; +show binary logs; save_master_pos; connection slave; -slave start; +start slave; sync_with_master; -show master logs; +show binary logs; --replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT $VERSION VERSION -show binlog events in 'slave-bin.001' from 4; +show binlog events in 'slave-bin.000001' from 4; --replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT $VERSION VERSION -show binlog events in 'slave-bin.002' from 4; +show binlog events in 'slave-bin.000002' from 4; --replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT show slave status; # Need to recode the following -#show new master for slave with master_log_file='master-bin.001' and master_log_pos=4 and master_server_id=1; -#show new master for slave with master_log_file='master-bin.001' and master_log_pos=79 and master_server_id=1; -#show new master for slave with master_log_file='master-bin.001' and master_log_pos=311 and master_server_id=1; -#show new master for slave with master_log_file='master-bin.002' and master_log_pos=4 and master_server_id=1; -#show new master for slave with master_log_file='master-bin.002' and master_log_pos=122 and master_server_id=1; +#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=4 and master_server_id=1; +#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=79 and master_server_id=1; +#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=311 and master_server_id=1; +#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=4 and master_server_id=1; +#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=122 and master_server_id=1; --error 1220 -show binlog events in 'slave-bin.005' from 4; +show binlog events in 'slave-bin.000005' from 4; diff --git a/mysql-test/t/rpl_log_pos.test b/mysql-test/t/rpl_log_pos.test index e11ba92cfa7..bc1349a959a 100644 --- a/mysql-test/t/rpl_log_pos.test +++ b/mysql-test/t/rpl_log_pos.test @@ -3,29 +3,28 @@ # source include/master-slave.inc; show master status; -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; --replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT show slave status; -slave stop; +stop slave; change master to master_log_pos=73; -slave start; +start slave; sleep 5; -slave stop; +stop slave; change master to master_log_pos=73; --replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT show slave status; -slave start; +start slave; sleep 5; --replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT show slave status; -slave stop; +stop slave; change master to master_log_pos=173; --replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT -slave start; +start slave; sleep 2; +--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT show slave status; connection master; show master status; @@ -35,13 +34,11 @@ create table t1 (n int); insert into t1 values (1),(2),(3); save_master_pos; connection slave; -slave stop; +stop slave; change master to master_log_pos=79; -slave start; +start slave; sync_with_master; select * from t1; connection master; drop table t1; -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_mystery22.test b/mysql-test/t/rpl_mystery22.test index 5280cb360dd..d49f1a210f4 100644 --- a/mysql-test/t/rpl_mystery22.test +++ b/mysql-test/t/rpl_mystery22.test @@ -4,9 +4,7 @@ source include/master-slave.inc; # first, cause a duplicate key problem on the slave create table t1(n int auto_increment primary key); -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; insert into t1 values (2); connection master; insert into t1 values(NULL); @@ -16,11 +14,11 @@ connection slave; sleep 3; # there is no way around this sleep - we have to wait until # the slave tries to run the query, fails and aborts slave thread delete from t1 where n = 2; -slave start; +start slave; sync_with_master; #now the buggy slave would be confused on the offset but it can replicate #in order to make it break, we need to stop/start the slave one more time -slave stop; +stop slave; connection master; # to be able to really confuse the slave, we need some non-auto-increment # events in the log @@ -29,7 +27,7 @@ drop table t2; insert into t1 values(NULL); save_master_pos; connection slave; -slave start; +start slave; #now the truth comes out - if the slave is buggy, it will never sync because #the slave thread is not able to read events sync_with_master; @@ -37,7 +35,5 @@ select * from t1; #clean up connection master; drop table t1; -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_redirect.test b/mysql-test/t/rpl_redirect.test index 4082542f295..181d200b761 100644 --- a/mysql-test/t/rpl_redirect.test +++ b/mysql-test/t/rpl_redirect.test @@ -19,7 +19,6 @@ rpl_probe; #turn on master/slave query direction auto-magic enable_rpl_parse; -drop table if exists t1; create table t1 ( n int); insert into t1 values (1),(2),(3),(4); disable_rpl_parse; diff --git a/mysql-test/t/rpl_replicate_do.test b/mysql-test/t/rpl_replicate_do.test index 0800062dc05..dcb3c5034fd 100644 --- a/mysql-test/t/rpl_replicate_do.test +++ b/mysql-test/t/rpl_replicate_do.test @@ -2,9 +2,12 @@ # updates on t1 source include/master-slave.inc; +--disable_warnings drop table if exists t11; connection slave; drop table if exists t11; +--enable_warnings + create table t2 (n int); insert into t2 values(4); connection master; @@ -24,7 +27,7 @@ select * from t2; --error 1146 select * from t11; connection master; -drop table if exists t1,t2,t3,t11; +drop table if exists t1,t2,t11; save_master_pos; connection slave; sync_with_master; diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 6edbf363b1a..0852eb584d5 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -1,5 +1,5 @@ # -# Test are run with max_binlog_size=2048 to force automatic rotation of the +# Test is run with max_binlog_size=2048 to force automatic rotation of the # binary log # Tests done: # - Check that slaves reports correct failures if master.info has strange @@ -8,19 +8,23 @@ # - Ensure that temporary tables works over flush logs and binary log # changes # - Test creating a duplicate key error and recover from it -# + connect (master,localhost,root,,test,$MASTER_MYPORT,master.sock); +--disable_warnings drop table if exists t1, t2, t3, t4; +--enable_warnings connect (slave,localhost,root,,test,$SLAVE_MYPORT,slave.sock); system cat /dev/null > var/slave-data/master.info; system chmod 000 var/slave-data/master.info; connection slave; +--disable_warnings drop table if exists t1, t2, t3, t4; +--enable_warnings --error 1201 -slave start; +start slave; system chmod 600 var/slave-data/master.info; --error 1201 -slave start; +start slave; --replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT # Will get error 13 on Unix systems becasue file is not readable !eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root'; @@ -30,7 +34,7 @@ eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master connection master; reset master; connection slave; -slave start; +start slave; connection master; # @@ -40,24 +44,19 @@ create temporary table temp_table (a char(80) not null); insert into temp_table values ("testing temporary tables"); create table t1 (s text); insert into t1 values('Could not break slave'),('Tried hard'); -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; --replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT show slave status; select * from t1; connection master; flush logs; -drop table if exists t2; create table t2(m int not null auto_increment primary key); insert into t2 values (34),(67),(123); flush logs; -show master logs; +show binary logs; create table t3 select * from temp_table; -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; select * from t3; connection master; @@ -83,21 +82,19 @@ wait_for_slave_to_stop; #restart slave skipping one event set global sql_slave_skip_counter=1; -slave start; +start slave; connection master; -save_master_pos; #let slave catch up -connection slave; -sync_with_master; +sync_slave_with_master; connection master; -purge master logs to 'master-bin.003'; -show master logs; +purge master logs to 'master-bin.000002'; +show binary logs; +purge logs before now(); +show binary logs; insert into t2 values (65); -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; --replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT show slave status; select * from t2; @@ -110,7 +107,7 @@ connection master; create temporary table temp_table (a char(80) not null); insert into temp_table values ("testing temporary tables part 2"); let $1=100; -drop table if exists t3; + create table t3 (n int); disable_query_log; while ($1) @@ -121,12 +118,12 @@ while ($1) } enable_query_log; create table t4 select * from temp_table; -show master logs; +show binary logs; show master status; save_master_pos; connection slave; -#slave stop; -#slave start; +#stop slave; +#start slave; sync_with_master; select * from t4; @@ -140,6 +137,4 @@ unlock tables; #clean up connection master; drop table if exists t1,t2,t3,t4; -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_skip_error.test b/mysql-test/t/rpl_skip_error.test index d43c59ef024..86c89c70314 100644 --- a/mysql-test/t/rpl_skip_error.test +++ b/mysql-test/t/rpl_skip_error.test @@ -1,5 +1,4 @@ source include/master-slave.inc; -drop table if exists t1; create table t1 (n int not null primary key); save_master_pos; diff --git a/mysql-test/t/rpl_sporadic_master.test b/mysql-test/t/rpl_sporadic_master.test index e59b93b4475..b24901c62a9 100644 --- a/mysql-test/t/rpl_sporadic_master.test +++ b/mysql-test/t/rpl_sporadic_master.test @@ -9,22 +9,16 @@ insert into t1 values (NULL),(NULL); truncate table t1; # We have to use 4 in the following to make this test work with all table types insert into t1 values (4),(NULL); -save_master_pos; -connection slave; -sync_with_master; -slave stop; -slave start; +sync_slave_with_master; +stop slave; +start slave; connection master; insert into t1 values (NULL),(NULL); flush logs; truncate table t1; insert into t1 values (10),(NULL),(NULL),(NULL),(NULL),(NULL); -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; select * from t1; connection master; drop table t1,t2; -save_master_pos; -connection slave; -sync_with_master; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test new file mode 100644 index 00000000000..f939856ea1f --- /dev/null +++ b/mysql-test/t/rpl_temporary.test @@ -0,0 +1,99 @@ +source include/master-slave.inc; + +# Clean up old slave's binlogs. +# The slave is started with --log-slave-updates +# and this test does SHOW BINLOG EVENTS on the slave's +# binlog. But previous tests can influence the current test's +# binlog (e.g. a temporary table in the previous test has not +# been explicitly deleted, or it has but the slave hasn't had +# enough time to catch it before STOP SLAVE, +# and at the beginning of the current +# test the slave immediately writes DROP TEMPORARY TABLE this_old_table). +# We wait for the slave to have written all he wants to the binlog +# (otherwise RESET MASTER may come too early). +save_master_pos; +connection slave; +sync_with_master; +reset master; +connection master; + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); + +let $VERSION=`select version()`; + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +create table t1(f int); +create table t2(f int); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +connection con1; +create temporary table t3(f int); +insert into t3 select * from t1 where f<6; +sleep 1; + +connection con2; +create temporary table t3(f int); +sleep 1; + +connection con1; +insert into t2 select count(*) from t3; +sleep 1; + +connection con2; +insert into t3 select * from t1 where f>=4; +sleep 1; + +connection con1; +drop temporary table t3; +sleep 1; + +connection con2; +insert into t2 select count(*) from t3; +drop temporary table t3; + +select * from t2; + +--replace_result $VERSION VERSION +show binlog events; + +drop table t1, t2; + +use test; +SET TIMESTAMP=1040323920; +create table t1(f int); +SET TIMESTAMP=1040323931; +create table t2(f int); +SET TIMESTAMP=1040323938; +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +SET TIMESTAMP=1040323945; +SET @@session.pseudo_thread_id=1; +create temporary table t3(f int); +SET TIMESTAMP=1040323952; +SET @@session.pseudo_thread_id=1; +insert into t3 select * from t1 where f<6; +SET TIMESTAMP=1040324145; +SET @@session.pseudo_thread_id=2; +create temporary table t3(f int); +SET TIMESTAMP=1040324186; +SET @@session.pseudo_thread_id=1; +insert into t2 select count(*) from t3; +SET TIMESTAMP=1040324200; +SET @@session.pseudo_thread_id=2; +insert into t3 select * from t1 where f>=4; +SET TIMESTAMP=1040324211; +SET @@session.pseudo_thread_id=1; +drop temporary table t3; +SET TIMESTAMP=1040324219; +SET @@session.pseudo_thread_id=2; +insert into t2 select count(*) from t3; +SET TIMESTAMP=1040324224; +SET @@session.pseudo_thread_id=2; +drop temporary table t3; + +select * from t2; +drop table t1,t2; diff --git a/mysql-test/t/rpl_user_variables.test b/mysql-test/t/rpl_user_variables.test new file mode 100644 index 00000000000..7eeccaf64f2 --- /dev/null +++ b/mysql-test/t/rpl_user_variables.test @@ -0,0 +1,49 @@ +# +# Test of replicating user variables +# +source include/master-slave.inc; + +# Clean up old slave's binlogs. +# The slave is started with --log-slave-updates +# and this test does SHOW BINLOG EVENTS on the slave's +# binlog. But previous tests can influence the current test's +# binlog (e.g. a temporary table in the previous test has not +# been explicitly deleted, or it has but the slave hasn't had +# enough time to catch it before STOP SLAVE, +# and at the beginning of the current +# test the slave immediately writes DROP TEMPORARY TABLE this_old_table). +# We wait for the slave to have written all he wants to the binlog +# (otherwise RESET MASTER may come too early). +save_master_pos; +connection slave; +sync_with_master; +reset master; +connection master; + +create table t1(n char(30)); +set @i1:=12345678901234, @i2:=-12345678901234, @i3:=0, @i4:=-1; +set @s1:='This is a test', @r1:=12.5, @r2:=-12.5; +set @n1:=null; +set @s2:='', @s3:='abc\'def', @s4:= 'abc\\def', @s5:= 'abc''def'; +insert into t1 values (@i1), (@i2), (@i3), (@i4); +insert into t1 values (@r1), (@r2); +insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5); +insert into t1 values (@n1); +insert into t1 values (@n2); +insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1); +insert into t1 values (@a+(@b:=@a+1)); +set @q:='abc'; +insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2')); +set @a:=5; +insert into t1 values (@a),(@a); +save_master_pos; +connection slave; +sync_with_master; +select * from t1; +show binlog events from 141; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; +stop slave; diff --git a/mysql-test/t/sel000001.test b/mysql-test/t/sel000001.test deleted file mode 100644 index 77355f8d535..00000000000 --- a/mysql-test/t/sel000001.test +++ /dev/null @@ -1,18 +0,0 @@ -# sel000001 -# -# Versions -# -------- -# 3.22 -# 3.23 -# -# Description -# ----------- -# This test is just a simple select. -# Testing WHERE clause. -# - -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 (s CHAR(20) PRIMARY KEY, id INT); -INSERT INTO t1 VALUES ('cat', 1), ('mouse', 3), ('dog', 2), ('snake', 77); -SELECT s, id FROM t1 WHERE s = 'mouse'; -drop table t1; diff --git a/mysql-test/t/sel000002.test b/mysql-test/t/sel000002.test deleted file mode 100644 index 9a89db2821c..00000000000 --- a/mysql-test/t/sel000002.test +++ /dev/null @@ -1,17 +0,0 @@ -# sel000002 -# -# Versions -# -------- -# 3.22 -# 3.23 -# -# Description -# ----------- -# This test is just a simple select. -# - -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 (n INT); -INSERT INTO t1 VALUES (1), (2), (3); -SELECT * FROM t1; -drop table t1; diff --git a/mysql-test/t/sel000003.test b/mysql-test/t/sel000003.test deleted file mode 100644 index a3f6a7337c2..00000000000 --- a/mysql-test/t/sel000003.test +++ /dev/null @@ -1,18 +0,0 @@ -# sel000003 -# -# Versions -# -------- -# 3.22 -# 3.23 -# -# Description -# ----------- -# This test is just a simple select. -# Testing count() function and GROUP BY clause. -# - -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 (name CHAR(20) NOT NULL PRIMARY KEY, score SMALLINT NOT NULL, KEY(score)); -INSERT INTO t1 VALUES ('Sasha', 20), ('Matt', 20), ('Monty', 10), ('David', 10), ('Tim', 10), ('Jeremy', 10); -SELECT COUNT(*) as n, score FROM t1 GROUP BY score; -drop table t1; diff --git a/mysql-test/t/sel000031.test b/mysql-test/t/sel000031.test deleted file mode 100644 index 29bafbb3040..00000000000 --- a/mysql-test/t/sel000031.test +++ /dev/null @@ -1,20 +0,0 @@ -# sel000031 -# -# Versions -# -------- -# 3.22 -# 3.23 -# -# Description -# ----------- -# test for a bug with elt() and order by - -drop table if exists t1,t2; -create table t1 (id int(10) not null unique); -create table t2 (id int(10) not null primary key, -val int(10) not null); -insert into t1 values (1),(2),(4); -insert into t2 values (1,1),(2,1),(3,1),(4,2); - -select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id; -drop table t1,t2; diff --git a/mysql-test/t/sel000032.test b/mysql-test/t/sel000032.test deleted file mode 100644 index d31ba69e9d8..00000000000 --- a/mysql-test/t/sel000032.test +++ /dev/null @@ -1,20 +0,0 @@ -# sel000032 -# -# Versions -# -------- -# 3.22 -# 3.23 -# -# Description -# ----------- -# test for a bug with elt() - -drop table if exists t1,t2; -create table t1 (id int(10) not null unique); -create table t2 (id int(10) not null primary key, -val int(10) not null); -insert into t1 values (1),(2),(4); -insert into t2 values (1,1),(2,1),(3,1),(4,2); - -select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id; -drop table t1,t2; diff --git a/mysql-test/t/sel000033.test b/mysql-test/t/sel000033.test index 165e43ad9f8..72e096311ce 100644 --- a/mysql-test/t/sel000033.test +++ b/mysql-test/t/sel000033.test @@ -9,7 +9,9 @@ # ----------- # test for a bug with in() and unique key +--disable_warnings drop table if exists t1; +--enable_warnings create table t1 (id int(10) primary key); insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); diff --git a/mysql-test/t/sel000100.test b/mysql-test/t/sel000100.test index cedb78b17e7..2f9c06d5cf4 100644 --- a/mysql-test/t/sel000100.test +++ b/mysql-test/t/sel000100.test @@ -1,4 +1,6 @@ +--disable_warnings DROP TABLE IF EXISTS t1,t2; +--enable_warnings CREATE TABLE t1 ( ID int(11) NOT NULL auto_increment, diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index de90eeec2e8..3c26cf1903b 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -6,7 +6,9 @@ # Simple select test # +--disable_warnings drop table if exists t1,t2,t3,t4; +--enable_warnings CREATE TABLE t1 ( Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, @@ -1487,8 +1489,6 @@ select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2. # We need another table for join stuff.. # -drop table if exists company; - create table t4 ( companynr tinyint(2) unsigned zerofill NOT NULL default '00', companyname char(30) NOT NULL default '', @@ -1575,8 +1575,8 @@ select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld select count(*) from t1; select companynr,count(*),sum(fld1) from t2 group by companynr; select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; -select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1) from t2 where companynr = 34 and fld4<>""; -select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1) from t2 group by companynr limit 3; +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10; select /*! SQL_SMALL_RESULT */ companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10; select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; @@ -1765,6 +1765,10 @@ select wss_type from t1 where wss_type ='102935229216544104'; select wss_type from t1 where wss_type ='102935229216544093'; select wss_type from t1 where wss_type =102935229216544093; drop table t1; +select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +select @a; +select @b; +select @c; # # Test of removing redundant braces in the FROM part @@ -1817,4 +1821,3 @@ CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) TYPE=M INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; drop table t1,t2; - diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test index 0a483c860cb..06624d50a43 100644 --- a/mysql-test/t/select_found.test +++ b/mysql-test/t/select_found.test @@ -1,8 +1,10 @@ # # Testing of found_rows() # - +--disable_warnings drop table if exists t1,t2; +--enable_warnings + create table t1 (a int not null auto_increment, b int not null, primary key(a)); insert into t1 (b) values (2),(3),(5),(5),(5),(6),(7),(9); select SQL_CALC_FOUND_ROWS * from t1; @@ -84,4 +86,12 @@ INSERT INTO t1 (titre,maxnumrep) VALUES ('test1','1'),('test2','2'),('test3','3'); SELECT SQL_CALC_FOUND_ROWS titre,numeropost,maxnumrep FROM t1 WHERE numeropost IN (1,2) ORDER BY maxnumrep DESC LIMIT 0, 1; SELECT FOUND_ROWS(); +SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) as a LIMIT 0; +SELECT FOUND_ROWS(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1 LIMIT 0; +SELECT FOUND_ROWS(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 0; +SELECT FOUND_ROWS(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 ORDER BY numeropost LIMIT 0; +SELECT FOUND_ROWS(); drop table t1; diff --git a/mysql-test/t/select_safe.test b/mysql-test/t/select_safe.test index e76b7558997..cd8bce6369c 100644 --- a/mysql-test/t/select_safe.test +++ b/mysql-test/t/select_safe.test @@ -2,7 +2,10 @@ # test of safe selects # +--disable_warnings drop table if exists t1; +--enable_warnings + SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=4, SQL_MAX_JOIN_SIZE=9; create table t1 (a int primary key, b char(20)); insert into t1 values(1,"test"); diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index ba6fa930e22..f6f0ac0b82b 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -2,7 +2,10 @@ # Test of some show commands # +--disable_warnings drop table if exists t1,t2; +--enable_warnings + create table t1 (a int not null primary key, b int not null,c int not null, key(b,c)); insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4); check table t1 fast; @@ -49,9 +52,11 @@ drop table t2; create table t1 ( test_set set( 'val1', 'val2', 'val3' ) not null default '', - name char(20) default 'O''Brien' + name char(20) default 'O''Brien' comment 'O''Brien as default', + c int not null comment 'int column' ) comment = 'it\'s a table' ; show create table t1 ; +show full columns from t1; drop table t1; create table t1 (a int not null, unique aa (a)); @@ -78,6 +83,7 @@ drop table t1; create table t1 (a decimal(9,2), b decimal (9,0), e double(9,2), f double(5,0), h float(3,2), i float(3,0)); show columns from t1; +show full columns from t1; drop table t1; # diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test new file mode 100644 index 00000000000..fd464f74de4 --- /dev/null +++ b/mysql-test/t/sql_mode.test @@ -0,0 +1,30 @@ +--disable_warnings +drop table if exists t1; +--enable_warnings + +CREATE TABLE `t1` ( + a int not null auto_increment, + `pseudo` varchar(35) character set latin2 NOT NULL default '', + `email` varchar(60) character set latin2 NOT NULL default '', + PRIMARY KEY (a), + UNIQUE KEY `email` USING BTREE (`email`) +) TYPE=HEAP CHARSET=latin1 ROW_FORMAT DYNAMIC; +set @@sql_mode=""; +show variables like 'sql_mode'; +show create table t1; +set @@sql_mode="ansi_quotes"; +show variables like 'sql_mode'; +show create table t1; +set @@sql_mode="no_table_options"; +show variables like 'sql_mode'; +show create table t1; +set @@sql_mode="no_key_options"; +show variables like 'sql_mode'; +show create table t1; +set @@sql_mode="no_field_options,mysql323,mysql40"; +show variables like 'sql_mode'; +show create table t1; +set @@sql_mode="postgresql,oracle,mssql,db2,sapdb"; +show variables like 'sql_mode'; +show create table t1; +drop table t1; diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test index cffca437cf1..90d7f814359 100644 --- a/mysql-test/t/status.test +++ b/mysql-test/t/status.test @@ -13,7 +13,10 @@ flush status; show status like 'Table_lock%'; connection con1; SET SQL_LOG_BIN=0; +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1(n int) type=myisam; insert into t1 values(1); connection con2; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test new file mode 100644 index 00000000000..39dfd4c72e6 --- /dev/null +++ b/mysql-test/t/subselect.test @@ -0,0 +1,675 @@ +# Initialise +--disable_warnings +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12; +--enable_warnings + +select (select 2); +explain select (select 2); +SELECT (SELECT 1) UNION SELECT (SELECT 2); +explain SELECT (SELECT 1) UNION SELECT (SELECT 2); +SELECT (SELECT (SELECT 0 UNION SELECT 0)); +explain SELECT (SELECT (SELECT 0 UNION SELECT 0)); +-- error 1245 +SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a; +-- error 1245 +SELECT (SELECT 1 FROM (SELECT 1) as b HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) as c HAVING a=1) as b; +SELECT (SELECT 1),MAX(1) FROM (SELECT 1) as a; +-- error 1245 +SELECT (SELECT a) as a; +EXPLAIN SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; +SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; +-- error 1054 +SELECT (SELECT 1), a; +SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1; +-- error 1054 +SELECT 1 FROM (SELECT (SELECT a) b) c; +SELECT * FROM (SELECT 1 as id) b WHERE id IN (SELECT * FROM (SELECT 1 as id) c ORDER BY id); +-- error 1239 +SELECT * FROM (SELECT 1) a WHERE 1 IN (SELECT 1,1); +SELECT 1 IN (SELECT 1); +SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); +-- error 1221 +select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); +-- error 1108 +SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); +SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; +SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL; +SELECT (SELECT 1,2,3) = ROW(1,2,3); +SELECT (SELECT 1,2,3) = ROW(1,2,1); +SELECT (SELECT 1,2,3) < ROW(1,2,1); +SELECT (SELECT 1,2,3) > ROW(1,2,1); +SELECT (SELECT 1,2,3) = ROW(1,2,NULL); +SELECT ROW(1,2,3) = (SELECT 1,2,3); +SELECT ROW(1,2,3) = (SELECT 1,2,1); +SELECT ROW(1,2,3) < (SELECT 1,2,1); +SELECT ROW(1,2,3) > (SELECT 1,2,1); +SELECT ROW(1,2,3) = (SELECT 1,2,NULL); +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a'); +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b'); +SELECT (SELECT 1.5,2,'a') = ROW('b',2,'b'); +SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); +SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a'); +SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); + +-- error 1239 +SELECT (SELECT * FROM (SELECT 'test' a,'test' b) a); + +SELECT 1 as a,(SELECT a+a) b,(SELECT b); + +create table t1 (a int); +create table t2 (a int, b int); +create table t3 (a int); +create table t4 (a int, b int); +insert into t1 values (2); +insert into t2 values (1,7),(2,7); +insert into t4 values (4,8),(3,8),(5,9); +-- error 1245 +select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1; +select (select a from t1 where t1.a=t2.a), a from t2; +select (select a from t1 where t1.a=t2.b), a from t2; +select (select a from t1), a from t2; +select (select a from t3), a from t2; +select * from t2 where t2.a=(select a from t1); +insert into t3 values (6),(7),(3); +select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1); +(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 order by a limit 2) limit 3; +(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a); +explain (select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a); +select (select a from t3 where a<t2.a*4 order by 1 desc limit 1), a from t2; +select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from +(select * from t2 where a>1) as tt; +explain select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from +(select * from t2 where a>1) as tt; +select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1); +select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a > t1.a) order by 1 desc limit 1); +select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1); +select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; +explain select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; +select * from t3 where exists (select * from t2 where t2.b=t3.a); +select * from t3 where not exists (select * from t2 where t2.b=t3.a); +select * from t3 where a in (select b from t2); +select * from t3 where a not in (select b from t2); +select * from t3 where a = some (select b from t2); +select * from t3 where a <> any (select b from t2); + +# Rewrite: select * from t3 where not exists (select b from t2 where a <> b); +select * from t3 where a = all (select b from t2); + +select * from t3 where a <> all (select b from t2); +insert into t2 values (100, 5); +select * from t3 where a < any (select b from t2); +select * from t3 where a < all (select b from t2); +select * from t3 where a >= any (select b from t2); +select * from t3 where a >= all (select b from t2); +delete from t2 where a=100; +-- error 1239 +select * from t3 where a in (select a,b from t2); +-- error 1239 +select * from t3 where a in (select * from t2); +insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9); +select b,max(a) as ma from t4 group by b having b < (select max(t2.a) +from t2 where t2.b=t4.b); +select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) +from t2 where t2.b=t4.b); +create table t5 (a int); +select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +insert into t5 values (5); +select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +insert into t5 values (2); +select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +explain select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +-- error 1240 +select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; +create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); +create table t7( uq int primary key, name char(25)); +insert into t7 values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta"); +insert into t6 values (1,1),(1,2),(2,2),(1,3); +select * from t6 where exists (select * from t7 where uq = clinic_uq); + +# not unique fields +-- error 1052 +select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); + +# different tipes & group functions +drop table if exists t1,t2,t3; + +CREATE TABLE t3 (a varchar(20),b char(1) NOT NULL default '0'); +INSERT INTO t3 VALUES ('W','a'),('A','c'),('J','b'); +CREATE TABLE t2 (a varchar(20),b int NOT NULL default '0'); +INSERT INTO t2 VALUES ('W','1'),('A','3'),('J','2'); +CREATE TABLE t1 (a varchar(20),b date NOT NULL default '0000-00-00'); +INSERT INTO t1 VALUES ('W','1732-02-22'),('A','1735-10-30'),('J','1743-04-13'); +SELECT * FROM t1 WHERE b = (SELECT MIN(b) FROM t1); +SELECT * FROM t2 WHERE b = (SELECT MIN(b) FROM t2); +SELECT * FROM t3 WHERE b = (SELECT MIN(b) FROM t3); + +CREATE TABLE `t8` ( + `pseudo` varchar(35) character set latin1 NOT NULL default '', + `email` varchar(60) character set latin1 NOT NULL default '', + PRIMARY KEY (`pseudo`), + UNIQUE KEY `email` (`email`) +) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC; + +INSERT INTO t8 (pseudo,email) VALUES ('joce','test'); +INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1'); +INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1'); +EXPLAIN SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); +-- error 1239 +SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM +t8 WHERE pseudo='joce'); +-- error 1239 +SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE +pseudo='joce'); +SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); +-- error 1240 +SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%joce%'); + +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8; + +#searchconthardwarefr3 forumconthardwarefr7 +CREATE TABLE `t1` ( + `topic` mediumint(8) unsigned NOT NULL default '0', + `date` date NOT NULL default '0000-00-00', + `pseudo` varchar(35) character set latin1 NOT NULL default '', + PRIMARY KEY (`pseudo`,`date`,`topic`), + KEY `topic` (`topic`) +) TYPE=MyISAM ROW_FORMAT=DYNAMIC; +INSERT INTO t1 (topic,date,pseudo) VALUES +('43506','2002-10-02','joce'),('40143','2002-08-03','joce'); +EXPLAIN SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'; +EXPLAIN SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'); +SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'; +SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'); +SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1; +-- error 1240 +SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1; +EXPLAIN SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1); +drop table t1; + +#forumconthardwarefr7 searchconthardwarefr7 +CREATE TABLE `t1` ( + `numeropost` mediumint(8) unsigned NOT NULL auto_increment, + `maxnumrep` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`numeropost`), + UNIQUE KEY `maxnumrep` (`maxnumrep`) +) TYPE=MyISAM ROW_FORMAT=FIXED; + +INSERT INTO t1 (numeropost,maxnumrep) VALUES (40143,1),(43506,2); + +CREATE TABLE `t2` ( + `mot` varchar(30) NOT NULL default '', + `topic` mediumint(8) unsigned NOT NULL default '0', + `date` date NOT NULL default '0000-00-00', + `pseudo` varchar(35) NOT NULL default '', + PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`) + ) TYPE=MyISAM ROW_FORMAT=DYNAMIC; + +INSERT INTO t2 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce'); +select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1); +SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND date >= '2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20; +-- error 1054 +SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) b; +-- error 1054 +SELECT 1 IN (SELECT 1 FROM t2 HAVING a); + +SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic); +SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100); +SELECT * from t2 where topic IN (SELECT SUM(topic) FROM t1); +SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic); +SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100); +SELECT * from t2 where topic = any (SELECT SUM(topic) FROM t1); +SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic); +SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100); +SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2; +SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2); +SELECT * from t2 where topic <> any (SELECT SUM(topic) FROM t2); +SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); +SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); +SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); +SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2; +drop table t1,t2; + +#forumconthardwarefr7 +CREATE TABLE `t1` ( + `numeropost` mediumint(8) unsigned NOT NULL auto_increment, + `maxnumrep` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`numeropost`), + UNIQUE KEY `maxnumrep` (`maxnumrep`) +) TYPE=MyISAM ROW_FORMAT=FIXED; + +INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1); +-- error 1240 +select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1); +-- error 1240 +select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1); +drop table t1; + +#iftest +CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b'); +INSERT INTO t1 VALUES (); +-- error 1240 +SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b'); +drop table t1; + +# threadhardwarefr7 +CREATE TABLE `t1` ( + `numeropost` mediumint(8) unsigned NOT NULL default '0', + `numreponse` int(10) unsigned NOT NULL auto_increment, + `pseudo` varchar(35) NOT NULL default '', + PRIMARY KEY (`numeropost`,`numreponse`), + UNIQUE KEY `numreponse` (`numreponse`), + KEY `pseudo` (`pseudo`,`numeropost`) +) TYPE=MyISAM; +-- error 1245 +SELECT (SELECT numeropost FROM t1 HAVING numreponse=a),numreponse FROM (SELECT * FROM t1) as a; +-- error 1054 +SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=a) FROM (SELECT * FROM t1) as a; +SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT * FROM t1) as a; +INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); +-- error 1240 +EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); +EXPLAIN SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'; +EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); +drop table t1; + +CREATE TABLE t1 (a int(1)); +INSERT INTO t1 VALUES (1); +SELECT 1 FROM (SELECT a FROM t1) b HAVING (SELECT b.a)=1; +drop table t1; + +#update with subselects +create table t1 (a int NOT NULL, b int, primary key (a)); +create table t2 (a int NOT NULL, b int, primary key (a)); +insert into t1 values (0, 10),(1, 11),(2, 12); +insert into t2 values (1, 21),(2, 22),(3, 23); +select * from t1; +-- error 1093 +update t1 set b= (select b from t1); +-- error 1240 +update t1 set b= (select b from t2); +update t1 set b= (select b from t2 where t1.a = t2.a); +select * from t1; +drop table t1, t2; + +#delete with subselects +create table t1 (a int NOT NULL, b int, primary key (a)); +create table t2 (a int NOT NULL, b int, primary key (a)); +insert into t1 values (0, 10),(1, 11),(2, 12); +insert into t2 values (1, 21),(2, 12),(3, 23); +select * from t1; +select * from t1 where b = (select b from t2 where t1.a = t2.a); +-- error 1093 +delete from t1 where b = (select b from t1); +-- error 1240 +delete from t1 where b = (select b from t2); +delete from t1 where b = (select b from t2 where t1.a = t2.a); +select * from t1; +drop table t1, t2; + +#multi-delete with subselects + +create table t11 (a int NOT NULL, b int, primary key (a)); +create table t12 (a int NOT NULL, b int, primary key (a)); +create table t2 (a int NOT NULL, b int, primary key (a)); +insert into t11 values (0, 10),(1, 11),(2, 12); +insert into t12 values (33, 10),(22, 11),(2, 12); +insert into t2 values (1, 21),(2, 12),(3, 23); +select * from t11; +select * from t12; +-- error 1093 +delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a); +-- error 1240 +delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2); +delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a); +select * from t11; +select * from t12; +drop table t11, t12, t2; + +#insert with subselects +CREATE TABLE t1 (x int); +create table t2 (a int); +create table t3 (a int); +insert into t2 values (1); +insert into t3 values (1),(2); +-- error 1093 +INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); +-- error 1240 +INSERT INTO t1 (x) VALUES ((SELECT a FROM t3)); +INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); +select * from t1; +insert into t2 values (1); +INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); +-- sleep 1 +select * from t1; +INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; +select * from t1; +-- error 1093 +INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; +INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2)); +-- sleep 1 +select * from t1; +drop table t1, t2, t3; + +#replace with subselects +CREATE TABLE t1 (x int not null, y int, primary key (x)); +create table t2 (a int); +create table t3 (a int); +insert into t2 values (1); +insert into t3 values (1),(2); +select * from t1; +-- error 1093 +replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); +-- error 1240 +replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); +replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); +select * from t1; +replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+2 FROM t2)); +select * from t1; +replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a FROM t2)); +-- sleep 1 +select * from t1; +replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a+1 FROM t2)); +-- sleep 1 +select * from t1; +replace LOW_PRIORITY into t1 (x, y) VALUES ((SELECT a+1 FROM t2), (SELECT a FROM t2)); +select * from t1; +drop table t1, t2, t3; + +-- error 1096 +SELECT * FROM (SELECT 1) b WHERE 1 IN (SELECT *); + +CREATE TABLE t2 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t2 VALUES (1),(2); +SELECT * FROM t2 WHERE id IN (SELECT 1); +EXPLAIN SELECT * FROM t2 WHERE id IN (SELECT 1); +SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); +SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1)); +EXPLAIN SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1)); +EXPLAIN SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); +SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3); +SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); +-- error 1093 +INSERT INTO t2 VALUES ((SELECT * FROM t2)); +SELECT * FROM t2; +CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 values (1),(1); +-- error 1240 +UPDATE t2 SET id=(SELECT * FROM t1); +drop table t2, t1; + +#NULL test +create table t1 (a int); +insert into t1 values (1),(2),(3); +select 1 IN (SELECT * from t1); +select 10 IN (SELECT * from t1); +select NULL IN (SELECT * from t1); +update t1 set a=NULL where a=2; +select 1 IN (SELECT * from t1); +select 3 IN (SELECT * from t1); +select 10 IN (SELECT * from t1); +select 1 > ALL (SELECT * from t1); +select 10 > ALL (SELECT * from t1); +select 1 > ANY (SELECT * from t1); +select 10 > ANY (SELECT * from t1); +drop table t1; +create table t1 (a varchar(20)); +insert into t1 values ('A'),('BC'),('DEF'); +select 'A' IN (SELECT * from t1); +select 'XYZS' IN (SELECT * from t1); +select NULL IN (SELECT * from t1); +update t1 set a=NULL where a='BC'; +select 'A' IN (SELECT * from t1); +select 'DEF' IN (SELECT * from t1); +select 'XYZS' IN (SELECT * from t1); +select 'A' > ALL (SELECT * from t1); +select 'XYZS' > ALL (SELECT * from t1); +select 'A' > ANY (SELECT * from t1); +select 'XYZS' > ANY (SELECT * from t1); +drop table t1; +create table t1 (a float); +insert into t1 values (1.5),(2.5),(3.5); +select 1.5 IN (SELECT * from t1); +select 10.5 IN (SELECT * from t1); +select NULL IN (SELECT * from t1); +update t1 set a=NULL where a=2.5; +select 1.5 IN (SELECT * from t1); +select 3.5 IN (SELECT * from t1); +select 10.5 IN (SELECT * from t1); +select 1.5 > ALL (SELECT * from t1); +select 10.5 > ALL (SELECT * from t1); +select 1.5 > ANY (SELECT * from t1); +select 10.5 > ANY (SELECT * from t1); +explain select (select a+1) from t1; +select (select a+1) from t1; +drop table t1; + +# +# Null with keys +# + +CREATE TABLE t1 (a int(11) NOT NULL default '0', PRIMARY KEY (a)); +CREATE TABLE t2 (a int(11) default '0', INDEX (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t2 VALUES (1),(2),(3); +SELECT t1.a, t1.a in (select t2.a from t2) FROM t1; +explain SELECT t1.a, t1.a in (select t2.a from t2) FROM t1; +drop table t1,t2; + +#LIMIT is not supported now +create table t1 (a float); +-- error 1235 +select 10.5 IN (SELECT * from t1 LIMIT 1); +-- error 1235 +select 10.5 IN (SELECT * from t1 LIMIT 1 UNION SELECT 1.5); +drop table t1; + +create table t1 (a int, b int, c varchar(10)); +create table t2 (a int); +insert into t1 values (1,2,'a'),(2,3,'b'),(3,4,'c'); +insert into t2 values (1),(2),(NULL); +select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,2,'a'),(select c from t1 where a=t2.a) from t2; +select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b'),(select c from t1 where a=t2.a) from t2; +select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,4,'c'),(select c from t1 where a=t2.a) from t2; +drop table t1,t2; + +create table t1 (a int, b real, c varchar(10)); +insert into t1 values (1, 1, 'a'), (2,2,'b'), (NULL, 2, 'b'); +select ROW(1, 1, 'a') IN (select a,b,c from t1); +select ROW(1, 2, 'a') IN (select a,b,c from t1); +select ROW(1, 1, 'a') IN (select b,a,c from t1); +select ROW(1, 1, 'a') IN (select a,b,c from t1 where a is not null); +select ROW(1, 2, 'a') IN (select a,b,c from t1 where a is not null); +select ROW(1, 1, 'a') IN (select b,a,c from t1 where a is not null); +select ROW(1, 1, 'a') IN (select a,b,c from t1 where c='b' or c='a'); +select ROW(1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a'); +select ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a'); +-- error 1235 +select ROW(1, 1, 'a') IN (select b,a,c from t1 limit 2); +drop table t1; + +create table t1 (a int); +insert into t1 values (1); +do @a:=(SELECT a from t1); +select @a; +set @a:=2; +set @a:=(SELECT a from t1); +select @a; +drop table t1; +-- error 1146 +do (SELECT a from t1); +-- error 1146 +set @a:=(SELECT a from t1); + +CREATE TABLE t1 (a int, KEY(a)); +HANDLER t1 OPEN; +-- error 1149 +HANDLER t1 READ a=((SELECT 1)); +HANDLER t1 CLOSE; +drop table t1; + +create table t1 (a int); +create table t2 (b int); +insert into t1 values (1),(2); +insert into t2 values (1); +select a from t1 where a in (select a from t1 where a in (select b from t2)); +drop table t1, t2; + +create table t1 (a int, b int); +create table t2 like t1; +insert into t1 values (1,2),(1,3),(1,4),(1,5); +insert into t2 values (1,2),(1,3); +select * from t1 where row(a,b) in (select a,b from t2); +drop table t1, t2; + +CREATE TABLE `t1` (`i` int(11) NOT NULL default '0',PRIMARY KEY (`i`)) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 VALUES (1); +-- error 1111 +UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i)); +drop table t1; + +#test of uncacheable subqueries +CREATE TABLE t1 (a int(1)); +EXPLAIN SELECT (SELECT RAND() FROM t1) FROM t1; +EXPLAIN SELECT (SELECT ENCRYPT('test') FROM t1) FROM t1; +EXPLAIN SELECT (SELECT BENCHMARK(1,1) FROM t1) FROM t1; +drop table t1; + + +CREATE TABLE `t1` ( + `mot` varchar(30) character set latin1 NOT NULL default '', + `topic` mediumint(8) unsigned NOT NULL default '0', + `date` date NOT NULL default '0000-00-00', + `pseudo` varchar(35) character set latin1 NOT NULL default '', + PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`), + KEY `pseudo` (`pseudo`,`date`,`topic`), + KEY `topic` (`topic`) +) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC; + +CREATE TABLE `t2` ( + `mot` varchar(30) character set latin1 NOT NULL default '', + `topic` mediumint(8) unsigned NOT NULL default '0', + `date` date NOT NULL default '0000-00-00', + `pseudo` varchar(35) character set latin1 NOT NULL default '', + PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`), + KEY `pseudo` (`pseudo`,`date`,`topic`), + KEY `topic` (`topic`) +) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC; + +CREATE TABLE `t3` ( + `numeropost` mediumint(8) unsigned NOT NULL auto_increment, + `maxnumrep` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`numeropost`), + UNIQUE KEY `maxnumrep` (`maxnumrep`) +) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 VALUES ('joce','1','','joce'),('test','2','','test'); + +INSERT INTO t2 VALUES ('joce','1','','joce'),('test','2','','test'); + +INSERT INTO t3 VALUES (1,1); + +SELECT DISTINCT topic FROM t2 WHERE NOT EXISTS(SELECT * FROM t3 WHERE +numeropost=topic); +select * from t1; +DELETE FROM t1 WHERE topic IN (SELECT DISTINCT topic FROM t2 WHERE NOT +EXISTS(SELECT * FROM t3 WHERE numeropost=topic)); +select * from t1; + +drop table t1, t2, t3; + +SELECT * FROM (SELECT 1 as a,(SELECT a)) a; +CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT 1)) a; +SHOW CREATE TABLE t1; +drop table t1; +CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT a)) a; +SHOW CREATE TABLE t1; +drop table t1; +CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT a+0)) a; +SHOW CREATE TABLE t1; +drop table t1; +CREATE TABLE t1 SELECT (SELECT 1 as a UNION SELECT 1+1 limit 1,1) as a; +SHOW CREATE TABLE t1; +drop table t1; + +create table t1 (a int); +insert into t1 values (1), (2), (3); +explain select a,(select (select rand() from t1 limit 1) from t1 limit 1) +from t1; +drop table t1; + +# +# error in IN +# +-- error 1146 +select t1.Continent, t2.Name, t2.Population from t1 LEFT JOIN t2 ON t1.Code = t2.Country where t2.Population IN (select max(t2.Population) AS Population from t2, t1 where t2.Country = t1.Code group by Continent); + +# +# complex subquery +# + +CREATE TABLE t1 ( + ID int(11) NOT NULL auto_increment, + name char(35) NOT NULL default '', + t2 char(3) NOT NULL default '', + District char(20) NOT NULL default '', + Population int(11) NOT NULL default '0', + PRIMARY KEY (ID) +) TYPE=MyISAM; + +INSERT INTO t1 VALUES (130,'Sydney','AUS','New South Wales',3276207); +INSERT INTO t1 VALUES (131,'Melbourne','AUS','Victoria',2865329); +INSERT INTO t1 VALUES (132,'Brisbane','AUS','Queensland',1291117); + +CREATE TABLE t2 ( + Code char(3) NOT NULL default '', + Name char(52) NOT NULL default '', + Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL default 'Asia', + Region char(26) NOT NULL default '', + SurfaceArea float(10,2) NOT NULL default '0.00', + IndepYear smallint(6) default NULL, + Population int(11) NOT NULL default '0', + LifeExpectancy float(3,1) default NULL, + GNP float(10,2) default NULL, + GNPOld float(10,2) default NULL, + LocalName char(45) NOT NULL default '', + GovernmentForm char(45) NOT NULL default '', + HeadOfState char(60) default NULL, + Capital int(11) default NULL, + Code2 char(2) NOT NULL default '', + PRIMARY KEY (Code) +) TYPE=MyISAM; + +INSERT INTO t2 VALUES ('AUS','Australia','Oceania','Australia and New Zealand',7741220.00,1901,18886000,79.8,351182.00,392911.00,'Australia','Constitutional Monarchy, Federation','Elisabeth II',135,'AU'); +INSERT INTO t2 VALUES ('AZE','Azerbaijan','Asia','Middle East',86600.00,1991,7734000,62.9,4127.00,4100.00,'Azärbaycan','Federal Republic','Heydär Äliyev',144,'AZ'); + +select t2.Continent, t1.Name, t1.Population from t2 LEFT JOIN t1 ON t2.Code = t1.t2 where t1.Population IN (select max(t1.Population) AS Population from t1, t2 where t1.t2 = t2.Code group by Continent); + +drop table t1, t2; + +# +# constants in IN +# +CREATE TABLE `t1` ( + `id` mediumint(8) unsigned NOT NULL auto_increment, + `pseudo` varchar(35) character set latin1 NOT NULL default '', + PRIMARY KEY (`id`), + UNIQUE KEY `pseudo` (`pseudo`), +) TYPE=MyISAM PACK_KEYS=1 ROW_FORMAT=DYNAMIC; +INSERT INTO t1 (pseudo) VALUES ('test'); +SELECT 0 IN (SELECT 1 FROM t1 a); +EXPLAIN SELECT 0 IN (SELECT 1 FROM t1 a); +INSERT INTO t1 (pseudo) VALUES ('test1'); +SELECT 0 IN (SELECT 1 FROM t1 a); +EXPLAIN SELECT 0 IN (SELECT 1 FROM t1 a); +drop table t1; + +CREATE TABLE `t1` ( + `i` int(11) NOT NULL default '0', + PRIMARY KEY (`i`) +) TYPE=MyISAM CHARSET=latin1; + +INSERT INTO t1 VALUES (1); +-- error 1111 +UPDATE t1 SET i=i+(SELECT MAX(i) FROM (SELECT 1) t) WHERE i=(SELECT MAX(i)); +-- error 1111 +UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i)); +drop table t1; diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index 586761921b8..67126930e60 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -3,10 +3,14 @@ disable_query_log; show variables like "have_symlink"; enable_query_log; +--disable_warnings +drop table if exists t1,t2,t7,t8,t9; +--enable_warnings + # # First create little data to play with # -drop table if exists t1,t2,t7,t8,t9; + create table t1 (a int not null auto_increment, b char(16) not null, primary key (a)); create table t2 (a int not null auto_increment, b char(16) not null, primary key (a)); insert into t1 (b) values ("test"),("test1"),("test2"),("test3"); diff --git a/mysql-test/t/tablelock.test b/mysql-test/t/tablelock.test index fa8c4f03675..fbc5d685096 100644 --- a/mysql-test/t/tablelock.test +++ b/mysql-test/t/tablelock.test @@ -2,7 +2,10 @@ # Test of lock tables # +--disable_warnings drop table if exists t1,t2; +--enable_warnings + create table t1 ( n int auto_increment primary key); lock tables t1 write; insert into t1 values(NULL); diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test index 665e690a322..03b6fa35bfa 100644 --- a/mysql-test/t/temp_table.test +++ b/mysql-test/t/temp_table.test @@ -2,7 +2,10 @@ # Test of temporary tables # +--disable_warnings drop table if exists t1,t2; +--enable_warnings + CREATE TABLE t1 (c int not null, d char (10) not null); insert into t1 values(1,""),(2,"a"),(3,"b"); CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null); @@ -34,7 +37,6 @@ drop table t1; # Test CONCAT_WS with temporary tables # -drop table if exists t1; CREATE TABLE t1 (pkCrash INTEGER PRIMARY KEY,strCrash VARCHAR(255)); INSERT INTO t1 ( pkCrash, strCrash ) VALUES ( 1, '1'); SELECT CONCAT_WS(pkCrash, strCrash) FROM t1; @@ -74,8 +76,6 @@ drop table t1; # In MySQL 4.0.4 doing a GROUP BY on a NULL column created a disk based # temporary table when a memory based one would be good enough. -drop table if exists t1; - CREATE TABLE t1 ( d datetime default NULL ) TYPE=MyISAM; diff --git a/mysql-test/t/truncate.test b/mysql-test/t/truncate.test index eeb79f497fa..dd80baba269 100644 --- a/mysql-test/t/truncate.test +++ b/mysql-test/t/truncate.test @@ -1,7 +1,10 @@ # # Test of truncate # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (a integer, b integer,c1 CHAR(10)); insert into t1 (a) values (1),(2); truncate table t1; diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test index 5bdaad7ffac..002aeaed9dc 100644 --- a/mysql-test/t/type_blob.test +++ b/mysql-test/t/type_blob.test @@ -3,10 +3,43 @@ # # +# Basic cleanup +# +--disable_warnings +drop table if exists t1,t2,t3,t4,t5,t6,t7; +--enable_warnings + + +# +# Check syntax for creating BLOB/TEXT +# + +CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000)); +show columns from t1; +CREATE TABLE t2 (a char(257), b varchar(70000) binary, c varchar(70000000)); +show columns from t2; +create table t3 (a long, b long byte); +show create TABLE t3; +drop table t1,t2,t3 + +# +# Check errors with blob +# + +--error 1074 +CREATE TABLE t1 (a char(257) default "hello"); +--error 1101 +CREATE TABLE t2 (a blob default "hello"); + +# Safety to be able to continue with other tests if above fails +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +# # test of full join with blob # -drop table if exists t1,t2,t3,t4,t5,t6,t7; create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr)); insert into t1 values (null,"a","A"); insert into t1 values (null,"bbb","BBB"); @@ -58,6 +91,7 @@ select b from t1 where b like "%HELLO%"; select d from t1 where d like "%HELLO%"; select c from t1 having c like "%HELLO%"; select d from t1 having d like "%HELLO%"; +select d from t1 having d like "%HE%LLO%"; select t from t1 order by t; select c from t1 order by c; select b from t1 order by b; diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index 68c2d55aac9..6319a3990e6 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -1,6 +1,10 @@ # # test of problem with date fields # +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + create table t1 (a char(16), b date, c datetime); insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01'; select * from t1 where c = '2000-01-01'; @@ -11,7 +15,6 @@ drop table t1; # problem with date conversions # -drop table if exists t1,t2; CREATE TABLE t1 (name char(6),cdate date); INSERT INTO t1 VALUES ('name1','1998-01-01'); INSERT INTO t1 VALUES ('name2','1998-01-01'); diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index f5103958979..e9c45b2908f 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -2,7 +2,10 @@ # testing different DATETIME ranges # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (t datetime); insert into t1 values(101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959); select * from t1; @@ -19,7 +22,7 @@ drop table t1; CREATE TABLE t1 (a timestamp, b date, c time, d datetime); insert into t1 (b,c,d) values(now(),curtime(),now()); -select date_format(a,"%Y-%m-%d")=b,right(a,6)=c+0,a=d+0 from t1; +select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1; drop table t1; # diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 7f73ec34e3a..9b10e8943ad 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -1,6 +1,9 @@ # bug in decimal() with negative numbers by kaido@tradenet.ee +--disable_warnings DROP TABLE IF EXISTS t1; +--enable_warnings + CREATE TABLE t1 ( id int(11) DEFAULT '0' NOT NULL auto_increment, datatype_id int(11) DEFAULT '0' NOT NULL, diff --git a/mysql-test/t/type_enum.test b/mysql-test/t/type_enum.test index 8f399e4364e..49ba73acaa8 100644 --- a/mysql-test/t/type_enum.test +++ b/mysql-test/t/type_enum.test @@ -2,7 +2,10 @@ # Problem with many enums # +--disable_warnings DROP TABLE if exists t1; +--enable_warnings + CREATE TABLE t1 ( field enum('001001','001004','001010','001018','001019','001020','001021','001027','001028','001029','001030','001031','001100','002003','002004','002005','002007','002008','002009','002012','002013','002014','003002','003003','003004','003005','003006','003007','003008','003009','003010','003011','003012','003013','003014','003015','003016','003017','003018','003019','004002','004003','004005','004006','004007','004008','004010','004012','004014','004016','004017','004020','004021','004022','004023','004024','004025','004026','006002','006004','006006','006010','006011','006012','006013','006014','007001','007002','007003','007004','007005','007006','007007','007008','007009','007010','007011','007012','007013','007014','007015','007016','007017','007018','007019','007020','007021','007022','007023','007024','007025','007026','007027','007028','007029','007030','007031','007032','007033','007034','007035','007036','007037','007038','007039','007040','007043','007044','009001','009002','009004','009005','009006','009007','009008','009009','009010','009011','009012','009013','010002','010003','010004','010005','010006','010007','010008','010009','010010','010011','010012','010013','010015','010016','010017','010018','010019','010020','010021','010022','010023','010024','010025','010026','010027','010028','011001','011002','011003','011004','011006','011012','011013','011014','011015','011016','012017','012018','012019','012023','012027','012028','012029','012030','012031','012032','012033','012034','012035','012036','012037','012038','012039','014001','016002','016003','016004','016007','016010','016011','016016','016019','016020','016021','016022','016023','016024','016026','016027','016028','016029','016030','016031','016032','016033','016034','017002','018001','019002','019004','020001','020003','020004','020005','020006','020007','020008','020009','022001','022002','022003','023001','023002','023003','023004','023005','023006','023007','023008','023010','023011','023012','023017','023019','023020','023021','023025','023026','023027','023028','023029','023030','023031','023032','023033','023034','023035','025001','025003','025004','025005','025006','025007','025008','025009','025010','025011','025012','025013','025014','025015','025016','025017','025018','025019','025020','025021','025022','025023','025024','025025','025026','025027','025028','025029','025030','025031','025032','025033','025034','025035','025036','025037','025038','025039','025040','025041','025042','025043','025044','025045','025046','025047','025048','025049','025050','025051','025052','025053','025054','025055','025056','025057','025058','025059','025060','025061','025062','025063','027001','027002','027011','035008','035012','036001','037001','037003','037004','037005','037006','037007','037008','037009','038004','038005','038006','038007','038009','039001','039002','039003','039004','039005','039006','046001','046002','046003','046004','046005','046007','046008','046009','046010','046011','046012','046013','046014','047001','047002','048001','051001','051002','051003','051004','052001','052002','052005','053015','053016','053019','053020','053023','053024','053026','053028','053029','053033','053034','053036','053037','053038','053039','053041','053042','053043','053045','053046','053047','053048','053051','053052','053054','053055','053056','053057','053068','053069','053070','053073','053074','053075','053086','053094','053095','053096','053097','053098','053099','053100','053101','053102','053103','053104','053105','053107','053122','053123','053124','053125','053127','053128','054001','054002','054003','054004','054005','054006','054007','054009','054010','056001','056002','056003','056004','056005','056006','056009','056010','056011','056016','056017','056018','056019','056020','056021','056022','057001','057002','057003','057004','058002','058003','058004','058005','060001','060003','060004','060005','060006','060007','061002','061003','061004','061005','061006','069006','069007','069010','069011','069012','069013','069014','069015','069016','069017','069018','069020','069021','069022','069023','069024','071002','071003','071004','071005','071006','071008','071011','071013','071020','071021','071022','072001','073001','073002','073003','073004','074001','074002','074003','074004','074005','074006','074007','074008','074009','074010','074011','074012','075001','075007','076101','076102','076103','077001','077002','077003','077004','077006','077007','077008','077009','078005','079002','079003','079004','079005','079006','079007','081001','082006','082007','082011','082013','082014','082015','082016','082017','082021','082022','082023','082024','082025','082026','082027','082028','082029','082030','082031','082032','082033','082034','082035','082036','082037','082038','082039','082040','082041','082042','082043','082044','084001','084002','084003','084004','084005','084007','084008','084009','084011','084013','084014','084016','084017','084027','084031','084032','084033','084035','084036','084037','084038','084039','084040','084041','084042','084043','084044','084045','084046','084047','084048','084049','084050','084051','085001','085002','085003','085004','085005','085006','085007','085009','085011','085012','085013','085014','085015','085016','085017','085018','085019','085020','085021','085022','085023','085028','085029','085030','085031','085033','085034','085035','085036','085037','085038','085040','085041','085042','085043','085044','085045','085046','085047','085048','085063','085064','085065','085068','085070','085071','085073','085082','085083','085086','085088','085089','085090','085091','085092','085093','085094','085095','085096','085097','085098','085099','085100','085101','085102','085103','085104','085105','085106','085107','085108','085109','085110','085111','085112','085113','085115','085119','085120','085121','085122','085123','085124','085125','085126','085127','085128','085129','085130','085132','085133','085134','085135','085136','085137','086001','086002','086003','086004','086005','088001','088003','088005','088006','088007','088008','088009','089001','090001','090002','090003','090004','090005','090006','090007','090008','090009','090010','090013','090015','090016','090017','090018','090019','090022','090027','090028','091001','091002','091005','091008','091009','091010','091011','091012','091013','091014','091015','091016','091017','091018','093001','093003','093098','093100','093102','093104','093141','093142','093146','093151','093153','093167','093168','093176','094001','094002','094004','094005','095004','099001','099002','100001','101001','102002','102003','105001','105002','106001','113001','113002','113003','113004','113005','113006','113007','113008','113009','113010','113011','113012','113013','113014','113015','113016','113017','113018','113019','113020','113021','113022','113023','113024','113025','113026','113027','113028','114001','115001','115002','115003','115004','115005','115006','115007','115008','115009','115010','115011','115012','115013','115014','115015','115016','115017','115018','115020','115021','115022','115023','115025','115026','115027','115028','115029','115030','115031','115032','115033','115034','115035','115036','115039','115040','115041','115042','115043','115044','115045','115046','115047','115048','115049','115050','115051','115052','115053','115054','115055','115056','115057','115059','115060','115061','115062','115063','115064','115065','115066','115067','115068','115069','115070','115071','115072','115073','115075','115076','115081','115082','115085','115086','115087','115088','115095','115096','115097','115098','115099','115101','115102','115103','115104','115105','115106','115108','115109','115110','115111','115112','115113','115114','115115','115116','115117','115118','115119','115120','115121','115122','116001','116002','116003','116004','116005','116006','116007','116008','116009','116010','116011','116012','117001','117002','117003','123001','124010','124014','124015','124019','124024','124025','124026','124027','124028','124029','124030','124031','124032','124033','124035','124036','124037','124038','124039','124040','124041','124042','124043','124044','124045','124046','124047','124048','124049','124050','124051','124052','124053','124054','124055','124056','124057','124058','124059','124060','124061','124062','124063','124064','124065','126001','126002','126003','126004','126005','126006','126007','126008','126009','126010','126011','126012','130001','132001','132002','132003','133001','133008','133009','133010','133011','133012','133013','133014','133015','133016','133017','133018','133019','133020','133021','133022','133023','133024','133025','133027','133028','133029','133030','133031','134001','135001','135002','135003','135004','135005','135006','135007','135008','135009','135010','136001','137009','137010','137011','137012','137013','137014','137015','137016','137017','137018','137019','138001','138002','138003','138004','139001','139003','140001','141001','141002','141003','141006','141007','141008','141009','141011','141012','141014','141015','141016','141017','141018','141019','141020','141021','141022','141023','141024','141025','141026','141027','141028','142001','142002','142003','142004','142005','142006','142007','142008','142010','142011','142012','144001','145001','145002','145003','145004','145005','145006','145007','145008','145009','145010','145011','145012','145013','145014','145015','145016','147001','150003','150005','150009','150013','150014','150015','150016','150017','150020','150021','152001','152002','152003','152004','152005','152006','152007','154001','154002','154003','155001','155002','155003','155004','155005','155006','159001','159002','159003','159004','160001','160002','160003','161001','162001','162002','162003','162004','162007','162010','162011','162012','163001','163002','163003','163005','163010','163011','163014','163015','163016','165001','165002','165003','165004','165005','165006','165007','165008','165009','165010','165011','165012','165013','165014','165015','165016','165017','165018','165019','165020','165021','165022','165023','165024','165025','165026','165027','165028','165029','165030','165031','165032','165033','165034','165035','165036','167001','168001','168002','168003','168004','168005','168007','168008','168009','168010','168011','168012','168013','168014','169001','169002','169003','169007','169008','169009','169010','170001','171001','171002','171003','171004','171005','171006','171007','171008','171009','172001','174001','174002','174003','176001','176002','176003','177001','177002','179001','179002','179003','179004','179005','179006','179007','179008','179009','179010','179011','179012','179013','179014','179015','179016','179017','179018','179019','179020','179021','179022','179023','179024','179025','179026','179027','179028','179029','179030','179031','179032','179033','179034','179035','179036','179037','179038','179039','179040','179041','179042','179043','179044','179045','179046','179047','180001','180010','180012','180013','180014','180015','180016','180017','180018','180019','180020','180021','180022','180023','180024','180025','180026','180027','180028','180030','180031','180032','180033','180034','180035','180036','180037','180038','180039','180041','180042','180043','180044','180045','180046','180047','180048','180049','180050','180051','180052','180053','180054','180055','180056','180057','180058','180059','180060','180061','180062','180063','180064','180065','180066','180067','180068','180069','180070','180071','182001','184001','184002','184005','184006','184007','184008','184009','184010','184011','185001','185003','187001','188001','188002','188003','188004','188005','188006','188007','188008','188009','188010','188011','191001','191002','192002','194001','194002','194003','194004','194005','194006','194007','195001','195002','195003','195004','195005','195006','195007','196001','196002','197001','197002','197003','197004','197005','197006','198001','198003','198004','198005','198006','198007','198008','198009','198010','198011','198012','198013','198014','198015','198016','198017','201001','201002','201005','202001','203001','203002','203003','203017','203018','203019','204001','204002','204003','205001','208001','208002','208003','208004','208005','209001','209002','209003','210001','210002','210003','210004','210005','210006','210007','210008','210009','210010','210011','210012','210013','211017','212001','212002','212003','212004','212005','212006','212007','212008','212009','212010','212011','212012','212013','218001','218003','218004','218006','218007','218008','218009','218011','218015','218016','218017','218018','218019','218020','218021','218022','218023','218024','218025','218026','218027','218028','218029','218030','218031','218032','218033','218034','218035','218036','221001','221002','221003','221004','221005','221006','221007','221008','221009','221010','221011','221012','221013','223001','223002','223003','224001','224002','224003','224006','224007','224008','225001','225002','225003','225004','225005','225006','225007','225008','225009','225010','225011','225012','225013','226001','226002','226003','226004','226005','226006','226007','226008','226009','227001','227002','227003','227004','227005','227006','227007','227008','227009','227010','227011','227012','227013','227014','227015','227016','227017','227018','227019','227020','227021','227022','227023','227024','227025','227026','227027','227028','227029','227030','227031','227032','227033','227034','227035','227036','227037','227038','227039','227040','227041','227042','227043','227044','227045','227046','227047','227048','227049','227050','227051','227052','227053','227054','227055','227056','227057','227058','227059','227060','227061','227062','227063','227064','227065','227066','227067','227068','227069','227070','227071','227072','227073','227074','227075','227076','227077','227078','227079','227080','227081','227082','227083','227084','227085','227086','227087','227088','227089','227090','227091','227092','227093','227094','227095','227096','227097','227098','227099','227100','227101','227102','227103','227104','227105','227106','227107','227108','227109','227110','227111','227112','227113','227114','227115','227116','227117','227118','227119','227120','227122','227123','227124','227125','227126','227127','227128','227129','227130','227131','227132','227133','227134','227135','227136','227137','227138','227139','227140','227141','227142','227143','227144','227145','227146','227147','227148','227149','227150','227151','227152','228001','229001','229002','229003','229004','229005','230001','230002','232001','233001','233002','233003','233004','233005','233006','233007','233008','234001','234002','234003','234004','234005','234006','234007','234008','234009','234010','234011','234012','234013','234014','234015','234016','234017','234018','234019','234020','234021','234022','234023','234024','234025','234026','234027','234028','234029','234030','235001','235002','235003','235004','235005','236001','236002','236003','237001','238002','238003','238004','238005','238006','238007','238008','333013','333014','333015','333016','333017','333018','333019','333020','333021','333022','333023','333024','333025','333030','333031','333032','333033','333034','333035','334001','334002','334003','334004','334005','334006','334007','336004','337001','337002','337003','337004','339001','339002','343001','344001','344002','344003','344004','344005','345001','345002','345003','347001','347002','348001','348002','348003','348004','348005','349001','349002','349003','350001','353001','353002','353003','353004','355001','355002','355003','355004','355005','355006','356001','358001','359001','359002','360001','360002','360003','360004','360005','366001','366002','366003','366004','369001','373001','373002','373003','373004','373005','373006','373007','373008','373009','373010','373011','373012','373013','373014','373015','373016','373017','373018','373019','373020','373021','374001','374002','374003','374004','374005','374006','374007','374008','374009','374010','374011','374012','374013','374014','374015','374016','376001','376002','376003','376004','376005','376006','376007','376008','376009','376010','376011','376012','376013','376016','376017','376018','376019','376020','376021','379003','382001','382002','383001','384001','384002','385001','385002','386001','386002','386003','386004','386005','386006','386007','386008','386009','386010','386011','386012','386013','386014','387001','389001','389002','389003','389004','392001','393001','393002','393003','393004','395001','396001','397001','397002','399001','399002','399003','400001','400002','401001','401002','401003','402001','402002','402003','402004','402005','403001','403002','403003','504001','504002','504004','504005','504006','504007','504008','504009','504010','504011','504012','504013','504014','504017','504018','504019','504021','504022','504023','504024','504025','506001','506002','508001','508002','511001','511002','511003','511004','511005','511006','511007','511008','511009','511010','511011','511012','511013','511014','511017','511018','511020','511021','511022','511024','511028','511029','513001','513002','513003','513004','514001','515001','515002','515003','515007','515008','515009','515010','515011','515012','515013','515014','515015','518001','518002','518003','520001','520002','521001','521002','521003','521004','521005','521006','521007','521008','521009','521010','521011','521012','521013','521014','521015','521016','523001','523002','523003','523004','523005','523006','523007','524001','700001','701001','701002','701003','702001','702002','702003','702004','702005','702006','702007','702008','703001','703002','703003','704001','704002','704003','704004','705001','706001','706002','707001','707002','707003','708001','709001','709002','710001','710002','711001','711002','712001','713001','713002','714001','714002','715001','716001','718001','718002','719001','719002','991001','991002','991003','991004','991005','991006','991007','991008','992001','995001','996001','996002','996003','998001','998002','998003','998004','998005','998006','998007','999001','999002','011017','011018','034001','034002','071010','208006','239001','519001','519003','126013','184012','053071','374017','374018','374019','374020','374021','404001','405002','405001','405003','405007','405006','405005','405004','240011','240010','240009','240008','240007','240006','240005','240004','240003','240002','240001','240012','240013','240014','240015','240016','240017','357001','235006','235007','712002','355008','355007','056023','999999','046015','019005','126014','241003','241002','241001','240018','240020','240019','242001','242002','242003','242004','242005','242006','089002','406001','406002','406003','406004','406005','406006','243001','243002','243003','243004','243005','243006','243007','243008','010030','010029','407001','407006','407005','407004','407003','407002','408001','366005','133032','016035','077010','996004','025064','011019','407007','407008','407009','409001','115123','504026','039007','039009','039008','039010','039011','039012','180072','240021','240023','408002','405008','235008','525001','525002','525003','525004','410001','410002','410003','410004','410005','410006','410007','410008','410009','410010','410011','410012','410013','410014','410015','410016','344006','240031','240030','240029','240028','240027','240026','240025','240024','240034','240033','240032','410017','410018','411001','411002','411003','411004','411005','411006','411007','411008','203020','203021','203022','412001','412002','412003','412004','069025','244001','244002','244009','244008','244007','244006','244005','244004','244003','244015','244014','244013','244012','244011','244010','244016','244017','240042','240041','240040','240039','240038','240037','240036','240035','405009','405010','240043','504034','504033','504032','504031','504030','504029','504028','504027','504042','504041','504040','504039','504038','504037','504036','504035','800001','410019','410020','410021','244018','244019','244020','399004','413001','504043','198018','198019','344007','082045','010031','010032','010033','010034','010035','504044','515016','801002','801003','801004','801005','802001','801001','414001','414002','414003','141029','141030','803001','803002','803003','803004','803005','803006','803007','803008','803009','803010','803011','803012','803013','803014','803015','803016','803017','410022','410023','803018','803019','803020','415002','415001','244021','011020','011023','011022','011021','025065','165037','165038','165039','416001','416002','416003','417001','418001','504045','803022','803021','240022','419001','420001','804010','804009','804008','804007','804006','804005','804004','804003','804002','804001','804020','804019','804018','804017','804016','804015','804014','804013','804012','804011','804024','804021','804023','804022','511019','511016','511015','511032','511031','511030','511027','511026','511025','511033','511023','133034','133033','169011','344008','344009','244022','244026','244025','244030','244023','244024','244027','244028','244029','244031','082046','082047','082048','126015','126016','416004','416005','421001','421002','016037','016036','115124','115125','115126','240049','240048','240047','240046','240045','240044','244032','244033','422001','422002','422003','422004','422005','184013','239002','805001','805002','805003','805004','805005','056024','423001','344010','235009','212014','056025','056026','802002','244034','244035','244036','244037','244038','244039','515017','504046','203015','245002','245001','071023','056027','056028','056029','056030','056031','056032','424001','056034','056033','805006','805007','805008','805009','805010','422008','422007','422006','422010','422009','422011','209004','150022','150023','100002','056035','023036','185004','185005','246001','247001','247002','425001','416006','165042','165041','165040','165043','010040','010039','010038','010037','010036','422012','422013','422014','422015','426000','248001','248002','248003','248004','248005','249001','249002','249003','249004','249005','249006','250007','250001','250002','250003','250004','250005','250006','250008','250009','250010','250011','250012','250013','251001','251002','422016','422017','422018','806001','806002','116013','235010','235011','091026','091027','091028','091029','091019','091020','091021','091022','091023','091024','091025','252001','243009','249007','249008','249009','011024','011025','427001','428002','428001','169012','429001','429002','429003') DEFAULT '001001' NOT NULL, KEY field (field) diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 23941ad2913..f6281ca6c21 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -2,11 +2,14 @@ # ----------- # Numeric floating point. +--disable_warnings +drop table if exists t1; +--enable_warnings + SELECT 10,10.0,10.,.1e+2,100.0e-1; SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000; SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1; -drop table if exists t1; create table t1 (f1 float(24),f2 float(52)); show full columns from t1; insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150); @@ -44,6 +47,8 @@ drop table t1; # Errors -!$1063 create table t1 (f float(54)); # Should give an error +--error 1063 +create table t1 (f float(54)); # Should give an error +--disable_warnings drop table if exists t1; - +--enable_warnings diff --git a/mysql-test/t/type_ranges.test b/mysql-test/t/type_ranges.test index a07a1d97f37..767012d0b34 100644 --- a/mysql-test/t/type_ranges.test +++ b/mysql-test/t/type_ranges.test @@ -2,7 +2,9 @@ # Test ranges for all types and some other basic tests # +--disable_warnings drop table if exists t1,t2,t3; +--enable_warnings CREATE TABLE t1 ( auto int(5) unsigned DEFAULT 0 NOT NULL auto_increment, @@ -53,7 +55,7 @@ DROP INDEX test ON t1; insert into t1 values (10, 1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one'); insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,NULL,2,2,'two','two,one'); -insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303 101010','','','','3',3,3); +insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303101010','','','','3',3,3); insert into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1); insert into t1 values (0,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,NULL,0,0,0,-4294967295,-4294967295,-4294967295,'-4294967295',0,"one,two,tree"); insert into t1 values (0,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,NULL,0,0,0,4294967295,4294967295,4294967295,'4294967295',0,0); diff --git a/mysql-test/t/type_set.test b/mysql-test/t/type_set.test index 7f1a75e5dbd..4505e3f747b 100644 --- a/mysql-test/t/type_set.test +++ b/mysql-test/t/type_set.test @@ -2,7 +2,10 @@ # Test of SET with space # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (a set (' ','a','b') not null); show create table t1; drop table t1; diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test index 2496ec36915..2f342f8bf67 100644 --- a/mysql-test/t/type_time.test +++ b/mysql-test/t/type_time.test @@ -1,7 +1,11 @@ # # testing of the TIME column type # + +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (t time); insert into t1 values("10:22:33"),("12:34:56.78"),(10),(1234),(123456.78),(1234559.99),("1"),("1:23"),("1:23:45"), ("10.22"), ("-10 1:22:33.45"),("20 10:22:33"),("1999-02-03 20:33:34"); insert t1 values (30),(1230),("1230"),("12:30"),("12:30:35"),("1 12:30:31.32"); diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index eb0def74a17..cd76dbe6ab0 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -2,7 +2,10 @@ # Test timestamp # +--disable_warnings drop table if exists t1,t2; +--enable_warnings + CREATE TABLE t1 (a int, t timestamp); CREATE TABLE t2 (a int, t datetime); SET TIMESTAMP=1234; @@ -35,7 +38,7 @@ drop table t1; create table t1 (ix timestamp); insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000); -select * from t1; +select ix+0 from t1; drop table t1; CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp); diff --git a/mysql-test/t/type_uint.test b/mysql-test/t/type_uint.test index 32bcd61ecdb..b4c88eae95d 100644 --- a/mysql-test/t/type_uint.test +++ b/mysql-test/t/type_uint.test @@ -2,7 +2,10 @@ # test of unsigned int # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (this int unsigned); insert into t1 values (1); insert into t1 values (-1); diff --git a/mysql-test/t/type_year.test b/mysql-test/t/type_year.test index 8f4f23badb4..9922df447fc 100644 --- a/mysql-test/t/type_year.test +++ b/mysql-test/t/type_year.test @@ -1,7 +1,10 @@ # # Test year # +--disable_warnings drop table if exists t1; +--enable_warnings + create table t1 (y year,y2 year(2)); insert into t1 values (0,0),(1999,1999),(2000,2000),(2001,2001),(70,70),(69,69); select * from t1; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 6e6b43ebe3b..d2f35b59f54 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -2,7 +2,10 @@ # Test of unions # +--disable_warnings drop table if exists t1,t2,t3; +--enable_warnings + CREATE TABLE t1 (a int not null, b char (10) not null); insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); CREATE TABLE t2 (a int not null, b char (10) not null); @@ -20,8 +23,10 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g (select a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 4; (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1); (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc; +--error 1248 +(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b; explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc; -(select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2; +#(select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2; select found_rows(); # @@ -86,7 +91,7 @@ SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT pseudo FROM t1 WHERE pse SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION ALL SELECT pseudo FROM t1 WHERE pseudo1='joce'; SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT 1; drop table t1; -drop table if exists t1,t2; + create table t1 (a int); create table t2 (a int); insert into t1 values (1),(2),(3),(4),(5); @@ -98,3 +103,46 @@ set SQL_SELECT_LIMIT=2; (select * from t1 limit 1) union (select * from t2 limit 3); set SQL_SELECT_LIMIT=DEFAULT; drop table t1,t2; + +--error 1096 +select * union select 1; +select 1 as a,(select a union select a); +--disable_warnings +drop table if exists t1,t2; +--enable_warnings +CREATE TABLE t1 ( id int(3) unsigned default '0') TYPE=MyISAM; +INSERT INTO t1 (id) VALUES("1"); +CREATE TABLE t2 ( id int(3) unsigned default '0', id_master int(5) default '0', text1 varchar(5) default NULL, text2 varchar(5) default NULL) TYPE=MyISAM; +INSERT INTO t2 (id, id_master, text1, text2) VALUES("1", "1", +"foo1", "bar1"); +INSERT INTO t2 (id, id_master, text1, text2) VALUES("2", "1", +"foo2", "bar2"); +INSERT INTO t2 (id, id_master, text1, text2) VALUES("3", "1", NULL, +"bar3"); +INSERT INTO t2 (id, id_master, text1, text2) VALUES("4", "1", +"foo4", "bar4"); +SELECT 1 AS id_master, 1 AS id, NULL AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master; +SELECT 1 AS id_master, 1 AS id, 'ABCDE' AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master; +drop table if exists t1,t2; +(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2); + +# +# Test of bug when using the same table multiple times +# +create table t1 (a int not null primary key auto_increment, b int, key(b)); +create table t2 (a int not null primary key auto_increment, b int); +insert into t1 (b) values (1),(2),(2),(3); +insert into t2 (b) values (10),(11),(12),(13); + +explain (select * from t1 where a=1) union (select * from t2 where a=1); +(select * from t1 where a=5) union (select * from t2 where a=1); +(select * from t1 where a=5 and a=6) union (select * from t2 where a=1); +(select t1.a,t1.b from t1,t2 where t1.a=5) union (select * from t2 where a=1); +(select * from t1 where a=1) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a); +explain (select * from t1 where a=1 and b=10) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a); +explain (select * from t1 where a=1) union (select * from t1 where b=1); +drop table t1,t2; +--error 1054 +(select 1) union (select 2) order by 0; + +SELECT @a:=1 UNION SELECT @a:=@a+1; diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index 5cbbd2a350e..31d22c1f850 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -2,7 +2,10 @@ # test of updating of keys # -drop table if exists t1; +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + create table t1 (a int auto_increment , primary key (a)); insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); update t1 set a=a+10 where a > 34; @@ -85,5 +88,8 @@ create table t1 (a int not null, b int not null); insert into t1 values (1,1),(1,2),(1,3); update t1 set b=4 where a=1 order by b asc limit 1; update t1 set b=4 where a=1 order by b desc limit 1; +create table t2 (a int not null, b int not null); +insert into t2 values (1,1),(1,2),(1,3); select * from t1; -drop table t1; +update t1 set b=(select distinct 1 from (select * from t2) a); +drop table t1,t2; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index bb1a9b59611..6260db8c370 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -1,11 +1,15 @@ -error 1054; +# Initialise +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +--error 1054 set @a := foo; set @a := connection_id() + 3; select @a - connection_id(); # Check using and setting variables with SELECT DISTINCT -drop table if exists t1,t2; CREATE TABLE t1 ( i int not null, v int not null,index (i)); insert into t1 values (1,1),(1,3),(2,1); create table t2 (i int not null, unique (i)); diff --git a/mysql-test/t/varbinary.test b/mysql-test/t/varbinary.test index cc9ee99b7f9..d58954a189b 100644 --- a/mysql-test/t/varbinary.test +++ b/mysql-test/t/varbinary.test @@ -1,3 +1,8 @@ +# Initialise +--disable_warnings +drop table if exists t1; +--enable_warnings + # # varbinary as string and number # @@ -10,7 +15,6 @@ select x'31',X'ffff'+0; # Test of hex constants in WHERE: # -drop table if exists t1; create table t1 (ID int(8) unsigned zerofill not null auto_increment,UNIQ bigint(21) unsigned zerofill not null,primary key (ID),unique (UNIQ) ); insert into t1 set UNIQ=0x38afba1d73e6a18a; insert into t1 set UNIQ=123; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 5863cb97d57..39aa5a20a71 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -1,7 +1,10 @@ # # test variables # -drop table if exists t1; +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + set @`test`=1,@TEST=3,@select=2,@t5=1.23456; select @test,@`select`,@TEST,@not_used; set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL; @@ -229,7 +232,6 @@ set log_warnings=1; # key buffer # -DROP TABLE IF EXISTS t1,t2; create table t1 (a int not null auto_increment, primary key(a)); create table t2 (a int not null auto_increment, primary key(a)); insert into t1 values(null),(null),(null); diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test index 5fb536def71..8cff8706c43 100644 --- a/mysql-test/t/warnings.test +++ b/mysql-test/t/warnings.test @@ -1,7 +1,10 @@ # # Test some warnings # +--disable-warnings drop table if exists t1; +--enable-warnings + create table t1 (a int); insert into t1 values (1); insert into t1 values ("hej"); @@ -11,3 +14,15 @@ insert into t1 values ("hej"); insert into t1 values ("hej"),("då"); drop table t1; set SQL_WARNINGS=0; + +# +# Test other warnings + +drop temporary table if exists not_exists; +drop table if exists not_exists_table; +show warnings limit 1; +drop database if exists not_exists_db; +show count(*) warnings; +create table t1(id int); +create table if not exists t1(id int); +select @@warning_count; |