diff options
Diffstat (limited to 'mysql-test')
219 files changed, 10893 insertions, 436 deletions
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index d48b8c7dfe4..6c7207b0b2d 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -33,7 +33,7 @@ endif benchdir_root= $(prefix) testdir = $(benchdir_root)/mysql-test EXTRA_SCRIPTS = mysql-test-run-shell.sh install_test_db.sh valgrind.supp $(PRESCRIPTS) -EXTRA_DIST = $(EXTRA_SCRIPTS) +EXTRA_DIST = $(EXTRA_SCRIPTS) suite GENSCRIPTS = mysql-test-run-shell mysql-test-run install_test_db mtr PRESCRIPTS = mysql-test-run.pl test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS) @@ -67,6 +67,7 @@ dist-hook: $(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(distdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(distdir)/std_data $(INSTALL_DATA) $(srcdir)/lib/*.pl $(distdir)/lib + -rm -rf `find $(distdir)/suite -type d -name SCCS` install-data-local: $(mkinstalldirs) \ @@ -98,6 +99,12 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/lib/*.pl $(DESTDIR)$(testdir)/lib + for f in `(cd $(srcdir); find suite -type f | grep -v SCCS)`; \ + do \ + d=$(DESTDIR)$(testdir)/`dirname $$f`; \ + mkdir -p $$d ; \ + $(INSTALL_DATA) $(srcdir)/$$f $$d ; \ + done uninstall-local: @RM@ -f -r $(DESTDIR)$(testdir) diff --git a/mysql-test/include/gis_generic.inc b/mysql-test/include/gis_generic.inc index dc5d95baad9..70e82a13364 100644 --- a/mysql-test/include/gis_generic.inc +++ b/mysql-test/include/gis_generic.inc @@ -177,4 +177,73 @@ insert into t1 values (pointfromtext('point(1,1)')); drop table t1; -# End of 5.0 tests +--echo End of 4.1 tests + + +# +# Bug#24563: MBROverlaps does not seem to function propertly +# Bug#54888: MBROverlaps missing in 5.1? +# + +# Test all MBR* functions and their non-MBR-prefixed aliases, +# using shifted squares to verify the spatial relations. + +CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY); + +INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); + +INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); +INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); + +INSERT INTO t1 VALUES("up", GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))')); +INSERT INTO t1 VALUES("up2", GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))')); +INSERT INTO t1 VALUES("up3", GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))')); + +INSERT INTO t1 VALUES("down", GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))')); +INSERT INTO t1 VALUES("down2", GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))')); +INSERT INTO t1 VALUES("down3", GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))')); + +INSERT INTO t1 VALUES("right", GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))')); +INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))')); +INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))')); + +INSERT INTO t1 VALUES("left", GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))')); +INSERT INTO t1 VALUES("left2", GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))')); +INSERT INTO t1 VALUES("left3", GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))')); + +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal FROM t1 a1 JOIN t1 a2 ON MBREqual( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; + +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals FROM t1 a1 JOIN t1 a2 ON Equals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect FROM t1 a1 JOIN t1 a2 ON Intersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps FROM t1 a1 JOIN t1 a2 ON Overlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; + +# Overlaps needs a few more tests, with point and line dimensions + +SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))'); +SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))'); +SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))'); +SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))'); +SET @point1 = GeomFromText('POLYGON ((0 0))'); +SET @point2 = GeomFromText('POLYGON ((-2 0))'); + +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name; +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name; +SELECT Overlaps(@horiz1, @vert1) FROM DUAL; +SELECT Overlaps(@horiz1, @horiz2) FROM DUAL; +SELECT Overlaps(@horiz1, @horiz3) FROM DUAL; +SELECT Overlaps(@horiz1, @point1) FROM DUAL; +SELECT Overlaps(@horiz1, @point2) FROM DUAL; + +DROP TABLE t1; + +--echo End of 5.0 tests diff --git a/mysql-test/include/ndb_backup.inc b/mysql-test/include/ndb_backup.inc new file mode 100644 index 00000000000..f0a883d4e11 --- /dev/null +++ b/mysql-test/include/ndb_backup.inc @@ -0,0 +1,24 @@ +###################################################### +# By JBM 2006-02-16 So that the code is not repeated # +# in test cases and can be reused. # +###################################################### +--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "start backup" >> $NDB_TOOLS_OUTPUT + +# there is no neat way to find the backupid, this is a hack to find it... + +--exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $MYSQLTEST_VARDIR/tmp.dat + +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; + +DELETE FROM test.backup_info; + +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; + +--replace_column 1 <the_backup_id> + +SELECT @the_backup_id:=backup_id FROM test.backup_info; + +let the_backup_id=`select @the_backup_id`; + +DROP TABLE test.backup_info; + diff --git a/mysql-test/include/ndb_backup_print.inc b/mysql-test/include/ndb_backup_print.inc new file mode 100644 index 00000000000..57fb279491c --- /dev/null +++ b/mysql-test/include/ndb_backup_print.inc @@ -0,0 +1,6 @@ +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults $ndb_restore_opts -b $the_backup_id -n 1 $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id $ndb_restore_filter > $MYSQLTEST_VARDIR/tmp/tmp.dat +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults $ndb_restore_opts -b $the_backup_id -n 2 $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id $ndb_restore_filter >> $MYSQLTEST_VARDIR/tmp/tmp.dat +--exec sort $MYSQLTEST_VARDIR/tmp/tmp.dat +--exec rm -f $MYSQLTEST_VARDIR/tmp/tmp.dat +--let ndb_restore_opts= +--let ndb_restore_filter= diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index 22290a88d39..28c78fbffeb 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -498,6 +498,17 @@ sub collect_one_test_case($$$$$$$) { { mtr_options_from_test_file($tinfo,"$testdir/${tname}.test"); + if ( defined $::used_default_engine ) + { + # Different default engine is used + # tag test to require that engine + $tinfo->{'ndb_test'}= 1 + if ( $::used_default_engine =~ /^ndb/i ); + + $tinfo->{'innodb_test'}= 1 + if ( $::used_default_engine =~ /^innodb/i ); + } + if ( $tinfo->{'big_test'} and ! $::opt_big_test ) { $tinfo->{'skip'}= 1; diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 690ca8313dd..53bf37bcc83 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -38,8 +38,8 @@ sub mtr_kill_processes ($); sub mtr_ping_with_timeout($); sub mtr_ping_port ($); -# static in C -sub spawn_impl ($$$$$$$$); +# Local function +sub spawn_impl ($$$$$$$); ############################################################################## # @@ -47,18 +47,16 @@ sub spawn_impl ($$$$$$$$); # ############################################################################## -# This function try to mimic the C version used in "netware/mysql_test_run.c" - sub mtr_run ($$$$$$;$) { my $path= shift; my $arg_list_t= shift; my $input= shift; my $output= shift; my $error= shift; - my $pid_file= shift; + my $pid_file= shift; # Not used my $spawn_opts= shift; - return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,$pid_file, + return spawn_impl($path,$arg_list_t,'run',$input,$output,$error, $spawn_opts); } @@ -68,10 +66,10 @@ sub mtr_run_test ($$$$$$;$) { my $input= shift; my $output= shift; my $error= shift; - my $pid_file= shift; + my $pid_file= shift; # Not used my $spawn_opts= shift; - return spawn_impl($path,$arg_list_t,'test',$input,$output,$error,$pid_file, + return spawn_impl($path,$arg_list_t,'test',$input,$output,$error, $spawn_opts); } @@ -81,28 +79,22 @@ sub mtr_spawn ($$$$$$;$) { my $input= shift; my $output= shift; my $error= shift; - my $pid_file= shift; + my $pid_file= shift; # Not used my $spawn_opts= shift; - return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,$pid_file, + return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error, $spawn_opts); } -############################################################################## -# -# If $join is set, we return the error code, else we return the PID -# -############################################################################## -sub spawn_impl ($$$$$$$$) { +sub spawn_impl ($$$$$$$) { my $path= shift; my $arg_list_t= shift; my $mode= shift; my $input= shift; my $output= shift; my $error= shift; - my $pid_file= shift; # FIXME my $spawn_opts= shift; if ( $::opt_script_debug ) @@ -155,10 +147,6 @@ sub spawn_impl ($$$$$$$$) { else { # Child, redirect output and exec - # FIXME I tried POSIX::setsid() here to detach and, I hoped, - # avoid zombies. But everything went wild, somehow the parent - # became a deamon as well, and was hard to kill ;-) - # Need to catch SIGCHLD and do waitpid or something instead...... $SIG{INT}= 'DEFAULT'; # Parent do some stuff, we don't @@ -196,7 +184,15 @@ sub spawn_impl ($$$$$$$$) { } else { - if ( ! open(STDERR,$log_file_open_mode,$error) ) + if ( $::glob_win32_perl ) + { + # Don't redirect stdout on ActiveState perl since this is + # just another thread in the same process. + # Should be fixed so that the thread that is created with fork + # executes the exe in another process and wait's for it to return. + # In the meanwhile, we get all the output from mysqld's to screen + } + elsif ( ! open(STDERR,$log_file_open_mode,$error) ) { mtr_child_error("can't redirect STDERR to \"$error\": $!"); } @@ -259,9 +255,7 @@ sub spawn_parent_impl { # We do blocking waitpid() until we get the return from the # "mysqltest" call. But if a mysqld process dies that we # started, we take this as an error, and kill mysqltest. - # - # FIXME is this as it should be? Can't mysqld terminate - # normally from running a test case? + my $exit_value= -1; my $saved_exit_value; @@ -450,7 +444,6 @@ sub mtr_kill_leftovers () { # We scan the "var/run/" directory for other process id's to kill - # FIXME $path_run_dir or something my $rundir= "$::opt_vardir/run"; mtr_debug("Processing PID files in directory '$rundir'..."); diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index fadb7c5f0e0..b48ac6c5abc 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -304,6 +304,7 @@ our $path_sql_dir; our @data_dir_lst; our $used_binlog_format; +our $used_default_engine; our $debug_compiled_binaries; our $glob_tot_real_time= 0; @@ -353,7 +354,7 @@ sub do_before_start_slave ($); sub ndbd_start ($$$); sub ndb_mgmd_start ($); sub mysqld_start ($$$); -sub mysqld_arguments ($$$$$); +sub mysqld_arguments ($$$$); sub stop_all_servers (); sub run_mysqltest ($); sub usage ($); @@ -519,7 +520,7 @@ sub command_line_setup () { 'compress' => \$opt_compress, 'bench' => \$opt_bench, 'small-bench' => \$opt_small_bench, - 'with-ndbcluster' => \$opt_with_ndbcluster, + 'with-ndbcluster|ndb' => \$opt_with_ndbcluster, 'vs-config' => \$opt_vs_config, # Control what test suites or cases to run @@ -776,6 +777,26 @@ sub command_line_setup () { mtr_report("Using binlog format '$used_binlog_format'"); } + + # -------------------------------------------------------------------------- + # Find out default storage engine being used(if any) + # -------------------------------------------------------------------------- + if ( $opt_with_ndbcluster ) + { + # --ndb or --with-ndbcluster turns on --default-storage-engine=ndbcluster + push(@opt_extra_mysqld_opt, "--default-storage-engine=ndbcluster"); + } + + foreach my $arg ( @opt_extra_mysqld_opt ) + { + if ( $arg =~ /default-storage-engine=(\S+)/ ) + { + $used_default_engine= $1; + } + } + mtr_report("Using default engine '$used_default_engine'") + if defined $used_default_engine; + # -------------------------------------------------------------------------- # Check if we should speed up tests by trying to run on tmpfs # -------------------------------------------------------------------------- @@ -848,20 +869,22 @@ sub command_line_setup () { # -------------------------------------------------------------------------- # Check im suport # -------------------------------------------------------------------------- - if (!$opt_extern) + if ($opt_extern) { - if ( $mysql_version_id < 50000 ) { - # Instance manager is not supported until 5.0 - $opt_skip_im= 1; - - } - - if ( $glob_win32 ) { - mtr_report("Disable Instance manager - not supported on Windows"); - $opt_skip_im= 1; - } - + mtr_report("Disable instance manager when running with extern mysqld"); + $opt_skip_im= 1; + } + elsif ( $mysql_version_id < 50000 ) + { + # Instance manager is not supported until 5.0 + $opt_skip_im= 1; + } + elsif ( $glob_win32 ) + { + mtr_report("Disable Instance manager - testing not supported on Windows"); + $opt_skip_im= 1; } + # -------------------------------------------------------------------------- # Record flag # -------------------------------------------------------------------------- @@ -899,10 +922,6 @@ sub command_line_setup () { # -------------------------------------------------------------------------- # Ndb cluster flags # -------------------------------------------------------------------------- - if ( $opt_with_ndbcluster and !$opt_bench) - { - mtr_error("Can only use --with-ndbcluster togheter with --bench"); - } if ( $opt_ndbconnectstring ) { @@ -1055,8 +1074,6 @@ sub command_line_setup () { # socket path names. $sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) > 80 ); - # Put this into a hash, will be a C struct - $master->[0]= { pid => 0, @@ -1064,7 +1081,6 @@ sub command_line_setup () { idx => 0, path_myddir => "$opt_vardir/master-data", path_myerr => "$opt_vardir/log/master.err", - path_mylog => "$opt_vardir/log/master.log", path_pid => "$opt_vardir/run/master.pid", path_sock => "$sockdir/master.sock", port => $opt_master_myport, @@ -1080,7 +1096,6 @@ sub command_line_setup () { idx => 1, path_myddir => "$opt_vardir/master1-data", path_myerr => "$opt_vardir/log/master1.err", - path_mylog => "$opt_vardir/log/master1.log", path_pid => "$opt_vardir/run/master1.pid", path_sock => "$sockdir/master1.sock", port => $opt_master_myport + 1, @@ -1096,7 +1111,6 @@ sub command_line_setup () { idx => 0, path_myddir => "$opt_vardir/slave-data", path_myerr => "$opt_vardir/log/slave.err", - path_mylog => "$opt_vardir/log/slave.log", path_pid => "$opt_vardir/run/slave.pid", path_sock => "$sockdir/slave.sock", port => $opt_slave_myport, @@ -1113,7 +1127,6 @@ sub command_line_setup () { idx => 1, path_myddir => "$opt_vardir/slave1-data", path_myerr => "$opt_vardir/log/slave1.err", - path_mylog => "$opt_vardir/log/slave1.log", path_pid => "$opt_vardir/run/slave1.pid", path_sock => "$sockdir/slave1.sock", port => $opt_slave_myport + 1, @@ -1129,7 +1142,6 @@ sub command_line_setup () { idx => 2, path_myddir => "$opt_vardir/slave2-data", path_myerr => "$opt_vardir/log/slave2.err", - path_mylog => "$opt_vardir/log/slave2.log", path_pid => "$opt_vardir/run/slave2.pid", path_sock => "$sockdir/slave2.sock", port => $opt_slave_myport + 2, @@ -1333,7 +1345,7 @@ sub collect_mysqld_features () { # # Execute "mysqld --no-defaults --help --verbose" to get a - # of all features and settings + # list of all features and settings # my $list= `$exe_mysqld --no-defaults --verbose --help`; @@ -1397,6 +1409,40 @@ sub collect_mysqld_features () { } +sub run_query($$) { + my ($mysqld, $query)= @_; + + my $args; + mtr_init_args(\$args); + + mtr_add_arg($args, "--no-defaults"); + mtr_add_arg($args, "--user=%s", $opt_user); + mtr_add_arg($args, "--port=%d", $mysqld->{'port'}); + mtr_add_arg($args, "--socket=%s", $mysqld->{'path_sock'}); + mtr_add_arg($args, "--silent"); # Tab separated output + mtr_add_arg($args, "-e '%s'", $query); + + my $cmd= "$exe_mysql " . join(' ', @$args); + mtr_verbose("cmd: $cmd"); + return `$cmd`; +} + + +sub collect_mysqld_features_from_running_server () +{ + my $list= run_query($master->[0], "use mysql; SHOW VARIABLES"); + + foreach my $line (split('\n', $list)) + { + # Put variables into hash + if ( $line =~ /^([\S]+)[ \t]+(.*?)\r?$/ ) + { + print "$1=\"$2\"\n"; + $mysqld_variables{$1}= $2; + } + } +} + sub executable_setup_im () { # Look for instance manager binary - mysqlmanager @@ -1913,7 +1959,7 @@ sub environment_setup () { # ---------------------------------------------------- my $cmdline_mysqlbinlog= mtr_native_path($exe_mysqlbinlog) . - " --no-defaults --local-load=$opt_tmpdir"; + " --no-defaults"; if (!$opt_extern && $mysql_version_id >= 50000 ) { $cmdline_mysqlbinlog .=" --character-sets-dir=$path_charsetsdir"; @@ -3614,21 +3660,20 @@ sub do_before_start_slave ($) { } -sub mysqld_arguments ($$$$$) { +sub mysqld_arguments ($$$$) { my $args= shift; - my $type= shift; - my $idx= shift; + my $mysqld= shift; my $extra_opt= shift; my $slave_master_info= shift; + my $idx= $mysqld->{'idx'}; my $sidx= ""; # Index as string, 0 is empty string - if ( $idx > 0 ) + if ( $idx> 0 ) { - $sidx= "$idx"; + $sidx= $idx; } my $prefix= ""; # If mysqltest server arg - if ( $glob_use_embedded_server ) { $prefix= "--server-arg="; @@ -3642,8 +3687,16 @@ sub mysqld_arguments ($$$$$) { if ( $mysql_version_id >= 50036) { - # Prevent the started mysqld to access files outside of vardir - mtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir); + # By default, prevent the started mysqld to access files outside of vardir + my $secure_file_dir= $opt_vardir; + if ( $opt_suite ne "main" ) + { + # When running a suite other than default allow the mysqld + # access to subdirs of mysql-test/ in order to make it possible + # to "load data" from the suites data/ directory. + $secure_file_dir= $glob_mysql_test_dir; + } + mtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $secure_file_dir); } if ( $mysql_version_id >= 50000 ) @@ -3665,36 +3718,55 @@ sub mysqld_arguments ($$$$$) { } } + mtr_add_arg($args, "%s--pid-file=%s", $prefix, + $mysqld->{'path_pid'}); + + mtr_add_arg($args, "%s--port=%d", $prefix, + $mysqld->{'port'}); + + mtr_add_arg($args, "%s--socket=%s", $prefix, + $mysqld->{'path_sock'}); + + mtr_add_arg($args, "%s--datadir=%s", $prefix, + $mysqld->{'path_myddir'}); + + + if ( $mysql_version_id >= 50106 ) + { + # Turn on logging to bothe tables and file + mtr_add_arg($args, "%s--log-output=table,file", $prefix); + } + + my $log_base_path= "$opt_vardir/log/$mysqld->{'type'}$sidx"; + mtr_add_arg($args, "%s--log=%s.log", $prefix, $log_base_path); + mtr_add_arg($args, + "%s--log-slow-queries=%s-slow.log", $prefix, $log_base_path); + # Check if "extra_opt" contains --skip-log-bin my $skip_binlog= grep(/^--skip-log-bin/, @$extra_opt); - if ( $type eq 'master' ) + if ( $mysqld->{'type'} eq 'master' ) { - my $id= $idx > 0 ? $idx + 101 : 1; - if (! ($opt_skip_master_binlog || $skip_binlog) ) { mtr_add_arg($args, "%s--log-bin=%s/log/master-bin%s", $prefix, $opt_vardir, $sidx); } - mtr_add_arg($args, "%s--pid-file=%s", $prefix, - $master->[$idx]->{'path_pid'}); - mtr_add_arg($args, "%s--port=%d", $prefix, - $master->[$idx]->{'port'}); - mtr_add_arg($args, "%s--server-id=%d", $prefix, $id); - mtr_add_arg($args, "%s--socket=%s", $prefix, - $master->[$idx]->{'path_sock'}); - mtr_add_arg($args, "%s--innodb_data_file_path=ibdata1:10M:autoextend", $prefix); + + mtr_add_arg($args, "%s--server-id=%d", $prefix, + $idx > 0 ? $idx + 101 : 1); + + mtr_add_arg($args, "%s--innodb_data_file_path=ibdata1:10M:autoextend", + $prefix); + mtr_add_arg($args, "%s--local-infile", $prefix); - mtr_add_arg($args, "%s--datadir=%s", $prefix, - $master->[$idx]->{'path_myddir'}); if ( $idx > 0 or !$use_innodb) { mtr_add_arg($args, "%s--skip-innodb", $prefix); } - my $cluster= $clusters->[$master->[$idx]->{'cluster'}]; + my $cluster= $clusters->[$mysqld->{'cluster'}]; if ( $opt_skip_ndbcluster || !$cluster->{'pid'}) { @@ -3710,26 +3782,12 @@ sub mysqld_arguments ($$$$$) { mtr_add_arg($args, "%s--ndb-extra-logging", $prefix); } } - - if ( $mysql_version_id <= 50106 ) - { - # Force mysqld to use log files up until 5.1.6 - mtr_add_arg($args, "%s--log=%s", $prefix, $master->[0]->{'path_mylog'}); - } - else - { - # Turn on logging, will be sent to tables - mtr_add_arg($args, "%s--log=", $prefix); - } } - - if ( $type eq 'slave' ) + else { - my $slave_server_id= 2 + $idx; - my $slave_rpl_rank= $slave_server_id; + mtr_error("unknown mysqld type") + unless $mysqld->{'type'} eq 'slave'; - mtr_add_arg($args, "%s--datadir=%s", $prefix, - $slave->[$idx]->{'path_myddir'}); mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix); if (! ( $opt_skip_slave_binlog || $skip_binlog )) { @@ -3739,18 +3797,14 @@ sub mysqld_arguments ($$$$$) { } mtr_add_arg($args, "%s--master-retry-count=10", $prefix); - mtr_add_arg($args, "%s--pid-file=%s", $prefix, - $slave->[$idx]->{'path_pid'}); - mtr_add_arg($args, "%s--port=%d", $prefix, - $slave->[$idx]->{'port'}); + mtr_add_arg($args, "%s--relay-log=%s/log/slave%s-relay-bin", $prefix, $opt_vardir, $sidx); mtr_add_arg($args, "%s--report-host=127.0.0.1", $prefix); mtr_add_arg($args, "%s--report-port=%d", $prefix, - $slave->[$idx]->{'port'}); + $mysqld->{'port'}); mtr_add_arg($args, "%s--report-user=root", $prefix); mtr_add_arg($args, "%s--skip-innodb", $prefix); - mtr_add_arg($args, "%s--skip-ndbcluster", $prefix); mtr_add_arg($args, "%s--skip-slave-start", $prefix); # Directory where slaves find the dumps generated by "load data" @@ -3759,8 +3813,6 @@ sub mysqld_arguments ($$$$$) { my $slave_load_path= "../tmp"; mtr_add_arg($args, "%s--slave-load-tmpdir=%s", $prefix, $slave_load_path); - mtr_add_arg($args, "%s--socket=%s", $prefix, - $slave->[$idx]->{'path_sock'}); mtr_add_arg($args, "%s--set-variable=slave_net_timeout=10", $prefix); if ( @$slave_master_info ) @@ -3778,13 +3830,16 @@ sub mysqld_arguments ($$$$$) { mtr_add_arg($args, "%s--master-password=", $prefix); mtr_add_arg($args, "%s--master-port=%d", $prefix, $master->[0]->{'port'}); # First master + + my $slave_server_id= 2 + $idx; + my $slave_rpl_rank= $slave_server_id; mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id); mtr_add_arg($args, "%s--rpl-recovery-rank=%d", $prefix, $slave_rpl_rank); } if ( $opt_skip_ndbcluster_slave || - $slave->[$idx]->{'cluster'} == -1 || - !$clusters->[$slave->[$idx]->{'cluster'}]->{'pid'} ) + $mysqld->{'cluster'} == -1 || + !$clusters->[$mysqld->{'cluster'}]->{'pid'} ) { mtr_add_arg($args, "%s--skip-ndbcluster", $prefix); } @@ -3792,41 +3847,22 @@ sub mysqld_arguments ($$$$$) { { mtr_add_arg($args, "%s--ndbcluster", $prefix); mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix, - $clusters->[$slave->[$idx]->{'cluster'}]->{'connect_string'}); + $clusters->[$mysqld->{'cluster'}]->{'connect_string'}); + if ( $mysql_version_id >= 50100 ) { mtr_add_arg($args, "%s--ndb-extra-logging", $prefix); } } - if ( $mysql_version_id <= 50106 ) - { - # Force mysqld to use log files up until 5.1.6 - mtr_add_arg($args, "%s--log=%s", $prefix, $slave->[0]->{'path_mylog'}); - } - else - { - # Turn on logging, will be sent to tables - mtr_add_arg($args, "%s--log=", $prefix); - } - } # end slave if ( $opt_debug ) { - if ( $type eq 'master' ) - { - mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/master%s.trace", - $prefix, $path_vardir_trace, $sidx); - } - if ( $type eq 'slave' ) - { - mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/slave%s.trace", - $prefix, $path_vardir_trace, $sidx); - } + mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/%s%s.trace", + $prefix, $path_vardir_trace, $mysqld->{'type'}, $sidx); } - # FIXME always set nowdays??? SMALL_SERVER mtr_add_arg($args, "%s--key_buffer_size=1M", $prefix); mtr_add_arg($args, "%s--sort_buffer=256K", $prefix); mtr_add_arg($args, "%s--max_heap_table_size=1M", $prefix); @@ -3852,18 +3888,10 @@ sub mysqld_arguments ($$$$$) { mtr_add_arg($args, "%s--gdb", $prefix); } - # If we should run all tests cases, we will use a local server for that - - if ( -w "/" ) - { - # We are running as root; We need to add the --root argument - mtr_add_arg($args, "%s--user=root", $prefix); - } - my $found_skip_core= 0; foreach my $arg ( @opt_extra_mysqld_opt, @$extra_opt ) { - # Allow --skip-core-file to be set in master.opt file + # Allow --skip-core-file to be set in <testname>-[master|slave].opt file if ($arg eq "--skip-core-file") { $found_skip_core= 1; @@ -3887,7 +3915,7 @@ sub mysqld_arguments ($$$$$) { mtr_add_arg($args, "%s--rpl-recovery-rank=1", $prefix); mtr_add_arg($args, "%s--init-rpl-role=master", $prefix); } - elsif ( $type eq 'master' ) + elsif ( $mysqld->{'type'} eq 'master' ) { mtr_add_arg($args, "%s--open-files-limit=1024", $prefix); } @@ -3938,7 +3966,7 @@ sub mysqld_start ($$$) { valgrind_arguments($args, \$exe); } - mysqld_arguments($args,$type,$idx,$extra_opt,$slave_master_info); + mysqld_arguments($args,$mysqld,$extra_opt,$slave_master_info); if ( $opt_gdb || $opt_manual_gdb) { @@ -4682,7 +4710,7 @@ sub run_mysqltest ($) { if ( $glob_use_embedded_server ) { - mysqld_arguments($args,'master',0,$tinfo->{'master_opt'},[]); + mysqld_arguments($args,$master->[0],$tinfo->{'master_opt'},[]); } # ---------------------------------------------------------------------- @@ -5012,7 +5040,7 @@ Options to control what engine/variation to run skip-ssl Dont start server with support for ssl connections bench Run the benchmark suite small-bench Run the benchmarks with --small-tests --small-tables - with-ndbcluster Use cluster as default table type for benchmark + ndb|with-ndbcluster Use cluster as default table type vs-config Visual Studio configuration used to create executables (default: MTR_VS_CONFIG environment variable) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index d8de2655c6c..82c35ff963a 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -826,3 +826,37 @@ create table t1 (t varchar(255) default null, key t (t(80))) engine=myisam default charset=latin1; alter table t1 change t t text; drop table t1; +CREATE TABLE t1 (a varchar(500)); +ALTER TABLE t1 ADD b GEOMETRY NOT NULL, ADD SPATIAL INDEX(b); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(500) default NULL, + `b` geometry NOT NULL, + SPATIAL KEY `b` (`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +ALTER TABLE t1 ADD KEY(b(50)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(500) default NULL, + `b` geometry NOT NULL, + SPATIAL KEY `b` (`b`), + KEY `b_2` (`b`(50)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +ALTER TABLE t1 ADD c POINT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(500) default NULL, + `b` geometry NOT NULL, + `c` point default NULL, + SPATIAL KEY `b` (`b`), + KEY `b_2` (`b`(50)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 (a INT, KEY (a(20))); +ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys +ALTER TABLE t1 ADD d INT; +ALTER TABLE t1 ADD KEY (d(20)); +ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys +DROP TABLE t1; diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index f73a80dde65..d89cecedcdd 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -12355,3 +12355,12 @@ auto fld1 companynr fld3 fld4 fld5 4 011403 37 intercepted audiology tinily 4 011403 37 intercepted audiology tinily drop table t1, t2, t4; +create table t1 (i int) engine=archive; +insert into t1 values (1); +repair table t1 use_frm; +Table Op Msg_type Msg_text +test.t1 repair status OK +select * from t1; +i +1 +drop table t1; diff --git a/mysql-test/r/archive_gis.result b/mysql-test/r/archive_gis.result index 7fb69e54a4c..3137d43ec3a 100644 --- a/mysql-test/r/archive_gis.result +++ b/mysql-test/r/archive_gis.result @@ -392,7 +392,7 @@ Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r FROM gis_geometrycollection g1, gis_geometrycollection 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 +120 121 0 0 1 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 explain extended SELECT g1.fid as first, g2.fid as second, @@ -456,3 +456,89 @@ ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field insert into t1 values (pointfromtext('point(1,1)')); ERROR 23000: Column 'fl' cannot be null drop table t1; +End of 4.1 tests +CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY); +INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); +INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); +INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); +INSERT INTO t1 VALUES("up", GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))')); +INSERT INTO t1 VALUES("up2", GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))')); +INSERT INTO t1 VALUES("up3", GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))')); +INSERT INTO t1 VALUES("down", GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))')); +INSERT INTO t1 VALUES("down2", GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))')); +INSERT INTO t1 VALUES("down3", GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))')); +INSERT INTO t1 VALUES("right", GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))')); +INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))')); +INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))')); +INSERT INTO t1 VALUES("left", GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))')); +INSERT INTO t1 VALUES("left2", GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))')); +INSERT INTO t1 VALUES("left3", GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))')); +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrcontains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrdisjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal FROM t1 a1 JOIN t1 a2 ON MBREqual( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrequal +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrintersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbroverlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrtouches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrwithin +big,center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +contains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +disjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals FROM t1 a1 JOIN t1 a2 ON Equals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +equals +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect FROM t1 a1 JOIN t1 a2 ON Intersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +intersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps FROM t1 a1 JOIN t1 a2 ON Overlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +overlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +touches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +within +big,center +SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))'); +SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))'); +SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))'); +SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))'); +SET @point1 = GeomFromText('POLYGON ((0 0))'); +SET @point2 = GeomFromText('POLYGON ((-2 0))'); +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name; +overlaps +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name; +overlaps +SELECT Overlaps(@horiz1, @vert1) FROM DUAL; +Overlaps(@horiz1, @vert1) +0 +SELECT Overlaps(@horiz1, @horiz2) FROM DUAL; +Overlaps(@horiz1, @horiz2) +1 +SELECT Overlaps(@horiz1, @horiz3) FROM DUAL; +Overlaps(@horiz1, @horiz3) +0 +SELECT Overlaps(@horiz1, @point1) FROM DUAL; +Overlaps(@horiz1, @point1) +0 +SELECT Overlaps(@horiz1, @point2) FROM DUAL; +Overlaps(@horiz1, @point2) +0 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/bdb_gis.result b/mysql-test/r/bdb_gis.result index 512d681ff32..d48b5a26e1d 100644 --- a/mysql-test/r/bdb_gis.result +++ b/mysql-test/r/bdb_gis.result @@ -392,7 +392,7 @@ Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r FROM gis_geometrycollection g1, gis_geometrycollection 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 +120 121 0 0 1 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 explain extended SELECT g1.fid as first, g2.fid as second, @@ -456,3 +456,89 @@ ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field insert into t1 values (pointfromtext('point(1,1)')); ERROR 23000: Column 'fl' cannot be null drop table t1; +End of 4.1 tests +CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY); +INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); +INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); +INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); +INSERT INTO t1 VALUES("up", GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))')); +INSERT INTO t1 VALUES("up2", GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))')); +INSERT INTO t1 VALUES("up3", GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))')); +INSERT INTO t1 VALUES("down", GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))')); +INSERT INTO t1 VALUES("down2", GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))')); +INSERT INTO t1 VALUES("down3", GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))')); +INSERT INTO t1 VALUES("right", GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))')); +INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))')); +INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))')); +INSERT INTO t1 VALUES("left", GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))')); +INSERT INTO t1 VALUES("left2", GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))')); +INSERT INTO t1 VALUES("left3", GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))')); +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrcontains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrdisjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal FROM t1 a1 JOIN t1 a2 ON MBREqual( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrequal +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrintersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbroverlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrtouches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrwithin +big,center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +contains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +disjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals FROM t1 a1 JOIN t1 a2 ON Equals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +equals +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect FROM t1 a1 JOIN t1 a2 ON Intersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +intersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps FROM t1 a1 JOIN t1 a2 ON Overlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +overlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +touches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +within +big,center +SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))'); +SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))'); +SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))'); +SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))'); +SET @point1 = GeomFromText('POLYGON ((0 0))'); +SET @point2 = GeomFromText('POLYGON ((-2 0))'); +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name; +overlaps +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name; +overlaps +SELECT Overlaps(@horiz1, @vert1) FROM DUAL; +Overlaps(@horiz1, @vert1) +0 +SELECT Overlaps(@horiz1, @horiz2) FROM DUAL; +Overlaps(@horiz1, @horiz2) +1 +SELECT Overlaps(@horiz1, @horiz3) FROM DUAL; +Overlaps(@horiz1, @horiz3) +0 +SELECT Overlaps(@horiz1, @point1) FROM DUAL; +Overlaps(@horiz1, @point1) +0 +SELECT Overlaps(@horiz1, @point2) FROM DUAL; +Overlaps(@horiz1, @point2) +0 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/client_xml.result b/mysql-test/r/client_xml.result index 7395b2433e8..6a148954fcd 100644 --- a/mysql-test/r/client_xml.result +++ b/mysql-test/r/client_xml.result @@ -7,7 +7,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b'); <?xml version="1.0"?> <resultset statement="select * from t1 -"> +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <row> <field name="a&b">1</field> <field name="a<b">2</field> @@ -34,7 +34,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b'); <?xml version="1.0"?> <resultset statement="select count(*) from t1 -"> +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <row> <field name="count(*)">1</field> </row> @@ -42,7 +42,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b'); <?xml version="1.0"?> <resultset statement="select 1 < 2 from dual -"> +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <row> <field name="1 < 2">1</field> </row> @@ -50,7 +50,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b'); <?xml version="1.0"?> <resultset statement="select 1 > 2 from dual -"> +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <row> <field name="1 > 2">0</field> </row> @@ -58,7 +58,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b'); <?xml version="1.0"?> <resultset statement="select 1 & 3 from dual -"> +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <row> <field name="1 & 3">1</field> </row> @@ -66,7 +66,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b'); <?xml version="1.0"?> <resultset statement="select null from dual -"> +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <row> <field name="NULL" xsi:nil="true" /> </row> diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 11c1431de7b..afa005e74c0 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -447,8 +447,8 @@ t2 CREATE TABLE `t2` ( `ifnull(c,c)` mediumint(8) default NULL, `ifnull(d,d)` int(11) default NULL, `ifnull(e,e)` bigint(20) default NULL, - `ifnull(f,f)` float(24,2) default NULL, - `ifnull(g,g)` double(53,3) default NULL, + `ifnull(f,f)` float(3,2) default NULL, + `ifnull(g,g)` double(4,3) default NULL, `ifnull(h,h)` decimal(5,4) default NULL, `ifnull(i,i)` year(4) default NULL, `ifnull(j,j)` date default NULL, @@ -771,3 +771,4 @@ t1 CREATE TABLE `t1` ( drop table t1; create table t1 (upgrade int); drop table t1; +End of 5.0 tests diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index 3e286c77c00..1fd1493bf1e 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -2654,3 +2654,12 @@ ii 2 ii 2 İİ 4 İİ 4 ii 2 İİ 4 II 2 ıı 4 II 2 DROP TABLE t1; +CREATE TABLE t1 ( +c1 text character set ucs2 collate ucs2_polish_ci NOT NULL +) ENGINE=MyISAM; +insert into t1 values (''),('a'); +SELECT COUNT(*), c1 FROM t1 GROUP BY c1; +COUNT(*) c1 +1 +1 a +DROP TABLE IF EXISTS t1; diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index e32c1e8aae0..960953b3c5e 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -839,6 +839,24 @@ lily river drop table t1; deallocate prepare stmt; +set names latin1; +set character_set_connection=ucs2; +select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); +soundex('') soundex('he') soundex('hello all folks') soundex('#3556 in bugdb') + H000 H4142 I51231 +select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb')); +hex(soundex('')) hex(soundex('he')) hex(soundex('hello all folks')) hex(soundex('#3556 in bugdb')) + 0048003000300030 00480034003100340032 004900350031003200330031 +select 'mood' sounds like 'mud'; +'mood' sounds like 'mud' +1 +select hex(soundex(_ucs2 0x041004110412)); +hex(soundex(_ucs2 0x041004110412)) +0410003000300030 +select hex(soundex(_ucs2 0x00BF00C0)); +hex(soundex(_ucs2 0x00BF00C0)) +00C0003000300030 +set names latin1; create table t1(a blob, b text charset utf8, c text charset ucs2); select data_type, character_octet_length, character_maximum_length from information_schema.columns where table_name='t1'; diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index be1e1742ba6..1c6bc0e05b6 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -854,6 +854,18 @@ select * from t1 where soundex(a) = soundex('test'); id a 1 Test drop table t1; +select soundex(_utf8 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB); +soundex(_utf8 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB) +阅000 +select hex(soundex(_utf8 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)); +hex(soundex(_utf8 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)) +E99885303030 +select soundex(_utf8 0xD091D092D093); +soundex(_utf8 0xD091D092D093) +Б000 +select hex(soundex(_utf8 0xD091D092D093)); +hex(soundex(_utf8 0xD091D092D093)) +D091303030 SET collation_connection='utf8_general_ci'; create table t1 select repeat('a',4000) a; delete from t1; diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 8c3631c2707..f4ec6830cd5 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -186,12 +186,12 @@ date format datetime 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12 -10:20:10 %H:%i:%s 0000-00-00 00:00:00 -10:20:10 %h:%i:%s.%f 0000-00-00 00:00:00 -10:20:10 %T 0000-00-00 00:00:00 -10:20:10AM %h:%i:%s%p 0000-00-00 00:00:00 -10:20:10AM %r 0000-00-00 00:00:00 -10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 00:00:00 +10:20:10 %H:%i:%s 0000-00-00 10:20:10 +10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10 +10:20:10 %T 0000-00-00 10:20:10 +10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10 +10:20:10AM %r 0000-00-00 10:20:10 +10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 @@ -208,13 +208,6 @@ Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00 15-01-20 %d-%m-%y 2020-01-15 00:00:00 15-2001-1 %d-%Y-%c 2001-01-15 00:00:00 -Warnings: -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10.440000' select date,format,DATE(str_to_date(date, format)) as date2 from t1; date format date2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 @@ -255,12 +248,12 @@ date format time 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s NULL -10:20:10 %h:%i:%s.%f NULL -10:20:10 %T NULL -10:20:10AM %h:%i:%s%p NULL -10:20:10AM %r NULL -10:20:10.44AM %h:%i:%s.%f%p NULL +10:20:10 %H:%i:%s 10:20:10 +10:20:10 %h:%i:%s.%f 10:20:10 +10:20:10 %T 10:20:10 +10:20:10AM %h:%i:%s%p 10:20:10 +10:20:10AM %r 10:20:10 +10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 15 September 2001 %d %M %Y 00:00:00 15 SEPTEMB 2001 %d %M %Y 00:00:00 @@ -277,13 +270,6 @@ Tuesday 52 2001 %W %V %X 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 15-01-20 %d-%m-%y 00:00:00 15-2001-1 %d-%Y-%c 00:00:00 -Warnings: -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10.440000' select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1; date format time2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 @@ -293,12 +279,12 @@ date format time2 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s NULL -10:20:10 %h:%i:%s.%f NULL -10:20:10 %T NULL -10:20:10AM %h:%i:%s%p NULL -10:20:10AM %r NULL -10:20:10.44AM %h:%i:%s.%f%p NULL +10:20:10 %H:%i:%s 10:20:10 +10:20:10 %h:%i:%s.%f 10:20:10 +10:20:10 %T 10:20:10 +10:20:10AM %h:%i:%s%p 10:20:10 +10:20:10AM %r 10:20:10 +10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 15 September 2001 %d %M %Y 00:00:00 15 SEPTEMB 2001 %d %M %Y 00:00:00 @@ -315,13 +301,6 @@ Tuesday 52 2001 %W %V %X 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 15-01-20 %d-%m-%y 00:00:00 15-2001-1 %d-%Y-%c 00:00:00 -Warnings: -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10.440000' select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')); concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')) 2003-01-02 08:11:02.123456 @@ -470,8 +449,6 @@ create table t1 select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:% str_to_date("10:11:12.0012", "%H:%i:%S.%f") as f2, str_to_date("2003-01-02", "%Y-%m-%d") as f3, str_to_date("02", "%d") as f4, str_to_date("02 10", "%d %H") as f5; -Warnings: -Warning 1265 Data truncated for column 'f4' at row 1 describe t1; Field Type Null Key Default Extra f1 datetime YES NULL @@ -481,7 +458,7 @@ f4 date YES NULL f5 time YES NULL select * from t1; f1 f2 f3 f4 f5 -2003-01-02 10:11:12 10:11:12 2003-01-02 0000-00-00 58:00:00 +2003-01-02 10:11:12 10:11:12 2003-01-02 0000-00-02 58:00:00 drop table t1; create table t1 select "02 10" as a, "%d %H" as b; select str_to_date(a,b) from t1; diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result index 82a308c63e7..b37679847be 100644 --- a/mysql-test/r/delayed.result +++ b/mysql-test/r/delayed.result @@ -250,3 +250,8 @@ SELECT HEX(a) FROM t1; HEX(a) 1 DROP TABLE t1; +CREATE TABLE t1(c1 INT) ENGINE=MyISAM; +CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1); +INSERT DELAYED INTO t2 VALUES(1); +ERROR HY000: Table storage engine for 't2' doesn't have this option +DROP TABLE t1, t2; diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index ba4e9386312..4bdf1c770d3 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -214,3 +214,12 @@ select count(*) from t1; count(*) 0 drop table t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +DELETE FROM t1 ORDER BY x; +ERROR 42S22: Unknown column 'x' in 'order clause' +DELETE FROM t1 ORDER BY t2.x; +ERROR 42S22: Unknown column 't2.x' in 'order clause' +DELETE FROM t1 ORDER BY (SELECT x); +ERROR 42S22: Unknown column 'x' in 'field list' +DROP TABLE t1; diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index 3508a83a810..190e8595126 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -668,3 +668,17 @@ NULL 3 4 DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES(1,1),(1,2),(1,3); +SELECT DISTINCT a, b FROM t1; +a b +1 1 +1 2 +1 3 +SELECT DISTINCT a, a, b FROM t1; +a a b +1 1 1 +1 1 2 +1 1 3 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/errors.result b/mysql-test/r/errors.result index 0c84f24a2e4..94debb1785f 100644 --- a/mysql-test/r/errors.result +++ b/mysql-test/r/errors.result @@ -28,3 +28,16 @@ ERROR 42000: Display width out of range for column 'a' (max = 255) set sql_mode='traditional'; create table t1 (a varchar(66000)); ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead +set sql_mode=default; +CREATE TABLE t1 (a INT); +SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); +a +INSERT INTO t1 VALUES(1); +SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); +a +1 +INSERT INTO t1 VALUES(2),(3); +SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); +a +1 +DROP TABLE t1; diff --git a/mysql-test/r/flush2.result b/mysql-test/r/flush2.result index 7c94219fd71..13bcc371ef6 100644 --- a/mysql-test/r/flush2.result +++ b/mysql-test/r/flush2.result @@ -1,24 +1,12 @@ flush logs; set global expire_logs_days = 3; -show variables like 'log%'; +show variables like 'log_bin%'; Variable_name Value -log ON log_bin OFF log_bin_trust_function_creators ON -log_error -log_queries_not_using_indexes OFF -log_slave_updates OFF -log_slow_queries OFF -log_warnings 1 flush logs; -show variables like 'log%'; +show variables like 'log_bin%'; Variable_name Value -log ON log_bin OFF log_bin_trust_function_creators ON -log_error -log_queries_not_using_indexes OFF -log_slave_updates OFF -log_slow_queries OFF -log_warnings 1 set global expire_logs_days = 0; diff --git a/mysql-test/r/fulltext_left_join.result b/mysql-test/r/fulltext_left_join.result index fdf11c14cc4..ea4cacf2fab 100644 --- a/mysql-test/r/fulltext_left_join.result +++ b/mysql-test/r/fulltext_left_join.result @@ -90,3 +90,10 @@ id link name relevance 1 1 string 0 2 0 string 0 DROP TABLE t1,t2; +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT, c TEXT, KEY(b)); +INSERT INTO t1 VALUES(1); +INSERT INTO t2(b,c) VALUES(2,'castle'),(3,'castle'); +SELECT * FROM t1 LEFT JOIN t2 ON a=b WHERE MATCH(c) AGAINST('+castle' IN BOOLEAN MODE); +a b c +DROP TABLE t1, t2; diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 6989b89833b..71419b5b2c3 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -728,3 +728,13 @@ f2 group_concat(f1) aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 2 drop table t1; +CREATE TABLE t1(a TEXT, b CHAR(20)); +INSERT INTO t1 VALUES ("one.1","one.1"),("two.2","two.2"),("one.3","one.3"); +SELECT GROUP_CONCAT(DISTINCT UCASE(a)) FROM t1; +GROUP_CONCAT(DISTINCT UCASE(a)) +ONE.1,TWO.2,ONE.3 +SELECT GROUP_CONCAT(DISTINCT UCASE(b)) FROM t1; +GROUP_CONCAT(DISTINCT UCASE(b)) +ONE.1,TWO.2,ONE.3 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index e421da1c462..f245d272ede 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1296,6 +1296,15 @@ select var_samp(e) as '0.5', var_pop(e) as '0.25' from bug22555; 0.5 0.25 0.5000 0.2500 drop table bug22555; +create table t1 (a decimal(20)); +insert into t1 values (12345678901234567890); +select count(a) from t1; +count(a) +1 +select count(distinct a) from t1; +count(distinct a) +1 +drop table t1; CREATE TABLE t1 (a INT, b INT); INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8); INSERT INTO t1 SELECT a, b+8 FROM t1; diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index e06e7ffe00c..92265c77984 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -1964,6 +1964,15 @@ A B tire 0 # # 1 ## ## 2 +SELECT REPEAT('0', CAST(0 AS UNSIGNED)); +REPEAT('0', CAST(0 AS UNSIGNED)) + +SELECT REPEAT('0', -2); +REPEAT('0', -2) + +SELECT REPEAT('0', 2); +REPEAT('0', 2) +00 DROP TABLE t1; SELECT UNHEX('G'); UNHEX('G') diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result index 92de2abcdcb..e4b52fc0392 100644 --- a/mysql-test/r/gis-rtree.result +++ b/mysql-test/r/gis-rtree.result @@ -10,7 +10,7 @@ t1 CREATE TABLE `t1` ( `fid` int(11) NOT NULL auto_increment, `g` geometry NOT NULL, PRIMARY KEY (`fid`), - SPATIAL KEY `g` (`g`(32)) + SPATIAL KEY `g` (`g`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 INSERT INTO t1 (g) VALUES (GeomFromText('LineString(150 150, 150 150)')); INSERT INTO t1 (g) VALUES (GeomFromText('LineString(149 149, 151 151)')); @@ -293,7 +293,7 @@ t2 CREATE TABLE `t2` ( `fid` int(11) NOT NULL auto_increment, `g` geometry NOT NULL, PRIMARY KEY (`fid`), - SPATIAL KEY `g` (`g`(32)) + SPATIAL KEY `g` (`g`) ) ENGINE=MyISAM AUTO_INCREMENT=101 DEFAULT CHARSET=latin1 SELECT count(*) FROM t2; count(*) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index de034d93dc5..73e5b054f80 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -385,7 +385,7 @@ Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r FROM gis_geometrycollection g1, gis_geometrycollection 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 +120 121 0 0 1 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 explain extended SELECT g1.fid as first, g2.fid as second, @@ -730,6 +730,12 @@ point(b, b) IS NULL linestring(b) IS NULL polygon(b) IS NULL multipoint(b) IS NU 1 1 1 1 1 1 1 0 1 1 1 1 1 1 drop table t1; +CREATE TABLE t1(a POINT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1; +a +NULL +DROP TABLE t1; End of 4.1 tests create table t1 (s1 geometry not null,s2 char(100)); create trigger t1_bu before update on t1 for each row set new.s1 = null; @@ -763,3 +769,99 @@ create table t1 (g geometry not null); insert into t1 values(default); ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field drop table t1; +CREATE TABLE t1 (a GEOMETRY); +CREATE VIEW v1 AS SELECT GeomFromwkb(ASBINARY(a)) FROM t1; +CREATE VIEW v2 AS SELECT a FROM t1; +DESCRIBE v1; +Field Type Null Key Default Extra +GeomFromwkb(ASBINARY(a)) geometry YES NULL +DESCRIBE v2; +Field Type Null Key Default Extra +a geometry YES NULL +DROP VIEW v1,v2; +DROP TABLE t1; +create table t1 (name VARCHAR(100), square GEOMETRY); +INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); +INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); +INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); +INSERT INTO t1 VALUES("up", GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))')); +INSERT INTO t1 VALUES("up2", GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))')); +INSERT INTO t1 VALUES("up3", GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))')); +INSERT INTO t1 VALUES("down", GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))')); +INSERT INTO t1 VALUES("down2", GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))')); +INSERT INTO t1 VALUES("down3", GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))')); +INSERT INTO t1 VALUES("right", GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))')); +INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))')); +INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))')); +INSERT INTO t1 VALUES("left", GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))')); +INSERT INTO t1 VALUES("left2", GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))')); +INSERT INTO t1 VALUES("left3", GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))')); +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrcontains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrdisjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal FROM t1 a1 JOIN t1 a2 ON MBREqual( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrequal +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrintersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbroverlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrtouches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrwithin +big,center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +contains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +disjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals FROM t1 a1 JOIN t1 a2 ON Equals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +equals +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect FROM t1 a1 JOIN t1 a2 ON Intersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +intersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps FROM t1 a1 JOIN t1 a2 ON Overlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +overlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +touches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +within +big,center +SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))'); +SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))'); +SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))'); +SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))'); +SET @point1 = GeomFromText('POLYGON ((0 0))'); +SET @point2 = GeomFromText('POLYGON ((-2 0))'); +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name; +overlaps +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name; +overlaps +SELECT Overlaps(@horiz1, @vert1) FROM DUAL; +Overlaps(@horiz1, @vert1) +0 +SELECT Overlaps(@horiz1, @horiz2) FROM DUAL; +Overlaps(@horiz1, @horiz2) +1 +SELECT Overlaps(@horiz1, @horiz3) FROM DUAL; +Overlaps(@horiz1, @horiz3) +0 +SELECT Overlaps(@horiz1, @point1) FROM DUAL; +Overlaps(@horiz1, @point1) +0 +SELECT Overlaps(@horiz1, @point2) FROM DUAL; +Overlaps(@horiz1, @point2) +0 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index 5b9c7f2244f..91f51a95936 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -280,6 +280,33 @@ a 1 1 drop table t1; +CREATE TABLE t1 ( +c1 CHAR(3), +c2 INTEGER, +KEY USING BTREE(c1), +KEY USING BTREE(c2) +) ENGINE= MEMORY; +INSERT INTO t1 VALUES ('ABC',0), ('A',0), ('B',0), ('C',0); +UPDATE t1 SET c2= c2 + 1 WHERE c1 = 'A'; +SELECT * FROM t1; +c1 c2 +ABC 0 +A 1 +B 0 +C 0 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 ENUM('1', '2'), +UNIQUE USING BTREE(c1) +) ENGINE= MEMORY DEFAULT CHARSET= utf8; +INSERT INTO t1 VALUES('1'), ('2'); +DROP TABLE t1; +CREATE TABLE t1 ( +c1 SET('1', '2'), +UNIQUE USING BTREE(c1) +) ENGINE= MEMORY DEFAULT CHARSET= utf8; +INSERT INTO t1 VALUES('1'), ('2'); +DROP TABLE t1; End of 4.1 tests CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory; INSERT INTO t1 VALUES(0); diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 97bb5e4e446..b32e6323d9f 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -688,7 +688,7 @@ Warnings: Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them show create table v3; View Create View -v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `test`.`sub1`(1) AS `c` +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `sub1`(1) AS `c` Warnings: Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them drop view v2; diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 99f0d4100ee..0638152ba42 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -2968,3 +2968,21 @@ a drop table t2, t1; create table t1 (g geometry not null, spatial gk(g)) engine=innodb; ERROR HY000: The used table type doesn't support SPATIAL indexes +CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB; +CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL; +ALTER TABLE t2 MODIFY a INT NOT NULL; +ERROR HY000: Error on rename of '#sql-temporary' to './test/t2' (errno: 150) +DELETE FROM t1; +DROP TABLE t2,t1; +CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4); +DELETE FROM t1; +INSERT INTO t1 VALUES ('DDD'); +SELECT * FROM t1; +a +DDD +DROP TABLE t1; diff --git a/mysql-test/r/innodb_gis.result b/mysql-test/r/innodb_gis.result index 41a227a2850..2c62537aa94 100644 --- a/mysql-test/r/innodb_gis.result +++ b/mysql-test/r/innodb_gis.result @@ -392,7 +392,7 @@ Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r FROM gis_geometrycollection g1, gis_geometrycollection 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 +120 121 0 0 1 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 explain extended SELECT g1.fid as first, g2.fid as second, @@ -456,3 +456,89 @@ ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field insert into t1 values (pointfromtext('point(1,1)')); ERROR 23000: Column 'fl' cannot be null drop table t1; +End of 4.1 tests +CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY); +INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); +INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); +INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); +INSERT INTO t1 VALUES("up", GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))')); +INSERT INTO t1 VALUES("up2", GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))')); +INSERT INTO t1 VALUES("up3", GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))')); +INSERT INTO t1 VALUES("down", GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))')); +INSERT INTO t1 VALUES("down2", GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))')); +INSERT INTO t1 VALUES("down3", GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))')); +INSERT INTO t1 VALUES("right", GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))')); +INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))')); +INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))')); +INSERT INTO t1 VALUES("left", GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))')); +INSERT INTO t1 VALUES("left2", GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))')); +INSERT INTO t1 VALUES("left3", GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))')); +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrcontains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrdisjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal FROM t1 a1 JOIN t1 a2 ON MBREqual( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrequal +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrintersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbroverlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrtouches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrwithin +big,center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +contains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +disjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals FROM t1 a1 JOIN t1 a2 ON Equals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +equals +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect FROM t1 a1 JOIN t1 a2 ON Intersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +intersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps FROM t1 a1 JOIN t1 a2 ON Overlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +overlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +touches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +within +big,center +SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))'); +SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))'); +SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))'); +SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))'); +SET @point1 = GeomFromText('POLYGON ((0 0))'); +SET @point2 = GeomFromText('POLYGON ((-2 0))'); +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name; +overlaps +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name; +overlaps +SELECT Overlaps(@horiz1, @vert1) FROM DUAL; +Overlaps(@horiz1, @vert1) +0 +SELECT Overlaps(@horiz1, @horiz2) FROM DUAL; +Overlaps(@horiz1, @horiz2) +1 +SELECT Overlaps(@horiz1, @horiz3) FROM DUAL; +Overlaps(@horiz1, @horiz3) +0 +SELECT Overlaps(@horiz1, @point1) FROM DUAL; +Overlaps(@horiz1, @point1) +0 +SELECT Overlaps(@horiz1, @point2) FROM DUAL; +Overlaps(@horiz1, @point2) +0 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 92b3ea0e42b..a96add7eb9a 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -744,3 +744,32 @@ f1 f2 2 2 10 10 DROP TABLE t1, t2; +SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (c VARCHAR(30), INDEX ix_c (c(10))); +CREATE TABLE t2 (d VARCHAR(10)); +INSERT INTO t1 (c) VALUES ('7_chars'), ('13_characters'); +EXPLAIN +SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 SUBQUERY t1 ref ix_c ix_c 13 const 1 Using where +SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1; +(SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') +13 +13 +INSERT INTO t2 (d) +SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1; +INSERT INTO t2 (d) +SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='7_chars') FROM t1; +INSERT INTO t2 (d) +SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c IN (SELECT t1.c FROM t1)) +FROM t1; +SELECT * FROM t2; +d +13 +13 +7 +7 +20 +20 +DROP TABLE t1,t2; diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result index f658ff06624..fd70fcb9084 100644 --- a/mysql-test/r/insert_update.result +++ b/mysql-test/r/insert_update.result @@ -236,3 +236,103 @@ INSERT INTO t2 VALUES (1), (3); INSERT INTO t1 SELECT 1, COUNT(*) FROM t2 ON DUPLICATE KEY UPDATE j= a; ERROR 42S22: Unknown column 'a' in 'field list' DROP TABLE t1,t2; +SET SQL_MODE = 'TRADITIONAL'; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT NOT NULL); +INSERT INTO t1 (a) VALUES (1); +ERROR HY000: Field 'b' doesn't have a default value +INSERT INTO t1 (a) VALUES (1) ON DUPLICATE KEY UPDATE a = b; +ERROR HY000: Field 'b' doesn't have a default value +INSERT INTO t1 (a) VALUES (1) ON DUPLICATE KEY UPDATE b = b; +ERROR HY000: Field 'b' doesn't have a default value +SELECT * FROM t1; +a b +DROP TABLE t1; +CREATE TABLE t1 (f1 INT AUTO_INCREMENT PRIMARY KEY, +f2 VARCHAR(5) NOT NULL UNIQUE); +INSERT t1 (f2) VALUES ('test') ON DUPLICATE KEY UPDATE f1 = LAST_INSERT_ID(f1); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +INSERT t1 (f2) VALUES ('test') ON DUPLICATE KEY UPDATE f1 = LAST_INSERT_ID(f1); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +DROP TABLE t1; +SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; +CREATE TABLE `t1` ( +`id` int(11) PRIMARY KEY auto_increment, +`f1` varchar(10) NOT NULL UNIQUE +); +INSERT IGNORE INTO t1 (f1) VALUES ("test1") +ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +INSERT IGNORE INTO t1 (f1) VALUES ("test1") +ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +SELECT * FROM t1; +id f1 +1 test1 +INSERT IGNORE INTO t1 (f1) VALUES ("test2") +ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +SELECT * FROM t1; +id f1 +1 test1 +2 test2 +INSERT IGNORE INTO t1 (f1) VALUES ("test2") +ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2 +SELECT * FROM t1; +id f1 +1 test1 +2 test2 +INSERT IGNORE INTO t1 (f1) VALUES ("test3") +ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3 +SELECT * FROM t1; +id f1 +1 test1 +2 test2 +3 test3 +DROP TABLE t1; +CREATE TABLE `t1` ( +`id` int(11) PRIMARY KEY auto_increment, +`f1` varchar(10) NOT NULL UNIQUE +); +INSERT IGNORE INTO t1 (f1) VALUES ("test1") +ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +SELECT * FROM t1; +id f1 +1 test1 +INSERT IGNORE INTO t1 (f1) VALUES ("test1"),("test4") +ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +SELECT * FROM t1; +id f1 +1 test1 +2 test4 +DROP TABLE t1; +CREATE TABLE `t1` ( +`id` int(11) PRIMARY KEY auto_increment, +`f1` varchar(10) NOT NULL UNIQUE, +tim1 timestamp default '2003-01-01 00:00:00' on update current_timestamp +); +INSERT INTO t1 (f1) VALUES ("test1"); +SELECT id, f1 FROM t1; +id f1 +1 test1 +REPLACE INTO t1 VALUES (0,"test1",null); +SELECT id, f1 FROM t1; +id f1 +0 test1 +DROP TABLE t1; +SET SQL_MODE=''; diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index bef483569d4..0478e48025f 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -156,3 +156,12 @@ select load_file("MYSQL_TEST_DIR/t/loaddata.test"); load_file("MYSQL_TEST_DIR/t/loaddata.test") NULL drop table t1, t2; +create table t1(f1 int); +insert into t1 values(1),(null); +create table t2(f2 int auto_increment primary key); +select * from t2; +f2 +1 +2 +SET @@SQL_MODE=@OLD_SQL_MODE; +drop table t1,t2; diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index e45e5853c0c..c4419d64a65 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -803,11 +803,6 @@ CREATE TABLE tm1(a SMALLINT, b SMALLINT, KEY(a)) ENGINE=MERGE UNION=(t1); SELECT * FROM tm1; ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist DROP TABLE t1, tm1; -CREATE TABLE t1(c1 INT) ENGINE=MyISAM; -CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1); -INSERT DELAYED INTO t2 VALUES(1); -ERROR HY000: Table storage engine for 't2' doesn't have this option -DROP TABLE t1, t2; CREATE TABLE t1(c1 VARCHAR(1)); CREATE TABLE m1 LIKE t1; ALTER TABLE m1 ENGINE=MERGE UNION=(t1); diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 83359048a8c..94f2f1f72b3 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -943,6 +943,156 @@ SHOW TABLE STATUS LIKE 't1'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment t1 MyISAM 10 Dynamic X X X 72057594037927935 X X X X X X latin1_swedish_ci X max_rows=4100100100 avg_row_length=70100 DROP TABLE t1; +CREATE TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), +(''), (''), (''), (''), +(' B'), (' B'), (' B'), (' B'); +SELECT DISTINCT COUNT(*) FROM t1 WHERE c1 = ''; +COUNT(*) +4 +SELECT DISTINCT length(c1), c1 FROM t1 WHERE c1 = ''; +length(c1) c1 +0 +SELECT DISTINCT COUNT(*) FROM t1 IGNORE INDEX (c1) WHERE c1 = ''; +COUNT(*) +4 +SELECT DISTINCT length(c1), c1 FROM t1 IGNORE INDEX (c1) WHERE c1 = ''; +length(c1) c1 +0 +SELECT DISTINCT length(c1), c1 FROM t1 ORDER BY c1; +length(c1) c1 +0 +2 A +2 B +DROP TABLE t1; End of 4.1 tests set storage_engine=MyISAM; drop table if exists t1,t2,t3; diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index 217d3e5f64a..a50d131cca8 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -289,23 +289,23 @@ SET @@session.sql_mode=0/*!*/; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; create table t1 (a varchar(64) character set utf8)/*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-6-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-6-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=7/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-7-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-7-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=DEFAULT/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-8-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-8-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-9-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-9-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=7/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-a-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=DEFAULT/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-b-0' INTO table t1/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO table t1/*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r/*!*/; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r/*!*/; SET TIMESTAMP=1000000000/*!*/; drop table t1/*!*/; DELIMITER ; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 2d32984e4ef..5caaa9264d0 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -1567,29 +1567,17 @@ create table t3(a varchar(30) primary key, b int not null); test_sequence ------ Testing with illegal table names ------ mysqldump: Couldn't find table: "\d-2-1.sql" - mysqldump: Couldn't find table: "\t1" - mysqldump: Couldn't find table: "\t1" - mysqldump: Couldn't find table: "\\t1" - mysqldump: Couldn't find table: "t\1" - mysqldump: Couldn't find table: "t\1" - mysqldump: Couldn't find table: "t/1" - mysqldump: Couldn't find table: "T_1" - mysqldump: Couldn't find table: "T%1" - mysqldump: Couldn't find table: "T'1" - mysqldump: Couldn't find table: "T_1" - mysqldump: Couldn't find table: "T_" - test_sequence ------ Testing with illegal database names ------ mysqldump: Got error: 1049: Unknown database 'mysqldump_test_d' when selecting the database @@ -3218,5 +3206,82 @@ INSERT INTO t1 VALUES(1,0xff00fef0); </mysqldump> DROP TABLE t1; # +# Bug#26346: stack + buffer overrun in mysqldump +# +CREATE TABLE t1(a int); +INSERT INTO t1 VALUES (1), (2); +mysqldump: Input filename or options too long: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +DROP TABLE t1; +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +CREATE TABLE t1 (a int) ENGINE=merge UNION=(t2, t3); + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` int(11) default NULL +) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t2`,`t3`); +DROP TABLE IF EXISTS `t2`; +CREATE TABLE `t2` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +LOCK TABLES `t2` WRITE; +/*!40000 ALTER TABLE `t2` DISABLE KEYS */; +/*!40000 ALTER TABLE `t2` ENABLE KEYS */; +UNLOCK TABLES; +DROP TABLE IF EXISTS `t3`; +CREATE TABLE `t3` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +LOCK TABLES `t3` WRITE; +/*!40000 ALTER TABLE `t3` DISABLE KEYS */; +/*!40000 ALTER TABLE `t3` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +DROP TABLE t1, t2, t3; +# +# Bug #23491: MySQLDump prefix function call in a view by database name +# +create database bug23491_original; +create database bug23491_restore; +use bug23491_original; +create table t1 (c1 int); +create view v1 as select * from t1; +create procedure p1() select 1; +create function f1() returns int return 1; +create view v2 as select f1(); +create function f2() returns int return f1(); +create view v3 as select bug23491_original.f1(); +use bug23491_restore; +show create view bug23491_restore.v2; +View Create View +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `f1`() AS `f1()` +show create view bug23491_restore.v3; +View Create View +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `bug23491_original`.`f1`() AS `bug23491_original.f1()` +drop database bug23491_original; +drop database bug23491_restore; +use test; +# # End of 5.0 tests # diff --git a/mysql-test/r/ndb_autodiscover.result b/mysql-test/r/ndb_autodiscover.result index 6d1b7eb152d..01ea884a8ba 100644 --- a/mysql-test/r/ndb_autodiscover.result +++ b/mysql-test/r/ndb_autodiscover.result @@ -382,7 +382,7 @@ create table t1 (a int primary key) engine=ndb; select * from t1; a select * from t1; -ERROR HY000: Can't lock file (errno: 4009) +ERROR HY000: Can't lock file (errno: 157) use test; drop database test_only_ndb_tables; CREATE TABLE t9 ( diff --git a/mysql-test/r/ndb_blob.result b/mysql-test/r/ndb_blob.result index a5a40cffa91..2864b1dc7c9 100644 --- a/mysql-test/r/ndb_blob.result +++ b/mysql-test/r/ndb_blob.result @@ -76,6 +76,8 @@ commit; select a from t1 where d is null; a 1 +delete from t1 where a=45567; +commit; delete from t1 where a=1; delete from t1 where a=2; commit; diff --git a/mysql-test/r/ndb_gis.result b/mysql-test/r/ndb_gis.result index bdbbc65dd85..ec064ace651 100644 --- a/mysql-test/r/ndb_gis.result +++ b/mysql-test/r/ndb_gis.result @@ -392,7 +392,7 @@ Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r FROM gis_geometrycollection g1, gis_geometrycollection 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 +120 121 0 0 1 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 explain extended SELECT g1.fid as first, g2.fid as second, @@ -456,6 +456,92 @@ ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field insert into t1 values (pointfromtext('point(1,1)')); ERROR 23000: Column 'fl' cannot be null drop table t1; +End of 4.1 tests +CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY); +INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); +INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); +INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); +INSERT INTO t1 VALUES("up", GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))')); +INSERT INTO t1 VALUES("up2", GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))')); +INSERT INTO t1 VALUES("up3", GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))')); +INSERT INTO t1 VALUES("down", GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))')); +INSERT INTO t1 VALUES("down2", GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))')); +INSERT INTO t1 VALUES("down3", GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))')); +INSERT INTO t1 VALUES("right", GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))')); +INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))')); +INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))')); +INSERT INTO t1 VALUES("left", GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))')); +INSERT INTO t1 VALUES("left2", GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))')); +INSERT INTO t1 VALUES("left3", GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))')); +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrcontains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrdisjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal FROM t1 a1 JOIN t1 a2 ON MBREqual( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrequal +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrintersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbroverlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrtouches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrwithin +big,center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +contains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +disjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals FROM t1 a1 JOIN t1 a2 ON Equals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +equals +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect FROM t1 a1 JOIN t1 a2 ON Intersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +intersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps FROM t1 a1 JOIN t1 a2 ON Overlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +overlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +touches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +within +big,center +SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))'); +SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))'); +SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))'); +SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))'); +SET @point1 = GeomFromText('POLYGON ((0 0))'); +SET @point2 = GeomFromText('POLYGON ((-2 0))'); +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name; +overlaps +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name; +overlaps +SELECT Overlaps(@horiz1, @vert1) FROM DUAL; +Overlaps(@horiz1, @vert1) +0 +SELECT Overlaps(@horiz1, @horiz2) FROM DUAL; +Overlaps(@horiz1, @horiz2) +1 +SELECT Overlaps(@horiz1, @horiz3) FROM DUAL; +Overlaps(@horiz1, @horiz3) +0 +SELECT Overlaps(@horiz1, @point1) FROM DUAL; +Overlaps(@horiz1, @point1) +0 +SELECT Overlaps(@horiz1, @point2) FROM DUAL; +Overlaps(@horiz1, @point2) +0 +DROP TABLE t1; +End of 5.0 tests set engine_condition_pushdown = on; DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; CREATE TABLE gis_point (fid INTEGER, g POINT); @@ -850,7 +936,7 @@ Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r FROM gis_geometrycollection g1, gis_geometrycollection 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 +120 121 0 0 1 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 explain extended SELECT g1.fid as first, g2.fid as second, @@ -914,3 +1000,89 @@ ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field insert into t1 values (pointfromtext('point(1,1)')); ERROR 23000: Column 'fl' cannot be null drop table t1; +End of 4.1 tests +CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY); +INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); +INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); +INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); +INSERT INTO t1 VALUES("up", GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))')); +INSERT INTO t1 VALUES("up2", GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))')); +INSERT INTO t1 VALUES("up3", GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))')); +INSERT INTO t1 VALUES("down", GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))')); +INSERT INTO t1 VALUES("down2", GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))')); +INSERT INTO t1 VALUES("down3", GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))')); +INSERT INTO t1 VALUES("right", GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))')); +INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))')); +INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))')); +INSERT INTO t1 VALUES("left", GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))')); +INSERT INTO t1 VALUES("left2", GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))')); +INSERT INTO t1 VALUES("left3", GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))')); +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrcontains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrdisjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal FROM t1 a1 JOIN t1 a2 ON MBREqual( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrequal +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrintersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbroverlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrtouches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrwithin +big,center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +contains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +disjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals FROM t1 a1 JOIN t1 a2 ON Equals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +equals +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect FROM t1 a1 JOIN t1 a2 ON Intersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +intersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps FROM t1 a1 JOIN t1 a2 ON Overlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +overlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +touches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +within +big,center +SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))'); +SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))'); +SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))'); +SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))'); +SET @point1 = GeomFromText('POLYGON ((0 0))'); +SET @point2 = GeomFromText('POLYGON ((-2 0))'); +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name; +overlaps +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name; +overlaps +SELECT Overlaps(@horiz1, @vert1) FROM DUAL; +Overlaps(@horiz1, @vert1) +0 +SELECT Overlaps(@horiz1, @horiz2) FROM DUAL; +Overlaps(@horiz1, @horiz2) +1 +SELECT Overlaps(@horiz1, @horiz3) FROM DUAL; +Overlaps(@horiz1, @horiz3) +0 +SELECT Overlaps(@horiz1, @point1) FROM DUAL; +Overlaps(@horiz1, @point1) +0 +SELECT Overlaps(@horiz1, @point2) FROM DUAL; +Overlaps(@horiz1, @point2) +0 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result index e5bf4315e5c..bc31798cee7 100644 --- a/mysql-test/r/ndb_restore.result +++ b/mysql-test/r/ndb_restore.result @@ -1,14 +1,14 @@ use test; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; -CREATE TABLE `t1` ( -`capgoaledatta` smallint(5) unsigned NOT NULL auto_increment, +CREATE TABLE `t1_c` ( +`capgoaledatta` mediumint(5) unsigned NOT NULL auto_increment, `goaledatta` char(2) NOT NULL default '', `maturegarbagefa` varchar(32) NOT NULL default '', PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t1` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt'); -CREATE TABLE `t2` ( +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(400,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3000,'20','threetrees.qt'); +CREATE TABLE `t2_c` ( `capgotod` smallint(5) unsigned NOT NULL auto_increment, `gotod` smallint(5) unsigned NOT NULL default '0', `goaledatta` char(2) default NULL, @@ -16,16 +16,16 @@ CREATE TABLE `t2` ( `descrpooppo` varchar(64) default NULL, `svcutonsa` varchar(64) NOT NULL default '', PRIMARY KEY (`capgotod`), -KEY `i_quadaddsvr` (`gotod`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t2` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); -CREATE TABLE `t3` ( +KEY `i quadaddsvr` (`gotod`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); +CREATE TABLE `t3_c` ( `CapGoaledatta` smallint(5) unsigned NOT NULL default '0', `capgotod` smallint(5) unsigned NOT NULL default '0', PRIMARY KEY (`capgotod`,`CapGoaledatta`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t3` VALUES (5,3),(2,4),(5,4),(1,3); -CREATE TABLE `t4` ( +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3); +CREATE TABLE `t4_c` ( `capfa` bigint(20) unsigned NOT NULL auto_increment, `realm` varchar(32) NOT NULL default '', `authpwchap` varchar(32) default NULL, @@ -35,34 +35,34 @@ CREATE TABLE `t4` ( PRIMARY KEY (`fa`,`realm`), KEY `capfa` (`capfa`), KEY `i_quadentity` (`fa`,`realm`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t4` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); -CREATE TABLE `t5` ( +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(2200,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32000,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(290000000,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); +CREATE TABLE `t5_c` ( `capfa` bigint(20) unsigned NOT NULL default '0', `gotod` smallint(5) unsigned NOT NULL default '0', `orderutonsa` varchar(64) NOT NULL default '', PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t5` VALUES (21,2,''),(21,1,''),(22,4,''); -CREATE TABLE `t6` ( +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,''); +CREATE TABLE `t6_c` ( `capfa_parent` bigint(20) unsigned NOT NULL default '0', `capfa_child` bigint(20) unsigned NOT NULL default '0', `relatta` smallint(5) unsigned NOT NULL default '0', PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t6` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); -CREATE TABLE `t7` ( +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); +CREATE TABLE `t7_c` ( `dardpo` char(15) NOT NULL default '', -`dardtestard` tinyint(3) unsigned NOT NULL default '0', +`dardtestard` tinyint(3) unsigned NOT NULL auto_increment, `FastFA` char(5) NOT NULL default '', `FastCode` char(6) NOT NULL default '', `Fastca` char(1) NOT NULL default '', `Fastmag` char(1) NOT NULL default '', `Beareratta` char(2) NOT NULL default '', PRIMARY KEY (`dardpo`,`dardtestard`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t7` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); -CREATE TABLE `t8` ( +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); +CREATE TABLE `t8_c` ( `kattjame` varchar(32) NOT NULL default '', `realm` varchar(32) NOT NULL default '', `realm_entered` varchar(32) NOT NULL default '', @@ -88,9 +88,9 @@ CREATE TABLE `t8` ( `acctinputoctets` bigint(20) unsigned default NULL, PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), KEY `squardporoot` (`squardporoot`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t8` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); -CREATE TABLE `t9` ( +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); +CREATE TABLE `t9_c` ( `kattjame` varchar(32) NOT NULL default '', `kattjame_entered` varchar(32) NOT NULL default '', `realm` varchar(32) NOT NULL default '', @@ -114,20 +114,21 @@ CREATE TABLE `t9` ( `actinputocctets` bigint(20) unsigned default NULL, `terminateraste` tinyint(3) unsigned default NULL, PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t9` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); -create table t10 (a int auto_increment key); -insert into t10 values (1),(2),(3); -create table t1_c engine=ndbcluster as select * from t1; -create table t2_c engine=ndbcluster as select * from t2; -create table t3_c engine=ndbcluster as select * from t3; -create table t4_c engine=ndbcluster as select * from t4; -create table t5_c engine=ndbcluster as select * from t5; -create table t6_c engine=ndbcluster as select * from t6; -create table t7_c engine=ndbcluster as select * from t7; -create table t8_c engine=ndbcluster as select * from t8; -create table t9_c engine=ndbcluster as select * from t9; -create table t10_c engine=ndbcluster as select * from t10; +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); +create table t10_c (a int auto_increment key) ENGINE=ndbcluster; +insert into t10_c values (1),(2),(3); +insert into t10_c values (10000),(2000),(3000); +create table t1 engine=myisam as select * from t1_c; +create table t2 engine=myisam as select * from t2_c; +create table t3 engine=myisam as select * from t3_c; +create table t4 engine=myisam as select * from t4_c; +create table t5 engine=myisam as select * from t5_c; +create table t6 engine=myisam as select * from t6_c; +create table t7 engine=myisam as select * from t7_c; +create table t8 engine=myisam as select * from t8_c; +create table t9 engine=myisam as select * from t9_c; +create table t10 engine=myisam as select * from t10_c; drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c, t10_c; show tables; Tables_in_test @@ -255,6 +256,24 @@ a 1 2 3 +2000 +3000 +10000 +show table status like 't1_c'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +X X X X X X X X X X 3001 X X X X X X X +show table status like 't2_c'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +X X X X X X X X X X 501 X X X X X X X +show table status like 't4_c'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +X X X X X X X X X X 290000001 X X X X X X X +show table status like 't7_c'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +X X X X X X X X X X 29 X X X X X X X +show table status like 't10_c'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +X X X X X X X X X X 10001 X X X X X X X drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9, t10; drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c, t10_c; 520093696,1 diff --git a/mysql-test/r/ndb_restore_print.result b/mysql-test/r/ndb_restore_print.result new file mode 100644 index 00000000000..e05f8e43d1a --- /dev/null +++ b/mysql-test/r/ndb_restore_print.result @@ -0,0 +1,321 @@ +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +create table t1 +(pk int key +,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64) +,b1 TINYINT, b2 TINYINT UNSIGNED +,c1 SMALLINT, c2 SMALLINT UNSIGNED +,d1 INT, d2 INT UNSIGNED +,e1 BIGINT, e2 BIGINT UNSIGNED +,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY +,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY +,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255) +,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) +) engine myisam; +insert into t1 values +(1 +,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001 +,127, 255 +,32767, 65535 +,2147483647, 4294967295 +,9223372036854775807, 18446744073709551615 +,'1','12345678901234567890123456789012','123456789' + ,'1','12345678901234567890123456789012','123456789' + ,0x12,0x123456789abcdef0, 0x012345 +,0x12,0x123456789abcdef0, 0x00123450 +); +insert into t1 values +(2 +,0, 0, 0, 0, 0 +,-128, 0 +,-32768, 0 +,-2147483648, 0 +,-9223372036854775808, 0 +,'','','' + ,'','','' + ,0x0,0x0,0x0 +,0x0,0x0,0x0 +); +insert into t1 values +(3 +,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 +); +select pk +,hex(a1), hex(a2), hex(a3), hex(a4), hex(a5) +,b1, b2 +,c1 , c2 +,d1 , d2 +,e1 , e2 +,f1 , f2, f3 +,g1 , g2, g3 +,hex(h1), hex(h2), hex(h3) +,hex(i1), hex(i2), hex(i3) +from t1 order by pk; +pk 1 +hex(a1) 1 +hex(a2) 17 +hex(a3) 789A +hex(a4) 789ABCDE +hex(a5) FEDC0001 +b1 127 +b2 255 +c1 32767 +c2 65535 +d1 2147483647 +d2 4294967295 +e1 9223372036854775807 +e2 18446744073709551615 +f1 1 +f2 12345678901234567890123456789012 +f3 123456789 +g1 1 +g2 12345678901234567890123456789012 +g3 123456789 +hex(h1) 12 +hex(h2) 123456789ABCDEF0 +hex(h3) 012345000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +hex(i1) 12 +hex(i2) 123456789ABCDEF0 +hex(i3) 00123450 +pk 2 +hex(a1) 0 +hex(a2) 0 +hex(a3) 0 +hex(a4) 0 +hex(a5) 0 +b1 -128 +b2 0 +c1 -32768 +c2 0 +d1 -2147483648 +d2 0 +e1 -9223372036854775808 +e2 0 +f1 +f2 +f3 +g1 +g2 +g3 +hex(h1) 00 +hex(h2) 0000000000000000 +hex(h3) 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +hex(i1) 00 +hex(i2) 00 +hex(i3) 00 +pk 3 +hex(a1) NULL +hex(a2) NULL +hex(a3) NULL +hex(a4) NULL +hex(a5) NULL +b1 NULL +b2 NULL +c1 NULL +c2 NULL +d1 NULL +d2 NULL +e1 NULL +e2 NULL +f1 NULL +f2 NULL +f3 NULL +g1 NULL +g2 NULL +g3 NULL +hex(h1) NULL +hex(h2) NULL +hex(h3) NULL +hex(i1) NULL +hex(i2) NULL +hex(i3) NULL +alter table t1 engine ndb; +select pk +,hex(a1), hex(a2), hex(a3), hex(a4), hex(a5) +,b1, b2 +,c1 , c2 +,d1 , d2 +,e1 , e2 +,f1 , f2, f3 +,g1 , g2, g3 +,hex(h1), hex(h2), hex(h3) +,hex(i1), hex(i2), hex(i3) +from t1 order by pk; +pk 1 +hex(a1) 1 +hex(a2) 17 +hex(a3) 789A +hex(a4) 789ABCDE +hex(a5) FEDC0001 +b1 127 +b2 255 +c1 32767 +c2 65535 +d1 2147483647 +d2 4294967295 +e1 9223372036854775807 +e2 18446744073709551615 +f1 1 +f2 12345678901234567890123456789012 +f3 123456789 +g1 1 +g2 12345678901234567890123456789012 +g3 123456789 +hex(h1) 12 +hex(h2) 123456789ABCDEF0 +hex(h3) 012345000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +hex(i1) 12 +hex(i2) 123456789ABCDEF0 +hex(i3) 00123450 +pk 2 +hex(a1) 0 +hex(a2) 0 +hex(a3) 0 +hex(a4) 0 +hex(a5) 0 +b1 -128 +b2 0 +c1 -32768 +c2 0 +d1 -2147483648 +d2 0 +e1 -9223372036854775808 +e2 0 +f1 +f2 +f3 +g1 +g2 +g3 +hex(h1) 00 +hex(h2) 0000000000000000 +hex(h3) 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +hex(i1) 00 +hex(i2) 00 +hex(i3) 00 +pk 3 +hex(a1) NULL +hex(a2) NULL +hex(a3) NULL +hex(a4) NULL +hex(a5) NULL +b1 NULL +b2 NULL +c1 NULL +c2 NULL +d1 NULL +d2 NULL +e1 NULL +e2 NULL +f1 NULL +f2 NULL +f3 NULL +g1 NULL +g2 NULL +g3 NULL +hex(h1) NULL +hex(h2) NULL +hex(h3) NULL +hex(i1) NULL +hex(i2) NULL +hex(i3) NULL +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +1;0x1;0x17;0x789A;0x789ABCDE;0xFEDC0001;127;255;32767;65535;2147483647;4294967295;9223372036854775807;18446744073709551615;1;12345678901234567890123456789012;123456789;1;12345678901234567890123456789012;123456789;0x12;0x123456789ABCDEF0;0x012345;0x12;0x123456789ABCDEF0;0x00123450 +2;0x0;0x0;0x0;0x0;0x0;-128;0;-32768;0;-2147483648;0;-9223372036854775808;0;;;;;;;0x0;0x0;0x0;0x0;0x0;0x0 +3;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N +1,0x1,0x17,0x789A,0x789ABCDE,0xFEDC0001,127,255,32767,65535,2147483647,4294967295,9223372036854775807,18446744073709551615,'1','12345678901234567890123456789012','123456789','1','12345678901234567890123456789012','123456789',0x12,0x123456789ABCDEF0,0x012345,0x12,0x123456789ABCDEF0,0x00123450 +2,0x0,0x0,0x0,0x0,0x0,-128,0,-32768,0,-2147483648,0,-9223372036854775808,0,'','','','','','',0x0,0x0,0x0,0x0,0x0,0x0 +3,,,,,,,,,,,,,,,,,,,,,,,,, +drop table t1; +create table t1 +(pk int key +,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY +,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY +,h1 BINARY(1), h2 BINARY(9), h3 BINARY(255) +,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) +) engine ndb; +insert into t1 values +(1 +,'1','12345678901234567890123456789012','123456789 ' + ,'1 ','12345678901234567890123456789012 ','123456789 ' + ,0x20,0x123456789abcdef020, 0x012345000020 +,0x1200000020,0x123456789abcdef000000020, 0x00123450000020 +); +create table t2 (pk int key, a int) engine ndb; +create table t3 (pk int key, a int) engine ndb; +create table t4 (pk int key, a int) engine ndb; +insert into t2 values (1,11),(2,12),(3,13),(4,14),(5,15); +insert into t3 values (1,21),(2,22),(3,23),(4,24),(5,25); +insert into t4 values (1,31),(2,32),(3,33),(4,34),(5,35); +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +'1' '1' '12345678901234567890123456789012' '123456789' '1' '12345678901234567890123456789012' '123456789' '0x20' '0x123456789ABCDEF020' '0x012345000020' '0x1200000020' '0x123456789ABCDEF000000020' '0x00123450000020' + +t1 +-- +1 1 12345678901234567890123456789012 123456789 1 12345678901234567890123456789012 123456789 0x20 0x123456789ABCDEF020 0x012345000020 0x1200000020 0x123456789ABCDEF000000020 0x00123450000020 + +t2 +-- +1 11 +2 12 +3 13 +4 14 +5 15 + +t3 +-- +1 21 +2 22 +3 23 +4 24 +5 25 + +t4 +-- +1 31 +2 32 +3 33 +4 34 +5 35 +drop table t1; +create table t1 +(pk int key +,a1 MEDIUMINT, a2 MEDIUMINT UNSIGNED +) engine ndb; +insert into t1 values(1, 8388607, 16777215); +insert into t1 values(2, -8388608, 0); +insert into t1 values(3, -1, 1); +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +1;8388607;16777215 +2;-8388608;0 +3;-1;1 +drop table t1; +drop table t2; +drop table t3; +drop table t4; diff --git a/mysql-test/r/ndb_single_user.result b/mysql-test/r/ndb_single_user.result index 711d343fffb..7959d8478e1 100644 --- a/mysql-test/r/ndb_single_user.result +++ b/mysql-test/r/ndb_single_user.result @@ -1,7 +1,7 @@ use test; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; create table t1 (a int key, b int unique, c int) engine ndb; -ERROR HY000: Can't create table './test/t1.frm' (errno: 155) +ERROR HY000: Can't create table './test/t1.frm' (errno: 299) create table t1 (a int key, b int unique, c int) engine ndb; insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(10,10,0); create table t2 as select * from t1; @@ -28,19 +28,32 @@ insert into t1 select * from t2; drop table t1; ERROR 42S02: Unknown table 't1' create index new_index on t1 (c); -ERROR 42S02: Table 'test.t1' doesn't exist +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from ndbcluster insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(10,10,0); -ERROR 42S02: Table 'test.t1' doesn't exist +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from ndbcluster select * from t1 where a = 1; -ERROR 42S02: Table 'test.t1' doesn't exist +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from ndbcluster select * from t1 where b = 4; -ERROR 42S02: Table 'test.t1' doesn't exist +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from ndbcluster update t1 set b=102 where a = 2; -ERROR 42S02: Table 'test.t1' doesn't exist +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from ndbcluster update t1 set b=103 where b = 3; -ERROR 42S02: Table 'test.t1' doesn't exist +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from ndbcluster update t1 set b=b+100; -ERROR 42S02: Table 'test.t1' doesn't exist +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from ndbcluster update t1 set b=b+100 where a > 7; -ERROR 42S02: Table 'test.t1' doesn't exist +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from ndbcluster +BEGIN; +update t1 set b=b+100 where a=1; +BEGIN; +update t1 set b=b+100 where a=2; +update t1 set b=b+100 where a=3; +COMMIT; +update t1 set b=b+100 where a=4; +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from ndbcluster +COMMIT; +ERROR HY000: Got error 4350 'Transaction already aborted' from ndbcluster +create table t2 (a int) engine myisam; +alter table t2 add column (b int); +drop table t2; drop table t1; diff --git a/mysql-test/r/ndb_trigger.result b/mysql-test/r/ndb_trigger.result index 27f83df70c9..562c5120715 100644 --- a/mysql-test/r/ndb_trigger.result +++ b/mysql-test/r/ndb_trigger.result @@ -116,4 +116,175 @@ op a b d 1 1.050000000000000000000000000000 d 2 2.050000000000000000000000000000 drop tables t1, t2, t3; +CREATE TABLE t1 ( +id INT NOT NULL PRIMARY KEY, +xy INT +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES (1, 0); +CREATE TRIGGER t1_update AFTER UPDATE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id = NEW.id; END // +CREATE TABLE t2 ( +id INT NOT NULL PRIMARY KEY, +xy INT +) ENGINE=ndbcluster; +INSERT INTO t2 VALUES (2, 0); +CREATE TABLE t3 (id INT NOT NULL PRIMARY KEY) ENGINE=ndbcluster; +INSERT INTO t3 VALUES (1); +CREATE TABLE t4 LIKE t1; +CREATE TRIGGER t4_update AFTER UPDATE ON t4 FOR EACH ROW BEGIN REPLACE INTO t5 SELECT * FROM t4 WHERE t4.id = NEW.id; END // +CREATE TABLE t5 LIKE t2; +UPDATE t1 SET xy = 3 WHERE id = 1; +SELECT xy FROM t1 where id = 1; +xy +3 +SELECT xy FROM t2 where id = 1; +xy +3 +UPDATE t1 SET xy = 4 WHERE id IN (SELECT id FROM t3 WHERE id = 1); +SELECT xy FROM t1 where id = 1; +xy +4 +SELECT xy FROM t2 where id = 1; +xy +4 +INSERT INTO t4 SELECT * FROM t1; +INSERT INTO t5 SELECT * FROM t2; +UPDATE t1,t4 SET t1.xy = 3, t4.xy = 3 WHERE t1.id = 1 AND t4.id = 1; +SELECT xy FROM t1 where id = 1; +xy +3 +SELECT xy FROM t2 where id = 1; +xy +3 +SELECT xy FROM t4 where id = 1; +xy +3 +SELECT xy FROM t5 where id = 1; +xy +3 +UPDATE t1,t4 SET t1.xy = 4, t4.xy = 4 WHERE t1.id IN (SELECT id FROM t3 WHERE id = 1) AND t4.id IN (SELECT id FROM t3 WHERE id = 1); +SELECT xy FROM t1 where id = 1; +xy +4 +SELECT xy FROM t2 where id = 1; +xy +4 +SELECT xy FROM t4 where id = 1; +xy +4 +SELECT xy FROM t5 where id = 1; +xy +4 +INSERT INTO t1 VALUES (1,0) ON DUPLICATE KEY UPDATE xy = 5; +SELECT xy FROM t1 where id = 1; +xy +5 +SELECT xy FROM t2 where id = 1; +xy +5 +DROP TRIGGER t1_update; +DROP TRIGGER t4_update; +CREATE TRIGGER t1_delete AFTER DELETE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id > 4; END // +CREATE TRIGGER t4_delete AFTER DELETE ON t4 FOR EACH ROW BEGIN REPLACE INTO t5 SELECT * FROM t4 WHERE t4.id > 4; END // +INSERT INTO t1 VALUES (5, 0),(6,0); +INSERT INTO t2 VALUES (5, 1),(6,1); +INSERT INTO t3 VALUES (5); +SELECT * FROM t1 order by id; +id xy +1 5 +5 0 +6 0 +SELECT * FROM t2 order by id; +id xy +1 5 +2 0 +5 1 +6 1 +DELETE FROM t1 WHERE id IN (SELECT id FROM t3 WHERE id = 5); +SELECT * FROM t1 order by id; +id xy +1 5 +6 0 +SELECT * FROM t2 order by id; +id xy +1 5 +2 0 +5 1 +6 0 +INSERT INTO t1 VALUES (5,0); +UPDATE t2 SET xy = 1 WHERE id = 6; +TRUNCATE t4; +INSERT INTO t4 SELECT * FROM t1; +TRUNCATE t5; +INSERT INTO t5 SELECT * FROM t2; +SELECT * FROM t1 order by id; +id xy +1 5 +5 0 +6 0 +SELECT * FROM t2 order by id; +id xy +1 5 +2 0 +5 1 +6 1 +SELECT * FROM t4 order by id; +id xy +1 5 +5 0 +6 0 +SELECT * FROM t5 order by id; +id xy +1 5 +2 0 +5 1 +6 1 +DELETE FROM t1,t4 USING t1,t3,t4 WHERE t1.id IN (SELECT id FROM t3 WHERE id = 5) AND t4.id IN (SELECT id FROM t3 WHERE id = 5); +SELECT * FROM t1 order by id; +id xy +1 5 +6 0 +SELECT * FROM t2 order by id; +id xy +1 5 +2 0 +5 1 +6 0 +SELECT * FROM t4 order by id; +id xy +1 5 +6 0 +SELECT * FROM t5 order by id; +id xy +1 5 +2 0 +5 1 +6 0 +INSERT INTO t1 VALUES (5, 0); +REPLACE INTO t2 VALUES (6,1); +SELECT * FROM t1 order by id; +id xy +1 5 +5 0 +6 0 +SELECT * FROM t2 order by id; +id xy +1 5 +2 0 +5 1 +6 1 +REPLACE INTO t1 VALUES (5, 1); +SELECT * FROM t1 order by id; +id xy +1 5 +5 1 +6 0 +SELECT * FROM t2 order by id; +id xy +1 5 +2 0 +5 1 +6 0 +DROP TRIGGER t1_delete; +DROP TRIGGER t4_delete; +DROP TABLE t1, t2, t3, t4, t5; End of 5.0 tests diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result index 34d8e3ab768..92900ac1a83 100644 --- a/mysql-test/r/openssl_1.result +++ b/mysql-test/r/openssl_1.result @@ -51,3 +51,5 @@ SSL error: Unable to get private key from '' mysqltest: Could not open connection 'default': 2026 SSL connection error SSL error: Unable to get certificate from '' mysqltest: Could not open connection 'default': 2026 SSL connection error +Variable_name Value +Ssl_cipher DHE-RSA-AES256-SHA diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 0f28ade6523..eedc2fa476b 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -906,6 +906,90 @@ ERROR 23000: Column 'val' in order clause is ambiguous SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val > 1; ERROR 23000: Column 'val' in order clause is ambiguous DROP TABLE t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (3), (2), (4), (1); +SELECT a, IF(a IN (2,3), a, a+10) FROM t1 +ORDER BY IF(a IN (2,3), a, a+10); +a IF(a IN (2,3), a, a+10) +2 2 +3 3 +1 11 +4 14 +SELECT a, IF(a NOT IN (2,3), a, a+10) FROM t1 +ORDER BY IF(a NOT IN (2,3), a, a+10); +a IF(a NOT IN (2,3), a, a+10) +1 1 +4 4 +2 12 +3 13 +SELECT a, IF(a IN (2,3), a, a+10) FROM t1 +ORDER BY IF(a NOT IN (2,3), a, a+10); +a IF(a IN (2,3), a, a+10) +1 11 +4 14 +2 2 +3 3 +SELECT a, IF(a BETWEEN 2 AND 3, a, a+10) FROM t1 +ORDER BY IF(a BETWEEN 2 AND 3, a, a+10); +a IF(a BETWEEN 2 AND 3, a, a+10) +2 2 +3 3 +1 11 +4 14 +SELECT a, IF(a NOT BETWEEN 2 AND 3, a, a+10) FROM t1 +ORDER BY IF(a NOT BETWEEN 2 AND 3, a, a+10); +a IF(a NOT BETWEEN 2 AND 3, a, a+10) +1 1 +4 4 +2 12 +3 13 +SELECT a, IF(a BETWEEN 2 AND 3, a, a+10) FROM t1 +ORDER BY IF(a NOT BETWEEN 2 AND 3, a, a+10); +a IF(a BETWEEN 2 AND 3, a, a+10) +1 11 +4 14 +2 2 +3 3 +SELECT IF(a IN (1,2), a, '') as x1, IF(a NOT IN (1,2), a, '') as x2 +FROM t1 GROUP BY x1, x2; +x1 x2 + 3 + 4 +1 +2 +SELECT IF(a IN (1,2), a, '') as x1, IF(a NOT IN (1,2), a, '') as x2 +FROM t1 GROUP BY x1, IF(a NOT IN (1,2), a, ''); +x1 x2 + 3 + 4 +1 +2 +SELECT a, a IN (1,2) FROM t1 ORDER BY a IN (1,2); +a a IN (1,2) +3 0 +4 0 +2 1 +1 1 +SELECT a FROM t1 ORDER BY a IN (1,2); +a +3 +4 +2 +1 +SELECT a+10 FROM t1 ORDER BY a IN (1,2); +a+10 +13 +14 +12 +11 +SELECT a, IF(a IN (1,2), a, a+10) FROM t1 +ORDER BY IF(a IN (3,4), a, a+10); +a IF(a IN (1,2), a, a+10) +3 13 +4 14 +1 1 +2 2 +DROP TABLE t1; create table t1 (a int not null, b int not null, c int not null); insert t1 values (1,1,1),(1,1,2),(1,2,1); select a, b from t1 group by a, b order by sum(c); @@ -958,3 +1042,25 @@ a ratio 19 1.3333 9 2.6667 drop table t1; +CREATE TABLE t1 (a INT UNSIGNED NOT NULL, b TIME); +INSERT INTO t1 (a) VALUES (100000), (0), (100), (1000000),(10000), (1000), (10); +UPDATE t1 SET b = SEC_TO_TIME(a); +SELECT a, b FROM t1 ORDER BY b DESC; +a b +1000000 277:46:40 +100000 27:46:40 +10000 02:46:40 +1000 00:16:40 +100 00:01:40 +10 00:00:10 +0 00:00:00 +SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC; +a b +1000000 277:46:40 +100000 27:46:40 +10000 02:46:40 +1000 00:16:40 +100 00:01:40 +10 00:00:10 +0 00:00:00 +DROP TABLE t1; diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index e342e8d1d7f..58f8d077ac5 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -717,6 +717,147 @@ d8c4177d225791924.30714720 d8c4177d2380fc201.39666693 d8c4177d24ccef970.14957924 DROP TABLE t1; +create table t1 ( +c1 char(10), c2 char(10), c3 char(10), c4 char(10), +c5 char(10), c6 char(10), c7 char(10), c8 char(10), +c9 char(10), c10 char(10), c11 char(10), c12 char(10), +c13 char(10), c14 char(10), c15 char(10), c16 char(10), +index(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,c13,c14,c15,c16) +); +insert into t1 (c1) values ('1'),('1'),('1'),('1'); +select * from t1 where +c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC"); +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 +drop table t1; End of 4.1 tests CREATE TABLE t1 ( id int(11) NOT NULL auto_increment, diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result index 5b5f8b7b954..bb9e2109f0f 100644 --- a/mysql-test/r/row.result +++ b/mysql-test/r/row.result @@ -175,6 +175,24 @@ ROW(2,10) <=> ROW(3,4) SELECT ROW(NULL,10) <=> ROW(3,NULL); ROW(NULL,10) <=> ROW(3,NULL) 0 +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1)); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1),ROW(1,ROW(2,3))); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,ROW(2,2,2))); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3,4)) IN (ROW(1,ROW(2,3,4)),ROW(1,ROW(2,2))); +ERROR 21000: Operand should contain 3 column(s) +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1)); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1),ROW(1,ROW(2,4))); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3)) IN ((SELECT 1,1),ROW(1,ROW(2,3))); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(2,1) IN (ROW(21,2),ROW(ROW(1,1,3),0)); +ERROR 21000: Operand should contain 1 column(s) +SELECT ROW(2,1) IN (ROW(ROW(1,1,3),0),ROW(21,2)); +ERROR 21000: Operand should contain 1 column(s) SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NULL,1) = ROW(2,2,1) as `0`, ROW(1,NULL,1) = ROW(1,2,2) as `0`, ROW(1,NULL,1) = ROW(1,2,1) as `null` ; 1 0 0 0 null 1 0 0 0 NULL @@ -306,3 +324,16 @@ a b a b c 1 1 1 2 1 1 2 1 2 1 DROP TABLE t1,t2; +CREATE TABLE t1( +a int, b int, c int, d int, e int, f int, g int, h int, +PRIMARY KEY (a,b,c,d,e,f,g) +); +INSERT INTO t1 VALUES (1,2,3,4,5,6,7,99); +SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7); +h +99 +SET @x:= (SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7)); +SELECT @x; +@x +99 +DROP TABLE t1; diff --git a/mysql-test/r/rpl_ignore_table.result b/mysql-test/r/rpl_ignore_table.result index 136cf5cc5eb..80cff7c9a1e 100644 --- a/mysql-test/r/rpl_ignore_table.result +++ b/mysql-test/r/rpl_ignore_table.result @@ -14,6 +14,113 @@ SELECT * FROM t4; a DROP TABLE t1; DROP TABLE t4; +**** Test case for BUG#25482 **** +**** Adding GRANTS on master **** +create table test.t1(a int); +create table test.t4(a int); +GRANT SELECT ON test.t1 TO mysqltest1@localhost; +GRANT INSERT ON test.t4 TO mysqltest2@localhost; +GRANT select, update, insert, references on t1 +to mysqltest2@localhost; +GRANT SELECT ON test.* TO mysqltest3@localhost; +GRANT INSERT ON test.t4 TO mysqltest3@localhost; +GRANT select(a), update(a), insert(a), references(a) on t4 +to mysqltest3@localhost; +create database mysqltest2; +create table mysqltest2.t2 (id int); +GRANT SELECT ON mysqltest2.t2 TO mysqltest4@localhost IDENTIFIED BY 'pass'; +insert into mysql.user (user, host) values ("mysqltest5", "somehost"); +Warnings: +Warning 1364 Field 'ssl_cipher' doesn't have a default value +Warning 1364 Field 'x509_issuer' doesn't have a default value +Warning 1364 Field 'x509_subject' doesn't have a default value +GRANT SELECT ON *.* TO mysqltest6@localhost; +GRANT INSERT ON *.* TO mysqltest6@localhost; +GRANT INSERT ON test.* TO mysqltest6@localhost; +GRANT INSERT ON test.t1 TO mysqltest6@localhost; +show grants for mysqltest1@localhost; +Grants for mysqltest1@localhost +GRANT USAGE ON *.* TO 'mysqltest1'@'localhost' +GRANT SELECT ON `test`.`t1` TO 'mysqltest1'@'localhost' +show grants for mysqltest2@localhost; +Grants for mysqltest2@localhost +GRANT USAGE ON *.* TO 'mysqltest2'@'localhost' +GRANT SELECT, INSERT, UPDATE, REFERENCES ON `test`.`t1` TO 'mysqltest2'@'localhost' +GRANT INSERT ON `test`.`t4` TO 'mysqltest2'@'localhost' +show grants for mysqltest3@localhost; +Grants for mysqltest3@localhost +GRANT USAGE ON *.* TO 'mysqltest3'@'localhost' +GRANT SELECT ON `test`.* TO 'mysqltest3'@'localhost' +GRANT SELECT (a), INSERT, INSERT (a), UPDATE (a), REFERENCES (a) ON `test`.`t4` TO 'mysqltest3'@'localhost' +show grants for mysqltest4@localhost; +Grants for mysqltest4@localhost +GRANT USAGE ON *.* TO 'mysqltest4'@'localhost' IDENTIFIED BY PASSWORD '*196BDEDE2AE4F84CA44C47D54D78478C7E2BD7B7' +GRANT SELECT ON `mysqltest2`.`t2` TO 'mysqltest4'@'localhost' +show grants for mysqltest6@localhost; +Grants for mysqltest6@localhost +GRANT SELECT, INSERT ON *.* TO 'mysqltest6'@'localhost' +GRANT INSERT ON `test`.* TO 'mysqltest6'@'localhost' +GRANT INSERT ON `test`.`t1` TO 'mysqltest6'@'localhost' +flush privileges; +show grants for mysqltest5@somehost; +Grants for mysqltest5@somehost +GRANT USAGE ON *.* TO 'mysqltest5'@'somehost' +**** Checking grants on slave **** +show grants for mysqltest2@localhost; +Grants for mysqltest2@localhost +GRANT USAGE ON *.* TO 'mysqltest2'@'localhost' +GRANT INSERT ON `test`.`t4` TO 'mysqltest2'@'localhost' +show grants for mysqltest3@localhost; +Grants for mysqltest3@localhost +GRANT USAGE ON *.* TO 'mysqltest3'@'localhost' +GRANT SELECT ON `test`.* TO 'mysqltest3'@'localhost' +GRANT SELECT (a), INSERT, INSERT (a), UPDATE (a), REFERENCES (a) ON `test`.`t4` TO 'mysqltest3'@'localhost' +show grants for mysqltest4@localhost; +Grants for mysqltest4@localhost +GRANT USAGE ON *.* TO 'mysqltest4'@'localhost' IDENTIFIED BY PASSWORD '*196BDEDE2AE4F84CA44C47D54D78478C7E2BD7B7' +GRANT SELECT ON `mysqltest2`.`t2` TO 'mysqltest4'@'localhost' +show grants for mysqltest5@somehost; +Grants for mysqltest5@somehost +GRANT USAGE ON *.* TO 'mysqltest5'@'somehost' +show grants for mysqltest6@localhost; +Grants for mysqltest6@localhost +GRANT SELECT, INSERT ON *.* TO 'mysqltest6'@'localhost' +GRANT INSERT ON `test`.* TO 'mysqltest6'@'localhost' +show grants for mysqltest1@localhost; +ERROR 42000: There is no such grant defined for user 'mysqltest1' on host 'localhost' +**** Revoking grants on master **** +REVOKE SELECT ON test.t1 FROM mysqltest1@localhost; +REVOKE SELECT ON mysqltest2.t2 FROM mysqltest4@localhost; +REVOKE select(a) on t4 +from mysqltest3@localhost; +show grants for mysqltest1@localhost; +Grants for mysqltest1@localhost +GRANT USAGE ON *.* TO 'mysqltest1'@'localhost' +show grants for mysqltest3@localhost; +Grants for mysqltest3@localhost +GRANT USAGE ON *.* TO 'mysqltest3'@'localhost' +GRANT SELECT ON `test`.* TO 'mysqltest3'@'localhost' +GRANT INSERT, INSERT (a), UPDATE (a), REFERENCES (a) ON `test`.`t4` TO 'mysqltest3'@'localhost' +show grants for mysqltest4@localhost; +Grants for mysqltest4@localhost +GRANT USAGE ON *.* TO 'mysqltest4'@'localhost' IDENTIFIED BY PASSWORD '*196BDEDE2AE4F84CA44C47D54D78478C7E2BD7B7' +**** Checking grants on slave **** +show grants for mysqltest1@localhost; +ERROR 42000: There is no such grant defined for user 'mysqltest1' on host 'localhost' +show grants for mysqltest3@localhost; +Grants for mysqltest3@localhost +GRANT USAGE ON *.* TO 'mysqltest3'@'localhost' +GRANT SELECT ON `test`.* TO 'mysqltest3'@'localhost' +GRANT INSERT, INSERT (a), UPDATE (a), REFERENCES (a) ON `test`.`t4` TO 'mysqltest3'@'localhost' +show grants for mysqltest4@localhost; +Grants for mysqltest4@localhost +GRANT USAGE ON *.* TO 'mysqltest4'@'localhost' IDENTIFIED BY PASSWORD '*196BDEDE2AE4F84CA44C47D54D78478C7E2BD7B7' +drop table t1, t4, mysqltest2.t2; +drop database mysqltest2; +delete from mysql.user where user like "mysqltest%"; +delete from mysql.db where user like "mysqltest%"; +delete from mysql.tables_priv where user like "mysqltest%"; +delete from mysql.columns_priv where user like "mysqltest%"; DROP TABLE IF EXISTS t5; CREATE TABLE t5 ( word varchar(50) collate utf8_unicode_ci NOT NULL default '' diff --git a/mysql-test/r/rpl_misc_functions.result b/mysql-test/r/rpl_misc_functions.result index c11663b8ac8..526414cec9c 100644 --- a/mysql-test/r/rpl_misc_functions.result +++ b/mysql-test/r/rpl_misc_functions.result @@ -18,6 +18,29 @@ create table t2 like t1; load data local infile 'MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile' into table t2; select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p); id i r1 r2 p id i r1 r2 p -stop slave; -drop table t1; drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (col_a double default NULL); +CREATE PROCEDURE test_replication_sp1() +BEGIN +INSERT INTO t1 VALUES (rand()), (rand()); +INSERT INTO t1 VALUES (rand()); +END| +CREATE PROCEDURE test_replication_sp2() +BEGIN +CALL test_replication_sp1(); +CALL test_replication_sp1(); +END| +CREATE FUNCTION test_replication_sf() RETURNS DOUBLE DETERMINISTIC +BEGIN +RETURN (rand() + rand()); +END| +CALL test_replication_sp1(); +CALL test_replication_sp2(); +INSERT INTO t1 VALUES (test_replication_sf()); +INSERT INTO t1 VALUES (test_replication_sf()); +INSERT INTO t1 VALUES (test_replication_sf()); +DROP PROCEDURE IF EXISTS test_replication_sp1; +DROP PROCEDURE IF EXISTS test_replication_sp2; +DROP FUNCTION IF EXISTS test_replication_sf; +DROP TABLE IF EXISTS t1; diff --git a/mysql-test/r/rpl_packet.result b/mysql-test/r/rpl_packet.result index a5c9b43cabb..894bc81b08d 100644 --- a/mysql-test/r/rpl_packet.result +++ b/mysql-test/r/rpl_packet.result @@ -15,3 +15,12 @@ select count(*) from `DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_______________ count(*) 1 drop database DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________; +SET @@global.max_allowed_packet=4096; +SET @@global.net_buffer_length=4096; +STOP SLAVE; +START SLAVE; +CREATE TABLe `t1` (`f1` LONGTEXT) ENGINE=MyISAM; +INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048'); +SHOW STATUS LIKE 'Slave_running'; +Variable_name Value +Slave_running OFF diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index c3132a1b5f6..bfe0b9d19df 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -3628,6 +3628,21 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range si,ai si 5 NULL 2 Using where 1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a INT, b INT, KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,2); +EXPLAIN SELECT 1 FROM t1 WHERE a = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 5 const 1 Using where; Using index +EXPLAIN SELECT 1 FROM t1 IGNORE INDEX FOR JOIN (a) WHERE a = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +EXPLAIN SELECT 1 FROM t1 USE INDEX FOR JOIN (a) WHERE a = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 5 const 1 Using where; Using index +EXPLAIN SELECT 1 FROM t1 FORCE INDEX FOR JOIN (a) WHERE a = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 5 const 1 Using where; Using index +DROP TABLE t1; CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); CREATE TABLE t2 ( f11 int PRIMARY KEY ); INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0); @@ -3933,4 +3948,51 @@ cc cc 7 aa aa 2 aa aa 2 DROP TABLE t1,t2; +CREATE TABLE t1 ( +access_id int NOT NULL default '0', +name varchar(20) default NULL, +rank int NOT NULL default '0', +KEY idx (access_id) +); +CREATE TABLE t2 ( +faq_group_id int NOT NULL default '0', +faq_id int NOT NULL default '0', +access_id int default NULL, +UNIQUE KEY idx1 (faq_id), +KEY idx2 (faq_group_id,faq_id) +); +INSERT INTO t1 VALUES +(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4); +INSERT INTO t2 VALUES +(261,265,1),(490,494,1); +SELECT t2.faq_id +FROM t1 INNER JOIN t2 IGNORE INDEX (idx1) +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +SELECT t2.faq_id +FROM t1 INNER JOIN t2 +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, KEY inx (b,a)); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7); +EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 +ON ( f1.b=f2.b AND f1.a<f2.a ) +WHERE 1 AND f1.b NOT IN (100,2232,3343,51111); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index +1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/r/skip_grants.result b/mysql-test/r/skip_grants.result index 58ced16acac..3052bae8e97 100644 --- a/mysql-test/r/skip_grants.result +++ b/mysql-test/r/skip_grants.result @@ -58,3 +58,15 @@ DROP PROCEDURE p3; DROP FUNCTION f1; DROP FUNCTION f2; DROP FUNCTION f3; +select count(*) from information_schema.COLUMN_PRIVILEGES; +count(*) +0 +select count(*) from information_schema.SCHEMA_PRIVILEGES; +count(*) +0 +select count(*) from information_schema.TABLE_PRIVILEGES; +count(*) +0 +select count(*) from information_schema.USER_PRIVILEGES; +count(*) +0 diff --git a/mysql-test/r/sp-code.result b/mysql-test/r/sp-code.result index 67b030f87a4..9d86a6bc08d 100644 --- a/mysql-test/r/sp-code.result +++ b/mysql-test/r/sp-code.result @@ -187,7 +187,7 @@ Pos Instruction 32 set v_dig@4 (v_dig@4 + 1) 33 stmt 4 "update sudoku_work set dig = v_dig wh..." 34 set v_tcounter@6 (v_tcounter@6 + 1) -35 jump_if_not 37(37) (not(`test`.`sudoku_digit_ok`(v_row@7,v_col@8,v_dig@4))) +35 jump_if_not 37(37) (not(`sudoku_digit_ok`(v_row@7,v_col@8,v_dig@4))) 36 jump 15 37 set v_i@3 (v_i@3 + 1) 38 jump 15 diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 332d4fa4519..bdcb51c4db8 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1400,3 +1400,55 @@ drop table table_25345_b; drop procedure proc_25345; drop function func_25345; drop function func_25345_b; +create procedure proc_26503_error_1() +begin +retry: +repeat +begin +declare continue handler for sqlexception +begin +iterate retry; +end +select "do something"; +end +until true end repeat retry; +end// +ERROR 42000: ITERATE with no matching label: retry +create procedure proc_26503_error_2() +begin +retry: +repeat +begin +declare continue handler for sqlexception +iterate retry; +select "do something"; +end +until true end repeat retry; +end// +ERROR 42000: ITERATE with no matching label: retry +create procedure proc_26503_error_3() +begin +retry: +repeat +begin +declare continue handler for sqlexception +begin +leave retry; +end +select "do something"; +end +until true end repeat retry; +end// +ERROR 42000: LEAVE with no matching label: retry +create procedure proc_26503_error_4() +begin +retry: +repeat +begin +declare continue handler for sqlexception +leave retry; +select "do something"; +end +until true end repeat retry; +end// +ERROR 42000: LEAVE with no matching label: retry diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 34f2aa94000..c75697b93a2 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -5633,6 +5633,32 @@ call proc_bug19733()| call proc_bug19733()| drop procedure proc_bug19733| drop table t3| +DROP PROCEDURE IF EXISTS p1| +DROP VIEW IF EXISTS v1, v2| +DROP TABLE IF EXISTS t3, t4| +CREATE TABLE t3 (t3_id INT)| +INSERT INTO t3 VALUES (0)| +INSERT INTO t3 VALUES (1)| +CREATE TABLE t4 (t4_id INT)| +INSERT INTO t4 VALUES (2)| +CREATE VIEW v1 AS +SELECT t3.t3_id, t4.t4_id +FROM t3 JOIN t4 ON t3.t3_id = 0| +CREATE VIEW v2 AS +SELECT t3.t3_id AS t3_id_1, v1.t3_id AS t3_id_2, v1.t4_id +FROM t3 LEFT JOIN v1 ON t3.t3_id = 0| +CREATE PROCEDURE p1() SELECT * FROM v2| +CALL p1()| +t3_id_1 t3_id_2 t4_id +0 0 2 +1 NULL NULL +CALL p1()| +t3_id_1 t3_id_2 t4_id +0 0 2 +1 NULL NULL +DROP PROCEDURE p1| +DROP VIEW v1, v2| +DROP TABLE t3, t4| End of 5.0 tests DROP TABLE IF EXISTS bug23760| DROP TABLE IF EXISTS bug23760_log| @@ -5765,6 +5791,171 @@ func_8407_b() 1500 drop function func_8407_a| drop function func_8407_b| +drop table if exists table_26503| +drop procedure if exists proc_26503_ok_1| +drop procedure if exists proc_26503_ok_2| +drop procedure if exists proc_26503_ok_3| +drop procedure if exists proc_26503_ok_4| +create table table_26503(a int unique)| +create procedure proc_26503_ok_1(v int) +begin +declare i int default 5; +declare continue handler for sqlexception +begin +select 'caught something'; +retry: +while i > 0 do +begin +set i = i - 1; +select 'looping', i; +iterate retry; +select 'dead code'; +end; +end while retry; +select 'leaving handler'; +end; +select 'do something'; +insert into table_26503 values (v); +select 'do something again'; +insert into table_26503 values (v); +end| +create procedure proc_26503_ok_2(v int) +begin +declare i int default 5; +declare continue handler for sqlexception +begin +select 'caught something'; +retry: +while i > 0 do +begin +set i = i - 1; +select 'looping', i; +leave retry; +select 'dead code'; +end; +end while; +select 'leaving handler'; +end; +select 'do something'; +insert into table_26503 values (v); +select 'do something again'; +insert into table_26503 values (v); +end| +create procedure proc_26503_ok_3(v int) +begin +declare i int default 5; +retry: +begin +declare continue handler for sqlexception +begin +select 'caught something'; +retry: +while i > 0 do +begin +set i = i - 1; +select 'looping', i; +iterate retry; +select 'dead code'; +end; +end while retry; +select 'leaving handler'; +end; +select 'do something'; +insert into table_26503 values (v); +select 'do something again'; +insert into table_26503 values (v); +end; +end| +create procedure proc_26503_ok_4(v int) +begin +declare i int default 5; +retry: +begin +declare continue handler for sqlexception +begin +select 'caught something'; +retry: +while i > 0 do +begin +set i = i - 1; +select 'looping', i; +leave retry; +select 'dead code'; +end; +end while; +select 'leaving handler'; +end; +select 'do something'; +insert into table_26503 values (v); +select 'do something again'; +insert into table_26503 values (v); +end; +end| +call proc_26503_ok_1(1)| +do something +do something +do something again +do something again +caught something +caught something +looping i +looping 4 +looping i +looping 3 +looping i +looping 2 +looping i +looping 1 +looping i +looping 0 +leaving handler +leaving handler +call proc_26503_ok_2(2)| +do something +do something +do something again +do something again +caught something +caught something +looping i +looping 4 +leaving handler +leaving handler +call proc_26503_ok_3(3)| +do something +do something +do something again +do something again +caught something +caught something +looping i +looping 4 +looping i +looping 3 +looping i +looping 2 +looping i +looping 1 +looping i +looping 0 +leaving handler +leaving handler +call proc_26503_ok_4(4)| +do something +do something +do something again +do something again +caught something +caught something +looping i +looping 4 +leaving handler +leaving handler +drop table table_26503| +drop procedure proc_26503_ok_1| +drop procedure proc_26503_ok_2| +drop procedure proc_26503_ok_3| +drop procedure proc_26503_ok_4| DROP FUNCTION IF EXISTS bug25373| CREATE FUNCTION bug25373(p1 INTEGER) RETURNS INTEGER LANGUAGE SQL DETERMINISTIC @@ -5778,4 +5969,89 @@ SUM(f2) bug25373(f1) 21.300000071526 NULL DROP FUNCTION bug25373| DROP TABLE t3| +drop function if exists bug20777| +drop table if exists examplebug20777| +create function bug20777(f1 bigint unsigned) returns bigint unsigned +begin +set f1 = (f1 - 10); set f1 = (f1 + 10); +return f1; +end| +select bug20777(9223372036854775803) as '9223372036854775803 2**63-5'; +9223372036854775803 2**63-5 +9223372036854775803 +select bug20777(9223372036854775804) as '9223372036854775804 2**63-4'; +9223372036854775804 2**63-4 +9223372036854775804 +select bug20777(9223372036854775805) as '9223372036854775805 2**63-3'; +9223372036854775805 2**63-3 +9223372036854775805 +select bug20777(9223372036854775806) as '9223372036854775806 2**63-2'; +9223372036854775806 2**63-2 +9223372036854775806 +select bug20777(9223372036854775807) as '9223372036854775807 2**63-1'; +9223372036854775807 2**63-1 +9223372036854775807 +select bug20777(9223372036854775808) as '9223372036854775808 2**63+0'; +9223372036854775808 2**63+0 +9223372036854775808 +select bug20777(9223372036854775809) as '9223372036854775809 2**63+1'; +9223372036854775809 2**63+1 +9223372036854775809 +select bug20777(9223372036854775810) as '9223372036854775810 2**63+2'; +9223372036854775810 2**63+2 +9223372036854775810 +select bug20777(-9223372036854775808) as 'lower bounds signed bigint'; +lower bounds signed bigint +0 +select bug20777(9223372036854775807) as 'upper bounds signed bigint'; +upper bounds signed bigint +9223372036854775807 +select bug20777(0) as 'lower bounds unsigned bigint'; +lower bounds unsigned bigint +0 +select bug20777(18446744073709551615) as 'upper bounds unsigned bigint'; +upper bounds unsigned bigint +18446744073709551615 +select bug20777(18446744073709551616) as 'upper bounds unsigned bigint + 1'; +upper bounds unsigned bigint + 1 +18446744073709551615 +select bug20777(-1) as 'lower bounds unsigned bigint - 1'; +lower bounds unsigned bigint - 1 +0 +create table examplebug20777 as select +0 as 'i', +bug20777(9223372036854775806) as '2**63-2', +bug20777(9223372036854775807) as '2**63-1', +bug20777(9223372036854775808) as '2**63', +bug20777(9223372036854775809) as '2**63+1', +bug20777(18446744073709551614) as '2**64-2', +bug20777(18446744073709551615) as '2**64-1', +bug20777(18446744073709551616) as '2**64', +bug20777(0) as '0', +bug20777(-1) as '-1'; +insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616, 0, -1); +show create table examplebug20777; +Table Create Table +examplebug20777 CREATE TABLE `examplebug20777` ( + `i` int(1) NOT NULL default '0', + `2**63-2` bigint(20) unsigned default NULL, + `2**63-1` bigint(20) unsigned default NULL, + `2**63` bigint(20) unsigned default NULL, + `2**63+1` bigint(20) unsigned default NULL, + `2**64-2` bigint(20) unsigned default NULL, + `2**64-1` bigint(20) unsigned default NULL, + `2**64` bigint(20) unsigned default NULL, + `0` bigint(20) unsigned default NULL, + `-1` bigint(20) unsigned default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from examplebug20777 order by i; +i 2**63-2 2**63-1 2**63 2**63+1 2**64-2 2**64-1 2**64 0 -1 +0 9223372036854775806 9223372036854775807 9223372036854775808 9223372036854775809 18446744073709551614 18446744073709551615 18446744073709551615 0 0 +1 9223372036854775806 9223372036854775807 223372036854775808 9223372036854775809 18446744073709551614 18446744073709551615 8446744073709551616 0 0 +drop table examplebug20777; +select bug20777(18446744073709551613)+1; +bug20777(18446744073709551613)+1 +18446744073709551614 +drop function bug20777; +End of 5.0 tests. drop table t1,t2; diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index 702fc68bb25..f9d84df5d9f 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -7,7 +7,6 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (col1 date); INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29'); INSERT INTO t1 VALUES('0000-10-31'); -ERROR 22007: Incorrect date value: '0000-10-31' for column 'col1' at row 1 INSERT INTO t1 VALUES('2004-0-31'); ERROR 22007: Incorrect date value: '2004-0-31' for column 'col1' at row 1 INSERT INTO t1 VALUES('2004-01-02'),('2004-0-31'); @@ -57,6 +56,7 @@ select * from t1; col1 2004-01-01 2004-02-29 +0000-10-31 2004-01-02 2004-01-03 2004-00-31 @@ -124,7 +124,6 @@ set @@sql_mode='ansi,traditional'; CREATE TABLE t1 (col1 datetime); INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00'); INSERT INTO t1 VALUES('0000-10-31 15:30:00'); -ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col1' at row 1 INSERT INTO t1 VALUES('2004-0-31 15:30:00'); ERROR 22007: Incorrect datetime value: '2004-0-31 15:30:00' for column 'col1' at row 1 INSERT INTO t1 VALUES('2004-10-0 15:30:00'); @@ -145,6 +144,7 @@ select * from t1; col1 2004-10-31 15:30:00 2004-02-29 15:30:00 +0000-10-31 15:30:00 drop table t1; CREATE TABLE t1 (col1 timestamp); INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00'); @@ -206,7 +206,6 @@ INSERT INTO t1 (col1) VALUES (STR_TO_DATE('15.10.2004','%d.%m.%Y')); INSERT INTO t1 (col2) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i')); INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i')); INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i')); -ERROR 22007: Incorrect date value: '0000-10-31 15:30:00' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i')); ERROR 22007: Incorrect date value: '2004-00-31 15:30:00' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i')); @@ -222,7 +221,6 @@ ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_ti INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y')); ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i')); -ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col2' at row 1 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i')); ERROR 22007: Incorrect datetime value: '2004-00-31 15:30:00' for column 'col2' at row 1 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i')); @@ -259,7 +257,6 @@ INSERT INTO t1 (col1) VALUES (CAST('2004-10-15' AS DATE)); INSERT INTO t1 (col2) VALUES (CAST('2004-10-15 10:15' AS DATETIME)); INSERT INTO t1 (col3) VALUES (CAST('2004-10-15 10:15' AS DATETIME)); INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE)); -ERROR 22007: Truncated incorrect datetime value: '0000-10-31' INSERT INTO t1 (col1) VALUES(CAST('2004-10-0' AS DATE)); ERROR 22007: Incorrect date value: '2004-10-00' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(CAST('2004-0-10' AS DATE)); @@ -267,7 +264,6 @@ ERROR 22007: Incorrect date value: '2004-00-10' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE)); ERROR 22007: Truncated incorrect datetime value: '0000-00-00' INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME)); -ERROR 22007: Truncated incorrect datetime value: '0000-10-31 15:30' INSERT INTO t1 (col2) VALUES(CAST('2004-10-0 15:30' AS DATETIME)); ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1 INSERT INTO t1 (col2) VALUES(CAST('2004-0-10 15:30' AS DATETIME)); @@ -275,7 +271,7 @@ ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col2' a INSERT INTO t1 (col2) VALUES(CAST('0000-00-00' AS DATETIME)); ERROR 22007: Truncated incorrect datetime value: '0000-00-00' INSERT INTO t1 (col3) VALUES(CAST('0000-10-31 15:30' AS DATETIME)); -ERROR 22007: Truncated incorrect datetime value: '0000-10-31 15:30' +ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1 INSERT INTO t1 (col3) VALUES(CAST('2004-10-0 15:30' AS DATETIME)); ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1 INSERT INTO t1 (col3) VALUES(CAST('2004-0-10 15:30' AS DATETIME)); @@ -288,7 +284,6 @@ INSERT INTO t1 (col1) VALUES (CONVERT('2004-10-15',DATE)); INSERT INTO t1 (col2) VALUES (CONVERT('2004-10-15 10:15',DATETIME)); INSERT INTO t1 (col3) VALUES (CONVERT('2004-10-15 10:15',DATETIME)); INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE)); -ERROR 22007: Truncated incorrect datetime value: '0000-10-31' INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE)); ERROR 22007: Incorrect date value: '2004-10-00' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE)); @@ -296,7 +291,6 @@ ERROR 22007: Incorrect date value: '2004-00-10' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE)); ERROR 22007: Truncated incorrect datetime value: '0000-00-00' INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME)); -ERROR 22007: Truncated incorrect datetime value: '0000-10-31 15:30' INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-0 15:30',DATETIME)); ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1 INSERT INTO t1 (col2) VALUES(CONVERT('2004-0-10 15:30',DATETIME)); @@ -304,7 +298,7 @@ ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col2' a INSERT INTO t1 (col2) VALUES(CONVERT('0000-00-00',DATETIME)); ERROR 22007: Truncated incorrect datetime value: '0000-00-00' INSERT INTO t1 (col3) VALUES(CONVERT('0000-10-31 15:30',DATETIME)); -ERROR 22007: Truncated incorrect datetime value: '0000-10-31 15:30' +ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1 INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-0 15:30',DATETIME)); ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1 INSERT INTO t1 (col3) VALUES(CONVERT('2004-0-10 15:30',DATETIME)); @@ -1352,3 +1346,49 @@ t1 CREATE TABLE `t1` ( `i` int(11) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='123456789*123456789*123456789*123456789*123456789*123456789*' drop table t1; +set sql_mode= 'traditional'; +create table t1(col1 tinyint, col2 tinyint unsigned, +col3 smallint, col4 smallint unsigned, +col5 mediumint, col6 mediumint unsigned, +col7 int, col8 int unsigned, +col9 bigint, col10 bigint unsigned); +insert into t1(col1) values('-'); +ERROR HY000: Incorrect integer value: '-' for column 'col1' at row 1 +insert into t1(col2) values('+'); +ERROR HY000: Incorrect integer value: '+' for column 'col2' at row 1 +insert into t1(col3) values('-'); +ERROR HY000: Incorrect integer value: '-' for column 'col3' at row 1 +insert into t1(col4) values('+'); +ERROR HY000: Incorrect integer value: '+' for column 'col4' at row 1 +insert into t1(col5) values('-'); +ERROR HY000: Incorrect integer value: '-' for column 'col5' at row 1 +insert into t1(col6) values('+'); +ERROR HY000: Incorrect integer value: '+' for column 'col6' at row 1 +insert into t1(col7) values('-'); +ERROR HY000: Incorrect integer value: '-' for column 'col7' at row 1 +insert into t1(col8) values('+'); +ERROR HY000: Incorrect integer value: '+' for column 'col8' at row 1 +insert into t1(col9) values('-'); +ERROR HY000: Incorrect integer value: '-' for column 'col9' at row 1 +insert into t1(col10) values('+'); +ERROR HY000: Incorrect integer value: '+' for column 'col10' at row 1 +drop table t1; +set sql_mode='traditional'; +create table t1(a year); +insert into t1 values ('-'); +ERROR HY000: Incorrect integer value: '-' for column 'a' at row 1 +insert into t1 values ('+'); +ERROR HY000: Incorrect integer value: '+' for column 'a' at row 1 +insert into t1 values (''); +ERROR HY000: Incorrect integer value: '' for column 'a' at row 1 +insert into t1 values ('2000a'); +ERROR 01000: Data truncated for column 'a' at row 1 +insert into t1 values ('2E3x'); +ERROR 01000: Data truncated for column 'a' at row 1 +drop table t1; +set sql_mode='traditional'; +create table t1 (f1 set('a','a')); +ERROR HY000: Column 'f1' has duplicated value 'a' in SET +create table t1 (f1 enum('a','a')); +ERROR HY000: Column 'f1' has duplicated value 'a' in ENUM +End of 5.0 tests diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 71dbff65e7d..94075df57b4 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -48,7 +48,7 @@ id select_type table type possible_keys key key_len ref rows Extra 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used 2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1276 Field or reference 'a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having ((select '1' AS `a`) = 1) SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; @@ -330,7 +330,7 @@ patient_uq clinic_uq explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t6 ALL NULL NULL NULL NULL 4 Using where -2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 t6.clinic_uq 1 Using where; Using index +2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 Using index Warnings: Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 AS `Not_used` from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`)) @@ -1741,7 +1741,7 @@ Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `tes explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY tt ALL NULL NULL NULL NULL 12 Using where -2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 tt.id 1 Using where; Using index +2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 Using where; Using index Warnings: Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(exists(select `test`.`t1`.`id` AS `id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null)))) @@ -3867,3 +3867,148 @@ id_1 DROP TABLE t1; DROP TABLE t2; DROP TABLE t1xt2; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (3), (1), (2); +SELECT 'this is ' 'a test.' AS col1, a AS col2 FROM t1; +col1 col2 +this is a test. 3 +this is a test. 1 +this is a test. 2 +SELECT * FROM (SELECT 'this is ' 'a test.' AS col1, a AS t2 FROM t1) t; +col1 t2 +this is a test. 3 +this is a test. 1 +this is a test. 2 +DROP table t1; +CREATE TABLE t1 (a int, b int); +CREATE TABLE t2 (m int, n int); +INSERT INTO t1 VALUES (2,2), (2,2), (3,3), (3,3), (3,3), (4,4); +INSERT INTO t2 VALUES (1,11), (2,22), (3,32), (4,44), (4,44); +SELECT COUNT(*), a, +(SELECT m FROM t2 WHERE m = count(*) LIMIT 1) +FROM t1 GROUP BY a; +COUNT(*) a (SELECT m FROM t2 WHERE m = count(*) LIMIT 1) +2 2 2 +3 3 3 +1 4 1 +SELECT COUNT(*), a, +(SELECT MIN(m) FROM t2 WHERE m = count(*)) +FROM t1 GROUP BY a; +COUNT(*) a (SELECT MIN(m) FROM t2 WHERE m = count(*)) +2 2 2 +3 3 3 +1 4 1 +SELECT COUNT(*), a +FROM t1 GROUP BY a +HAVING (SELECT MIN(m) FROM t2 WHERE m = count(*)) > 1; +COUNT(*) a +2 2 +3 3 +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b int); +CREATE TABLE t2 (m int, n int); +INSERT INTO t1 VALUES (2,2), (2,2), (3,3), (3,3), (3,3), (4,4); +INSERT INTO t2 VALUES (1,11), (2,22), (3,32), (4,44), (4,44); +SELECT COUNT(*) c, a, +(SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a) +FROM t1 GROUP BY a; +c a (SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a) +2 2 2 +3 3 3 +1 4 1,1 +SELECT COUNT(*) c, a, +(SELECT GROUP_CONCAT(COUNT(a)+1) FROM t2 WHERE m = a) +FROM t1 GROUP BY a; +c a (SELECT GROUP_CONCAT(COUNT(a)+1) FROM t2 WHERE m = a) +2 2 3 +3 3 4 +1 4 2,2 +DROP table t1,t2; +CREATE TABLE t1 (a int, b INT, d INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b)); +INSERT INTO t1 VALUES (1,1,0,'a'), (1,2,0,'b'), (1,3,0,'c'), (1,4,0,'d'), +(1,5,0,'e'), (2,1,0,'f'), (2,2,0,'g'), (2,3,0,'h'), (3,4,0,'i'), (3,3,0,'j'), +(3,2,0,'k'), (3,1,0,'l'), (1,9,0,'m'), (1,0,10,'n'), (2,0,5,'o'), (3,0,7,'p'); +SELECT a, MAX(b), +(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b + 0)) as test +FROM t1 GROUP BY a; +a MAX(b) test +1 9 m +2 3 h +3 4 i +SELECT a x, MAX(b), +(SELECT t.c FROM t1 AS t WHERE x=t.a AND t.b=MAX(t1.b + 0)) as test +FROM t1 GROUP BY a; +x MAX(b) test +1 9 m +2 3 h +3 4 i +SELECT a, AVG(b), +(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=AVG(t1.b)) AS test +FROM t1 WHERE t1.d=0 GROUP BY a; +a AVG(b) test +1 4.0000 d +2 2.0000 g +3 2.5000 NULL +SELECT tt.a, +(SELECT (SELECT c FROM t1 as t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a) +LIMIT 1) FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test +FROM t1 as tt; +a test +1 n +1 n +1 n +1 n +1 n +1 n +1 n +2 o +2 o +2 o +2 o +3 p +3 p +3 p +3 p +3 p +SELECT tt.a, +(SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a) +LIMIT 1) +FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test +FROM t1 as tt GROUP BY tt.a; +a test +1 n +2 o +3 p +SELECT tt.a, MAX( +(SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a) +LIMIT 1) +FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1)) as test +FROM t1 as tt GROUP BY tt.a; +a test +1 n +2 o +3 p +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (2,22),(1,11),(2,22); +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a; +a +1 +2 +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a; +a +SELECT a FROM t1 t0 +WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a; +a +1 +2 +SET @@sql_mode='ansi'; +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a; +ERROR HY000: Invalid use of group function +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a; +ERROR HY000: Invalid use of group function +SELECT a FROM t1 t0 +WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a; +ERROR HY000: Invalid use of group function +SET @@sql_mode=default; +DROP TABLE t1; diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result index b975ea8cbdc..33e7fc54ed2 100644 --- a/mysql-test/r/subselect3.result +++ b/mysql-test/r/subselect3.result @@ -432,7 +432,7 @@ alter table t1 add index idx(oref,ie); explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 7 -2 DEPENDENT SUBQUERY t1 ref_or_null idx idx 10 t2.oref,func 4 Using where; Using index; Full scan on NULL key +2 DEPENDENT SUBQUERY t1 ref_or_null idx idx 10 test.t2.oref,func 4 Using where; Using index; Full scan on NULL key select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; oref a Z ee NULL NULL @@ -457,7 +457,7 @@ group by grp having min(ie) > 1) Z from t2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 7 -2 DEPENDENT SUBQUERY t1 ref idx idx 5 t2.oref 2 Using where; Using temporary; Using filesort +2 DEPENDENT SUBQUERY t1 ref idx idx 5 test.t2.oref 2 Using where; Using temporary; Using filesort select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp having min(ie) > 1) Z @@ -645,3 +645,50 @@ a b Z 2 2 0 3 3 1 drop table t1,t2; +CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b)); +INSERT INTO t1 VALUES (1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'), +(2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'),(3,3,'j'), (3,2,'k'), (3,1,'l'), +(1,9,'m'); +CREATE TABLE t2 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b)); +INSERT INTO t2 SELECT * FROM t1; +SELECT a, MAX(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)) +as test FROM t1 GROUP BY a; +a MAX(b) test +1 9 m +2 3 h +3 4 i +SELECT * FROM t1 GROUP by t1.a +HAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.c +HAVING MAX(t2.b+t1.a) < 10)); +a b c +SELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c; +a b c +1 3 c +2 3 h +3 3 j +1 4 d +3 4 i +1 9 m +SELECT a, MAX(b), +(SELECT COUNT(DISTINCT t.c) FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) +LIMIT 1) +as cnt, +(SELECT t.b FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) +as t_b, +(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) +as t_b, +(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) ORDER BY t.c LIMIT 1) +as t_b +FROM t1 GROUP BY a; +a MAX(b) cnt t_b t_b t_b +1 9 1 9 m m +2 3 1 3 h h +3 4 1 4 i i +SELECT a, MAX(b), +(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) as test +FROM t1 GROUP BY a; +a MAX(b) test +1 9 m +2 3 h +3 4 i +DROP TABLE t1, t2; diff --git a/mysql-test/r/temp_table.result b/mysql-test/r/temp_table.result index 139a7da77de..d6adf51602b 100644 --- a/mysql-test/r/temp_table.result +++ b/mysql-test/r/temp_table.result @@ -152,3 +152,24 @@ SELECT * FROM t1; i DROP TABLE t1; End of 4.1 tests. +CREATE TABLE t1 ( c FLOAT( 20, 14 ) ); +INSERT INTO t1 VALUES( 12139 ); +CREATE TABLE t2 ( c FLOAT(30,18) ); +INSERT INTO t2 VALUES( 123456 ); +SELECT AVG( c ) FROM t1 UNION SELECT 1; +AVG( c ) +12139 +1 +SELECT 1 UNION SELECT AVG( c ) FROM t1; +1 +1 +12139 +SELECT 1 UNION SELECT * FROM t2 UNION SELECT 1; +1 +1 +123456 +SELECT c/1 FROM t1 UNION SELECT 1; +c/1 +12139 +1 +DROP TABLE t1, t2; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index aa511ca27a7..0a0be41927a 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1372,4 +1372,46 @@ INSERT INTO bug22580_t1 VALUES (1,1); DROP TABLE bug22580_t1; DROP PROCEDURE bug22580_proc_1; DROP PROCEDURE bug22580_proc_2; +DROP TRIGGER IF EXISTS trg27006_a_update; +DROP TRIGGER IF EXISTS trg27006_a_insert; +CREATE TABLE t1 ( +`id` int(10) unsigned NOT NULL auto_increment, +`val` varchar(10) NOT NULL, +PRIMARY KEY (`id`) +); +CREATE TABLE t2 like t1; +CREATE TRIGGER trg27006_a_insert AFTER INSERT ON t1 FOR EACH ROW +BEGIN +insert into t2 values (NULL,new.val); +END | +CREATE TRIGGER trg27006_a_update AFTER UPDATE ON t1 FOR EACH ROW +BEGIN +insert into t2 values (NULL,new.val); +END | +INSERT INTO t1(val) VALUES ('test1'),('test2'); +SELECT * FROM t1; +id val +1 test1 +2 test2 +SELECT * FROM t2; +id val +1 test1 +2 test2 +INSERT INTO t1 VALUES (2,'test2') ON DUPLICATE KEY UPDATE val=VALUES(val); +INSERT INTO t1 VALUES (2,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val); +INSERT INTO t1 VALUES (3,'test4') ON DUPLICATE KEY UPDATE val=VALUES(val); +SELECT * FROM t1; +id val +1 test1 +2 test3 +3 test4 +SELECT * FROM t2; +id val +1 test1 +2 test2 +3 test3 +4 test4 +DROP TRIGGER trg27006_a_insert; +DROP TRIGGER trg27006_a_update; +drop table t1,t2; End of 5.0 tests diff --git a/mysql-test/r/truncate.result b/mysql-test/r/truncate.result index 74a6cb72cc6..b194f9b7dc6 100644 --- a/mysql-test/r/truncate.result +++ b/mysql-test/r/truncate.result @@ -53,3 +53,10 @@ a 3 4 drop table t1; +create table t1 (s1 int); +insert into t1 (s1) values (1), (2), (3), (4), (5); +create view v1 as select * from t1; +truncate table v1; +ERROR 42S02: Table 'test.v1' doesn't exist +drop view v1; +drop table t1; diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index ed15293bb45..644d4d971c6 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -99,7 +99,7 @@ DROP TABLE t1, t2, t3; CREATE TABLE t1 (y YEAR); INSERT INTO t1 VALUES ('abc'); Warnings: -Warning 1264 Out of range value adjusted for column 'y' at row 1 +Warning 1366 Incorrect integer value: 'abc' for column 'y' at row 1 SELECT * FROM t1; y 0000 diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 7fc1c4f398d..7caa23d330d 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -26,8 +26,6 @@ Table Op Msg_type Msg_text test.t1 check status OK delete from t1; insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030100000000"),("20030000000000"); -Warnings: -Warning 1264 Out of range value adjusted for column 't' at row 5 insert into t1 values ("2003-003-03"); insert into t1 values ("20030102T131415"),("2001-01-01T01:01:01"), ("2001-1-1T1:01:01"); select * from t1; @@ -36,7 +34,7 @@ t 2069-12-31 00:00:00 1970-01-01 00:00:00 1999-12-31 00:00:00 -0000-00-00 00:00:00 +0000-01-01 00:00:00 0001-01-01 00:00:00 9999-12-31 00:00:00 2000-10-10 00:00:00 @@ -168,6 +166,9 @@ dt 0000-00-00 00:00:00 0000-00-00 00:00:00 drop table t1; +select cast('2006-12-05 22:10:10' as datetime) + 0; +cast('2006-12-05 22:10:10' as datetime) + 0 +20061205221010.000000 CREATE TABLE t1(a DATETIME NOT NULL); INSERT INTO t1 VALUES ('20060606155555'); SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555"); diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index 0cb77f42caf..188963c5bdf 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -92,7 +92,7 @@ show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `col1` double default NULL, - `col2` double(53,5) default NULL, + `col2` double(22,5) default NULL, `col3` double default NULL, `col4` double default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 @@ -232,12 +232,12 @@ insert into t2 values ("1.23456780"); create table t3 select * from t2 union select * from t1; select * from t3; d -1.234567800 -100000000.000000000 +1.2345678 +100000000 show create table t3; Table Create Table t3 CREATE TABLE `t3` ( - `d` double(22,9) default NULL + `d` double default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1, t2, t3; create table t1 select 105213674794682365.00 + 0.0 x; diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index e65e76ded3f..359a929d9a3 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -1423,3 +1423,11 @@ cast(19999999999999999999 as unsigned) 18446744073709551615 Warnings: Error 1292 Truncated incorrect DECIMAL value: '' +create table t1(a decimal(18)); +insert into t1 values(123456789012345678); +alter table t1 modify column a decimal(19); +select * from t1; +a +123456789012345678 +drop table t1; +End of 5.0 tests diff --git a/mysql-test/r/type_set.result b/mysql-test/r/type_set.result index fdda4aca25c..03de20baef2 100644 --- a/mysql-test/r/type_set.result +++ b/mysql-test/r/type_set.result @@ -66,3 +66,22 @@ ss ue ue DROP TABLE t1; +create table t1(f1 +set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17', +'18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33', +'34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49', +'50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','128')); +ERROR HY000: Too many strings for column f1 and SET +create table t1(f1 +set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17', +'18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33', +'34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49', +'50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','1')); +Warnings: +Note 1291 Column 'f1' has duplicated value '1' in SET +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','1') default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/r/type_year.result b/mysql-test/r/type_year.result index 84b688429db..e52947455c8 100644 --- a/mysql-test/r/type_year.result +++ b/mysql-test/r/type_year.result @@ -34,3 +34,15 @@ select if(y = now(), 1, 0) from t1; if(y = now(), 1, 0) 1 drop table t1; +create table t1(a year); +insert into t1 values (2000.5), ('2000.5'), ('2001a'), ('2.001E3'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 3 +select * from t1; +a +2001 +2001 +2001 +2001 +drop table t1; +End of 5.0 tests diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index d5f59247084..7c52e7da496 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -159,7 +159,7 @@ EXPLAIN EXTENDED SELECT myfunc_int(fn(MIN(b))) as c FROM t1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort Warnings: -Note 1003 select myfunc_int(`test`.`fn`(min(`test`.`t1`.`b`)) AS `fn(MIN(b))`) AS `c` from `test`.`t1` group by `test`.`t1`.`a` +Note 1003 select myfunc_int(`fn`(min(`test`.`t1`.`b`)) AS `fn(MIN(b))`) AS `c` from `test`.`t1` group by `test`.`t1`.`a` EXPLAIN EXTENDED SELECT myfunc_int(test.fn(MIN(b))) as c FROM t1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 9861b1bffeb..efdd8195fb5 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -554,7 +554,7 @@ aa show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` varbinary(20) NOT NULL default '' + `a` varbinary(2) NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT 12 as a UNION select 12.2 as a; @@ -655,7 +655,7 @@ f show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `f` varbinary(24) default NULL + `f` varbinary(12) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT y from t2 UNION select da from t2; @@ -1381,4 +1381,12 @@ a SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test; ERROR 42S22: Unknown column 'c' in 'order clause' DROP TABLE t1; +(select 1 into @var) union (select 1); +ERROR HY000: Incorrect usage of UNION and INTO +(select 1) union (select 1 into @var); +select @var; +@var +1 +(select 2) union (select 1 into @var); +ERROR 42000: Result consisted of more than one row End of 5.0 tests diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index dc87f97b322..71d743f37b9 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2395,6 +2395,16 @@ Table Op Msg_type Msg_text test.v1 optimize error 'test.v1' is not BASE TABLE Warnings: Error 1347 'test.v1' is not BASE TABLE +ANALYZE TABLE v1; +Table Op Msg_type Msg_text +test.v1 analyze error 'test.v1' is not BASE TABLE +Warnings: +Error 1347 'test.v1' is not BASE TABLE +REPAIR TABLE v1; +Table Op Msg_type Msg_text +test.v1 repair error 'test.v1' is not BASE TABLE +Warnings: +Error 1347 'test.v1' is not BASE TABLE DROP VIEW v1; create definer = current_user() sql security invoker view v1 as select 1; show create view v1; diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index 45cf5076fe1..6fec52896c9 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -773,4 +773,25 @@ DROP DATABASE mysqltest_db1; DROP DATABASE mysqltest_db2; DROP USER mysqltest_u1@localhost; DROP USER mysqltest_u2@localhost; +CREATE DATABASE db26813; +USE db26813; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE VIEW v1 AS SELECT f1 FROM t1; +CREATE VIEW v2 AS SELECT f1 FROM t1; +CREATE VIEW v3 AS SELECT f1 FROM t1; +CREATE USER u26813@localhost; +GRANT DROP ON db26813.v1 TO u26813@localhost; +GRANT CREATE VIEW ON db26813.v2 TO u26813@localhost; +GRANT DROP, CREATE VIEW ON db26813.v3 TO u26813@localhost; +GRANT SELECT ON db26813.t1 TO u26813@localhost; +ALTER VIEW v1 AS SELECT f2 FROM t1; +ERROR 42000: CREATE VIEW command denied to user 'u26813'@'localhost' for table 'v1' +ALTER VIEW v2 AS SELECT f2 FROM t1; +ERROR 42000: DROP command denied to user 'u26813'@'localhost' for table 'v2' +ALTER VIEW v3 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v3; +View Create View +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1` +DROP USER u26813@localhost; +DROP DATABASE db26813; End of 5.0 tests. diff --git a/mysql-test/suite/row_lock/include/row_lock.inc b/mysql-test/suite/row_lock/include/row_lock.inc new file mode 100644 index 00000000000..8572bc0246e --- /dev/null +++ b/mysql-test/suite/row_lock/include/row_lock.inc @@ -0,0 +1,83 @@ +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings +SET autocommit=0; +# Create additional connections used through test +CONNECT (root1, localhost, root,,); +SET autocommit=0; +--echo connection default; +CONNECTION default; +eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +eval $indext1; +eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +eval $indext2; +COMMIT; +SELECT @@global.tx_isolation; + +# Both transaction are able to update the tables +eval EXPLAIN $select; +eval $select; + +--echo connection root1; +CONNECTION root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +COMMIT; + +--echo connection root1; +CONNECTION root1; +ROLLBACK; + +--echo connection default; +CONNECTION default; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +DISCONNECT root1; +--echo connection default; +CONNECTION default; +DROP TABLE t1, t2; + diff --git a/mysql-test/suite/row_lock/include/row_lock_big_tab.inc b/mysql-test/suite/row_lock/include/row_lock_big_tab.inc new file mode 100644 index 00000000000..f0823067eac --- /dev/null +++ b/mysql-test/suite/row_lock/include/row_lock_big_tab.inc @@ -0,0 +1,94 @@ +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +--enable_warnings +SET autocommit=0; +# Create additional connections used through test +CONNECT (root1, localhost, root,,); +SET autocommit=0; +--echo connection default; +CONNECTION default; +eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +eval $indext1; +eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +eval $indext2; +DELIMITER |; +CREATE PROCEDURE fill_t1 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO + INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100); + SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t1() RETURNS int +BEGIN + DECLARE res int DEFAULT 0; + SELECT count(*)/2 INTO res FROM t1; + RETURN res; +END; +| +CREATE PROCEDURE fill_t2 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO + INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100); + SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t2() RETURNS int +BEGIN + DECLARE res int DEFAULT 0; + SELECT count(*)/2 INTO res FROM t2; + RETURN res; +END; +| +DELIMITER ;| +CALL fill_t1 (10); +CALL fill_t2 (10); +COMMIT; +SELECT @@global.tx_isolation; +# With the two separate selects (without join) the differs from +# that select with join. + +# Both transaction are able to update the tables +eval EXPLAIN $select; +eval $select; + +--echo connection root1; +CONNECTION root1; +SELECT k from t1 WHERE k < half_t1(); +SELECT k from t1 WHERE k >= half_t1(); +UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k < half_t1() AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k >= half_t1() AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +COMMIT; + +--echo connection root1; +CONNECTION root1; +ROLLBACK; + +--echo connection default; +CONNECTION default; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +DISCONNECT root1; +--echo connection default; +CONNECTION default; +DROP VIEW IF EXISTS v1; +DROP TABLE t1, t2; +#DROP VIEW v1; + diff --git a/mysql-test/suite/row_lock/include/row_lock_big_tab_1.inc b/mysql-test/suite/row_lock/include/row_lock_big_tab_1.inc new file mode 100644 index 00000000000..8535c016819 --- /dev/null +++ b/mysql-test/suite/row_lock/include/row_lock_big_tab_1.inc @@ -0,0 +1,93 @@ +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +--enable_warnings +SET autocommit=0; +# Create additional connections used through test +CONNECT (root1, localhost, root,,); +SET autocommit=0; +--echo connection default; +CONNECTION default; +eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +eval $indext1; +eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +eval $indext2; +DELIMITER |; +CREATE PROCEDURE fill_t1 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO + INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100); + SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t1() RETURNS int +BEGIN + DECLARE res int DEFAULT 0; + SELECT MOD(k,2) INTO res FROM t1; + RETURN res; +END; +| +CREATE PROCEDURE fill_t2 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO + INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100); + SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t2() RETURNS int +BEGIN + DECLARE res int DEFAULT 0; + SELECT MOD(k,2) INTO res FROM t2; + RETURN res; +END; +| +DELIMITER ;| +eval CALL fill_t1 ($nbrows); +eval CALL fill_t2 ($nbrows); +COMMIT; +SELECT @@global.tx_isolation; +# With the two separate selects (without join) the differs from +# that select with join. + +# Both transaction are able to update the tables +eval EXPLAIN $select; +eval $select; + +--echo connection root1; +CONNECTION root1; +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 1 AND t1.k = t2.k LOCK IN SHARE MODE; +UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k % 2 = 1 AND t1.k = t2.k; +SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k; +SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k % 2 = 0 AND t1.k = t2.k; +SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k; +SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k; + +COMMIT; + +--echo connection root1; +CONNECTION root1; +ROLLBACK; + +--echo connection default; +CONNECTION default; +SELECT * FROM t1 WHERE k < 40 ORDER BY t1.k; +SELECT * FROM t2 WHERE k < 40 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +SELECT * FROM t1 WHERE k < 40 ORDER BY t1.k; +SELECT * FROM t2 WHERE k < 40 ORDER BY t2.k; +DISCONNECT root1; +--echo connection default; +CONNECTION default; +DROP TABLE t1, t2; + + diff --git a/mysql-test/suite/row_lock/include/row_lock_big_tab_2.inc b/mysql-test/suite/row_lock/include/row_lock_big_tab_2.inc new file mode 100644 index 00000000000..050f2a54016 --- /dev/null +++ b/mysql-test/suite/row_lock/include/row_lock_big_tab_2.inc @@ -0,0 +1,93 @@ +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +--enable_warnings +SET autocommit=0; +# Create additional connections used through test +CONNECT (root1, localhost, root,,); +SET autocommit=0; +--echo connection default; +CONNECTION default; +eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +eval $indext1; +eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +eval $indext2; +DELIMITER |; +CREATE PROCEDURE fill_t1 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO + INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100); + SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t1() RETURNS int +BEGIN + DECLARE res int DEFAULT 0; + SELECT MOD(k,2) INTO res FROM t1; + RETURN res; +END; +| +CREATE PROCEDURE fill_t2 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO + INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100); + SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t2() RETURNS int +BEGIN + DECLARE res int DEFAULT 0; + SELECT MOD(k,2) INTO res FROM t2; + RETURN res; +END; +| +DELIMITER ;| +eval CALL fill_t1 ($nbrows); +eval CALL fill_t2 ($nbrows); +COMMIT; +SELECT @@global.tx_isolation; +# With the two separate selects (without join) the differs from +# that select with join. + +# Both transaction are able to update the tables +eval EXPLAIN $select; +eval $select; + +--echo connection root1; +CONNECTION root1; +#SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 1 AND t1.k = t2.k FOR UPDATE; +DELETE FROM t1 WHERE t1.k % 2 = 1; +SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k; +SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k % 2 = 0 AND t1.k = t2.k; +SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k; +SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k; + +COMMIT; + +--echo connection root1; +CONNECTION root1; +ROLLBACK; + +--echo connection default; +CONNECTION default; +SELECT * FROM t1 WHERE k < 40 ORDER BY t1.k; +SELECT * FROM t2 WHERE k < 40 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +SELECT * FROM t1 WHERE k < 40 ORDER BY t1.k; +SELECT * FROM t2 WHERE k < 40 ORDER BY t2.k; +DISCONNECT root1; +--echo connection default; +CONNECTION default; +DROP TABLE t1, t2; + + diff --git a/mysql-test/suite/row_lock/include/row_lock_trig.inc b/mysql-test/suite/row_lock/include/row_lock_trig.inc new file mode 100644 index 00000000000..384f00f243e --- /dev/null +++ b/mysql-test/suite/row_lock/include/row_lock_trig.inc @@ -0,0 +1,96 @@ +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +--enable_warnings +SET autocommit=0; +# Create additional connections used through test +CONNECT (root1, localhost, root,,); +SET autocommit=0; +--echo connection default; +CONNECTION default; +eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +eval $indext1; +eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +eval $indext2; +DELIMITER |; + +CREATE TRIGGER trig_t2 AFTER UPDATE ON t2 + FOR EACH ROW BEGIN + UPDATE t1 SET l = NEW.i WHERE i = OLD.i; + END; +| + +DELIMITER ;| + +COMMIT; +SELECT @@global.tx_isolation; +# With the two separate selects (without join) the differs from +# that select with join. + +# Both transaction are able to update the tables +eval EXPLAIN $select; +eval $select; +--echo connection root1; +CONNECTION root1; +UPDATE t2 SET t2.i=225 WHERE t2.i=125; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +UPDATE t2 SET t2.i=223 WHERE t2.i=123; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +UPDATE t2 SET t2.i=226 WHERE t2.i=126; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +UPDATE t2 SET t2.i=224 WHERE t2.i=124; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +COMMIT; + +--echo connection root1; +CONNECTION root1; +ROLLBACK; + +--echo connection default; +CONNECTION default; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +DISCONNECT root1; +--echo connection default; +CONNECTION default; +DROP TABLE t1, t2; +#DROP VIEW v1; + diff --git a/mysql-test/suite/row_lock/include/row_lock_view.inc b/mysql-test/suite/row_lock/include/row_lock_view.inc new file mode 100644 index 00000000000..fbed8f64d3a --- /dev/null +++ b/mysql-test/suite/row_lock/include/row_lock_view.inc @@ -0,0 +1,89 @@ +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +--enable_warnings +SET autocommit=0; +# Create additional connections used through test +CONNECT (root1, localhost, root,,); +SET autocommit=0; +--echo connection default; +CONNECTION default; +eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +eval $indext1; +eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +eval $indext2; +CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2; +COMMIT; +SELECT @@global.tx_isolation; +# With the two separate selects (without join) the differs from +# that select with join. + +# Both transaction are able to update the tables +eval EXPLAIN $select; +eval $select; + +--echo connection root1; +CONNECTION root1; +UPDATE v1 SET i=325 where i=125; +SELECT * FROM v1 ORDER BY i,l; +SELECT * FROM t1 ORDER BY t1.k; + +--echo connection default; +CONNECTION default; +UPDATE v1 SET i=323 where i=123; +SELECT * FROM v1 ORDER BY i,l; +SELECT * FROM t1 ORDER BY t1.k; + +--echo connection root1; +CONNECTION root1; +UPDATE v1 SET i=326 where i=126; +SELECT * FROM v1 ORDER BY i,l; +SELECT * FROM t1 ORDER BY t1.k; + +--echo connection default; +CONNECTION default; +UPDATE v1 SET i=324 where i=124; +SELECT * FROM v1 ORDER BY i,l; +SELECT * FROM t1 ORDER BY t1.k; + +--echo connection root1; +CONNECTION root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +COMMIT; + +--echo connection root1; +CONNECTION root1; +ROLLBACK; + +--echo connection default; +CONNECTION default; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +DISCONNECT root1; +--echo connection default; +CONNECTION default; +DROP VIEW IF EXISTS v1; +DROP TABLE t1, t2; +#DROP VIEW v1; + diff --git a/mysql-test/suite/row_lock/include/row_lock_view_mix.inc b/mysql-test/suite/row_lock/include/row_lock_view_mix.inc new file mode 100644 index 00000000000..9e8cf3d34fc --- /dev/null +++ b/mysql-test/suite/row_lock/include/row_lock_view_mix.inc @@ -0,0 +1,92 @@ +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +--enable_warnings +SET autocommit=0; +# Create additional connections used through test +CONNECT (root1, localhost, root,,); +SET autocommit=0; +--echo connection default; +CONNECTION default; +eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +eval $indext1; +eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +eval $indext2; +CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2; +COMMIT; +SELECT @@global.tx_isolation; +# With the two separate selects (without join) the differs from +# that select with join. + +# Both transaction are able to update the tables +eval EXPLAIN $select; +eval $select; + +--echo connection root1; +CONNECTION root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +#UPDATE v1 SET i=325 where i=125; +#SELECT * FROM v1 ORDER BY i,l; +#SELECT * FROM t1 ORDER BY t1.k; + +--echo connection default; +CONNECTION default; +UPDATE v1 SET i=323 where i=123; +SELECT * FROM v1 ORDER BY i,l; +SELECT * FROM t1 ORDER BY t1.k; + +--echo connection root1; +CONNECTION root1; +UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +UPDATE v1 SET i=324 where i=124; +SELECT * FROM v1 ORDER BY i,l; +SELECT * FROM t1 ORDER BY t1.k; + +--echo connection root1; +CONNECTION root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +COMMIT; + +--echo connection root1; +CONNECTION root1; +ROLLBACK; + +--echo connection default; +CONNECTION default; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +DISCONNECT root1; +--echo connection default; +CONNECTION default; +DROP VIEW IF EXISTS v1; +DROP TABLE t1, t2; +#DROP VIEW v1; + diff --git a/mysql-test/suite/row_lock/include/row_lock_view_storedp.inc b/mysql-test/suite/row_lock/include/row_lock_view_storedp.inc new file mode 100644 index 00000000000..479392098be --- /dev/null +++ b/mysql-test/suite/row_lock/include/row_lock_view_storedp.inc @@ -0,0 +1,126 @@ +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +DROP PROCEDURE IF EXISTS stp_t; +--enable_warnings +SET autocommit=0; +# Create additional connections used through test +CONNECT (root1, localhost, root,,); +SET autocommit=0; +CONNECT (root2, localhost, root,,); +SET autocommit=0; +--echo connection default; +CONNECTION default; +eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +INSERT INTO t1 VALUES (5,127,5,127); +INSERT INTO t1 VALUES (6,128,6,128); +eval $indext1; +eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +INSERT INTO t2 VALUES (5,127,5,127); +INSERT INTO t2 VALUES (6,128,6,128); +eval $indext2; +CREATE VIEW v1 AS SELECT t1.i from t1; +DELIMITER |; + +CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA + BEGIN + UPDATE t2 SET i = p2 WHERE i = p1; + UPDATE v1 SET i = p2 WHERE i = p1; + SELECT * FROM v1 ORDER BY i; + SELECT * FROM t1 ORDER BY t1.k; + SELECT * FROM t2 ORDER BY t2.k; + END; +| + +DELIMITER ;| + +COMMIT; +SELECT @@global.tx_isolation; +eval EXPLAIN $select; +eval $select; +--echo connection root1; +CONNECTION root1; +CALL stp_t (125, 225); + +--echo connection root2; +CONNECTION root2; +CALL stp_t (127, 227); + +--echo connection default; +CONNECTION default; +CALL stp_t (123, 223); + +--echo connection root1; +CONNECTION root1; +CALL stp_t (126, 226); + +--echo connection root2; +CONNECTION root2; +CALL stp_t (128, 228); + +--echo connection default; +CONNECTION default; +CALL stp_t (124, 224); + +--echo connection root1; +CONNECTION root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root2; +CONNECTION root2; +DELETE FROM t1 WHERE t1.i=228; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +COMMIT; + +--echo connection root1; +CONNECTION root1; +ROLLBACK; + +--echo connection root1; +CONNECTION root1; +COMMIT; + +--echo connection default; +CONNECTION default; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +DISCONNECT root1; + +--echo connection root2; +CONNECTION root2; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +DISCONNECT root2; + +--echo connection default; +CONNECTION default; +--disable_warnings +DROP VIEW v1; +DROP PROCEDURE stp_t; +DROP TABLE t1, t2; +--enable_warnings diff --git a/mysql-test/suite/row_lock/include/row_lock_view_trig.inc b/mysql-test/suite/row_lock/include/row_lock_view_trig.inc new file mode 100644 index 00000000000..785eb1b66a9 --- /dev/null +++ b/mysql-test/suite/row_lock/include/row_lock_view_trig.inc @@ -0,0 +1,99 @@ +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +--enable_warnings +SET autocommit=0; +# Create additional connections used through test +CONNECT (root1, localhost, root,,); +SET autocommit=0; +--echo connection default; +CONNECTION default; +eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +eval $indext1; +eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +eval $indext2; +CREATE VIEW v1 AS SELECT t1.i from t1; +DELIMITER |; + +CREATE TRIGGER trig_t2 AFTER UPDATE ON t2 + FOR EACH ROW BEGIN + UPDATE v1 SET i = NEW.i WHERE i = OLD.i; + END; +| + +DELIMITER ;| + +COMMIT; +SELECT @@global.tx_isolation; +eval EXPLAIN $select; +eval $select; +--echo connection root1; +CONNECTION root1; +UPDATE t2 SET t2.i=225 WHERE t2.i=125; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +UPDATE t2 SET t2.i=223 WHERE t2.i=123; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +UPDATE t2 SET t2.i=226 WHERE t2.i=126; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +UPDATE t2 SET t2.i=224 WHERE t2.i=124; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection default; +CONNECTION default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +COMMIT; + +--echo connection root1; +CONNECTION root1; +ROLLBACK; + +--echo connection default; +CONNECTION default; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; + +--echo connection root1; +CONNECTION root1; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +DISCONNECT root1; +--echo connection default; +CONNECTION default; +DROP TABLE t1, t2; +DROP VIEW v1; + diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_1.result new file mode 100644 index 00000000000..54ed4350ba9 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_1.result @@ -0,0 +1,142 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index +1 SIMPLE t2 ref ixi ixi 5 test.t1.i 2 Using where; Using index +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +i i +123 123 +124 124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +connection default; +UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +COMMIT; +connection root1; +ROLLBACK; +connection default; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DROP TABLE t1, t2; +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_2.result new file mode 100644 index 00000000000..56154e64489 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_2.result @@ -0,0 +1,32 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t2 (i); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +i i +123 123 +124 124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_3.result b/mysql-test/suite/row_lock/r/innodb_row_lock_3.result new file mode 100644 index 00000000000..a89c55973d2 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_3.result @@ -0,0 +1,32 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t2 (i); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +i i +123 123 +124 124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_4.result b/mysql-test/suite/row_lock/r/innodb_row_lock_4.result new file mode 100644 index 00000000000..310d24a456a --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_4.result @@ -0,0 +1,142 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index +1 SIMPLE t2 ref ixi ixi 5 test.t1.i 2 Using where; Using index +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +i i +123 123 +124 124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +connection default; +UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +COMMIT; +connection root1; +ROLLBACK; +connection default; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DROP TABLE t1, t2; +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_5.result b/mysql-test/suite/row_lock/r/innodb_row_lock_5.result new file mode 100644 index 00000000000..ace5fddfad5 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_5.result @@ -0,0 +1,32 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where +SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +i i +123 123 +124 124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab.result b/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab.result new file mode 100644 index 00000000000..8f00c3a0bb7 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab.result @@ -0,0 +1,97 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +CREATE INDEX ixi ON t2 (i); +CREATE PROCEDURE fill_t1 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO +INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100); +SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t1() RETURNS int +BEGIN +DECLARE res int DEFAULT 0; +SELECT count(*)/2 INTO res FROM t1; +RETURN res; +END; +| +CREATE PROCEDURE fill_t2 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO +INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100); +SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t2() RETURNS int +BEGIN +DECLARE res int DEFAULT 0; +SELECT count(*)/2 INTO res FROM t2; +RETURN res; +END; +| +CALL fill_t1 (10); +CALL fill_t2 (10); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index ixi ixi 5 NULL 10 Using where; Using index +1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where; Using index +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE; +i i +connection root1; +SELECT k from t1 WHERE k < half_t1(); +k +0 +1 +2 +3 +4 +SELECT k from t1 WHERE k >= half_t1(); +k +5 +6 +7 +8 +9 +UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k < half_t1() AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +0 1111 0 100 +1 1111 1 101 +2 1111 2 102 +3 1111 3 103 +4 1111 4 104 +5 105 5 105 +6 106 6 106 +7 107 7 107 +8 108 8 108 +9 109 9 109 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +0 2222 0 100 +1 2222 1 101 +2 2222 2 102 +3 2222 3 103 +4 2222 4 104 +5 105 5 105 +6 106 6 106 +7 107 7 107 +8 108 8 108 +9 109 9 109 +connection default; +UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k >= half_t1() AND t2.i=t1.i; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_1.result new file mode 100644 index 00000000000..0b12f149193 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_1.result @@ -0,0 +1,145 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +CREATE INDEX ixi ON t2 (i); +CREATE PROCEDURE fill_t1 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO +INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100); +SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t1() RETURNS int +BEGIN +DECLARE res int DEFAULT 0; +SELECT MOD(k,2) INTO res FROM t1; +RETURN res; +END; +| +CREATE PROCEDURE fill_t2 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO +INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100); +SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t2() RETURNS int +BEGIN +DECLARE res int DEFAULT 0; +SELECT MOD(k,2) INTO res FROM t2; +RETURN res; +END; +| +CALL fill_t1 (40); +CALL fill_t2 (40); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY ixi 5 NULL 40 Using where; Using index +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.k 1 +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE; +i i +100 100 +102 102 +104 104 +106 106 +108 108 +110 110 +112 112 +114 114 +116 116 +118 118 +120 120 +122 122 +124 124 +126 126 +128 128 +130 130 +132 132 +134 134 +136 136 +138 138 +connection root1; +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 1 AND t1.k = t2.k LOCK IN SHARE MODE; +i i +101 101 +103 103 +105 105 +107 107 +109 109 +111 111 +113 113 +115 115 +117 117 +119 119 +121 121 +123 123 +125 125 +127 127 +129 129 +131 131 +133 133 +135 135 +137 137 +139 139 +UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k % 2 = 1 AND t1.k = t2.k; +SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k; +k i j l +0 100 0 100 +1 1111 1 101 +2 102 2 102 +3 1111 3 103 +4 104 4 104 +5 1111 5 105 +6 106 6 106 +7 1111 7 107 +8 108 8 108 +9 1111 9 109 +10 110 10 110 +11 1111 11 111 +12 112 12 112 +13 1111 13 113 +14 114 14 114 +15 1111 15 115 +16 116 16 116 +17 1111 17 117 +18 118 18 118 +19 1111 19 119 +SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k; +k i j l +0 100 0 100 +1 2222 1 101 +2 102 2 102 +3 2222 3 103 +4 104 4 104 +5 2222 5 105 +6 106 6 106 +7 2222 7 107 +8 108 8 108 +9 2222 9 109 +10 110 10 110 +11 2222 11 111 +12 112 12 112 +13 2222 13 113 +14 114 14 114 +15 2222 15 115 +16 116 16 116 +17 2222 17 117 +18 118 18 118 +19 2222 19 119 +connection default; +UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k % 2 = 0 AND t1.k = t2.k; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_2.result new file mode 100644 index 00000000000..cc9f297f9fb --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_big_tab_2.result @@ -0,0 +1,113 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +CREATE INDEX ixi ON t2 (i); +CREATE PROCEDURE fill_t1 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO +INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100); +SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t1() RETURNS int +BEGIN +DECLARE res int DEFAULT 0; +SELECT MOD(k,2) INTO res FROM t1; +RETURN res; +END; +| +CREATE PROCEDURE fill_t2 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO +INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100); +SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t2() RETURNS int +BEGIN +DECLARE res int DEFAULT 0; +SELECT MOD(k,2) INTO res FROM t2; +RETURN res; +END; +| +CALL fill_t1 (40); +CALL fill_t2 (40); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY ixi 5 NULL 40 Using where; Using index +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.k 1 +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE; +i i +100 100 +102 102 +104 104 +106 106 +108 108 +110 110 +112 112 +114 114 +116 116 +118 118 +120 120 +122 122 +124 124 +126 126 +128 128 +130 130 +132 132 +134 134 +136 136 +138 138 +connection root1; +DELETE FROM t1 WHERE t1.k % 2 = 1; +SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k; +k i j l +0 100 0 100 +2 102 2 102 +4 104 4 104 +6 106 6 106 +8 108 8 108 +10 110 10 110 +12 112 12 112 +14 114 14 114 +16 116 16 116 +18 118 18 118 +SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k; +k i j l +0 100 0 100 +1 101 1 101 +2 102 2 102 +3 103 3 103 +4 104 4 104 +5 105 5 105 +6 106 6 106 +7 107 7 107 +8 108 8 108 +9 109 9 109 +10 110 10 110 +11 111 11 111 +12 112 12 112 +13 113 13 113 +14 114 14 114 +15 115 15 115 +16 116 16 116 +17 117 17 117 +18 118 18 118 +19 119 19 119 +connection default; +UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k % 2 = 0 AND t1.k = t2.k; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_trig_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_trig_1.result new file mode 100644 index 00000000000..dd43e5752e5 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_trig_1.result @@ -0,0 +1,151 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +CREATE TRIGGER trig_t2 AFTER UPDATE ON t2 +FOR EACH ROW BEGIN +UPDATE t1 SET l = NEW.i WHERE i = OLD.i; +END; +| +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index +SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +i +123 +124 +connection root1; +UPDATE t2 SET t2.i=225 WHERE t2.i=125; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 225 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +connection default; +UPDATE t2 SET t2.i=223 WHERE t2.i=123; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 223 +2 124 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +UPDATE t2 SET t2.i=226 WHERE t2.i=126; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 225 +4 126 4 226 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +UPDATE t2 SET t2.i=224 WHERE t2.i=124; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 223 +2 124 2 224 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 225 +4 126 4 226 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 223 +2 124 2 224 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +COMMIT; +connection root1; +ROLLBACK; +connection default; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 223 +2 124 2 224 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 223 +2 124 2 224 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DROP TABLE t1, t2; +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_trig_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_trig_2.result new file mode 100644 index 00000000000..cb3a5c692e9 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_trig_2.result @@ -0,0 +1,37 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t2 (i); +CREATE TRIGGER trig_t2 AFTER UPDATE ON t2 +FOR EACH ROW BEGIN +UPDATE t1 SET l = NEW.i WHERE i = OLD.i; +END; +| +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where +SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +i +123 +124 +connection root1; +UPDATE t2 SET t2.i=225 WHERE t2.i=125; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_1.result new file mode 100644 index 00000000000..834cb669833 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_1.result @@ -0,0 +1,34 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2; +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index +1 SIMPLE t2 ref ixi ixi 5 test.t1.i 2 Using where; Using index +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +i i +123 123 +124 124 +connection root1; +UPDATE v1 SET i=325 where i=125; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_2.result new file mode 100644 index 00000000000..440138d4cd1 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_2.result @@ -0,0 +1,40 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2; +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index +1 SIMPLE t2 index NULL PRIMARY 4 NULL 4 Using index +SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE; +i +123 +124 +123 +124 +123 +124 +123 +124 +connection root1; +UPDATE v1 SET i=325 where i=125; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_1.result new file mode 100644 index 00000000000..230873b67a0 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_1.result @@ -0,0 +1,48 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2; +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index +1 SIMPLE t2 ref ixi ixi 5 test.t1.i 2 Using where; Using index +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +i i +123 123 +124 124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +connection default; +UPDATE v1 SET i=323 where i=123; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_2.result new file mode 100644 index 00000000000..d792d573f8e --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_mix_2.result @@ -0,0 +1,40 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2; +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index +1 SIMPLE t2 index NULL PRIMARY 4 NULL 4 Using index +SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE; +i +123 +124 +123 +124 +123 +124 +123 +124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_1.result new file mode 100644 index 00000000000..77b9a4dd964 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_1.result @@ -0,0 +1,312 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +INSERT INTO t1 VALUES (5,127,5,127); +INSERT INTO t1 VALUES (6,128,6,128); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +INSERT INTO t2 VALUES (5,127,5,127); +INSERT INTO t2 VALUES (6,128,6,128); +CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i from t1; +CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA +BEGIN +UPDATE t2 SET i = p2 WHERE i = p1; +UPDATE v1 SET i = p2 WHERE i = p1; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +END; +| +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index ixi ixi 5 NULL 6 Using where; Using index +SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +i +123 +124 +connection root1; +CALL stp_t (125, 225); +i +123 +124 +126 +127 +128 +225 +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +connection root2; +CALL stp_t (127, 227); +i +123 +124 +125 +126 +128 +227 +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +6 128 6 128 +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +6 128 6 128 +connection default; +CALL stp_t (123, 223); +i +124 +125 +126 +127 +128 +223 +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +connection root1; +CALL stp_t (126, 226); +i +123 +124 +127 +128 +225 +226 +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +5 127 5 127 +6 128 6 128 +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +5 127 5 127 +6 128 6 128 +connection root2; +CALL stp_t (128, 228); +i +123 +124 +125 +126 +227 +228 +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +6 228 6 128 +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +6 228 6 128 +connection default; +CALL stp_t (124, 224); +i +125 +126 +127 +128 +223 +224 +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +5 127 5 127 +6 128 6 128 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +5 127 5 127 +6 128 6 128 +connection root2; +DELETE FROM t1 WHERE t1.i=228; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +6 228 6 128 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +COMMIT; +connection root1; +ROLLBACK; +connection root1; +COMMIT; +connection default; +SELECT * FROM v1 ORDER BY i; +i +125 +126 +127 +128 +223 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +connection root1; +SELECT * FROM v1 ORDER BY i; +i +125 +126 +127 +128 +223 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +connection root2; +SELECT * FROM v1 ORDER BY i; +i +123 +124 +125 +126 +227 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +6 228 6 128 +connection default; +DROP TABLE t1, t2; +DROP VIEW v1; +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_2.result new file mode 100644 index 00000000000..73d8a3f4bea --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_storedp_2.result @@ -0,0 +1,47 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +INSERT INTO t1 VALUES (5,127,5,127); +INSERT INTO t1 VALUES (6,128,6,128); +#CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +INSERT INTO t2 VALUES (5,127,5,127); +INSERT INTO t2 VALUES (6,128,6,128); +#CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i from t1; +CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA +BEGIN +UPDATE t2 SET i = p2 WHERE i = p1; +UPDATE v1 SET i = p2 WHERE i = p1; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +END; +| +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using where +SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +i +123 +124 +connection root1; +CALL stp_t (125, 225); diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_1.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_1.result new file mode 100644 index 00000000000..90383a9489f --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_1.result @@ -0,0 +1,183 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i from t1; +CREATE TRIGGER trig_t2 AFTER UPDATE ON t2 +FOR EACH ROW BEGIN +UPDATE v1 SET i = NEW.i WHERE i = OLD.i; +END; +| +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index +SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +i +123 +124 +connection root1; +UPDATE t2 SET t2.i=225 WHERE t2.i=125; +SELECT * FROM v1 ORDER BY i; +i +123 +124 +126 +225 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +connection default; +UPDATE t2 SET t2.i=223 WHERE t2.i=123; +SELECT * FROM v1 ORDER BY i; +i +124 +125 +126 +223 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +UPDATE t2 SET t2.i=226 WHERE t2.i=126; +SELECT * FROM v1 ORDER BY i; +i +123 +124 +225 +226 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +UPDATE t2 SET t2.i=224 WHERE t2.i=124; +SELECT * FROM v1 ORDER BY i; +i +125 +126 +223 +224 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +COMMIT; +connection root1; +ROLLBACK; +connection default; +SELECT * FROM v1 ORDER BY i; +i +125 +126 +223 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +SELECT * FROM v1 ORDER BY i; +i +125 +126 +223 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DROP TABLE t1, t2; +DROP VIEW v1; +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_2.result b/mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_2.result new file mode 100644 index 00000000000..55793558b21 --- /dev/null +++ b/mysql-test/suite/row_lock/r/innodb_row_lock_view_trig_2.result @@ -0,0 +1,38 @@ +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i from t1; +CREATE TRIGGER trig_t2 AFTER UPDATE ON t2 +FOR EACH ROW BEGIN +UPDATE v1 SET i = NEW.i WHERE i = OLD.i; +END; +| +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where +SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +i +123 +124 +connection root1; +UPDATE t2 SET t2.i=225 WHERE t2.i=125; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_1.result new file mode 100644 index 00000000000..248c7d5ea1f --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_1.result @@ -0,0 +1,139 @@ +DROP TABLE IF EXISTS t1, t2; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where +1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +i i +123 123 +124 124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +connection default; +UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +COMMIT; +connection root1; +ROLLBACK; +connection default; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DROP TABLE t1, t2; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_2.result new file mode 100644 index 00000000000..109d99dd036 --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_2.result @@ -0,0 +1,31 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t2 (i); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +i i +123 123 +124 124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_3.result b/mysql-test/suite/row_lock/r/ndb_row_lock_3.result new file mode 100644 index 00000000000..c936ea209ff --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_3.result @@ -0,0 +1,30 @@ +DROP TABLE IF EXISTS t1, t2; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t2 (i); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +i i +123 123 +124 124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_4.result b/mysql-test/suite/row_lock/r/ndb_row_lock_4.result new file mode 100644 index 00000000000..875c783bd81 --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_4.result @@ -0,0 +1,139 @@ +DROP TABLE IF EXISTS t1, t2; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where +1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +i i +123 123 +124 124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +connection default; +UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +COMMIT; +connection root1; +ROLLBACK; +connection default; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DROP TABLE t1, t2; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_5.result b/mysql-test/suite/row_lock/r/ndb_row_lock_5.result new file mode 100644 index 00000000000..0d94f8abf72 --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_5.result @@ -0,0 +1,30 @@ +DROP TABLE IF EXISTS t1, t2; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where +SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +i i +123 123 +124 124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab.result b/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab.result new file mode 100644 index 00000000000..94b67c63d94 --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab.result @@ -0,0 +1,177 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +CREATE INDEX ixi ON t2 (i); +CREATE PROCEDURE fill_t1 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO +INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100); +SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t1() RETURNS int +BEGIN +DECLARE res int DEFAULT 0; +SELECT count(*)/2 INTO res FROM t1; +RETURN res; +END; +| +CREATE PROCEDURE fill_t2 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO +INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100); +SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t2() RETURNS int +BEGIN +DECLARE res int DEFAULT 0; +SELECT count(*)/2 INTO res FROM t2; +RETURN res; +END; +| +CALL fill_t1 (10); +CALL fill_t2 (10); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where +1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE; +i i +connection root1; +SELECT k from t1 WHERE k < half_t1(); +k +0 +3 +1 +2 +4 +SELECT k from t1 WHERE k >= half_t1(); +k +6 +7 +9 +5 +8 +UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k < half_t1() AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +0 1111 0 100 +1 1111 1 101 +2 1111 2 102 +3 1111 3 103 +4 1111 4 104 +5 105 5 105 +6 106 6 106 +7 107 7 107 +8 108 8 108 +9 109 9 109 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +0 2222 0 100 +1 2222 1 101 +2 2222 2 102 +3 2222 3 103 +4 2222 4 104 +5 105 5 105 +6 106 6 106 +7 107 7 107 +8 108 8 108 +9 109 9 109 +connection default; +UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k >= half_t1() AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +0 100 0 100 +1 101 1 101 +2 102 2 102 +3 103 3 103 +4 104 4 104 +5 3333 5 105 +6 3333 6 106 +7 3333 7 107 +8 3333 8 108 +9 3333 9 109 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +0 100 0 100 +1 101 1 101 +2 102 2 102 +3 103 3 103 +4 104 4 104 +5 4444 5 105 +6 4444 6 106 +7 4444 7 107 +8 4444 8 108 +9 4444 9 109 +COMMIT; +connection root1; +ROLLBACK; +connection default; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +0 100 0 100 +1 101 1 101 +2 102 2 102 +3 103 3 103 +4 104 4 104 +5 3333 5 105 +6 3333 6 106 +7 3333 7 107 +8 3333 8 108 +9 3333 9 109 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +0 100 0 100 +1 101 1 101 +2 102 2 102 +3 103 3 103 +4 104 4 104 +5 4444 5 105 +6 4444 6 106 +7 4444 7 107 +8 4444 8 108 +9 4444 9 109 +connection root1; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +0 100 0 100 +1 101 1 101 +2 102 2 102 +3 103 3 103 +4 104 4 104 +5 3333 5 105 +6 3333 6 106 +7 3333 7 107 +8 3333 8 108 +9 3333 9 109 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +0 100 0 100 +1 101 1 101 +2 102 2 102 +3 103 3 103 +4 104 4 104 +5 4444 5 105 +6 4444 6 106 +7 4444 7 107 +8 4444 8 108 +9 4444 9 109 +connection default; +DROP VIEW IF EXISTS v1; +Warnings: +Note 1051 Unknown table 'test.v1' +DROP TABLE t1, t2; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_1.result new file mode 100644 index 00000000000..9803895e1a7 --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_1.result @@ -0,0 +1,357 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +CREATE INDEX ixi ON t2 (i); +CREATE PROCEDURE fill_t1 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO +INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100); +SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t1() RETURNS int +BEGIN +DECLARE res int DEFAULT 0; +SELECT MOD(k,2) INTO res FROM t1; +RETURN res; +END; +| +CREATE PROCEDURE fill_t2 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO +INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100); +SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t2() RETURNS int +BEGIN +DECLARE res int DEFAULT 0; +SELECT MOD(k,2) INTO res FROM t2; +RETURN res; +END; +| +CALL fill_t1 (200); +CALL fill_t2 (200); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 200 Using where +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.k 1 +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE; +i i +135 135 +119 119 +211 211 +184 184 +232 232 +105 105 +188 188 +216 216 +255 255 +154 154 +197 197 +279 279 +218 218 +127 127 +203 203 +281 281 +194 194 +161 161 +276 276 +122 122 +139 139 +183 183 +114 114 +247 247 +144 144 +148 148 +174 174 +267 267 +142 142 +168 168 +226 226 +258 258 +231 231 +146 146 +253 253 +189 189 +230 230 +290 290 +178 178 +158 158 +130 130 +214 214 +133 133 +229 229 +294 294 +295 295 +108 108 +112 112 +297 297 +151 151 +251 251 +270 270 +291 291 +159 159 +132 132 +121 121 +244 244 +272 272 +293 293 +186 186 +111 111 +166 166 +201 201 +175 175 +180 180 +209 209 +192 192 +246 246 +195 195 +107 107 +233 233 +239 239 +103 103 +109 109 +128 128 +266 266 +143 143 +160 160 +187 187 +243 243 +273 273 +259 259 +110 110 +176 176 +141 141 +170 170 +215 215 +191 191 +200 200 +271 271 +162 162 +260 260 +106 106 +150 150 +126 126 +147 147 +155 155 +193 193 +207 207 +287 287 +235 235 +252 252 +129 129 +205 205 +268 268 +278 278 +116 116 +137 137 +199 199 +217 217 +234 234 +190 190 +236 236 +257 257 +100 100 +210 210 +212 212 +264 264 +221 221 +241 241 +256 256 +262 262 +265 265 +269 269 +277 277 +173 173 +177 177 +208 208 +219 219 +285 285 +101 101 +164 164 +113 113 +125 125 +202 202 +140 140 +156 156 +282 282 +181 181 +206 206 +299 299 +102 102 +145 145 +227 227 +196 196 +138 138 +198 198 +204 204 +237 237 +171 171 +284 284 +263 263 +292 292 +104 104 +149 149 +250 250 +296 296 +228 228 +280 280 +242 242 +248 248 +185 185 +220 220 +245 245 +275 275 +118 118 +120 120 +152 152 +153 153 +157 157 +182 182 +179 179 +254 254 +288 288 +172 172 +283 283 +286 286 +115 115 +238 238 +289 289 +131 131 +223 223 +134 134 +136 136 +222 222 +225 225 +261 261 +274 274 +123 123 +163 163 +224 224 +117 117 +298 298 +169 169 +124 124 +167 167 +240 240 +249 249 +165 165 +213 213 +connection root1; +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 1 AND t1.k = t2.k LOCK IN SHARE MODE; +i i +209 209 +195 195 +107 107 +233 233 +239 239 +103 103 +109 109 +143 143 +187 187 +243 243 +273 273 +259 259 +141 141 +215 215 +191 191 +271 271 +147 147 +155 155 +193 193 +207 207 +287 287 +235 235 +129 129 +205 205 +137 137 +199 199 +217 217 +257 257 +221 221 +241 241 +265 265 +269 269 +277 277 +173 173 +177 177 +135 135 +119 119 +211 211 +105 105 +255 255 +197 197 +279 279 +127 127 +203 203 +281 281 +161 161 +139 139 +183 183 +247 247 +267 267 +231 231 +253 253 +189 189 +133 133 +229 229 +295 295 +297 297 +151 151 +251 251 +291 291 +159 159 +121 121 +293 293 +111 111 +201 201 +175 175 +185 185 +245 245 +275 275 +153 153 +157 157 +179 179 +283 283 +115 115 +289 289 +131 131 +223 223 +225 225 +261 261 +123 123 +163 163 +117 117 +169 169 +167 167 +249 249 +165 165 +213 213 +219 219 +285 285 +101 101 +113 113 +125 125 +181 181 +299 299 +145 145 +227 227 +237 237 +171 171 +263 263 +149 149 +UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k % 2 = 1 AND t1.k = t2.k; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_2.result new file mode 100644 index 00000000000..adb89b03480 --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_big_tab_2.result @@ -0,0 +1,255 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +CREATE INDEX ixi ON t2 (i); +CREATE PROCEDURE fill_t1 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO +INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100); +SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t1() RETURNS int +BEGIN +DECLARE res int DEFAULT 0; +SELECT MOD(k,2) INTO res FROM t1; +RETURN res; +END; +| +CREATE PROCEDURE fill_t2 (IN upb int) +BEGIN +DECLARE cnt int DEFAULT 0; +WHILE cnt < upb DO +INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100); +SET cnt= cnt+1; +END WHILE; +END; +| +CREATE FUNCTION half_t2() RETURNS int +BEGIN +DECLARE res int DEFAULT 0; +SELECT MOD(k,2) INTO res FROM t2; +RETURN res; +END; +| +CALL fill_t1 (200); +CALL fill_t2 (200); +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 200 Using where +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.k 1 +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE; +i i +135 135 +119 119 +211 211 +184 184 +232 232 +105 105 +188 188 +216 216 +255 255 +154 154 +197 197 +279 279 +218 218 +127 127 +203 203 +281 281 +194 194 +161 161 +276 276 +122 122 +139 139 +183 183 +114 114 +247 247 +144 144 +148 148 +174 174 +267 267 +142 142 +168 168 +226 226 +258 258 +231 231 +146 146 +253 253 +189 189 +230 230 +290 290 +178 178 +158 158 +130 130 +214 214 +133 133 +229 229 +294 294 +295 295 +108 108 +112 112 +297 297 +151 151 +251 251 +270 270 +291 291 +159 159 +132 132 +121 121 +244 244 +272 272 +293 293 +186 186 +111 111 +166 166 +201 201 +175 175 +180 180 +209 209 +192 192 +246 246 +195 195 +107 107 +233 233 +239 239 +103 103 +109 109 +128 128 +266 266 +143 143 +160 160 +187 187 +243 243 +273 273 +259 259 +110 110 +176 176 +141 141 +170 170 +215 215 +191 191 +200 200 +271 271 +162 162 +260 260 +106 106 +150 150 +126 126 +147 147 +155 155 +193 193 +207 207 +287 287 +235 235 +252 252 +129 129 +205 205 +268 268 +278 278 +116 116 +137 137 +199 199 +217 217 +234 234 +190 190 +236 236 +257 257 +100 100 +210 210 +212 212 +264 264 +221 221 +241 241 +256 256 +262 262 +265 265 +269 269 +277 277 +173 173 +177 177 +208 208 +219 219 +285 285 +101 101 +164 164 +113 113 +125 125 +202 202 +140 140 +156 156 +282 282 +181 181 +206 206 +299 299 +102 102 +145 145 +227 227 +196 196 +138 138 +198 198 +204 204 +237 237 +171 171 +284 284 +263 263 +292 292 +104 104 +149 149 +250 250 +296 296 +228 228 +280 280 +242 242 +248 248 +185 185 +220 220 +245 245 +275 275 +118 118 +120 120 +152 152 +153 153 +157 157 +182 182 +179 179 +254 254 +288 288 +172 172 +283 283 +286 286 +115 115 +238 238 +289 289 +131 131 +223 223 +134 134 +136 136 +222 222 +225 225 +261 261 +274 274 +123 123 +163 163 +224 224 +117 117 +298 298 +169 169 +124 124 +167 167 +240 240 +249 249 +165 165 +213 213 +connection root1; +DELETE FROM t1 WHERE t1.k % 2 = 1; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_trig_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_trig_1.result new file mode 100644 index 00000000000..eb69fd2e306 --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_trig_1.result @@ -0,0 +1,148 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +CREATE TRIGGER trig_t2 AFTER UPDATE ON t2 +FOR EACH ROW BEGIN +UPDATE t1 SET l = NEW.i WHERE i = OLD.i; +END; +| +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where +SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +i +123 +124 +connection root1; +UPDATE t2 SET t2.i=225 WHERE t2.i=125; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 225 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +connection default; +UPDATE t2 SET t2.i=223 WHERE t2.i=123; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 223 +2 124 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +UPDATE t2 SET t2.i=226 WHERE t2.i=126; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 225 +4 126 4 226 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +UPDATE t2 SET t2.i=224 WHERE t2.i=124; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 223 +2 124 2 224 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 225 +4 126 4 226 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 223 +2 124 2 224 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +COMMIT; +connection root1; +ROLLBACK; +connection default; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 223 +2 124 2 224 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 223 +2 124 2 224 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DROP TABLE t1, t2; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_trig_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_trig_2.result new file mode 100644 index 00000000000..bedb75da93a --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_trig_2.result @@ -0,0 +1,35 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t2 (i); +CREATE TRIGGER trig_t2 AFTER UPDATE ON t2 +FOR EACH ROW BEGIN +UPDATE t1 SET l = NEW.i WHERE i = OLD.i; +END; +| +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where +SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +i +123 +124 +connection root1; +UPDATE t2 SET t2.i=225 WHERE t2.i=125; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_1.result new file mode 100644 index 00000000000..279f2626c73 --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_1.result @@ -0,0 +1,194 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2; +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where +1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +i i +123 123 +124 124 +connection root1; +UPDATE v1 SET i=325 where i=125; +SELECT * FROM v1 ORDER BY i,l; +i l +123 123 +123 124 +123 125 +123 126 +124 123 +124 124 +124 125 +124 126 +126 123 +126 124 +126 125 +126 126 +325 123 +325 124 +325 125 +325 126 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 325 3 125 +4 126 4 126 +connection default; +UPDATE v1 SET i=323 where i=123; +SELECT * FROM v1 ORDER BY i,l; +i l +124 123 +124 124 +124 125 +124 126 +125 123 +125 124 +125 125 +125 126 +126 123 +126 124 +126 125 +126 126 +323 123 +323 124 +323 125 +323 126 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +UPDATE v1 SET i=326 where i=126; +SELECT * FROM v1 ORDER BY i,l; +i l +123 123 +123 124 +123 125 +123 126 +124 123 +124 124 +124 125 +124 126 +325 123 +325 124 +325 125 +325 126 +326 123 +326 124 +326 125 +326 126 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 325 3 125 +4 326 4 126 +connection default; +UPDATE v1 SET i=324 where i=124; +SELECT * FROM v1 ORDER BY i,l; +i l +125 123 +125 124 +125 125 +125 126 +126 123 +126 124 +126 125 +126 126 +323 123 +323 124 +323 125 +323 126 +324 123 +324 124 +324 125 +324 126 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 324 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 325 3 125 +4 326 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 324 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +COMMIT; +connection root1; +ROLLBACK; +connection default; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 324 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 324 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DROP VIEW IF EXISTS v1; +DROP TABLE t1, t2; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_2.result new file mode 100644 index 00000000000..9e74e93b0cc --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_2.result @@ -0,0 +1,200 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2; +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 +SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE; +i +123 +124 +123 +124 +123 +124 +123 +124 +connection root1; +UPDATE v1 SET i=325 where i=125; +SELECT * FROM v1 ORDER BY i,l; +i l +123 123 +123 124 +123 125 +123 126 +124 123 +124 124 +124 125 +124 126 +126 123 +126 124 +126 125 +126 126 +325 123 +325 124 +325 125 +325 126 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 325 3 125 +4 126 4 126 +connection default; +UPDATE v1 SET i=323 where i=123; +SELECT * FROM v1 ORDER BY i,l; +i l +124 123 +124 124 +124 125 +124 126 +125 123 +125 124 +125 125 +125 126 +126 123 +126 124 +126 125 +126 126 +323 123 +323 124 +323 125 +323 126 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +UPDATE v1 SET i=326 where i=126; +SELECT * FROM v1 ORDER BY i,l; +i l +123 123 +123 124 +123 125 +123 126 +124 123 +124 124 +124 125 +124 126 +325 123 +325 124 +325 125 +325 126 +326 123 +326 124 +326 125 +326 126 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 325 3 125 +4 326 4 126 +connection default; +UPDATE v1 SET i=324 where i=124; +SELECT * FROM v1 ORDER BY i,l; +i l +125 123 +125 124 +125 125 +125 126 +126 123 +126 124 +126 125 +126 126 +323 123 +323 124 +323 125 +323 126 +324 123 +324 124 +324 125 +324 126 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 324 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 325 3 125 +4 326 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 324 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +COMMIT; +connection root1; +ROLLBACK; +connection default; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 324 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 324 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DROP VIEW IF EXISTS v1; +DROP TABLE t1, t2; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_1.result new file mode 100644 index 00000000000..b5b1c519702 --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_1.result @@ -0,0 +1,169 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2; +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where +1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where +SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +i i +123 123 +124 124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +connection default; +UPDATE v1 SET i=323 where i=123; +SELECT * FROM v1 ORDER BY i,l; +i l +124 123 +124 124 +124 125 +124 126 +125 123 +125 124 +125 125 +125 126 +126 123 +126 124 +126 125 +126 126 +323 123 +323 124 +323 125 +323 126 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +UPDATE v1 SET i=324 where i=124; +SELECT * FROM v1 ORDER BY i,l; +i l +125 123 +125 124 +125 125 +125 126 +126 123 +126 124 +126 125 +126 126 +323 123 +323 124 +323 125 +323 126 +324 123 +324 124 +324 125 +324 126 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 324 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 324 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +COMMIT; +connection root1; +ROLLBACK; +connection default; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 324 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 323 1 123 +2 324 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DROP VIEW IF EXISTS v1; +DROP TABLE t1, t2; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_2.result new file mode 100644 index 00000000000..d92f9ad9664 --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_mix_2.result @@ -0,0 +1,38 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2; +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 +SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE; +i +123 +124 +123 +124 +123 +124 +123 +124 +connection root1; +UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_1.result new file mode 100644 index 00000000000..e2a2a6e7deb --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_1.result @@ -0,0 +1,309 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +DROP PROCEDURE IF EXISTS stp_t; +SET autocommit=0; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +INSERT INTO t1 VALUES (5,127,5,127); +INSERT INTO t1 VALUES (6,128,6,128); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +INSERT INTO t2 VALUES (5,127,5,127); +INSERT INTO t2 VALUES (6,128,6,128); +CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i from t1; +CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA +BEGIN +UPDATE t2 SET i = p2 WHERE i = p1; +UPDATE v1 SET i = p2 WHERE i = p1; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +END; +| +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where +SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +i +123 +124 +connection root1; +CALL stp_t (125, 225); +i +123 +124 +126 +127 +128 +225 +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +connection root2; +CALL stp_t (127, 227); +i +123 +124 +125 +126 +128 +227 +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +6 128 6 128 +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +6 128 6 128 +connection default; +CALL stp_t (123, 223); +i +124 +125 +126 +127 +128 +223 +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +connection root1; +CALL stp_t (126, 226); +i +123 +124 +127 +128 +225 +226 +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +5 127 5 127 +6 128 6 128 +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +5 127 5 127 +6 128 6 128 +connection root2; +CALL stp_t (128, 228); +i +123 +124 +125 +126 +227 +228 +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +6 228 6 128 +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +6 228 6 128 +connection default; +CALL stp_t (124, 224); +i +125 +126 +127 +128 +223 +224 +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +5 127 5 127 +6 128 6 128 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +5 127 5 127 +6 128 6 128 +connection root2; +DELETE FROM t1 WHERE t1.i=228; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +6 228 6 128 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +COMMIT; +connection root1; +ROLLBACK; +connection root1; +COMMIT; +connection default; +SELECT * FROM v1 ORDER BY i; +i +125 +126 +127 +128 +223 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +connection root1; +SELECT * FROM v1 ORDER BY i; +i +125 +126 +127 +128 +223 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +5 127 5 127 +6 128 6 128 +connection root2; +SELECT * FROM v1 ORDER BY i; +i +125 +126 +223 +227 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +5 227 5 127 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +5 227 5 127 +6 228 6 128 +connection default; +DROP VIEW v1; +DROP PROCEDURE stp_t; +DROP TABLE t1, t2; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_2.result new file mode 100644 index 00000000000..6dbd5f834ed --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_storedp_2.result @@ -0,0 +1,46 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +DROP PROCEDURE IF EXISTS stp_t; +SET autocommit=0; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +INSERT INTO t1 VALUES (5,127,5,127); +INSERT INTO t1 VALUES (6,128,6,128); +#CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +INSERT INTO t2 VALUES (5,127,5,127); +INSERT INTO t2 VALUES (6,128,6,128); +#CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i from t1; +CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA +BEGIN +UPDATE t2 SET i = p2 WHERE i = p1; +UPDATE v1 SET i = p2 WHERE i = p1; +SELECT * FROM v1 ORDER BY i; +SELECT * FROM t1 ORDER BY t1.k; +SELECT * FROM t2 ORDER BY t2.k; +END; +| +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using where +SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +i +123 +124 +connection root1; +CALL stp_t (125, 225); diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_1.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_1.result new file mode 100644 index 00000000000..f5c745ca41c --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_1.result @@ -0,0 +1,180 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i from t1; +CREATE TRIGGER trig_t2 AFTER UPDATE ON t2 +FOR EACH ROW BEGIN +UPDATE v1 SET i = NEW.i WHERE i = OLD.i; +END; +| +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where +SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +i +123 +124 +connection root1; +UPDATE t2 SET t2.i=225 WHERE t2.i=125; +SELECT * FROM v1 ORDER BY i; +i +123 +124 +126 +225 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 126 4 126 +connection default; +UPDATE t2 SET t2.i=223 WHERE t2.i=123; +SELECT * FROM v1 ORDER BY i; +i +124 +125 +126 +223 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 124 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +UPDATE t2 SET t2.i=226 WHERE t2.i=126; +SELECT * FROM v1 ORDER BY i; +i +123 +124 +225 +226 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +UPDATE t2 SET t2.i=224 WHERE t2.i=124; +SELECT * FROM v1 ORDER BY i; +i +125 +126 +223 +224 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +DELETE FROM t1 WHERE t1.i=226; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 123 1 123 +2 124 2 124 +3 225 3 125 +4 226 4 126 +connection default; +DELETE FROM t1 WHERE t1.i=224; +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +COMMIT; +connection root1; +ROLLBACK; +connection default; +SELECT * FROM v1 ORDER BY i; +i +125 +126 +223 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection root1; +SELECT * FROM v1 ORDER BY i; +i +125 +126 +223 +SELECT * FROM t1 ORDER BY t1.k; +k i j l +1 223 1 123 +3 125 3 125 +4 126 4 126 +SELECT * FROM t2 ORDER BY t2.k; +k i j l +1 223 1 123 +2 224 2 124 +3 125 3 125 +4 126 4 126 +connection default; +DROP TABLE t1, t2; +DROP VIEW v1; diff --git a/mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_2.result b/mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_2.result new file mode 100644 index 00000000000..d6a38753c1d --- /dev/null +++ b/mysql-test/suite/row_lock/r/ndb_row_lock_view_trig_2.result @@ -0,0 +1,36 @@ +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +SET autocommit=0; +SET autocommit=0; +connection default; +CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t1 VALUES (1,123,1,123); +INSERT INTO t1 VALUES (2,124,2,124); +INSERT INTO t1 VALUES (3,125,3,125); +INSERT INTO t1 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t1 (i); +CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB; +INSERT INTO t2 VALUES (1,123,1,123); +INSERT INTO t2 VALUES (2,124,2,124); +INSERT INTO t2 VALUES (3,125,3,125); +INSERT INTO t2 VALUES (4,126,4,126); +#CREATE INDEX ixi ON t2 (i); +CREATE VIEW v1 AS SELECT t1.i from t1; +CREATE TRIGGER trig_t2 AFTER UPDATE ON t2 +FOR EACH ROW BEGIN +UPDATE v1 SET i = NEW.i WHERE i = OLD.i; +END; +| +COMMIT; +SELECT @@global.tx_isolation; +@@global.tx_isolation +REPEATABLE-READ +EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where +SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +i +123 +124 +connection root1; +UPDATE t2 SET t2.i=225 WHERE t2.i=125; diff --git a/mysql-test/suite/row_lock/readme.txt b/mysql-test/suite/row_lock/readme.txt new file mode 100644 index 00000000000..b43f04ecda4 --- /dev/null +++ b/mysql-test/suite/row_lock/readme.txt @@ -0,0 +1,9 @@ +All row lock test with InnoDB have to be executed with the options + +--innodb_lock_wait_timeout=1 +--innodb_locks_unsafe_for_binlog + +for example + +perl mysql-test-run.pl --mysqld=--innodb_lock_wait_timeout=2 --mysqld=--innodb_locks_unsafe_for_binlog --suite=row_lock innodb_row_lock_2 + diff --git a/mysql-test/suite/row_lock/summary_of_sel_test.txt b/mysql-test/suite/row_lock/summary_of_sel_test.txt new file mode 100644 index 00000000000..0fa332e957a --- /dev/null +++ b/mysql-test/suite/row_lock/summary_of_sel_test.txt @@ -0,0 +1,36 @@ +Test plan: +Create 2 tables with a primary key and 3 integer columns. Both get the same rows (1,123,1,123),(2,124,2,124),(3,125,3,125),(4,126,4,126). The second and third column may get an index to have cases with, without and mutilple index. Create views on the tables. Create an update trigger. Create a stored procedure updating the table. Create a stored function updating the table and deliver the key as result. + +The test isself consists of 2 sessions (transactions) running in "parallel" (same user "root") accessing and locking the same tables on basis of a row lock. Expected is that both sessions(transactions) can update the table successfully. + +First session +execute an explain to every select and one of the following selects on the first half of table t1: +- select <non index columns> ... where ... for update; +- select <non index columns> ... where ... lock in share mode; +- select <indexed columns> ... where ... for update; +- select <indexed columns> ... where ... lock in share mode; +- select <indexed columns> ... ignore index ... where ... for update; +- select <indexed columns> ... ignore index ... where ... lock in share mode; +- select ... where (select...) ... for update; +- select ... where (select...) ... lock in share mode; +- (select ... where) union (select ... where) for update; +- (select ... where) union (select ... where) lock in...; +- select <view> ... where ... for update; +- select <view> ... where ... lock in ...; +- select <join> ... where ... for update; +- select <join> ... where ... lock in ...; +Then executes +- update +- delete +- trigger accessing table t1 +- stored procedure accessing table t1 +- stored function accessing table t1 + +Second session +executes the same on the last half of table t1 + +call of mysqld with option +--innodb_locks_unsafe_for_binlog + +As the tests above work with small tables (<10 rows) there must be at least one test with a big table (>1000 rows) doing a table scan. + diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_1.test new file mode 100644 index 00000000000..e0440fe2669 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_1.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_2.test new file mode 100644 index 00000000000..5cb3ea9f2d9 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_2.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +let $indext1= #CREATE INDEX ixi ON t1 (i); +let $indext2= #CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_3.test b/mysql-test/suite/row_lock/t/innodb_row_lock_3.test new file mode 100644 index 00000000000..11f4dc423d6 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_3.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +let $indext1= #CREATE INDEX ixi ON t1 (i); +let $indext2= #CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_4.test b/mysql-test/suite/row_lock/t/innodb_row_lock_4.test new file mode 100644 index 00000000000..0a8ca9c13a0 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_4.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_5.test b/mysql-test/suite/row_lock/t/innodb_row_lock_5.test new file mode 100644 index 00000000000..7e411d31649 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_5.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab.test b/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab.test new file mode 100644 index 00000000000..0c5b8b41bd5 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_big_tab.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_1.test new file mode 100644 index 00000000000..a12a07d82a9 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_1.test @@ -0,0 +1,10 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $nbrows= 40; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_big_tab_1.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_2.test new file mode 100644 index 00000000000..49e834eb2ce --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_big_tab_2.test @@ -0,0 +1,10 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $nbrows= 40; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_big_tab_2.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_trig_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_trig_1.test new file mode 100644 index 00000000000..225513d3f87 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_trig_1.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_trig.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_trig_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_trig_2.test new file mode 100644 index 00000000000..88dee5f23f8 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_trig_2.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +let $indext1= #CREATE INDEX ixi ON t1 (i); +let $indext2= #CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_trig.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_1.test new file mode 100644 index 00000000000..d6381e1da5b --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_1.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_2.test new file mode 100644 index 00000000000..ee45e683669 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_2.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_1.test new file mode 100644 index 00000000000..49cba88dd23 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_1.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view_mix.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_2.test new file mode 100644 index 00000000000..b07f3a3378a --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_mix_2.test @@ -0,0 +1,10 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +#let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +let $select= SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view_mix.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_1.test new file mode 100644 index 00000000000..d507ff3296f --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_1.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view_storedp.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_2.test new file mode 100644 index 00000000000..a1bfb16055e --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_storedp_2.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +let $indext1= #CREATE INDEX ixi ON t1 (i); +let $indext2= #CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view_storedp.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_1.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_1.test new file mode 100644 index 00000000000..24c76532d17 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_1.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view_trig.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_2.test b/mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_2.test new file mode 100644 index 00000000000..a8a67d77979 --- /dev/null +++ b/mysql-test/suite/row_lock/t/innodb_row_lock_view_trig_2.test @@ -0,0 +1,9 @@ +--source include/have_innodb.inc +SELECT @@global.innodb_table_locks into @table_locks; +SET @@global.innodb_table_locks= OFF; +let $engine= InnoDB; +let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +let $indext1= #CREATE INDEX ixi ON t1 (i); +let $indext2= #CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view_trig.inc +SET @@global.innodb_table_locks= @table_locks; diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_1.test new file mode 100644 index 00000000000..6ac2e829008 --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_1.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_2.test new file mode 100644 index 00000000000..994ecba96b0 --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_2.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +let $indext1= #CREATE INDEX ixi ON t1 (i); +let $indext2= #CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_3.test b/mysql-test/suite/row_lock/t/ndb_row_lock_3.test new file mode 100644 index 00000000000..2de43c61c2a --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_3.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +let $indext1= #CREATE INDEX ixi ON t1 (i); +let $indext2= #CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_4.test b/mysql-test/suite/row_lock/t/ndb_row_lock_4.test new file mode 100644 index 00000000000..72b20488c74 --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_4.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_5.test b/mysql-test/suite/row_lock/t/ndb_row_lock_5.test new file mode 100644 index 00000000000..045f127a4ef --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_5.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab.test b/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab.test new file mode 100644 index 00000000000..bf2df104e03 --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_big_tab.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_1.test new file mode 100644 index 00000000000..4d32991d379 --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_1.test @@ -0,0 +1,7 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $nbrows= 200; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_big_tab_1.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_2.test new file mode 100644 index 00000000000..894a83fc1b0 --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_big_tab_2.test @@ -0,0 +1,7 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $nbrows= 200; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_big_tab_2.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_trig_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_trig_1.test new file mode 100644 index 00000000000..a5586a6101e --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_trig_1.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_trig.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_trig_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_trig_2.test new file mode 100644 index 00000000000..7af13697ccc --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_trig_2.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +let $indext1= #CREATE INDEX ixi ON t1 (i); +let $indext2= #CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_trig.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_1.test new file mode 100644 index 00000000000..a1aaf5ab441 --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_1.test @@ -0,0 +1,7 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view.inc + diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_2.test new file mode 100644 index 00000000000..b8feef693e7 --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_2.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_1.test new file mode 100644 index 00000000000..a97626048d3 --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_1.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view_mix.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_2.test new file mode 100644 index 00000000000..e7a9a715785 --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_mix_2.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view_mix.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_1.test new file mode 100644 index 00000000000..f57bcb3dd1b --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_1.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view_storedp.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_2.test new file mode 100644 index 00000000000..b0aaa38fb93 --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_storedp_2.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +let $indext1= #CREATE INDEX ixi ON t1 (i); +let $indext2= #CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view_storedp.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_1.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_1.test new file mode 100644 index 00000000000..9c4128d78bf --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_1.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +let $indext1= CREATE INDEX ixi ON t1 (i); +let $indext2= CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view_trig.inc diff --git a/mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_2.test b/mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_2.test new file mode 100644 index 00000000000..38c9472fb3d --- /dev/null +++ b/mysql-test/suite/row_lock/t/ndb_row_lock_view_trig_2.test @@ -0,0 +1,6 @@ +--source include/have_ndb.inc +let $engine= NDB; +let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE; +let $indext1= #CREATE INDEX ixi ON t1 (i); +let $indext2= #CREATE INDEX ixi ON t2 (i); +--source suite/row_lock/include/row_lock_view_trig.inc diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 01f55931ca4..307138added 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -613,3 +613,26 @@ create table t1 (t varchar(255) default null, key t (t(80))) engine=myisam default charset=latin1; alter table t1 change t t text; drop table t1; + +# +# Bug #26794: Adding an index with a prefix on a SPATIAL type breaks ALTER +# TABLE +# +CREATE TABLE t1 (a varchar(500)); + +ALTER TABLE t1 ADD b GEOMETRY NOT NULL, ADD SPATIAL INDEX(b); +SHOW CREATE TABLE t1; +ALTER TABLE t1 ADD KEY(b(50)); +SHOW CREATE TABLE t1; + +ALTER TABLE t1 ADD c POINT; +SHOW CREATE TABLE t1; + +--error ER_WRONG_SUB_KEY +CREATE TABLE t2 (a INT, KEY (a(20))); + +ALTER TABLE t1 ADD d INT; +--error ER_WRONG_SUB_KEY +ALTER TABLE t1 ADD KEY (d(20)); + +DROP TABLE t1; diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 80533f21311..0ffbfab3d4f 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1364,3 +1364,13 @@ SELECT * from t2; drop table t1, t2, t4; + +# +# BUG#26138 - REPAIR TABLE with option USE_FRM erases all records in ARCHIVE +# table +# +create table t1 (i int) engine=archive; +insert into t1 values (1); +repair table t1 use_frm; +select * from t1; +drop table t1; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 8e55bf62ba6..ba5f56e12b1 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -656,6 +656,7 @@ create table t1(a set("a,b","c,d") not null); # End of 4.1 tests + # # Bug #14155: Maximum value of MAX_ROWS handled incorrectly on 64-bit # platforms @@ -674,4 +675,4 @@ drop table t1; create table t1 (upgrade int); drop table t1; -# End of 5.0 tests +--echo End of 5.0 tests diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index 3e49b9de883..64349bc40a6 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -475,3 +475,13 @@ ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf8 collate utf8_turkish_ci; SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu FROM t1 ORDER BY id; DROP TABLE t1; + +# +# Bug #27079 Crash while grouping empty ucs2 strings +# +CREATE TABLE t1 ( + c1 text character set ucs2 collate ucs2_polish_ci NOT NULL +) ENGINE=MyISAM; +insert into t1 values (''),('a'); +SELECT COUNT(*), c1 FROM t1 GROUP BY c1; +DROP TABLE IF EXISTS t1; diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 5a3720dc431..c3320159c41 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -573,6 +573,20 @@ drop table t1; deallocate prepare stmt; # +# Bug#22638 SOUNDEX broken for international characters +# +set names latin1; +set character_set_connection=ucs2; +select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); +select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb')); +select 'mood' sounds like 'mud'; +# Cyrillic A, BE, VE +select hex(soundex(_ucs2 0x041004110412)); +# Make sure that "U+00BF INVERTED QUESTION MARK" is not considered as letter +select hex(soundex(_ucs2 0x00BF00C0)); +set names latin1; + +# # Bug #14290: character_maximum_length for text fields # create table t1(a blob, b text charset utf8, c text charset ucs2); diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 04b7ec78842..79b73fc7880 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -702,6 +702,14 @@ select * from t1 where soundex(a) = soundex('TEST'); select * from t1 where soundex(a) = soundex('test'); drop table t1; +# +# Bug#22638 SOUNDEX broken for international characters +# +select soundex(_utf8 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB); +select hex(soundex(_utf8 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)); +select soundex(_utf8 0xD091D092D093); +select hex(soundex(_utf8 0xD091D092D093)); + SET collation_connection='utf8_general_ci'; -- source include/ctype_filesort.inc diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 773927f6015..13615c8c269 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -242,3 +242,13 @@ INSERT DELAYED INTO t1 VALUES(1); FLUSH TABLE t1; SELECT HEX(a) FROM t1; DROP TABLE t1; + +# +# Bug#26464 - insert delayed + update + merge = corruption +# +CREATE TABLE t1(c1 INT) ENGINE=MyISAM; +CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1); +--error 1031 +INSERT DELAYED INTO t2 VALUES(1); +DROP TABLE t1, t2; + diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 306447dbd5a..36d627209db 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -203,3 +203,21 @@ select * from t1 where a is null; delete from t1 where a is null; select count(*) from t1; drop table t1; + +# +# Bug #26186: delete order by, sometimes accept unknown column +# +CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1); + +--error ER_BAD_FIELD_ERROR +DELETE FROM t1 ORDER BY x; + +# even columns from a table not used in query (and not even existing) +--error ER_BAD_FIELD_ERROR +DELETE FROM t1 ORDER BY t2.x; + +# subquery (as long as the subquery from is valid or DUAL) +--error ER_BAD_FIELD_ERROR +DELETE FROM t1 ORDER BY (SELECT x); + +DROP TABLE t1; diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 2116e9f51e0..df56165950f 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -12,4 +12,3 @@ ndb_load : Bug#17233 user_limits : Bug#23921 random failure of user_limits.test -ndb_single_user : Bug#27021 Error codes in mysqld in single user mode varies diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index 476e4ce7735..7310f98cd16 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -540,3 +540,16 @@ EXPLAIN SELECT a FROM t1 GROUP BY a; SELECT a FROM t1 GROUP BY a; DROP TABLE t1; + +# +#Bug #27659: SELECT DISTINCT returns incorrect result set when field is +#repeated +# +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES(1,1),(1,2),(1,3); +SELECT DISTINCT a, b FROM t1; +SELECT DISTINCT a, a, b FROM t1; +DROP TABLE t1; + +--echo End of 5.0 tests diff --git a/mysql-test/t/errors.test b/mysql-test/t/errors.test index f5647a293e8..4fbdcba635f 100644 --- a/mysql-test/t/errors.test +++ b/mysql-test/t/errors.test @@ -40,5 +40,17 @@ create table t1 (a int(256)); set sql_mode='traditional'; --error 1074 create table t1 (a varchar(66000)); +set sql_mode=default; + +# +# Bug #27513: mysql 5.0.x + NULL pointer DoS +# +CREATE TABLE t1 (a INT); +SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); +INSERT INTO t1 VALUES(1); +SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); +INSERT INTO t1 VALUES(2),(3); +SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); +DROP TABLE t1; # End of 5.0 tests diff --git a/mysql-test/t/flush2.test b/mysql-test/t/flush2.test index fc9e88e3141..7582ab8426b 100644 --- a/mysql-test/t/flush2.test +++ b/mysql-test/t/flush2.test @@ -3,7 +3,7 @@ # flush logs; set global expire_logs_days = 3; -show variables like 'log%'; +show variables like 'log_bin%'; flush logs; -show variables like 'log%'; +show variables like 'log_bin%'; set global expire_logs_days = 0; diff --git a/mysql-test/t/fulltext_left_join.test b/mysql-test/t/fulltext_left_join.test index 5942ce119ee..8c13ae5cad9 100644 --- a/mysql-test/t/fulltext_left_join.test +++ b/mysql-test/t/fulltext_left_join.test @@ -87,3 +87,14 @@ SELECT t1.*, MATCH(t1.name) AGAINST('string') AS relevance DROP TABLE t1,t2; # End of 4.1 tests + +# +# BUG#25729 - boolean full text search is confused by NULLs produced by LEFT +# JOIN +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT, c TEXT, KEY(b)); +INSERT INTO t1 VALUES(1); +INSERT INTO t2(b,c) VALUES(2,'castle'),(3,'castle'); +SELECT * FROM t1 LEFT JOIN t2 ON a=b WHERE MATCH(c) AGAINST('+castle' IN BOOLEAN MODE); +DROP TABLE t1, t2; diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 3ff4b35873b..0dd82864520 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -497,4 +497,14 @@ select f2,group_concat(f1) from t1 group by f2; --disable_metadata drop table t1; -# End of 4.1 tests +# +# Bug #26815: Unexpected built-in function behavior: group_concat(distinct +# substring_index()) +# +CREATE TABLE t1(a TEXT, b CHAR(20)); +INSERT INTO t1 VALUES ("one.1","one.1"),("two.2","two.2"),("one.3","one.3"); +SELECT GROUP_CONCAT(DISTINCT UCASE(a)) FROM t1; +SELECT GROUP_CONCAT(DISTINCT UCASE(b)) FROM t1; +DROP TABLE t1; + +--echo End of 5.0 tests diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index b102148472a..654bb8bb75d 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -794,6 +794,16 @@ drop table bug22555; # +# Bug #21976: Unnecessary warning with count(decimal) +# + +create table t1 (a decimal(20)); +insert into t1 values (12345678901234567890); +select count(a) from t1; +select count(distinct a) from t1; +drop table t1; + +# # Bug #23184: SELECT causes server crash # CREATE TABLE t1 (a INT, b INT); @@ -817,5 +827,4 @@ SELECT a,AVG(DISTINCT b) AS average FROM t1 GROUP BY a HAVING average > 50; DROP TABLE t1; -### --echo End of 5.0 tests diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index d42be70c057..0e4b404fe3a 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -1038,6 +1038,10 @@ INSERT INTO `t1` (`id`, `tire`) VALUES ('A', 0), ('B', 1),('C', 2); SELECT REPEAT( '#', tire ) AS A, REPEAT( '#', tire % 999 ) AS B, tire FROM `t1`; +SELECT REPEAT('0', CAST(0 AS UNSIGNED)); +SELECT REPEAT('0', -2); +SELECT REPEAT('0', 2); + DROP TABLE t1; # diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index b32764f1f62..ccc38db8dea 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -423,6 +423,14 @@ from t1; drop table t1; +# +# Bug #27164: Crash when mixing InnoDB and MyISAM Geospatial tables +# +CREATE TABLE t1(a POINT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1; +DROP TABLE t1; + --echo End of 4.1 tests # @@ -471,3 +479,82 @@ create table t1 (g geometry not null); insert into t1 values(default); drop table t1; +# +# Bug #27300: create view with geometry functions lost columns types +# +CREATE TABLE t1 (a GEOMETRY); +CREATE VIEW v1 AS SELECT GeomFromwkb(ASBINARY(a)) FROM t1; +CREATE VIEW v2 AS SELECT a FROM t1; +DESCRIBE v1; +DESCRIBE v2; + +DROP VIEW v1,v2; +DROP TABLE t1; + +# +# Bug#24563: MBROverlaps does not seem to function propertly +# Bug#54888: MBROverlaps missing in 5.1? +# + +# Test all MBR* functions and their non-MBR-prefixed aliases, +# using shifted squares to verify the spatial relations. + +create table t1 (name VARCHAR(100), square GEOMETRY); + +INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); + +INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); +INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); + +INSERT INTO t1 VALUES("up", GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))')); +INSERT INTO t1 VALUES("up2", GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))')); +INSERT INTO t1 VALUES("up3", GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))')); + +INSERT INTO t1 VALUES("down", GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))')); +INSERT INTO t1 VALUES("down2", GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))')); +INSERT INTO t1 VALUES("down3", GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))')); + +INSERT INTO t1 VALUES("right", GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))')); +INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))')); +INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))')); + +INSERT INTO t1 VALUES("left", GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))')); +INSERT INTO t1 VALUES("left2", GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))')); +INSERT INTO t1 VALUES("left3", GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))')); + +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal FROM t1 a1 JOIN t1 a2 ON MBREqual( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; + +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals FROM t1 a1 JOIN t1 a2 ON Equals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect FROM t1 a1 JOIN t1 a2 ON Intersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps FROM t1 a1 JOIN t1 a2 ON Overlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; + +# Overlaps needs a few more tests, with point and line dimensions + +SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))'); +SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))'); +SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))'); +SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))'); +SET @point1 = GeomFromText('POLYGON ((0 0))'); +SET @point2 = GeomFromText('POLYGON ((-2 0))'); + +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name; +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name; +SELECT Overlaps(@horiz1, @vert1) FROM DUAL; +SELECT Overlaps(@horiz1, @horiz2) FROM DUAL; +SELECT Overlaps(@horiz1, @horiz3) FROM DUAL; +SELECT Overlaps(@horiz1, @point1) FROM DUAL; +SELECT Overlaps(@horiz1, @point2) FROM DUAL; + +DROP TABLE t1; + +--echo End of 5.0 tests diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index 03ba8661a3c..d5a4fb7a734 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -182,6 +182,37 @@ delete from t1 where a >= 2; select a from t1 order by a; drop table t1; +# +# Bug#26996 - Update of a Field in a Memory Table ends with wrong result +# +CREATE TABLE t1 ( + c1 CHAR(3), + c2 INTEGER, + KEY USING BTREE(c1), + KEY USING BTREE(c2) +) ENGINE= MEMORY; +INSERT INTO t1 VALUES ('ABC',0), ('A',0), ('B',0), ('C',0); +UPDATE t1 SET c2= c2 + 1 WHERE c1 = 'A'; +SELECT * FROM t1; +DROP TABLE t1; + +# +# Bug#24985 - UTF8 ENUM primary key on MEMORY using BTREE +# causes incorrect duplicate entries +# +CREATE TABLE t1 ( + c1 ENUM('1', '2'), + UNIQUE USING BTREE(c1) +) ENGINE= MEMORY DEFAULT CHARSET= utf8; +INSERT INTO t1 VALUES('1'), ('2'); +DROP TABLE t1; +CREATE TABLE t1 ( + c1 SET('1', '2'), + UNIQUE USING BTREE(c1) +) ENGINE= MEMORY DEFAULT CHARSET= utf8; +INSERT INTO t1 VALUES('1'), ('2'); +DROP TABLE t1; + --echo End of 4.1 tests # @@ -205,3 +236,4 @@ INSERT INTO t1 VALUES(NULL),(NULL); DROP TABLE t1; --echo End of 5.0 tests + diff --git a/mysql-test/t/init_connect.test b/mysql-test/t/init_connect.test index c9a18a4003d..0a08559279c 100644 --- a/mysql-test/t/init_connect.test +++ b/mysql-test/t/init_connect.test @@ -2,10 +2,11 @@ # Test of init_connect variable # +# should work with embedded server after mysqltest is fixed +--source include/not_embedded.inc + --source include/add_anonymous_users.inc -# should work with embedded server after mysqltest is fixed --- source include/not_embedded.inc connect (con0,localhost,root,,); connection con0; select hex(@a); diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index aa25677bd99..e762d740d66 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -1976,6 +1976,34 @@ drop table t2, t1; --error ER_TABLE_CANT_HANDLE_SPKEYS create table t1 (g geometry not null, spatial gk(g)) engine=innodb; +# +# Bug #25927: Prevent ALTER TABLE ... MODIFY ... NOT NULL on columns +# for which there is a foreign key constraint ON ... SET NULL. +# + +CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB; +CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL; +--replace_regex /'\.\/test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ +--error 1025 +ALTER TABLE t2 MODIFY a INT NOT NULL; +DELETE FROM t1; +DROP TABLE t2,t1; + +# +# Bug #26835: table corruption after delete+insert +# + +CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4); +DELETE FROM t1; +INSERT INTO t1 VALUES ('DDD'); +SELECT * FROM t1; +DROP TABLE t1; + ####################################################################### # # # Please, DO NOT TOUCH this file as well as the innodb.result file. # diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 31508b3d6c4..bbc51be6dc9 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -306,4 +306,29 @@ INSERT INTO t2 (f1, f2) SELECT * FROM t2; DROP TABLE t1, t2; - +# +# Bug #26207: inserts don't work with shortened index +# +SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; + +CREATE TABLE t1 (c VARCHAR(30), INDEX ix_c (c(10))); +CREATE TABLE t2 (d VARCHAR(10)); +INSERT INTO t1 (c) VALUES ('7_chars'), ('13_characters'); + +EXPLAIN + SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1; + +SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1; + +INSERT INTO t2 (d) + SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1; + +INSERT INTO t2 (d) + SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='7_chars') FROM t1; + +INSERT INTO t2 (d) + SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c IN (SELECT t1.c FROM t1)) + FROM t1; + +SELECT * FROM t2; +DROP TABLE t1,t2; diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test index 4581cc7a875..76df4502769 100644 --- a/mysql-test/t/insert_update.test +++ b/mysql-test/t/insert_update.test @@ -162,3 +162,88 @@ INSERT INTO t2 VALUES (1), (3); --error ER_BAD_FIELD_ERROR INSERT INTO t1 SELECT 1, COUNT(*) FROM t2 ON DUPLICATE KEY UPDATE j= a; DROP TABLE t1,t2; + +# +# Bug #26261: Missing default value isn't noticed in +# insert ... on duplicate key update +# +SET SQL_MODE = 'TRADITIONAL'; + +CREATE TABLE t1 (a INT PRIMARY KEY, b INT NOT NULL); + +--error 1364 +INSERT INTO t1 (a) VALUES (1); + +--error 1364 +INSERT INTO t1 (a) VALUES (1) ON DUPLICATE KEY UPDATE a = b; + +--error 1364 +INSERT INTO t1 (a) VALUES (1) ON DUPLICATE KEY UPDATE b = b; + +SELECT * FROM t1; + +DROP TABLE t1; + +# +# Bug#27033: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE if rows were +# touched but not actually changed. +# +CREATE TABLE t1 (f1 INT AUTO_INCREMENT PRIMARY KEY, + f2 VARCHAR(5) NOT NULL UNIQUE); +INSERT t1 (f2) VALUES ('test') ON DUPLICATE KEY UPDATE f1 = LAST_INSERT_ID(f1); +SELECT LAST_INSERT_ID(); +INSERT t1 (f2) VALUES ('test') ON DUPLICATE KEY UPDATE f1 = LAST_INSERT_ID(f1); +SELECT LAST_INSERT_ID(); +DROP TABLE t1; + +# +# Bug#23233: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE in the +# NO_AUTO_VALUE_ON_ZERO mode. +# +SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; +CREATE TABLE `t1` ( + `id` int(11) PRIMARY KEY auto_increment, + `f1` varchar(10) NOT NULL UNIQUE +); +INSERT IGNORE INTO t1 (f1) VALUES ("test1") + ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +INSERT IGNORE INTO t1 (f1) VALUES ("test1") + ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +SELECT LAST_INSERT_ID(); +SELECT * FROM t1; +INSERT IGNORE INTO t1 (f1) VALUES ("test2") + ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +SELECT * FROM t1; +INSERT IGNORE INTO t1 (f1) VALUES ("test2") + ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +SELECT LAST_INSERT_ID(); +SELECT * FROM t1; +INSERT IGNORE INTO t1 (f1) VALUES ("test3") + ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +SELECT LAST_INSERT_ID(); +SELECT * FROM t1; +DROP TABLE t1; +CREATE TABLE `t1` ( + `id` int(11) PRIMARY KEY auto_increment, + `f1` varchar(10) NOT NULL UNIQUE +); +INSERT IGNORE INTO t1 (f1) VALUES ("test1") + ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +SELECT LAST_INSERT_ID(); +SELECT * FROM t1; +INSERT IGNORE INTO t1 (f1) VALUES ("test1"),("test4") + ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +SELECT LAST_INSERT_ID(); +SELECT * FROM t1; +DROP TABLE t1; +CREATE TABLE `t1` ( + `id` int(11) PRIMARY KEY auto_increment, + `f1` varchar(10) NOT NULL UNIQUE, + tim1 timestamp default '2003-01-01 00:00:00' on update current_timestamp +); +INSERT INTO t1 (f1) VALUES ("test1"); +SELECT id, f1 FROM t1; +REPLACE INTO t1 VALUES (0,"test1",null); +SELECT id, f1 FROM t1; +DROP TABLE t1; +SET SQL_MODE=''; diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 125a65826ca..e6788cd7798 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -136,4 +136,20 @@ eval select load_file("$MYSQL_TEST_DIR/t/loaddata.test"); # cleanup drop table t1, t2; +# +# Bug#27586: Wrong autoinc value assigned by LOAD DATA in the +# NO_AUTO_VALUE_ON_ZERO mode +# +create table t1(f1 int); +insert into t1 values(1),(null); +create table t2(f2 int auto_increment primary key); +disable_query_log; +eval select * into outfile '$MYSQLTEST_VARDIR/tmp/t1' from t1; +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=NO_AUTO_VALUE_ON_ZERO; +eval load data infile '$MYSQLTEST_VARDIR/tmp/t1' into table t2; +enable_query_log; +select * from t2; +--exec rm $MYSQLTEST_VARDIR/tmp/t1 +SET @@SQL_MODE=@OLD_SQL_MODE; +drop table t1,t2; # End of 5.0 tests diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 07923fa020c..490010c0a42 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -430,16 +430,7 @@ CREATE TABLE tm1(a SMALLINT, b SMALLINT, KEY(a)) ENGINE=MERGE UNION=(t1); SELECT * FROM tm1; DROP TABLE t1, tm1; -# -# Bug#26464 - insert delayed + update + merge = corruption -# -CREATE TABLE t1(c1 INT) ENGINE=MyISAM; -CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1); ---error 1031 -INSERT DELAYED INTO t2 VALUES(1); -DROP TABLE t1, t2; -# # BUG#26881 - Large MERGE tables report incorrect specification when no # differences in tables # diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 59e3206d1c3..82d10059c65 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -874,6 +874,150 @@ CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100; SHOW TABLE STATUS LIKE 't1'; DROP TABLE t1; +# +# Bug#26231 - select count(*) on myisam table returns wrong value +# when index is used +# +CREATE TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM; +# Fill at least two key blocks. "Tab, A" must be in both blocks. +INSERT INTO t1 VALUES + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), + (''), (''), (''), (''), + (' B'), (' B'), (' B'), (' B'); +SELECT DISTINCT COUNT(*) FROM t1 WHERE c1 = ''; +SELECT DISTINCT length(c1), c1 FROM t1 WHERE c1 = ''; +SELECT DISTINCT COUNT(*) FROM t1 IGNORE INDEX (c1) WHERE c1 = ''; +SELECT DISTINCT length(c1), c1 FROM t1 IGNORE INDEX (c1) WHERE c1 = ''; +SELECT DISTINCT length(c1), c1 FROM t1 ORDER BY c1; +DROP TABLE t1; + --echo End of 4.1 tests diff --git a/mysql-test/t/mysqlbinlog-cp932.test b/mysql-test/t/mysqlbinlog-cp932.test index 0e0a4e2bfae..1487606a6c2 100644 --- a/mysql-test/t/mysqlbinlog-cp932.test +++ b/mysql-test/t/mysqlbinlog-cp932.test @@ -1,3 +1,5 @@ +# disabled in embedded until tools running is fixed with embedded +--source include/not_embedded.inc -- source include/have_cp932.inc # Bug#16217 (mysql client did not know how not switch its internal charset) diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 97239360507..a7b3f413f23 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -201,7 +201,7 @@ load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8 select hex(a) from t1; drop table t1; flush logs; ---replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000009 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000009 --echo End of 5.0 tests diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 31741cdba9f..126412057ab 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -918,7 +918,7 @@ port=1234 EOF --exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 --exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 mysqltest1 ---remov_file $MYSQLTEST_VARDIR/tmp/tmp.cnf +--remove_file $MYSQLTEST_VARDIR/tmp/tmp.cnf --echo # --echo # Test of fix to BUG 12597 @@ -1429,6 +1429,72 @@ INSERT INTO t1 VALUES(1,0xff00fef0); DROP TABLE t1; + + +--echo # +--echo # Bug#26346: stack + buffer overrun in mysqldump +--echo # + +CREATE TABLE t1(a int); +INSERT INTO t1 VALUES (1), (2); + +# too long a file path causes an error +--error 1 +--exec $MYSQL_DUMP --tab=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test 2>&1 + +--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-terminated-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test +--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-enclosed-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test +--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-optionally-enclosed-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test +--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-escaped-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test +--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --lines-terminated-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test + +--remove_file $MYSQLTEST_VARDIR/tmp/t1.sql +--remove_file $MYSQLTEST_VARDIR/tmp/t1.txt + +DROP TABLE t1; + +# +# Bug #25993: crashe with a merge table and -c +# + +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +CREATE TABLE t1 (a int) ENGINE=merge UNION=(t2, t3); +--exec $MYSQL_DUMP --skip-comments -c test +DROP TABLE t1, t2, t3; + +--echo # +--echo # Bug #23491: MySQLDump prefix function call in a view by database name +--echo # + +# Setup +create database bug23491_original; +create database bug23491_restore; +use bug23491_original; +create table t1 (c1 int); +create view v1 as select * from t1; +create procedure p1() select 1; +create function f1() returns int return 1; +create view v2 as select f1(); +create function f2() returns int return f1(); +create view v3 as select bug23491_original.f1(); + +# Backup. +--exec $MYSQL_DUMP --skip-comments -uroot --opt --routines bug23491_original > $MYSQLTEST_VARDIR/tmp/bug23491_backup.sql + +# Restore. +--exec $MYSQL bug23491_restore < $MYSQLTEST_VARDIR/tmp/bug23491_backup.sql + +# Verify +use bug23491_restore; +show create view bug23491_restore.v2; +show create view bug23491_restore.v3; + +# Cleanup +drop database bug23491_original; +drop database bug23491_restore; +use test; + --echo # --echo # End of 5.0 tests --echo # diff --git a/mysql-test/t/ndb_autodiscover3.test b/mysql-test/t/ndb_autodiscover3.test index 73b4bf8b94f..259da6e3501 100644 --- a/mysql-test/t/ndb_autodiscover3.test +++ b/mysql-test/t/ndb_autodiscover3.test @@ -1,5 +1,6 @@ -- source include/have_ndb.inc -- source include/have_multi_ndb.inc +-- source include/ndb_default_cluster.inc -- source include/not_embedded.inc @@ -7,6 +8,11 @@ drop table if exists t1, t2; --enable_warnings +# Workaround for Bug#27644 +# ndb: connecting api node/mysqld may "steal" node_id from running mysqld +# - let ndb_waiter use a fixed node id so "steal" cannot happen +--let connect_str = "nodeid=6;$NDB_CONNECTSTRING" + # # Transaction ongoing while cluster is restarted # @@ -17,7 +23,7 @@ begin; insert into t1 values (1); --exec $NDB_MGM --no-defaults -e "all restart" >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT --error 1297 insert into t1 values (2); @@ -35,7 +41,7 @@ insert into t2 values (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10, select * from t2 order by a limit 3; --exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT --connection server2 create table t2 (a int key) engine=ndbcluster; @@ -49,7 +55,7 @@ select * from t2 order by a limit 3; select * from t2 order by a limit 3; --exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT --connection server1 show tables; diff --git a/mysql-test/t/ndb_blob.test b/mysql-test/t/ndb_blob.test index d6e0edc89f0..32699017c03 100644 --- a/mysql-test/t/ndb_blob.test +++ b/mysql-test/t/ndb_blob.test @@ -96,6 +96,11 @@ update t1 set d=null where a=1; commit; select a from t1 where d is null; +# bug#24028 - does not occur on MySQL level +# bug#17986 - not seen by us anymore but could show as warning here +delete from t1 where a=45567; +commit; + # pk delete delete from t1 where a=1; delete from t1 where a=2; diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index 39c7ab67efb..5b839a0d3aa 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -8,15 +8,22 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; --enable_warnings -CREATE TABLE `t1` ( - `capgoaledatta` smallint(5) unsigned NOT NULL auto_increment, +# Bug #27775 - mediumint auto inc not restored correctly +# - check mediumint +CREATE TABLE `t1_c` ( + `capgoaledatta` mediumint(5) unsigned NOT NULL auto_increment, `goaledatta` char(2) NOT NULL default '', `maturegarbagefa` varchar(32) NOT NULL default '', PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t1` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt'); - -CREATE TABLE `t2` ( +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(400,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3000,'20','threetrees.qt'); +# +# Bug #27758 Restoring NDB backups makes table usable in SQL nodes +# - space in key made table unusable after restore +# +# Bug #27775 - mediumint auto inc not restored correctly +# - check smallint +CREATE TABLE `t2_c` ( `capgotod` smallint(5) unsigned NOT NULL auto_increment, `gotod` smallint(5) unsigned NOT NULL default '0', `goaledatta` char(2) default NULL, @@ -24,18 +31,20 @@ CREATE TABLE `t2` ( `descrpooppo` varchar(64) default NULL, `svcutonsa` varchar(64) NOT NULL default '', PRIMARY KEY (`capgotod`), - KEY `i_quadaddsvr` (`gotod`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t2` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); + KEY `i quadaddsvr` (`gotod`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); -CREATE TABLE `t3` ( +CREATE TABLE `t3_c` ( `CapGoaledatta` smallint(5) unsigned NOT NULL default '0', `capgotod` smallint(5) unsigned NOT NULL default '0', PRIMARY KEY (`capgotod`,`CapGoaledatta`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t3` VALUES (5,3),(2,4),(5,4),(1,3); +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3); -CREATE TABLE `t4` ( +# Bug #27775 - mediumint auto inc not restored correctly +# - check bigint +CREATE TABLE `t4_c` ( `capfa` bigint(20) unsigned NOT NULL auto_increment, `realm` varchar(32) NOT NULL default '', `authpwchap` varchar(32) default NULL, @@ -45,38 +54,40 @@ CREATE TABLE `t4` ( PRIMARY KEY (`fa`,`realm`), KEY `capfa` (`capfa`), KEY `i_quadentity` (`fa`,`realm`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t4` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(2200,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32000,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(290000000,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); -CREATE TABLE `t5` ( +CREATE TABLE `t5_c` ( `capfa` bigint(20) unsigned NOT NULL default '0', `gotod` smallint(5) unsigned NOT NULL default '0', `orderutonsa` varchar(64) NOT NULL default '', PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t5` VALUES (21,2,''),(21,1,''),(22,4,''); +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,''); -CREATE TABLE `t6` ( +CREATE TABLE `t6_c` ( `capfa_parent` bigint(20) unsigned NOT NULL default '0', `capfa_child` bigint(20) unsigned NOT NULL default '0', `relatta` smallint(5) unsigned NOT NULL default '0', PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t6` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); -CREATE TABLE `t7` ( +# Bug #27775 - mediumint auto inc not restored correctly +# - check tinyint +CREATE TABLE `t7_c` ( `dardpo` char(15) NOT NULL default '', - `dardtestard` tinyint(3) unsigned NOT NULL default '0', + `dardtestard` tinyint(3) unsigned NOT NULL auto_increment, `FastFA` char(5) NOT NULL default '', `FastCode` char(6) NOT NULL default '', `Fastca` char(1) NOT NULL default '', `Fastmag` char(1) NOT NULL default '', `Beareratta` char(2) NOT NULL default '', PRIMARY KEY (`dardpo`,`dardtestard`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t7` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); -CREATE TABLE `t8` ( +CREATE TABLE `t8_c` ( `kattjame` varchar(32) NOT NULL default '', `realm` varchar(32) NOT NULL default '', `realm_entered` varchar(32) NOT NULL default '', @@ -102,10 +113,10 @@ CREATE TABLE `t8` ( `acctinputoctets` bigint(20) unsigned default NULL, PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), KEY `squardporoot` (`squardporoot`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t8` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); -CREATE TABLE `t9` ( +CREATE TABLE `t9_c` ( `kattjame` varchar(32) NOT NULL default '', `kattjame_entered` varchar(32) NOT NULL default '', `realm` varchar(32) NOT NULL default '', @@ -129,26 +140,29 @@ CREATE TABLE `t9` ( `actinputocctets` bigint(20) unsigned default NULL, `terminateraste` tinyint(3) unsigned default NULL, PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) -) ENGINE=myisam DEFAULT CHARSET=latin1; -INSERT INTO `t9` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); # Bug #20820 # auto inc table not handled correctly when restored from cluster backup # - before fix ndb_restore would not set auto inc value correct, # seen by select below -create table t10 (a int auto_increment key); -insert into t10 values (1),(2),(3); +create table t10_c (a int auto_increment key) ENGINE=ndbcluster; +insert into t10_c values (1),(2),(3); +# Bug #27775 - mediumint auto inc not restored correctly +# - check int +insert into t10_c values (10000),(2000),(3000); -create table t1_c engine=ndbcluster as select * from t1; -create table t2_c engine=ndbcluster as select * from t2; -create table t3_c engine=ndbcluster as select * from t3; -create table t4_c engine=ndbcluster as select * from t4; -create table t5_c engine=ndbcluster as select * from t5; -create table t6_c engine=ndbcluster as select * from t6; -create table t7_c engine=ndbcluster as select * from t7; -create table t8_c engine=ndbcluster as select * from t8; -create table t9_c engine=ndbcluster as select * from t9; -create table t10_c engine=ndbcluster as select * from t10; +create table t1 engine=myisam as select * from t1_c; +create table t2 engine=myisam as select * from t2_c; +create table t3 engine=myisam as select * from t3_c; +create table t4 engine=myisam as select * from t4_c; +create table t5 engine=myisam as select * from t5_c; +create table t6 engine=myisam as select * from t6_c; +create table t7 engine=myisam as select * from t7_c; +create table t8 engine=myisam as select * from t8_c; +create table t9 engine=myisam as select * from t9_c; +create table t10 engine=myisam as select * from t10_c; --exec $NDB_MGM --no-defaults -e "start backup" >> $NDB_TOOLS_OUTPUT @@ -215,6 +229,18 @@ select count(*) # Bug #20820 cont'd select * from t10_c order by a; +# Bug #27775 cont'd +# - auto inc info should be correct +--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X +show table status like 't1_c'; +--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X +show table status like 't2_c'; +--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X +show table status like 't4_c'; +--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X +show table status like 't7_c'; +--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X +show table status like 't10_c'; --disable_warnings drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9, t10; diff --git a/mysql-test/t/ndb_restore_print.test b/mysql-test/t/ndb_restore_print.test new file mode 100644 index 00000000000..6dbbfdf5933 --- /dev/null +++ b/mysql-test/t/ndb_restore_print.test @@ -0,0 +1,189 @@ +-- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +--disable_warnings +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +--enable_warnings + +# basic datatypes +create table t1 + (pk int key + ,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64) + ,b1 TINYINT, b2 TINYINT UNSIGNED + ,c1 SMALLINT, c2 SMALLINT UNSIGNED + ,d1 INT, d2 INT UNSIGNED + ,e1 BIGINT, e2 BIGINT UNSIGNED + ,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY + ,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY + ,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255) + ,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) + ) engine myisam; + +# max values +insert into t1 values + (1 + ,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001 + ,127, 255 + ,32767, 65535 + ,2147483647, 4294967295 + ,9223372036854775807, 18446744073709551615 + ,'1','12345678901234567890123456789012','123456789' + ,'1','12345678901234567890123456789012','123456789' + ,0x12,0x123456789abcdef0, 0x012345 + ,0x12,0x123456789abcdef0, 0x00123450 + ); + +# min values +insert into t1 values + (2 + ,0, 0, 0, 0, 0 + ,-128, 0 + ,-32768, 0 + ,-2147483648, 0 + ,-9223372036854775808, 0 + ,'','','' + ,'','','' + ,0x0,0x0,0x0 + ,0x0,0x0,0x0 + ); + +# null values +insert into t1 values + (3 + ,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 + ); + +--vertical_results +select pk + ,hex(a1), hex(a2), hex(a3), hex(a4), hex(a5) + ,b1, b2 + ,c1 , c2 + ,d1 , d2 + ,e1 , e2 + ,f1 , f2, f3 + ,g1 , g2, g3 + ,hex(h1), hex(h2), hex(h3) + ,hex(i1), hex(i2), hex(i3) + from t1 order by pk; + +alter table t1 engine ndb; + +select pk + ,hex(a1), hex(a2), hex(a3), hex(a4), hex(a5) + ,b1, b2 + ,c1 , c2 + ,d1 , d2 + ,e1 , e2 + ,f1 , f2, f3 + ,g1 , g2, g3 + ,hex(h1), hex(h2), hex(h3) + ,hex(i1), hex(i2), hex(i3) + from t1 order by pk; +--horizontal_results + +--source include/ndb_backup.inc + +--let ndb_restore_filter=test t1 +--let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by=";" +--source include/ndb_backup_print.inc + +--let ndb_restore_filter=test t1 +--let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by="," --fields-optionally-enclosed-by="'" +--source include/ndb_backup_print.inc + + +drop table t1; + +# some binary char tests with trailing spaces +create table t1 + (pk int key + ,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY + ,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY + ,h1 BINARY(1), h2 BINARY(9), h3 BINARY(255) + ,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) + ) engine ndb; + +insert into t1 values + (1 + ,'1','12345678901234567890123456789012','123456789 ' + ,'1 ','12345678901234567890123456789012 ','123456789 ' + ,0x20,0x123456789abcdef020, 0x012345000020 + ,0x1200000020,0x123456789abcdef000000020, 0x00123450000020 + ); + +create table t2 (pk int key, a int) engine ndb; +create table t3 (pk int key, a int) engine ndb; +create table t4 (pk int key, a int) engine ndb; + +insert into t2 values (1,11),(2,12),(3,13),(4,14),(5,15); +insert into t3 values (1,21),(2,22),(3,23),(4,24),(5,25); +insert into t4 values (1,31),(2,32),(3,33),(4,34),(5,35); + +--source include/ndb_backup.inc +--let ndb_restore_opts=--verbose=0 --print_data --hex --fields-enclosed-by="'" --fields-optionally-enclosed-by="X" +--let ndb_restore_filter=test t1 +--source include/ndb_backup_print.inc + +--exec rm -f $MYSQLTEST_VARDIR/tmp/t1.txt +--exec rm -f $MYSQLTEST_VARDIR/tmp/t2.txt +--exec rm -f $MYSQLTEST_VARDIR/tmp/t3.txt +--exec rm -f $MYSQLTEST_VARDIR/tmp/t4.txt + +--let ndb_restore_opts=--verbose=0 --print_data --hex --tab $MYSQLTEST_VARDIR/tmp --append +--let ndb_restore_filter=test +--source include/ndb_backup_print.inc + +--let $message= t1 +--source include/show_msg.inc +--exec sort $MYSQLTEST_VARDIR/tmp/t1.txt +--let $message= t2 +--source include/show_msg.inc +--exec sort $MYSQLTEST_VARDIR/tmp/t2.txt +--let $message= t3 +--source include/show_msg.inc +--exec sort $MYSQLTEST_VARDIR/tmp/t3.txt +--let $message= t4 +--source include/show_msg.inc +--exec sort $MYSQLTEST_VARDIR/tmp/t4.txt + +--exec rm -f $MYSQLTEST_VARDIR/tmp/t1.txt +--exec rm -f $MYSQLTEST_VARDIR/tmp/t2.txt +--exec rm -f $MYSQLTEST_VARDIR/tmp/t3.txt +--exec rm -f $MYSQLTEST_VARDIR/tmp/t4.txt + +# now test some other datatypes +drop table t1; +create table t1 + (pk int key + ,a1 MEDIUMINT, a2 MEDIUMINT UNSIGNED + ) engine ndb; + +# max values +insert into t1 values(1, 8388607, 16777215); +# min values +insert into t1 values(2, -8388608, 0); +# small values +insert into t1 values(3, -1, 1); + +# backup and print +--source include/ndb_backup.inc + +--let ndb_restore_filter=test t1 +--let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by=";" +--source include/ndb_backup_print.inc + +# clean up +drop table t1; +drop table t2; +drop table t3; +drop table t4; diff --git a/mysql-test/t/ndb_single_user.test b/mysql-test/t/ndb_single_user.test index c655124f79f..f2f47becb0c 100644 --- a/mysql-test/t/ndb_single_user.test +++ b/mysql-test/t/ndb_single_user.test @@ -51,34 +51,67 @@ insert into t1 select * from t2; --connection server2 --error 1051 drop table t1; ---error 1146 -#--error 1296 +--error 1296 create index new_index on t1 (c); ---error 1146 -#--error 1296 +--error 1296 insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(10,10,0); ---error 1146 -#--error 1296 +--error 1296 select * from t1 where a = 1; ---error 1146 -#--error 1296 +--error 1296 select * from t1 where b = 4; ---error 1146 -#--error 1296 +--error 1296 update t1 set b=102 where a = 2; ---error 1146 -#--error 1296 +--error 1296 update t1 set b=103 where b = 3; ---error 1146 -#--error 1296 +--error 1296 update t1 set b=b+100; ---error 1146 -#--error 1296 +--error 1296 update t1 set b=b+100 where a > 7; --exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "exit single user mode" >> $NDB_TOOLS_OUTPUT --exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT +# +# we should be able to run transaction while in single user mode +# +--connection server1 +BEGIN; +update t1 set b=b+100 where a=1; + +--connection server2 +BEGIN; +update t1 set b=b+100 where a=2; + +# enter single user mode +--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "enter single user mode $node_id" >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" --single-user >> $NDB_TOOLS_OUTPUT + +--connection server1 +update t1 set b=b+100 where a=3; +COMMIT; + +# while on other mysqld it should be aborted +--connection server2 +--error 1296 +update t1 set b=b+100 where a=4; +--error 1296 +COMMIT; + +# Bug #25275 SINGLE USER MODE prevents ALTER on non-ndb +# tables for other mysqld nodes +--connection server2 +create table t2 (a int) engine myisam; +alter table t2 add column (b int); + +# exit single user mode +--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "exit single user mode" >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT + # cleanup +--connection server2 +drop table t2; --connection server1 drop table t1; + +# End of 5.0 tests + diff --git a/mysql-test/t/ndb_trigger.test b/mysql-test/t/ndb_trigger.test index 2521ef17842..25b079cfe7c 100644 --- a/mysql-test/t/ndb_trigger.test +++ b/mysql-test/t/ndb_trigger.test @@ -89,4 +89,112 @@ select * from t2 order by op, a, b; drop tables t1, t2, t3; +# Test for bug#26242 +# Verify that AFTER UPDATE/DELETE triggers are executed +# after the change has actually taken place + +CREATE TABLE t1 ( + id INT NOT NULL PRIMARY KEY, + xy INT +) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES (1, 0); + +DELIMITER //; +CREATE TRIGGER t1_update AFTER UPDATE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id = NEW.id; END // +DELIMITER ;// + +CREATE TABLE t2 ( + id INT NOT NULL PRIMARY KEY, + xy INT +) ENGINE=ndbcluster; + +INSERT INTO t2 VALUES (2, 0); + +CREATE TABLE t3 (id INT NOT NULL PRIMARY KEY) ENGINE=ndbcluster; + +INSERT INTO t3 VALUES (1); + +CREATE TABLE t4 LIKE t1; + +DELIMITER //; +CREATE TRIGGER t4_update AFTER UPDATE ON t4 FOR EACH ROW BEGIN REPLACE INTO t5 SELECT * FROM t4 WHERE t4.id = NEW.id; END // +DELIMITER ;// + +CREATE TABLE t5 LIKE t2; + +UPDATE t1 SET xy = 3 WHERE id = 1; +SELECT xy FROM t1 where id = 1; +SELECT xy FROM t2 where id = 1; + +UPDATE t1 SET xy = 4 WHERE id IN (SELECT id FROM t3 WHERE id = 1); +SELECT xy FROM t1 where id = 1; +SELECT xy FROM t2 where id = 1; + +INSERT INTO t4 SELECT * FROM t1; +INSERT INTO t5 SELECT * FROM t2; +UPDATE t1,t4 SET t1.xy = 3, t4.xy = 3 WHERE t1.id = 1 AND t4.id = 1; +SELECT xy FROM t1 where id = 1; +SELECT xy FROM t2 where id = 1; +SELECT xy FROM t4 where id = 1; +SELECT xy FROM t5 where id = 1; + +UPDATE t1,t4 SET t1.xy = 4, t4.xy = 4 WHERE t1.id IN (SELECT id FROM t3 WHERE id = 1) AND t4.id IN (SELECT id FROM t3 WHERE id = 1); +SELECT xy FROM t1 where id = 1; +SELECT xy FROM t2 where id = 1; +SELECT xy FROM t4 where id = 1; +SELECT xy FROM t5 where id = 1; + +INSERT INTO t1 VALUES (1,0) ON DUPLICATE KEY UPDATE xy = 5; +SELECT xy FROM t1 where id = 1; +SELECT xy FROM t2 where id = 1; + +DROP TRIGGER t1_update; +DROP TRIGGER t4_update; + +DELIMITER //; +CREATE TRIGGER t1_delete AFTER DELETE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id > 4; END // +DELIMITER ;// + +DELIMITER //; +CREATE TRIGGER t4_delete AFTER DELETE ON t4 FOR EACH ROW BEGIN REPLACE INTO t5 SELECT * FROM t4 WHERE t4.id > 4; END // +DELIMITER ;// + +INSERT INTO t1 VALUES (5, 0),(6,0); +INSERT INTO t2 VALUES (5, 1),(6,1); +INSERT INTO t3 VALUES (5); +SELECT * FROM t1 order by id; +SELECT * FROM t2 order by id; +DELETE FROM t1 WHERE id IN (SELECT id FROM t3 WHERE id = 5); +SELECT * FROM t1 order by id; +SELECT * FROM t2 order by id; + +INSERT INTO t1 VALUES (5,0); +UPDATE t2 SET xy = 1 WHERE id = 6; +TRUNCATE t4; +INSERT INTO t4 SELECT * FROM t1; +TRUNCATE t5; +INSERT INTO t5 SELECT * FROM t2; +SELECT * FROM t1 order by id; +SELECT * FROM t2 order by id; +SELECT * FROM t4 order by id; +SELECT * FROM t5 order by id; +DELETE FROM t1,t4 USING t1,t3,t4 WHERE t1.id IN (SELECT id FROM t3 WHERE id = 5) AND t4.id IN (SELECT id FROM t3 WHERE id = 5); +SELECT * FROM t1 order by id; +SELECT * FROM t2 order by id; +SELECT * FROM t4 order by id; +SELECT * FROM t5 order by id; + +INSERT INTO t1 VALUES (5, 0); +REPLACE INTO t2 VALUES (6,1); +SELECT * FROM t1 order by id; +SELECT * FROM t2 order by id; +REPLACE INTO t1 VALUES (5, 1); +SELECT * FROM t1 order by id; +SELECT * FROM t2 order by id; + +DROP TRIGGER t1_delete; +DROP TRIGGER t4_delete; +DROP TABLE t1, t2, t3, t4, t5; + --echo End of 5.0 tests diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test index 8772b8157e3..362443023e1 100644 --- a/mysql-test/t/openssl_1.test +++ b/mysql-test/t/openssl_1.test @@ -96,4 +96,11 @@ drop table t1; --error 1 --exec $MYSQL_TEST --ssl-cert= --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 - +# +# Bug#25309 SSL connections without CA certificate broken since MySQL 5.0.23 +# +# Test that we can open encrypted connection to server without +# verification of servers certificate by setting both ca certificate +# and ca path to NULL +# +--exec $MYSQL --ssl --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem -e "SHOW STATUS LIKE 'ssl_Cipher'" 2>&1 diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index a0a1147336c..3e8fa07dfb7 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -617,7 +617,6 @@ UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol; UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol; DROP TABLE bug25126; - # # Bug #25427: crash when order by expression contains a name # that cannot be resolved unambiguously @@ -633,6 +632,41 @@ SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val > 1; DROP TABLE t1; +# +# Bug #27532: ORDER/GROUP BY expressions with IN/BETWEEN and NOT IN/BETWEEN +# + +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (3), (2), (4), (1); + +SELECT a, IF(a IN (2,3), a, a+10) FROM t1 + ORDER BY IF(a IN (2,3), a, a+10); +SELECT a, IF(a NOT IN (2,3), a, a+10) FROM t1 + ORDER BY IF(a NOT IN (2,3), a, a+10); +SELECT a, IF(a IN (2,3), a, a+10) FROM t1 + ORDER BY IF(a NOT IN (2,3), a, a+10); + +SELECT a, IF(a BETWEEN 2 AND 3, a, a+10) FROM t1 + ORDER BY IF(a BETWEEN 2 AND 3, a, a+10); +SELECT a, IF(a NOT BETWEEN 2 AND 3, a, a+10) FROM t1 + ORDER BY IF(a NOT BETWEEN 2 AND 3, a, a+10); +SELECT a, IF(a BETWEEN 2 AND 3, a, a+10) FROM t1 + ORDER BY IF(a NOT BETWEEN 2 AND 3, a, a+10); + +SELECT IF(a IN (1,2), a, '') as x1, IF(a NOT IN (1,2), a, '') as x2 + FROM t1 GROUP BY x1, x2; +SELECT IF(a IN (1,2), a, '') as x1, IF(a NOT IN (1,2), a, '') as x2 + FROM t1 GROUP BY x1, IF(a NOT IN (1,2), a, ''); + +# The remaining queries are for better coverage +SELECT a, a IN (1,2) FROM t1 ORDER BY a IN (1,2); +SELECT a FROM t1 ORDER BY a IN (1,2); +SELECT a+10 FROM t1 ORDER BY a IN (1,2); +SELECT a, IF(a IN (1,2), a, a+10) FROM t1 + ORDER BY IF(a IN (3,4), a, a+10); +DROP TABLE t1; + +# End of 4.1 create table t1 (a int not null, b int not null, c int not null); insert t1 values (1,1,1),(1,1,2),(1,2,1); select a, b from t1 group by a, b order by sum(c); @@ -677,3 +711,18 @@ create table t1 (a int, b int, c int); insert into t1 values (1,2,3), (9,8,3), (19,4,3), (1,4,9); select a,(sum(b)/sum(c)) as ratio from t1 group by a order by sum(b)/sum(c) asc; drop table t1; + +# +# Bug#26672: Incorrect SEC_TO_TIME() casting in ORDER BY +# +CREATE TABLE t1 (a INT UNSIGNED NOT NULL, b TIME); +INSERT INTO t1 (a) VALUES (100000), (0), (100), (1000000),(10000), (1000), (10); +UPDATE t1 SET b = SEC_TO_TIME(a); + +-- Correct ORDER +SELECT a, b FROM t1 ORDER BY b DESC; + +-- must be ordered as the above +SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC; + +DROP TABLE t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 72be4e12c6a..b8d4b91f03d 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -568,6 +568,149 @@ SELECT s.oxid FROM t1 v, t1 s DROP TABLE t1; +# BUG#26624 high mem usage (crash) in range optimizer (depends on order of fields in where) +create table t1 ( + c1 char(10), c2 char(10), c3 char(10), c4 char(10), + c5 char(10), c6 char(10), c7 char(10), c8 char(10), + c9 char(10), c10 char(10), c11 char(10), c12 char(10), + c13 char(10), c14 char(10), c15 char(10), c16 char(10), + index(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,c13,c14,c15,c16) +); +insert into t1 (c1) values ('1'),('1'),('1'),('1'); + +# This must run without crash and fast: +select * from t1 where + c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", + "abcdefg1", "123456781", "qwertyui1", "asddfg1", + "abcdefg2", "123456782", "qwertyui2", "asddfg2", + "abcdefg3", "123456783", "qwertyui3", "asddfg3", + "abcdefg4", "123456784", "qwertyui4", "asddfg4", + "abcdefg5", "123456785", "qwertyui5", "asddfg5", + "abcdefg6", "123456786", "qwertyui6", "asddfg6", + "abcdefg7", "123456787", "qwertyui7", "asddfg7", + "abcdefg8", "123456788", "qwertyui8", "asddfg8", + "abcdefg9", "123456789", "qwertyui9", "asddfg9", + "abcdefgA", "12345678A", "qwertyuiA", "asddfgA", + "abcdefgB", "12345678B", "qwertyuiB", "asddfgB", + "abcdefgC", "12345678C", "qwertyuiC", "asddfgC") + and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", + "abcdefg1", "123456781", "qwertyui1", "asddfg1", + "abcdefg2", "123456782", "qwertyui2", "asddfg2", + "abcdefg3", "123456783", "qwertyui3", "asddfg3", + "abcdefg4", "123456784", "qwertyui4", "asddfg4", + "abcdefg5", "123456785", "qwertyui5", "asddfg5", + "abcdefg6", "123456786", "qwertyui6", "asddfg6", + "abcdefg7", "123456787", "qwertyui7", "asddfg7", + "abcdefg8", "123456788", "qwertyui8", "asddfg8", + "abcdefg9", "123456789", "qwertyui9", "asddfg9", + "abcdefgA", "12345678A", "qwertyuiA", "asddfgA", + "abcdefgB", "12345678B", "qwertyuiB", "asddfgB", + "abcdefgC", "12345678C", "qwertyuiC", "asddfgC") + and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", + "abcdefg1", "123456781", "qwertyui1", "asddfg1", + "abcdefg2", "123456782", "qwertyui2", "asddfg2", + "abcdefg3", "123456783", "qwertyui3", "asddfg3", + "abcdefg4", "123456784", "qwertyui4", "asddfg4", + "abcdefg5", "123456785", "qwertyui5", "asddfg5", + "abcdefg6", "123456786", "qwertyui6", "asddfg6", + "abcdefg7", "123456787", "qwertyui7", "asddfg7", + "abcdefg8", "123456788", "qwertyui8", "asddfg8", + "abcdefg9", "123456789", "qwertyui9", "asddfg9", + "abcdefgA", "12345678A", "qwertyuiA", "asddfgA", + "abcdefgB", "12345678B", "qwertyuiB", "asddfgB", + "abcdefgC", "12345678C", "qwertyuiC", "asddfgC") + and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", + "abcdefg1", "123456781", "qwertyui1", "asddfg1", + "abcdefg2", "123456782", "qwertyui2", "asddfg2", + "abcdefg3", "123456783", "qwertyui3", "asddfg3", + "abcdefg4", "123456784", "qwertyui4", "asddfg4", + "abcdefg5", "123456785", "qwertyui5", "asddfg5", + "abcdefg6", "123456786", "qwertyui6", "asddfg6", + "abcdefg7", "123456787", "qwertyui7", "asddfg7", + "abcdefg8", "123456788", "qwertyui8", "asddfg8", + "abcdefg9", "123456789", "qwertyui9", "asddfg9", + "abcdefgA", "12345678A", "qwertyuiA", "asddfgA", + "abcdefgB", "12345678B", "qwertyuiB", "asddfgB", + "abcdefgC", "12345678C", "qwertyuiC", "asddfgC") + and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", + "abcdefg1", "123456781", "qwertyui1", "asddfg1", + "abcdefg2", "123456782", "qwertyui2", "asddfg2", + "abcdefg3", "123456783", "qwertyui3", "asddfg3", + "abcdefg4", "123456784", "qwertyui4", "asddfg4", + "abcdefg5", "123456785", "qwertyui5", "asddfg5", + "abcdefg6", "123456786", "qwertyui6", "asddfg6", + "abcdefg7", "123456787", "qwertyui7", "asddfg7", + "abcdefg8", "123456788", "qwertyui8", "asddfg8", + "abcdefg9", "123456789", "qwertyui9", "asddfg9", + "abcdefgA", "12345678A", "qwertyuiA", "asddfgA", + "abcdefgB", "12345678B", "qwertyuiB", "asddfgB", + "abcdefgC", "12345678C", "qwertyuiC", "asddfgC") + and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", + "abcdefg1", "123456781", "qwertyui1", "asddfg1", + "abcdefg2", "123456782", "qwertyui2", "asddfg2", + "abcdefg3", "123456783", "qwertyui3", "asddfg3", + "abcdefg4", "123456784", "qwertyui4", "asddfg4", + "abcdefg5", "123456785", "qwertyui5", "asddfg5", + "abcdefg6", "123456786", "qwertyui6", "asddfg6", + "abcdefg7", "123456787", "qwertyui7", "asddfg7", + "abcdefg8", "123456788", "qwertyui8", "asddfg8", + "abcdefg9", "123456789", "qwertyui9", "asddfg9", + "abcdefgA", "12345678A", "qwertyuiA", "asddfgA", + "abcdefgB", "12345678B", "qwertyuiB", "asddfgB", + "abcdefgC", "12345678C", "qwertyuiC", "asddfgC") + and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", + "abcdefg1", "123456781", "qwertyui1", "asddfg1", + "abcdefg2", "123456782", "qwertyui2", "asddfg2", + "abcdefg3", "123456783", "qwertyui3", "asddfg3", + "abcdefg4", "123456784", "qwertyui4", "asddfg4", + "abcdefg5", "123456785", "qwertyui5", "asddfg5", + "abcdefg6", "123456786", "qwertyui6", "asddfg6", + "abcdefg7", "123456787", "qwertyui7", "asddfg7", + "abcdefg8", "123456788", "qwertyui8", "asddfg8", + "abcdefg9", "123456789", "qwertyui9", "asddfg9", + "abcdefgA", "12345678A", "qwertyuiA", "asddfgA", + "abcdefgB", "12345678B", "qwertyuiB", "asddfgB", + "abcdefgC", "12345678C", "qwertyuiC", "asddfgC") + and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", + "abcdefg1", "123456781", "qwertyui1", "asddfg1", + "abcdefg2", "123456782", "qwertyui2", "asddfg2", + "abcdefg3", "123456783", "qwertyui3", "asddfg3", + "abcdefg4", "123456784", "qwertyui4", "asddfg4", + "abcdefg5", "123456785", "qwertyui5", "asddfg5", + "abcdefg6", "123456786", "qwertyui6", "asddfg6", + "abcdefg7", "123456787", "qwertyui7", "asddfg7", + "abcdefg8", "123456788", "qwertyui8", "asddfg8", + "abcdefg9", "123456789", "qwertyui9", "asddfg9", + "abcdefgA", "12345678A", "qwertyuiA", "asddfgA", + "abcdefgB", "12345678B", "qwertyuiB", "asddfgB", + "abcdefgC", "12345678C", "qwertyuiC", "asddfgC") + and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", + "abcdefg1", "123456781", "qwertyui1", "asddfg1", + "abcdefg2", "123456782", "qwertyui2", "asddfg2", + "abcdefg3", "123456783", "qwertyui3", "asddfg3", + "abcdefg4", "123456784", "qwertyui4", "asddfg4", + "abcdefg5", "123456785", "qwertyui5", "asddfg5", + "abcdefg6", "123456786", "qwertyui6", "asddfg6", + "abcdefg7", "123456787", "qwertyui7", "asddfg7", + "abcdefg8", "123456788", "qwertyui8", "asddfg8", + "abcdefg9", "123456789", "qwertyui9", "asddfg9", + "abcdefgA", "12345678A", "qwertyuiA", "asddfgA", + "abcdefgB", "12345678B", "qwertyuiB", "asddfgB", + "abcdefgC", "12345678C", "qwertyuiC", "asddfgC") + and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", + "abcdefg1", "123456781", "qwertyui1", "asddfg1", + "abcdefg2", "123456782", "qwertyui2", "asddfg2", + "abcdefg3", "123456783", "qwertyui3", "asddfg3", + "abcdefg4", "123456784", "qwertyui4", "asddfg4", + "abcdefg5", "123456785", "qwertyui5", "asddfg5", + "abcdefg6", "123456786", "qwertyui6", "asddfg6", + "abcdefg7", "123456787", "qwertyui7", "asddfg7", + "abcdefg8", "123456788", "qwertyui8", "asddfg8", + "abcdefg9", "123456789", "qwertyui9", "asddfg9", + "abcdefgA", "12345678A", "qwertyuiA", "asddfgA", + "abcdefgB", "12345678B", "qwertyuiB", "asddfgB", + "abcdefgC", "12345678C", "qwertyuiC", "asddfgC"); +drop table t1; --echo End of 4.1 tests # diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test index 63c611e6be6..bf25359b7be 100644 --- a/mysql-test/t/row.test +++ b/mysql-test/t/row.test @@ -85,6 +85,31 @@ drop table t1; SELECT ROW(2,10) <=> ROW(3,4); SELECT ROW(NULL,10) <=> ROW(3,NULL); +# +# Bug #27484: nested row expressions in IN predicate +# + +--error 1241 +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1)); +--error 1241 +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1),ROW(1,ROW(2,3))); +--error 1241 +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,ROW(2,2,2))); +--error 1241 +SELECT ROW(1,ROW(2,3,4)) IN (ROW(1,ROW(2,3,4)),ROW(1,ROW(2,2))); + +--error 1241 +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1)); +--error 1241 +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1),ROW(1,ROW(2,4))); +--error 1241 +SELECT ROW(1,ROW(2,3)) IN ((SELECT 1,1),ROW(1,ROW(2,3))); + +--error 1241 +SELECT ROW(2,1) IN (ROW(21,2),ROW(ROW(1,1,3),0)); +--error 1241 +SELECT ROW(2,1) IN (ROW(ROW(1,1,3),0),ROW(21,2)); + # End of 4.1 tests # @@ -139,3 +164,20 @@ EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1); SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1); DROP TABLE t1,t2; + +# +# Bug #27154: crash (memory corruption) when using row equalities +# + +CREATE TABLE t1( + a int, b int, c int, d int, e int, f int, g int, h int, + PRIMARY KEY (a,b,c,d,e,f,g) +); +INSERT INTO t1 VALUES (1,2,3,4,5,6,7,99); + +SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7); + +SET @x:= (SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7)); +SELECT @x; + +DROP TABLE t1; diff --git a/mysql-test/t/rpl_dual_pos_advance.test b/mysql-test/t/rpl_dual_pos_advance.test index 518fa9df885..074aeec63b1 100644 --- a/mysql-test/t/rpl_dual_pos_advance.test +++ b/mysql-test/t/rpl_dual_pos_advance.test @@ -106,3 +106,9 @@ connection slave; sync_with_master; # End of 4.1 tests + +# Cleanup +# The A->B->A replication causes the master to start writing relay logs +# in var/run, remove them +remove_file $MYSQLTEST_VARDIR/run/master-relay-bin.000001; +remove_file $MYSQLTEST_VARDIR/run/master-relay-bin.index; diff --git a/mysql-test/t/rpl_ignore_table.test b/mysql-test/t/rpl_ignore_table.test index b875075f71c..79235f0cd4a 100644 --- a/mysql-test/t/rpl_ignore_table.test +++ b/mysql-test/t/rpl_ignore_table.test @@ -29,6 +29,105 @@ DROP TABLE t4; # +# Bug#25482 GRANT statements are not replicated if +# you use "replicate-ignore-table" +# + +--echo **** Test case for BUG#25482 **** +--echo **** Adding GRANTS on master **** + +connection master; +create table test.t1(a int); +create table test.t4(a int); + +# Simple user that should not replicate +GRANT SELECT ON test.t1 TO mysqltest1@localhost; + +# Partial replicate +GRANT INSERT ON test.t4 TO mysqltest2@localhost; +GRANT select, update, insert, references on t1 + to mysqltest2@localhost; + +# Partial replicate 2 +GRANT SELECT ON test.* TO mysqltest3@localhost; +GRANT INSERT ON test.t4 TO mysqltest3@localhost; +GRANT select(a), update(a), insert(a), references(a) on t4 + to mysqltest3@localhost; + +# Create another database and table +create database mysqltest2; +create table mysqltest2.t2 (id int); +# Create a grant that should replicate +GRANT SELECT ON mysqltest2.t2 TO mysqltest4@localhost IDENTIFIED BY 'pass'; + +# Create a grant manually +insert into mysql.user (user, host) values ("mysqltest5", "somehost"); + +# Partial replicate 3 with *.* +GRANT SELECT ON *.* TO mysqltest6@localhost; +GRANT INSERT ON *.* TO mysqltest6@localhost; +GRANT INSERT ON test.* TO mysqltest6@localhost; +GRANT INSERT ON test.t1 TO mysqltest6@localhost; + +show grants for mysqltest1@localhost; +show grants for mysqltest2@localhost; +show grants for mysqltest3@localhost; +show grants for mysqltest4@localhost; +show grants for mysqltest6@localhost; + +flush privileges; +show grants for mysqltest5@somehost; + + +sync_slave_with_master; + +--echo **** Checking grants on slave **** + +# Check that grants are replicated to slave +show grants for mysqltest2@localhost; +show grants for mysqltest3@localhost; +show grants for mysqltest4@localhost; +show grants for mysqltest5@somehost; +show grants for mysqltest6@localhost; + +# mysqltest1 should not be on slave +--error 1141 +show grants for mysqltest1@localhost; + +--echo **** Revoking grants on master **** +connection master; +REVOKE SELECT ON test.t1 FROM mysqltest1@localhost; +REVOKE SELECT ON mysqltest2.t2 FROM mysqltest4@localhost; +REVOKE select(a) on t4 + from mysqltest3@localhost; + +show grants for mysqltest1@localhost; +show grants for mysqltest3@localhost; +show grants for mysqltest4@localhost; + +sync_slave_with_master; + +--echo **** Checking grants on slave **** + +# mysqltest1 should not be on slave +--error 1141 +show grants for mysqltest1@localhost; +show grants for mysqltest3@localhost; +show grants for mysqltest4@localhost; + +# Cleanup +connection master; +drop table t1, t4, mysqltest2.t2; +drop database mysqltest2; +delete from mysql.user where user like "mysqltest%"; +delete from mysql.db where user like "mysqltest%"; +delete from mysql.tables_priv where user like "mysqltest%"; +delete from mysql.columns_priv where user like "mysqltest%"; +sync_slave_with_master; + +connection master; + +# # bug#22877 replication character sets get out of sync # using replicate-wild-ignore-table # diff --git a/mysql-test/t/rpl_misc_functions.test b/mysql-test/t/rpl_misc_functions.test index 6e0bda90503..f00beff583a 100644 --- a/mysql-test/t/rpl_misc_functions.test +++ b/mysql-test/t/rpl_misc_functions.test @@ -28,10 +28,76 @@ create table t2 like t1; eval load data local infile '$MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile' into table t2; # compare them with the replica; the SELECT below should return no row select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p); -stop slave; -drop table t1; connection master; drop table t1; # End of 4.1 tests + +# +# BUG#25543 test calling rand() multiple times on the master in +# a stored procedure. +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (col_a double default NULL); + +DELIMITER |; + +# Use a SP that calls rand() multiple times +CREATE PROCEDURE test_replication_sp1() +BEGIN + INSERT INTO t1 VALUES (rand()), (rand()); + INSERT INTO t1 VALUES (rand()); +END| + +# Use a SP that calls another SP to call rand() multiple times +CREATE PROCEDURE test_replication_sp2() +BEGIN + CALL test_replication_sp1(); + CALL test_replication_sp1(); +END| + +# Use a SF that calls rand() multiple times +CREATE FUNCTION test_replication_sf() RETURNS DOUBLE DETERMINISTIC +BEGIN + RETURN (rand() + rand()); +END| + +DELIMITER ;| + +# Exercise the functions and procedures then compare the results on +# the master to those on the slave. +CALL test_replication_sp1(); +CALL test_replication_sp2(); +INSERT INTO t1 VALUES (test_replication_sf()); +INSERT INTO t1 VALUES (test_replication_sf()); +INSERT INTO t1 VALUES (test_replication_sf()); + +# Record the results of the query on the master +--exec $MYSQL --port=$MASTER_MYPORT test -e "SELECT * FROM test.t1" > $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql + +--sync_slave_with_master + +# Record the results of the query on the slave +--exec $MYSQL --port=$SLAVE_MYPORT test -e "SELECT * FROM test.t1" > $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql + +# Compare the results from the master to the slave. +--exec diff $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql + +# Cleanup +connection master; +--disable_warnings +DROP PROCEDURE IF EXISTS test_replication_sp1; +DROP PROCEDURE IF EXISTS test_replication_sp2; +DROP FUNCTION IF EXISTS test_replication_sf; +DROP TABLE IF EXISTS t1; +--enable_warnings +--sync_slave_with_master + +# If all is good, when can cleanup our dump files. +--system rm $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql +--system rm $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql diff --git a/mysql-test/t/rpl_packet.test b/mysql-test/t/rpl_packet.test index d01979a4731..db6f475dc94 100644 --- a/mysql-test/t/rpl_packet.test +++ b/mysql-test/t/rpl_packet.test @@ -36,4 +36,37 @@ save_master_pos; connection slave; sync_with_master; +# +# Bug #23755: Replicated event larger that max_allowed_packet infinitely re-transmits +# +# Check that a situation when the size of event on the master is greater than +# max_allowed_packet on the slave does not lead to infinite re-transmits. + +connection master; + +# Change the max packet size on master + +SET @@global.max_allowed_packet=4096; +SET @@global.net_buffer_length=4096; + +# Restart slave for new setting to take effect +connection slave; +STOP SLAVE; +START SLAVE; + +# Reconnect to master for new setting to take effect +disconnect master; +connect (master, localhost, root) +connection master; + +CREATE TABLe `t1` (`f1` LONGTEXT) ENGINE=MyISAM; + +INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048'); + +# The slave I/O thread must stop after trying to read the above event +connection slave; +sleep 2; +SHOW STATUS LIKE 'Slave_running'; + + # End of tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index ea5fadb2e1b..56b2f1b02b8 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3103,7 +3103,18 @@ SELECT t3.a FROM t1,t2,t3 t3.c IN ('bb','ee'); DROP TABLE t1,t2,t3; - + +# +# WL3527: Extend IGNORE INDEX so places where index is ignored can +# be specified +# +CREATE TABLE t1 (a INT, b INT, KEY (a)); INSERT INTO t1 VALUES (1,1),(2,2); +EXPLAIN SELECT 1 FROM t1 WHERE a = 1; +EXPLAIN SELECT 1 FROM t1 IGNORE INDEX FOR JOIN (a) WHERE a = 1; +EXPLAIN SELECT 1 FROM t1 USE INDEX FOR JOIN (a) WHERE a = 1; +EXPLAIN SELECT 1 FROM t1 FORCE INDEX FOR JOIN (a) WHERE a = 1; +DROP TABLE t1; + # # Bug#25172: Not checked buffer size leads to a server crash # @@ -3299,4 +3310,64 @@ SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; DROP TABLE t1,t2; + +# +# Bug #26963: join with predicates that contain fields from equalities evaluated +# to constants after constant table substitution +# + +CREATE TABLE t1 ( + access_id int NOT NULL default '0', + name varchar(20) default NULL, + rank int NOT NULL default '0', + KEY idx (access_id) +); + +CREATE TABLE t2 ( + faq_group_id int NOT NULL default '0', + faq_id int NOT NULL default '0', + access_id int default NULL, + UNIQUE KEY idx1 (faq_id), + KEY idx2 (faq_group_id,faq_id) +); + +INSERT INTO t1 VALUES + (1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4); +INSERT INTO t2 VALUES + (261,265,1),(490,494,1); + + +SELECT t2.faq_id + FROM t1 INNER JOIN t2 IGNORE INDEX (idx1) + ON (t1.access_id = t2.access_id) + LEFT JOIN t2 t + ON (t.faq_group_id = t2.faq_group_id AND + find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) + WHERE + t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); + +SELECT t2.faq_id + FROM t1 INNER JOIN t2 + ON (t1.access_id = t2.access_id) + LEFT JOIN t2 t + ON (t.faq_group_id = t2.faq_group_id AND + find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) + WHERE + t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); + +DROP TABLE t1,t2; + + +# +# Bug #19372: Optimizer does not use index anymore when WHERE index NOT IN +# () is added +# +CREATE TABLE t1 (a INT, b INT, KEY inx (b,a)); + +INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7); +EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 + ON ( f1.b=f2.b AND f1.a<f2.a ) + WHERE 1 AND f1.b NOT IN (100,2232,3343,51111); +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/mysql-test/t/skip_grants.test b/mysql-test/t/skip_grants.test index 6dda97fcf8a..75694672a17 100644 --- a/mysql-test/t/skip_grants.test +++ b/mysql-test/t/skip_grants.test @@ -108,3 +108,11 @@ DROP PROCEDURE p3; DROP FUNCTION f1; DROP FUNCTION f2; DROP FUNCTION f3; + +# +# Bug#26285 Selecting information_schema crahes server +# +select count(*) from information_schema.COLUMN_PRIVILEGES; +select count(*) from information_schema.SCHEMA_PRIVILEGES; +select count(*) from information_schema.TABLE_PRIVILEGES; +select count(*) from information_schema.USER_PRIVILEGES; diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test index 4f5f1cdcb9b..13ddaa43fad 100644 --- a/mysql-test/t/sp-destruct.test +++ b/mysql-test/t/sp-destruct.test @@ -7,13 +7,10 @@ # In the case of trouble you might want to skip this. # -# We're using --system things that probably doesn't work on Windows. ---source include/not_windows.inc - # Backup proc table ---system rm -rf $MYSQLTEST_VARDIR/master-data/mysql/backup ---system mkdir $MYSQLTEST_VARDIR/master-data/mysql/backup ---system cp $MYSQLTEST_VARDIR/master-data/mysql/proc.* $MYSQLTEST_VARDIR/master-data/mysql/backup/ +--copy_file $MYSQLTEST_VARDIR/master-data/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/proc.frm +--copy_file $MYSQLTEST_VARDIR/master-data/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/proc.MYD +--copy_file $MYSQLTEST_VARDIR/master-data/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/proc.MYI use test; @@ -45,22 +42,25 @@ insert into t1 values (0); flush table mysql.proc; # Thrashing the .frm file ---system echo 'saljdlfa' > $MYSQLTEST_VARDIR/master-data/mysql/proc.frm ---replace_result $MYSQLTEST_VARDIR . master-data// '' +--write_file $MYSQLTEST_VARDIR/master-data/mysql/proc.frm +saljdfa +EOF +--replace_result $MYSQLTEST_VARDIR . master-data// '' '\\' '/' --error ER_NOT_FORM_FILE call bug14233(); ---replace_result $MYSQLTEST_VARDIR . master-data// '' +--replace_result $MYSQLTEST_VARDIR . master-data// '' '\\' '/' --error ER_NOT_FORM_FILE create view v1 as select bug14233_f(); ---replace_result $MYSQLTEST_VARDIR . master-data// '' +--replace_result $MYSQLTEST_VARDIR . master-data// '' '\\' '/' --error ER_NOT_FORM_FILE insert into t1 values (0); - flush table mysql.proc; # Drop the mysql.proc table ---system rm $MYSQLTEST_VARDIR/master-data/mysql/proc.* +--remove_file $MYSQLTEST_VARDIR/master-data/mysql/proc.frm +--remove_file $MYSQLTEST_VARDIR/master-data/mysql/proc.MYD +--remove_file $MYSQLTEST_VARDIR/master-data/mysql/proc.MYI --error ER_NO_SUCH_TABLE call bug14233(); --error ER_NO_SUCH_TABLE @@ -69,8 +69,12 @@ create view v1 as select bug14233_f(); insert into t1 values (0); # Restore mysql.proc ---system mv $MYSQLTEST_VARDIR/master-data/mysql/backup/* $MYSQLTEST_VARDIR/master-data/mysql/ ---system rmdir $MYSQLTEST_VARDIR/master-data/mysql/backup +--copy_file $MYSQLTEST_VARDIR/tmp/proc.frm $MYSQLTEST_VARDIR/master-data/mysql/proc.frm +--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYD $MYSQLTEST_VARDIR/master-data/mysql/proc.MYD +--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYI $MYSQLTEST_VARDIR/master-data/mysql/proc.MYI +--remove_file $MYSQLTEST_VARDIR/tmp/proc.frm +--remove_file $MYSQLTEST_VARDIR/tmp/proc.MYD +--remove_file $MYSQLTEST_VARDIR/tmp/proc.MYI flush table mysql.proc; flush privileges; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 396c1552e37..9e5c795d586 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -2022,6 +2022,74 @@ drop function func_25345; drop function func_25345_b; # +# Bug#26503 (Illegal SQL exception handler code causes the server to crash) +# + +delimiter //; + +--error ER_SP_LILABEL_MISMATCH +create procedure proc_26503_error_1() +begin +retry: + repeat + begin + declare continue handler for sqlexception + begin + iterate retry; + end + + select "do something"; + end + until true end repeat retry; +end// + +--error ER_SP_LILABEL_MISMATCH +create procedure proc_26503_error_2() +begin +retry: + repeat + begin + declare continue handler for sqlexception + iterate retry; + + select "do something"; + end + until true end repeat retry; +end// + +--error ER_SP_LILABEL_MISMATCH +create procedure proc_26503_error_3() +begin +retry: + repeat + begin + declare continue handler for sqlexception + begin + leave retry; + end + + select "do something"; + end + until true end repeat retry; +end// + +--error ER_SP_LILABEL_MISMATCH +create procedure proc_26503_error_4() +begin +retry: + repeat + begin + declare continue handler for sqlexception + leave retry; + + select "do something"; + end + until true end repeat retry; +end// + +delimiter ;// + +# # BUG#NNNN: New bug synopsis # #--disable_warnings diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 9af24ee0337..8403c8589ef 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -6592,6 +6592,47 @@ call proc_bug19733()| drop procedure proc_bug19733| drop table t3| + +# +# BUG#20492: Subsequent calls to stored procedure yeild incorrect +# result if join is used +# +# Optimized ON expression in join wasn't properly saved for reuse. +# +--disable_warnings +DROP PROCEDURE IF EXISTS p1| +DROP VIEW IF EXISTS v1, v2| +DROP TABLE IF EXISTS t3, t4| +--enable_warnings + +CREATE TABLE t3 (t3_id INT)| + +INSERT INTO t3 VALUES (0)| +INSERT INTO t3 VALUES (1)| + +CREATE TABLE t4 (t4_id INT)| + +INSERT INTO t4 VALUES (2)| + +CREATE VIEW v1 AS +SELECT t3.t3_id, t4.t4_id +FROM t3 JOIN t4 ON t3.t3_id = 0| + +CREATE VIEW v2 AS +SELECT t3.t3_id AS t3_id_1, v1.t3_id AS t3_id_2, v1.t4_id +FROM t3 LEFT JOIN v1 ON t3.t3_id = 0| + +CREATE PROCEDURE p1() SELECT * FROM v2| + +# Results should not differ. +CALL p1()| +CALL p1()| + +DROP PROCEDURE p1| +DROP VIEW v1, v2| +DROP TABLE t3, t4| + + --echo End of 5.0 tests @@ -6739,6 +6780,141 @@ drop function func_8407_a| drop function func_8407_b| # +# Bug#26503 (Illegal SQL exception handler code causes the server to crash) +# + +--disable_warnings +drop table if exists table_26503| +drop procedure if exists proc_26503_ok_1| +drop procedure if exists proc_26503_ok_2| +drop procedure if exists proc_26503_ok_3| +drop procedure if exists proc_26503_ok_4| +--enable_warnings + +create table table_26503(a int unique)| + +create procedure proc_26503_ok_1(v int) +begin + declare i int default 5; + + declare continue handler for sqlexception + begin + select 'caught something'; + retry: + while i > 0 do + begin + set i = i - 1; + select 'looping', i; + iterate retry; + select 'dead code'; + end; + end while retry; + select 'leaving handler'; + end; + + select 'do something'; + insert into table_26503 values (v); + select 'do something again'; + insert into table_26503 values (v); +end| + +create procedure proc_26503_ok_2(v int) +begin + declare i int default 5; + + declare continue handler for sqlexception + begin + select 'caught something'; + retry: + while i > 0 do + begin + set i = i - 1; + select 'looping', i; + leave retry; + select 'dead code'; + end; + end while; + select 'leaving handler'; + end; + + select 'do something'; + insert into table_26503 values (v); + select 'do something again'; + insert into table_26503 values (v); +end| + +## The outer retry label should not prevent using the inner label. + +create procedure proc_26503_ok_3(v int) +begin + declare i int default 5; + +retry: + begin + declare continue handler for sqlexception + begin + select 'caught something'; + retry: + while i > 0 do + begin + set i = i - 1; + select 'looping', i; + iterate retry; + select 'dead code'; + end; + end while retry; + select 'leaving handler'; + end; + + select 'do something'; + insert into table_26503 values (v); + select 'do something again'; + insert into table_26503 values (v); + end; +end| + +## The outer retry label should not prevent using the inner label. + +create procedure proc_26503_ok_4(v int) +begin + declare i int default 5; + +retry: + begin + declare continue handler for sqlexception + begin + select 'caught something'; + retry: + while i > 0 do + begin + set i = i - 1; + select 'looping', i; + leave retry; + select 'dead code'; + end; + end while; + select 'leaving handler'; + end; + + select 'do something'; + insert into table_26503 values (v); + select 'do something again'; + insert into table_26503 values (v); + end; +end| + +call proc_26503_ok_1(1)| +call proc_26503_ok_2(2)| +call proc_26503_ok_3(3)| +call proc_26503_ok_4(4)| + +drop table table_26503| +drop procedure proc_26503_ok_1| +drop procedure proc_26503_ok_2| +drop procedure proc_26503_ok_3| +drop procedure proc_26503_ok_4| + +# # Bug#25373: Stored functions wasn't compared correctly which leads to a wrong # result. # @@ -6754,9 +6930,54 @@ SELECT SUM(f2), bug25373(f1) FROM t3 GROUP BY bug25373(f1) WITH ROLLUP| DROP FUNCTION bug25373| DROP TABLE t3| # -# NOTE: The delimiter is `|`, and not `;`. It is changed to `;` -# at the end of the file! -# +# Bug#20777: Function w BIGINT UNSIGNED shows diff. behaviour --ps-protocol +--disable_warnings +drop function if exists bug20777| +drop table if exists examplebug20777| +--enabled_warnings +create function bug20777(f1 bigint unsigned) returns bigint unsigned +begin + set f1 = (f1 - 10); set f1 = (f1 + 10); +return f1; +end| +delimiter ;| +select bug20777(9223372036854775803) as '9223372036854775803 2**63-5'; +select bug20777(9223372036854775804) as '9223372036854775804 2**63-4'; +select bug20777(9223372036854775805) as '9223372036854775805 2**63-3'; +select bug20777(9223372036854775806) as '9223372036854775806 2**63-2'; +select bug20777(9223372036854775807) as '9223372036854775807 2**63-1'; +select bug20777(9223372036854775808) as '9223372036854775808 2**63+0'; +select bug20777(9223372036854775809) as '9223372036854775809 2**63+1'; +select bug20777(9223372036854775810) as '9223372036854775810 2**63+2'; +select bug20777(-9223372036854775808) as 'lower bounds signed bigint'; +select bug20777(9223372036854775807) as 'upper bounds signed bigint'; +select bug20777(0) as 'lower bounds unsigned bigint'; +select bug20777(18446744073709551615) as 'upper bounds unsigned bigint'; +select bug20777(18446744073709551616) as 'upper bounds unsigned bigint + 1'; +select bug20777(-1) as 'lower bounds unsigned bigint - 1'; + +create table examplebug20777 as select + 0 as 'i', + bug20777(9223372036854775806) as '2**63-2', + bug20777(9223372036854775807) as '2**63-1', + bug20777(9223372036854775808) as '2**63', + bug20777(9223372036854775809) as '2**63+1', + bug20777(18446744073709551614) as '2**64-2', + bug20777(18446744073709551615) as '2**64-1', + bug20777(18446744073709551616) as '2**64', + bug20777(0) as '0', + bug20777(-1) as '-1'; +insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616, 0, -1); +show create table examplebug20777; +select * from examplebug20777 order by i; + +drop table examplebug20777; +select bug20777(18446744073709551613)+1; +drop function bug20777; +delimiter |; + +### +--echo End of 5.0 tests. # # BUG#NNNN: New bug synopsis @@ -6765,8 +6986,13 @@ DROP TABLE t3| #drop procedure if exists bugNNNN| #--enable_warnings #create procedure bugNNNN... - +# # Add bugs above this line. Use existing tables t1 and t2 when -# practical, or create table t3, t4 etc temporarily (and drop them). +# practical, or create table t3,t4 etc temporarily (and drop them). +# NOTE: The delimiter is `|`, and not `;`. It is changed to `;` +# at the end of the file! +# + delimiter ;| drop table t1,t2; + diff --git a/mysql-test/t/ssl_des-master.opt b/mysql-test/t/ssl_des-master.opt deleted file mode 100644 index 0b2b8cb85ac..00000000000 --- a/mysql-test/t/ssl_des-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose_ssl-cert=std_data/server-cert-des.pem --loose_ssl-key=std_data/server-key-des.pem diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index 224a7422de1..1792c0fccbc 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -14,7 +14,6 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (col1 date); INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29'); ---error 1292 INSERT INTO t1 VALUES('0000-10-31'); # All test cases expected to fail should return @@ -100,7 +99,6 @@ set @@sql_mode='ansi,traditional'; CREATE TABLE t1 (col1 datetime); INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00'); ---error 1292 INSERT INTO t1 VALUES('0000-10-31 15:30:00'); # All test cases expected to fail should return @@ -194,7 +192,6 @@ INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i')); # All test cases expected to fail should return # SQLSTATE 22007 <invalid date value> ---error 1292 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i')); --error 1292 @@ -216,7 +213,6 @@ INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y')); # All test cases expected to fail should return # SQLSTATE 22007 <invalid datetime value> ---error 1292 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i')); --error 1292 @@ -271,7 +267,6 @@ INSERT INTO t1 (col3) VALUES (CAST('2004-10-15 10:15' AS DATETIME)); # All test cases expected to fail should return # SQLSTATE 22007 <invalid date value> ---error 1292 INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE)); --error 1292 @@ -299,7 +294,6 @@ INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE)); # All test cases expected to fail should return # SQLSTATE 22007 <invalid datetime value> ---error 1292 INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME)); --error 1292 @@ -367,7 +361,6 @@ INSERT INTO t1 (col3) VALUES (CONVERT('2004-10-15 10:15',DATETIME)); # All test cases expected to fail should return # SQLSTATE 22007 <invalid date value> ---error 1292 INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE)); --error 1292 @@ -394,7 +387,6 @@ INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE)); # All test cases expected to fail should return # SQLSTATE 22007 <invalid datetime value> ---error 1292 INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME)); --error 1292 @@ -1208,3 +1200,62 @@ create table t1 (i int) comment '123456789*123456789*123456789*123456789*123456789*123456789*'; show create table t1; drop table t1; + +# +# Bug #26359: Strings becoming truncated and converted to numbers under STRICT mode +# +set sql_mode= 'traditional'; +create table t1(col1 tinyint, col2 tinyint unsigned, + col3 smallint, col4 smallint unsigned, + col5 mediumint, col6 mediumint unsigned, + col7 int, col8 int unsigned, + col9 bigint, col10 bigint unsigned); +--error 1366 +insert into t1(col1) values('-'); +--error 1366 +insert into t1(col2) values('+'); +--error 1366 +insert into t1(col3) values('-'); +--error 1366 +insert into t1(col4) values('+'); +--error 1366 +insert into t1(col5) values('-'); +--error 1366 +insert into t1(col6) values('+'); +--error 1366 +insert into t1(col7) values('-'); +--error 1366 +insert into t1(col8) values('+'); +--error 1366 +insert into t1(col9) values('-'); +--error 1366 +insert into t1(col10) values('+'); +drop table t1; + +# +# Bug #27176: Assigning a string to an year column has unexpected results +# +set sql_mode='traditional'; +create table t1(a year); +--error 1366 +insert into t1 values ('-'); +--error 1366 +insert into t1 values ('+'); +--error 1366 +insert into t1 values (''); +--error 1265 +insert into t1 values ('2000a'); +--error 1265 +insert into t1 values ('2E3x'); +drop table t1; + +# +# Bug#27069 set with identical elements are created +# +set sql_mode='traditional'; +--error 1291 +create table t1 (f1 set('a','a')); +--error 1291 +create table t1 (f1 enum('a','a')); + +--echo End of 5.0 tests diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 1deda2a4382..482b3e883e6 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2729,3 +2729,119 @@ DROP TABLE t1; DROP TABLE t2; DROP TABLE t1xt2; +# +# Bug #26728: derived table with concatanation of literals in select list +# + +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (3), (1), (2); + +SELECT 'this is ' 'a test.' AS col1, a AS col2 FROM t1; +SELECT * FROM (SELECT 'this is ' 'a test.' AS col1, a AS t2 FROM t1) t; + +DROP table t1; + +# +# Bug #27257: COUNT(*) aggregated in outer query +# + +CREATE TABLE t1 (a int, b int); +CREATE TABLE t2 (m int, n int); +INSERT INTO t1 VALUES (2,2), (2,2), (3,3), (3,3), (3,3), (4,4); +INSERT INTO t2 VALUES (1,11), (2,22), (3,32), (4,44), (4,44); + +SELECT COUNT(*), a, + (SELECT m FROM t2 WHERE m = count(*) LIMIT 1) + FROM t1 GROUP BY a; + +SELECT COUNT(*), a, + (SELECT MIN(m) FROM t2 WHERE m = count(*)) + FROM t1 GROUP BY a; + +SELECT COUNT(*), a + FROM t1 GROUP BY a + HAVING (SELECT MIN(m) FROM t2 WHERE m = count(*)) > 1; + +DROP TABLE t1,t2; + +# +# Bug #27229: GROUP_CONCAT in subselect with COUNT() as an argument +# + +CREATE TABLE t1 (a int, b int); +CREATE TABLE t2 (m int, n int); +INSERT INTO t1 VALUES (2,2), (2,2), (3,3), (3,3), (3,3), (4,4); +INSERT INTO t2 VALUES (1,11), (2,22), (3,32), (4,44), (4,44); + +SELECT COUNT(*) c, a, + (SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a) + FROM t1 GROUP BY a; + +SELECT COUNT(*) c, a, + (SELECT GROUP_CONCAT(COUNT(a)+1) FROM t2 WHERE m = a) + FROM t1 GROUP BY a; + +DROP table t1,t2; + +# +# Bug#27321: Wrong subquery result in a grouping select +# +CREATE TABLE t1 (a int, b INT, d INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b)); +INSERT INTO t1 VALUES (1,1,0,'a'), (1,2,0,'b'), (1,3,0,'c'), (1,4,0,'d'), +(1,5,0,'e'), (2,1,0,'f'), (2,2,0,'g'), (2,3,0,'h'), (3,4,0,'i'), (3,3,0,'j'), +(3,2,0,'k'), (3,1,0,'l'), (1,9,0,'m'), (1,0,10,'n'), (2,0,5,'o'), (3,0,7,'p'); + +SELECT a, MAX(b), + (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b + 0)) as test + FROM t1 GROUP BY a; +SELECT a x, MAX(b), + (SELECT t.c FROM t1 AS t WHERE x=t.a AND t.b=MAX(t1.b + 0)) as test + FROM t1 GROUP BY a; +SELECT a, AVG(b), + (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=AVG(t1.b)) AS test + FROM t1 WHERE t1.d=0 GROUP BY a; + +SELECT tt.a, + (SELECT (SELECT c FROM t1 as t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a) + LIMIT 1) FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test + FROM t1 as tt; + +SELECT tt.a, + (SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a) + LIMIT 1) + FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test + FROM t1 as tt GROUP BY tt.a; + +SELECT tt.a, MAX( + (SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a) + LIMIT 1) + FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1)) as test + FROM t1 as tt GROUP BY tt.a; + +DROP TABLE t1; +# +# Bug #27348: SET FUNCTION used in a subquery from WHERE condition +# + +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (2,22),(1,11),(2,22); + +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a; +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a; + +SELECT a FROM t1 t0 + WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a; + +SET @@sql_mode='ansi'; +--error 1111 +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a; +--error 1111 +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a; + +--error 1111 +SELECT a FROM t1 t0 + WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a; + +SET @@sql_mode=default; + +DROP TABLE t1; diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test index ed8480ba464..11468cd6759 100644 --- a/mysql-test/t/subselect3.test +++ b/mysql-test/t/subselect3.test @@ -489,3 +489,42 @@ select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1; drop table t1,t2; +# +# Bug #24484: Aggregate function used in column list subquery gives erroneous +# error +# +CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b)); +INSERT INTO t1 VALUES (1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'), + (2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'),(3,3,'j'), (3,2,'k'), (3,1,'l'), + (1,9,'m'); +CREATE TABLE t2 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b)); +INSERT INTO t2 SELECT * FROM t1; + +# Gives error, but should work since it is (a, b) is the PK so only one +# given match possible +SELECT a, MAX(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)) + as test FROM t1 GROUP BY a; +SELECT * FROM t1 GROUP by t1.a + HAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.c + HAVING MAX(t2.b+t1.a) < 10)); + +SELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c; + +SELECT a, MAX(b), + (SELECT COUNT(DISTINCT t.c) FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) + LIMIT 1) + as cnt, + (SELECT t.b FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) + as t_b, + (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) + as t_b, + (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) ORDER BY t.c LIMIT 1) + as t_b + FROM t1 GROUP BY a; + +SELECT a, MAX(b), + (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) as test + FROM t1 GROUP BY a; + + +DROP TABLE t1, t2; diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test index 8cb9e34ca08..90f868f5932 100644 --- a/mysql-test/t/temp_table.test +++ b/mysql-test/t/temp_table.test @@ -163,3 +163,19 @@ DROP TABLE t1; --echo End of 4.1 tests. + +# +# Bug #24791: Union with AVG-groups generates wrong results +# +CREATE TABLE t1 ( c FLOAT( 20, 14 ) ); +INSERT INTO t1 VALUES( 12139 ); + +CREATE TABLE t2 ( c FLOAT(30,18) ); +INSERT INTO t2 VALUES( 123456 ); + +SELECT AVG( c ) FROM t1 UNION SELECT 1; +SELECT 1 UNION SELECT AVG( c ) FROM t1; +SELECT 1 UNION SELECT * FROM t2 UNION SELECT 1; +SELECT c/1 FROM t1 UNION SELECT 1; + +DROP TABLE t1, t2; diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 5c95004c901..a01efba11db 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1699,4 +1699,42 @@ DROP TABLE bug22580_t1; DROP PROCEDURE bug22580_proc_1; DROP PROCEDURE bug22580_proc_2; +# +# Bug#27006: AFTER UPDATE triggers not fired with INSERT ... ON DUPLICATE +# +--disable_warnings +DROP TRIGGER IF EXISTS trg27006_a_update; +DROP TRIGGER IF EXISTS trg27006_a_insert; +--enable_warnings + +CREATE TABLE t1 ( + `id` int(10) unsigned NOT NULL auto_increment, + `val` varchar(10) NOT NULL, + PRIMARY KEY (`id`) +); +CREATE TABLE t2 like t1; +DELIMITER |; + +CREATE TRIGGER trg27006_a_insert AFTER INSERT ON t1 FOR EACH ROW +BEGIN + insert into t2 values (NULL,new.val); +END | +CREATE TRIGGER trg27006_a_update AFTER UPDATE ON t1 FOR EACH ROW +BEGIN + insert into t2 values (NULL,new.val); +END | +DELIMITER ;| + +INSERT INTO t1(val) VALUES ('test1'),('test2'); +SELECT * FROM t1; +SELECT * FROM t2; +INSERT INTO t1 VALUES (2,'test2') ON DUPLICATE KEY UPDATE val=VALUES(val); +INSERT INTO t1 VALUES (2,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val); +INSERT INTO t1 VALUES (3,'test4') ON DUPLICATE KEY UPDATE val=VALUES(val); +SELECT * FROM t1; +SELECT * FROM t2; +DROP TRIGGER trg27006_a_insert; +DROP TRIGGER trg27006_a_update; +drop table t1,t2; + --echo End of 5.0 tests diff --git a/mysql-test/t/truncate.test b/mysql-test/t/truncate.test index f806bd8ec17..ba5364bd324 100644 --- a/mysql-test/t/truncate.test +++ b/mysql-test/t/truncate.test @@ -52,3 +52,20 @@ SELECT * from t1; drop table t1; # End of 4.1 tests + +# Test for Bug#5507 "TRUNCATE should work with views" +# +# when it'll be fixed, the error should become 1347 +# (test.v1' is not BASE TABLE) +# + +create table t1 (s1 int); +insert into t1 (s1) values (1), (2), (3), (4), (5); +create view v1 as select * from t1; +--error 1146 +truncate table v1; +drop view v1; +drop table t1; + +# End of 5.0 tests + diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index 3ad6bdc53e4..3d04eb85cf3 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -113,6 +113,12 @@ insert into t1 values ("00-00-00"), ("00-00-00 00:00:00"); select * from t1; drop table t1; +# +# Bug #16546 DATETIME+0 not always coerced the same way +# +select cast('2006-12-05 22:10:10' as datetime) + 0; + + # End of 4.1 tests # diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index f315e88fd0e..4c6098d2121 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -1120,3 +1120,14 @@ drop table t1; # select cast(19999999999999999999 as unsigned); +# +# Bug #24558: Increasing decimal column length causes data loss +# + +create table t1(a decimal(18)); +insert into t1 values(123456789012345678); +alter table t1 modify column a decimal(19); +select * from t1; +drop table t1; + +--echo End of 5.0 tests diff --git a/mysql-test/t/type_set.test b/mysql-test/t/type_set.test index 56df3328246..b1c816f3371 100644 --- a/mysql-test/t/type_set.test +++ b/mysql-test/t/type_set.test @@ -39,3 +39,20 @@ SELECT c FROM t1 ORDER BY concat(c); DROP TABLE t1; # End of 4.1 tests + +# +# Bug#27069 set with identical elements are created +# +--error 1097 +create table t1(f1 +set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17', +'18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33', +'34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49', +'50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','128')); +create table t1(f1 +set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17', +'18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33', +'34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49', +'50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','1')); +show create table t1; +drop table t1; diff --git a/mysql-test/t/type_year.test b/mysql-test/t/type_year.test index 9744da24c02..0e174a556d6 100644 --- a/mysql-test/t/type_year.test +++ b/mysql-test/t/type_year.test @@ -21,4 +21,12 @@ insert into t1 values (now()); select if(y = now(), 1, 0) from t1; drop table t1; -# End of 4.1 tests +# +# Bug #27176: Assigning a string to an year column has unexpected results +# +create table t1(a year); +insert into t1 values (2000.5), ('2000.5'), ('2001a'), ('2.001E3'); +select * from t1; +drop table t1; + +--echo End of 5.0 tests diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 29a9ee36481..22f09466b1c 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -868,4 +868,13 @@ SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test; DROP TABLE t1; +# +# Bug#23345: Wrongly allowed INTO in a non-last select of a UNION. +# +--error 1221 +(select 1 into @var) union (select 1); +(select 1) union (select 1 into @var); +select @var; +--error 1172 +(select 2) union (select 1 into @var); --echo End of 5.0 tests diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 1b229298896..920fcee3b24 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2228,6 +2228,8 @@ REPAIR TABLE v1; DROP TABLE t1; OPTIMIZE TABLE v1; +ANALYZE TABLE v1; +REPAIR TABLE v1; DROP VIEW v1; diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test index 0785b74dd47..b45afe4f312 100644 --- a/mysql-test/t/view_grant.test +++ b/mysql-test/t/view_grant.test @@ -1034,5 +1034,36 @@ DROP DATABASE mysqltest_db2; DROP USER mysqltest_u1@localhost; DROP USER mysqltest_u2@localhost; +# +# Bug#26813: The SUPER privilege is wrongly required to alter a view created +# by another user. +# +connection root; +CREATE DATABASE db26813; +USE db26813; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE VIEW v1 AS SELECT f1 FROM t1; +CREATE VIEW v2 AS SELECT f1 FROM t1; +CREATE VIEW v3 AS SELECT f1 FROM t1; +CREATE USER u26813@localhost; +GRANT DROP ON db26813.v1 TO u26813@localhost; +GRANT CREATE VIEW ON db26813.v2 TO u26813@localhost; +GRANT DROP, CREATE VIEW ON db26813.v3 TO u26813@localhost; +GRANT SELECT ON db26813.t1 TO u26813@localhost; + +connect (u1,localhost,u26813,,db26813); +connection u1; +--error 1142 +ALTER VIEW v1 AS SELECT f2 FROM t1; +--error 1142 +ALTER VIEW v2 AS SELECT f2 FROM t1; +ALTER VIEW v3 AS SELECT f2 FROM t1; + +connection root; +SHOW CREATE VIEW v3; + +DROP USER u26813@localhost; +DROP DATABASE db26813; +disconnect u1; --echo End of 5.0 tests. diff --git a/mysql-test/t/wait_for_socket.sh b/mysql-test/t/wait_for_socket.sh index 8c17c8ac0ac..2fa7d5c5b7e 100755 --- a/mysql-test/t/wait_for_socket.sh +++ b/mysql-test/t/wait_for_socket.sh @@ -61,7 +61,7 @@ fi ########################################################################### -client_args="--silent --socket=$socket_path --connect_timeout=1 " +client_args="--no-defaults --silent --socket=$socket_path --connect_timeout=1 " [ -n "$username" ] && client_args="$client_args --user=$username " [ -n "$password" ] && client_args="$client_args --password=$password " |