Commit fc7f407a authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.0-rpl

into  maint1.mysql.com:/data/localhome/tsmith/bk/maint/50


mysql-test/t/innodb.test:
  Auto merged
mysql-test/r/innodb.result:
  Manual merge
parents 12e1a9df 0e99d690
# include/wait_for_slave_param.inc
#
# SUMMARY
#
# Waits until SHOW SLAVE STATUS has returned a spicified value.
#
# USAGE
#
# let $slave_param= Slave_SQL_Running;
# let $slave_param_value= No;
# --source include/slave_wait_param.inc
let $slave_wait_param_counter= 300;
let $slave_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
while (`select "$slave_value" != "$slave_param_value"`)
{
dec $slave_wait_param_counter;
if (!$slave_wait_param_counter)
{
--echo ERROR: failed while waiting for slave parameter $slave_param: $slave_param_value
query_vertical show slave status;
exit;
}
sleep 0.1;
let $slave_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
}
......@@ -547,72 +547,87 @@ sub mtr_kill_leftovers () {
}
# Check that all processes in list are killed
# The argument is a list of 'ports', 'pids', 'pidfiles' and 'socketfiles'
# for which shutdown has been started. Make sure they all get killed
# in one way or the other.
#
# FIXME On Cygwin, and maybe some other platforms, $srv->{'pid'} and
# the pid in $srv->{'pidfile'} will not be the same PID. We need to try to kill
# both I think.
# Check that all processes in "spec" are shutdown gracefully
# else kill them off hard
#
sub mtr_check_stop_servers ($) {
my $spec= shift;
# Return if no processes are defined
return if ! @$spec;
#mtr_report("mtr_check_stop_servers");
mtr_verbose("mtr_check_stop_servers");
# ----------------------------------------------------------------------
# Wait until servers in "spec" has stopped listening
# to their ports or timeout occurs
# ----------------------------------------------------------------------
mtr_ping_with_timeout(\@$spec);
# ----------------------------------------------------------------------
# We loop with waitpid() nonblocking to see how many of the ones we
# are to kill, actually got killed by mysqladmin or ndb_mgm
#
# Note that we don't rely on this, the mysqld server might have stopped
# listening to the port, but still be alive. But it is a start.
# Use waitpid() nonblocking for a little while, to see how
# many process's will exit sucessfully.
# This is the normal case.
# ----------------------------------------------------------------------
my $wait_counter= 50; # Max number of times to redo the loop
foreach my $srv ( @$spec )
{
my $pid= $srv->{'pid'};
my $ret_pid;
if ( $srv->{'pid'} )
if ( $pid )
{
$ret_pid= waitpid($srv->{'pid'},&WNOHANG);
if ($ret_pid == $srv->{'pid'})
$ret_pid= waitpid($pid,&WNOHANG);
if ($ret_pid == $pid)
{
mtr_verbose("Caught exit of process $ret_pid");
$srv->{'pid'}= 0;
}
elsif ($ret_pid == 0)
{
mtr_verbose("Process $pid is still alive");
if ($wait_counter-- > 0)
{
# Give the processes more time to exit
select(undef, undef, undef, (0.1));
redo;
}
}
else
{
# mtr_warning("caught exit of unknown child $ret_pid");
mtr_warning("caught exit of unknown child $ret_pid");
}
}
}
# ----------------------------------------------------------------------
# We know the process was started from this file, so there is a PID
# saved, or else we have nothing to do.
# Might be that is is recorded to be missing, but we failed to
# take away the PID file earlier, then we do it now.
# The processes that haven't yet exited need to
# be killed hard, put them in "kill_pids" hash
# ----------------------------------------------------------------------
my %mysqld_pids;
my %kill_pids;
foreach my $srv ( @$spec )
{
if ( $srv->{'pid'} )
my $pid= $srv->{'pid'};
if ( $pid )
{
$mysqld_pids{$srv->{'pid'}}= 1;
# Server is still alive, put it in list to be hard killed
$kill_pids{$pid}= 1;
# Write a message to the process's error log (if it has one)
# that it's being killed hard.
if ( defined $srv->{'errfile'} )
{
mtr_tofile($srv->{'errfile'}, "Note: Forcing kill of process $pid\n");
}
mtr_warning("Forcing kill of process $pid");
}
else
{
# Server is dead, we remove the pidfile if any
# Race, could have been removed between I tested with -f
# and the unlink() below, so I better check again with -f
# Server is dead, remove the pidfile if it exists
#
# Race, could have been removed between test with -f
# and the unlink() below, so better check again with -f
if ( -f $srv->{'pidfile'} and ! unlink($srv->{'pidfile'}) and
-f $srv->{'pidfile'} )
{
......@@ -621,69 +636,35 @@ sub mtr_check_stop_servers ($) {
}
}
# ----------------------------------------------------------------------
# If all the processes in list already have been killed,
# then we don't have to do anything.
# ----------------------------------------------------------------------
if ( ! keys %mysqld_pids )
if ( ! keys %kill_pids )
{
# All processes has exited gracefully
return;
}
# ----------------------------------------------------------------------
# In mtr_mysqladmin_shutdown() we only waited for the mysqld servers
# not to listen to the port. But we are not sure we got them all
# killed. If we suspect it lives, try nice kill with SIG_TERM. Note
# that for true Win32 processes, kill(0,$pid) will not return 1.
# ----------------------------------------------------------------------
start_reap_all(); # Avoid zombies
my @mysqld_pids= keys %mysqld_pids;
mtr_kill_processes(\@mysqld_pids);
stop_reap_all(); # Get into control again
mtr_kill_processes(\%kill_pids);
# ----------------------------------------------------------------------
# Now, we check if all we can find using kill(0,$pid) are dead,
# and just assume the rest are. We cleanup socket and PID files.
# All processes are killed, cleanup leftover files
# ----------------------------------------------------------------------
{
my $errors= 0;
foreach my $srv ( @$spec )
{
if ( $srv->{'pid'} )
{
if ( kill(0,$srv->{'pid'}) )
{
# FIXME In Cygwin there seem to be some fast reuse
# of PIDs, so dying may not be the right thing to do.
$errors++;
mtr_warning("can't kill process $srv->{'pid'}");
}
else
# Server has been hard killed, clean it's resources
foreach my $file ($srv->{'pidfile'}, $srv->{'sockfile'})
{
# We managed to kill it at last
# FIXME In Cygwin, we will get here even if the process lives.
# Not needed as we know the process is dead, but to be safe
# we unlink and check success in two steps. We first unlink
# without checking the error code, and then check if the
# file still exists.
foreach my $file ($srv->{'pidfile'}, $srv->{'sockfile'})
# Know it is dead so should be no race, careful anyway
if ( defined $file and -f $file and ! unlink($file) and -f $file )
{
# Know it is dead so should be no race, careful anyway
if ( defined $file and -f $file and ! unlink($file) and -f $file )
{
$errors++;
mtr_warning("couldn't delete $file");
}
}
$srv->{'pid'}= 0;
}
$errors++;
mtr_warning("couldn't delete $file");
}
}
$srv->{'pid'}= 0;
}
}
if ( $errors )
......@@ -701,12 +682,9 @@ sub mtr_check_stop_servers ($) {
}
}
}
# FIXME We just assume they are all dead, for Cygwin we are not
# really sure
}
# Wait for all the process in the list to terminate
sub mtr_wait_blocking($) {
my $admin_pids= shift;
......@@ -1095,9 +1073,9 @@ sub sleep_until_file_created ($$$) {
sub mtr_kill_processes ($) {
my $pids = shift;
mtr_verbose("mtr_kill_processes " . join(" ", @$pids));
mtr_verbose("mtr_kill_processes (" . join(" ", keys %{$pids}) . ")");
foreach my $pid (@$pids)
foreach my $pid (keys %{$pids})
{
if ($pid <= 0)
......@@ -1106,11 +1084,26 @@ sub mtr_kill_processes ($) {
next;
}
foreach my $sig (15, 9)
my $signaled_procs= kill(9, $pid);
if ($signaled_procs == 0)
{
last if mtr_im_kill_process([ $pid ], $sig, 10, 1);
# No such process existed, assume it's killed
mtr_verbose("killed $pid(no such process)");
}
else
{
my $ret_pid= waitpid($pid,0);
if ($ret_pid == $pid)
{
mtr_verbose("killed $pid(got the pid)");
}
elsif ($ret_pid == -1)
{
mtr_verbose("killed $pid(got -1)");
}
}
}
mtr_verbose("done killing processes");
}
......
......@@ -272,6 +272,7 @@ sub mtr_report_stats ($) {
{
foreach my $errlog ( sort glob("$::opt_vardir/log/*.err") )
{
my $testname= "";
unless ( open(ERR, $errlog) )
{
mtr_warning("can't read $errlog");
......@@ -287,10 +288,14 @@ sub mtr_report_stats ($) {
{
next; # Skip these lines
}
if ( /CURRENT_TEST: (.*)/ )
{
$testname= $1;
}
if ( /$pattern/ )
{
$found_problems= 1;
print WARN $_;
print WARN basename($errlog) . ": $testname: $_";
}
}
}
......
......@@ -3318,9 +3318,12 @@ sub find_testcase_skipped_reason($)
{
my ($tinfo)= @_;
# Open mysqltest-time
my $F= IO::File->new($path_timefile) or
mtr_error("can't open file \"$path_timefile\": $!");
# Set default message
$tinfo->{'comment'}= "Detected by testcase(no log file)";
# Open mysqltest-time(the mysqltest log file)
my $F= IO::File->new($path_timefile)
or return;
my $reason;
while ( my $line= <$F> )
......@@ -3373,8 +3376,8 @@ sub analyze_testcase_failure($)
my ($tinfo)= @_;
# Open mysqltest.log
my $F= IO::File->new($path_timefile) or
mtr_error("can't open file \"$path_timefile\": $!");
my $F= IO::File->new($path_timefile)
or return;
while ( my $line= <$F> )
{
......@@ -4093,6 +4096,7 @@ sub stop_all_servers () {
pidfile => $mysqld->{'path_pid'},
sockfile => $mysqld->{'path_sock'},
port => $mysqld->{'port'},
errfile => $mysqld->{'path_myerr'},
});
$mysqld->{'pid'}= 0; # Assume we are done with it
......@@ -4299,6 +4303,7 @@ sub run_testcase_stop_servers($$$) {
pidfile => $mysqld->{'path_pid'},
sockfile => $mysqld->{'path_sock'},
port => $mysqld->{'port'},
errfile => $mysqld->{'path_myerr'},
});
$mysqld->{'pid'}= 0; # Assume we are done with it
......@@ -4349,6 +4354,7 @@ sub run_testcase_stop_servers($$$) {
pidfile => $mysqld->{'path_pid'},
sockfile => $mysqld->{'path_sock'},
port => $mysqld->{'port'},
errfile => $mysqld->{'path_myerr'},
});
......
show status like "binlog_cache_use";
Variable_name Value
Binlog_cache_use 0
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 0
create table t1 (a int) engine=innodb;
show status like "binlog_cache_use";
Variable_name Value
Binlog_cache_use 1
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 1
begin;
delete from t1;
commit;
show status like "binlog_cache_use";
Variable_name Value
Binlog_cache_use 2
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 1
drop table t1;
......@@ -1673,29 +1673,6 @@ t2 CREATE TABLE `t2` (
CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t2, t1;
show status like "binlog_cache_use";
Variable_name Value
Binlog_cache_use 158
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 0
create table t1 (a int) engine=innodb;
show status like "binlog_cache_use";
Variable_name Value
Binlog_cache_use 159
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 1
begin;
delete from t1;
commit;
show status like "binlog_cache_use";
Variable_name Value
Binlog_cache_use 160
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 1
drop table t1;
create table t1 (c char(10), index (c,c)) engine=innodb;
ERROR 42S21: Duplicate column name 'c'
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
......@@ -1815,10 +1792,10 @@ Variable_name Value
Innodb_page_size 16384
show status like "Innodb_rows_deleted";
Variable_name Value
Innodb_rows_deleted 2072
Innodb_rows_deleted 72
show status like "Innodb_rows_inserted";
Variable_name Value
Innodb_rows_inserted 31732
Innodb_rows_inserted 29732
show status like "Innodb_rows_updated";
Variable_name Value
Innodb_rows_updated 29532
......
......@@ -339,6 +339,7 @@ here is the sourced script
In loop
here is the sourced script
here is the sourced script
mysqltest: At line 1: Missing argument to sleep
mysqltest: At line 1: Missing argument to real_sleep
mysqltest: At line 1: Invalid argument to sleep "abc"
......
......@@ -179,12 +179,22 @@ a
1
2
3
select * from t1 where a IN (select sql_cache a from t1);
a
1
2
3
select * from t1 where a IN (select a from t1 union select sql_cache a from t1);
a
1
2
3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 4
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
Qcache_queries_in_cache 1
set query_cache_type=on;
reset query cache;
show status like "Qcache_queries_in_cache";
......@@ -195,6 +205,41 @@ a
1
2
3
select * from t1 union select sql_no_cache * from t1;
a
1
2
3
select * from t1 where a IN (select sql_no_cache a from t1);
a
1
2
3
select * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
a
1
2
3
select sql_cache sql_no_cache * from t1;
a
1
2
3
select sql_cache * from t1 union select sql_no_cache * from t1;
a
1
2
3
select sql_cache * from t1 where a IN (select sql_no_cache a from t1);
a
1
2
3
select sql_cache * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
a
1
2
3
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
......@@ -1416,3 +1461,9 @@ insert into t1 values ('c');
a
drop table t1;
set GLOBAL query_cache_size= default;
set GLOBAL query_cache_size=1000000;
create table t1 (a char);
insert into t1 values ('c');
a
drop table t1;
set GLOBAL query_cache_size= default;
......@@ -7,27 +7,78 @@ start slave;
show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 98
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 98 # # master-bin.000001 Yes Yes 0 0 98 # None 0 No #
stop slave;
change master to master_log_pos=73;
start slave;
stop slave;
change master to master_log_pos=73;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 # # master-bin.000001 No No 0 0 73 # None 0 No #
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos 73
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running No
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
Exec_Master_Log_Pos 73
Relay_Log_Space #
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
start slave;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 # # master-bin.000001 No Yes 0 0 73 # None 0 No #
stop slave;
change master to master_log_pos=173;
start slave;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 173 # # master-bin.000001 No Yes 0 0 173 # None 0 No #
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos 73
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running No
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
Exec_Master_Log_Pos 73
Relay_Log_Space #
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 98
......@@ -35,7 +86,6 @@ create table if not exists t1 (n int);
drop table if exists t1;
create table t1 (n int);
insert into t1 values (1),(2),(3);
stop slave;
change master to master_log_pos=98;
start slave;
select * from t1;
......@@ -44,3 +94,4 @@ n
2
3
drop table t1;
End of 5.0 tests
......@@ -92,3 +92,4 @@ Master_SSL_Cert MYSQL_TEST_DIR/std_data/client-cert.pem
Master_SSL_Cipher
Master_SSL_Key MYSQL_TEST_DIR/std_data/client-key.pem
Seconds_Behind_Master #
End of 5.0 tests
......@@ -273,4 +273,27 @@ drop function f3;
drop function metaphon;
drop function myfunc_double;
drop function myfunc_int;
CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
create table t1 (a char);
set GLOBAL query_cache_size=1355776;
reset query cache;
select metaphon('MySQL') from t1;
metaphon('MySQL')
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
select metaphon('MySQL') from t1;
metaphon('MySQL')
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
drop table t1;
drop function metaphon;
set GLOBAL query_cache_size=default;
End of 5.0 tests.
-- source include/have_innodb.inc
-- source include/have_log_bin.inc
#
# Let us test binlog_cache_use and binlog_cache_disk_use status vars.
# Actually this test has nothing to do with innodb per se, it just requires
# transactional table.
#
show status like "binlog_cache_use";
show status like "binlog_cache_disk_use";
create table t1 (a int) engine=innodb;
# Now we are going to create transaction which is long enough so its
# transaction binlog will be flushed to disk...
let $1=2000;
disable_query_log;
begin;
while ($1)
{
eval insert into t1 values( $1 );
dec $1;
}
commit;
enable_query_log;
show status like "binlog_cache_use";
show status like "binlog_cache_disk_use";
# Transaction which should not be flushed to disk and so should not
# increase binlog_cache_disk_use.
begin;
delete from t1;
commit;
show status like "binlog_cache_use";
show status like "binlog_cache_disk_use";
drop table t1;
......@@ -12,7 +12,6 @@
#######################################################################
-- source include/have_innodb.inc
-- source include/have_log_bin.inc
#
# Small basic test with ignore
......@@ -1194,40 +1193,6 @@ show create table t2;
drop table t2, t1;
#
# Let us test binlog_cache_use and binlog_cache_disk_use status vars.
# Actually this test has nothing to do with innodb per se, it just requires
# transactional table.
#
show status like "binlog_cache_use";
show status like "binlog_cache_disk_use";
create table t1 (a int) engine=innodb;
# Now we are going to create transaction which is long enough so its
# transaction binlog will be flushed to disk...
let $1=2000;
disable_query_log;
begin;
while ($1)
{
eval insert into t1 values( $1 );
dec $1;
}
commit;
enable_query_log;
show status like "binlog_cache_use";
show status like "binlog_cache_disk_use";
# Transaction which should not be flushed to disk and so should not
# increase binlog_cache_disk_use.
begin;
delete from t1;
commit;
show status like "binlog_cache_use";
show status like "binlog_cache_disk_use";
drop table t1;
#
# Bug #6126: Duplicate columns in keys gives misleading error message
#
......
......@@ -837,6 +837,10 @@ while ($num)
}
--enable_abort_on_error
--enable_query_log
# Test source $variable/<filename>
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
# ----------------------------------------------------------------------------
......
......@@ -89,7 +89,11 @@ show status like "Qcache_queries_in_cache";
select sql_cache * from t1 union select * from t1;
set query_cache_type=2;
select sql_cache * from t1 union select * from t1;
# all sql_cache statements, except for the first select, are ignored.
select * from t1 union select sql_cache * from t1;
select * from t1 where a IN (select sql_cache a from t1);
select * from t1 where a IN (select a from t1 union select sql_cache a from t1);
show status like "Qcache_hits";
show status like "Qcache_queries_in_cache";
set query_cache_type=on;
......@@ -102,6 +106,15 @@ show status like "Qcache_queries_in_cache";
# SELECT SQL_NO_CACHE
#
select sql_no_cache * from t1;
# sql_no_cache can occur in any nested select to turn on cacheing for the whole
# expression and it will always override a sql_cache statement.
select * from t1 union select sql_no_cache * from t1;
select * from t1 where a IN (select sql_no_cache a from t1);
select * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
select sql_cache sql_no_cache * from t1;
select sql_cache * from t1 union select sql_no_cache * from t1;
select sql_cache * from t1 where a IN (select sql_no_cache a from t1);
select sql_cache * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
show status like "Qcache_queries_in_cache";
drop table t1;
#
......@@ -994,4 +1007,25 @@ drop table t1;
set GLOBAL query_cache_size= default;
#
# Bug #29053 SQL_CACHE in UNION causes non-deterministic functions to be cached
#
set GLOBAL query_cache_size=1000000;
create table t1 (a char);
insert into t1 values ('c');
let $q1= `select RAND() from t1 union select sql_cache 1 from t1;`;
let $q2= `select RAND() from t1 union select sql_cache 1 from t1;`;
# disabling the logging of the query because the times are different each run.
--disable_query_log
eval select a from t1 where "$q1" = "$q2";
--enable_query_log
drop table t1;
set GLOBAL query_cache_size= default;
# End of 5.0 tests
......@@ -4,31 +4,29 @@
source include/master-slave.inc;
show master status;
sync_slave_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
show slave status;
stop slave;
change master to master_log_pos=73;
start slave;
sleep 5;
stop slave;
--source include/wait_for_slave_to_stop.inc
change master to master_log_pos=73;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
show slave status;
query_vertical show slave status;
start slave;
sleep 5;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
show slave status;
let $slave_param= Slave_SQL_Running;
let $slave_param_value= Yes;
--source include/wait_for_slave_param.inc
let $slave_param= Slave_IO_Running;
let $slave_param_value= No;
--source include/wait_for_slave_param.inc
stop slave;
change master to master_log_pos=173;
start slave;
sleep 2;
--source include/wait_for_slave_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
show slave status;
query_vertical show slave status;
connection master;
show master status;
create table if not exists t1 (n int);
......@@ -37,7 +35,6 @@ create table t1 (n int);
insert into t1 values (1),(2),(3);
save_master_pos;
connection slave;
stop slave;
change master to master_log_pos=98;
start slave;
sync_with_master;
......@@ -46,4 +43,4 @@ connection master;
drop table t1;
sync_slave_with_master;
# End of 4.1 tests
--echo End of 5.0 tests
......@@ -56,6 +56,9 @@ enable_query_log;
connection master;
insert into t1 values (NULL);
sync_slave_with_master;
--source include/wait_for_slave_to_start.inc
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT
--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
query_vertical show slave status;
--echo End of 5.0 tests
......@@ -288,4 +288,28 @@ drop function metaphon;
drop function myfunc_double;
drop function myfunc_int;
#
# Bug #28921: Queries containing UDF functions are cached
#
--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB";
create table t1 (a char);
set GLOBAL query_cache_size=1355776;
reset query cache;
select metaphon('MySQL') from t1;
show status like "Qcache_hits";
show status like "Qcache_queries_in_cache";
select metaphon('MySQL') from t1;
show status like "Qcache_hits";
show status like "Qcache_queries_in_cache";
drop table t1;
drop function metaphon;
set GLOBAL query_cache_size=default;
--echo End of 5.0 tests.
......@@ -402,13 +402,19 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
HANDLE handle_file_map = NULL;
ulong connect_number;
char connect_number_char[22], *p;
char tmp[64];
char *tmp= NULL;
char *suffix_pos;
DWORD error_allow = 0;
DWORD error_code = 0;
DWORD event_access_rights= SYNCHRONIZE | EVENT_MODIFY_STATE;
char *shared_memory_base_name = mysql->options.shared_memory_base_name;
/*
get enough space base-name + '_' + longest suffix we might ever send
*/
if (!(tmp= (char *)my_malloc(strlen(shared_memory_base_name) + 32L, MYF(MY_FAE))))
goto err;
/*
The name of event and file-mapping events create agree next rule:
shared_memory_base_name+unique_part
......@@ -551,6 +557,8 @@ err2:
CloseHandle(handle_file_map);
}
err:
if (tmp)
my_free(tmp, MYF(0));
if (error_allow)
error_code = GetLastError();
if (event_connect_request)
......
......@@ -4420,7 +4420,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg)
HANDLE event_connect_answer= 0;
ulong smem_buffer_length= shared_memory_buffer_length + 4;
ulong connect_number= 1;
char tmp[63];
char *tmp= NULL;
char *suffix_pos;
char connect_number_char[22], *p;
const char *errmsg= 0;
......@@ -4429,6 +4429,12 @@ pthread_handler_t handle_connections_shared_memory(void *arg)
DBUG_ENTER("handle_connections_shared_memorys");
DBUG_PRINT("general",("Waiting for allocated shared memory."));
/*
get enough space base-name + '_' + longest suffix we might ever send
*/
if (!(tmp= (char *)my_malloc(strlen(shared_memory_base_name) + 32L, MYF(MY_FAE))))
goto error;
if (my_security_attr_create(&sa_event, &errmsg,
GENERIC_ALL, SYNCHRONIZE | EVENT_MODIFY_STATE))
goto error;
......@@ -4616,6 +4622,9 @@ errorconn:
/* End shared memory handling */
error:
if (tmp)
my_free(tmp, MYF(0));
if (errmsg)
{
char buff[180];
......
......@@ -4363,8 +4363,12 @@ select_option:
}
| SQL_CACHE_SYM
{
/* Honor this flag only if SQL_NO_CACHE wasn't specified. */
if (Lex->select_lex.sql_cache != SELECT_LEX::SQL_NO_CACHE)
/*
Honor this flag only if SQL_NO_CACHE wasn't specified AND
we are parsing the outermost SELECT in the query.
*/
if (Lex->select_lex.sql_cache != SELECT_LEX::SQL_NO_CACHE &&
Lex->current_select == &Lex->select_lex)
{
Lex->safe_to_cache_query=1;
Lex->select_lex.options|= OPTION_TO_QUERY_CACHE;
......@@ -5150,8 +5154,8 @@ simple_expr:
$$= new Item_func_sp(Lex->current_context(), name, *$4);
else
$$= new Item_func_sp(Lex->current_context(), name);
lex->safe_to_cache_query=0;
}
}
lex->safe_to_cache_query=0;
}
| UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' expr_list ')'
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment