Commit 84af7972 authored by Mikael Ronström's avatar Mikael Ronström

merge

parents 54574a52 359549be
...@@ -3132,3 +3132,4 @@ VERSION.dep ...@@ -3132,3 +3132,4 @@ VERSION.dep
info_macros.cmake info_macros.cmake
Docs/INFO_BIN Docs/INFO_BIN
Docs/INFO_SRC Docs/INFO_SRC
Testing
...@@ -50,6 +50,23 @@ extern "C" void unireg_clear(int exit_code) ...@@ -50,6 +50,23 @@ extern "C" void unireg_clear(int exit_code)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/*
Wrapper error handler for embedded server to call client/server error
handler based on whether thread is in client/server context
*/
static void embedded_error_handler(uint error, const char *str, myf MyFlags)
{
DBUG_ENTER("embedded_error_handler");
/*
If current_thd is NULL, it means restore_global has been called and
thread is in client context, then call client error handler else call
server error handler.
*/
DBUG_RETURN(current_thd ? my_message_sql(error, str, MyFlags):
my_message_stderr(error, str, MyFlags));
}
/* /*
Reads error information from the MYSQL_DATA and puts Reads error information from the MYSQL_DATA and puts
...@@ -106,7 +123,8 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, ...@@ -106,7 +123,8 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
if (mysql->status != MYSQL_STATUS_READY) if (mysql->status != MYSQL_STATUS_READY)
{ {
set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
return 1; result= 1;
goto end;
} }
/* Clear result variables */ /* Clear result variables */
...@@ -147,6 +165,9 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, ...@@ -147,6 +165,9 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
#if defined(ENABLED_PROFILING) #if defined(ENABLED_PROFILING)
thd->profiling.finish_current_query(); thd->profiling.finish_current_query();
#endif #endif
end:
thd->restore_globals();
return result; return result;
} }
...@@ -545,7 +566,10 @@ int init_embedded_server(int argc, char **argv, char **groups) ...@@ -545,7 +566,10 @@ int init_embedded_server(int argc, char **argv, char **groups)
return 1; return 1;
} }
error_handler_hook = my_message_sql; /*
set error_handler_hook to embedded_error_handler wrapper.
*/
error_handler_hook= embedded_error_handler;
acl_error= 0; acl_error= 0;
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
......
...@@ -28,6 +28,7 @@ sys_vars.wait_timeout_func # Bug#41255 2010-04-26 alik wait_t ...@@ -28,6 +28,7 @@ sys_vars.wait_timeout_func # Bug#41255 2010-04-26 alik wait_t
sys_vars.ndb_log_update_as_write_basic sys_vars.ndb_log_update_as_write_basic
sys_vars.have_ndbcluster_basic sys_vars.have_ndbcluster_basic
sys_vars.ndb_log_updated_only_basic sys_vars.ndb_log_updated_only_basic
sys_vars.rpl_init_slave_func # Bug#12535301 2011-05-09 andrei sys_vars.rpl_init_slave_func mismatches in daily-5.5
main.gis-rtree # svoj: due to BUG#38965 main.gis-rtree # svoj: due to BUG#38965
main.type_float # svoj: due to BUG#38965 main.type_float # svoj: due to BUG#38965
......
# -*- cperl -*- # -*- cperl -*-
# Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc. # Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
...@@ -21,6 +21,7 @@ use Carp; ...@@ -21,6 +21,7 @@ use Carp;
use My::Platform; use My::Platform;
use File::Temp qw/ tempfile tempdir /; use File::Temp qw/ tempfile tempdir /;
use mtr_results;
my $hint_mysqld; # Last resort guess for executable path my $hint_mysqld; # Last resort guess for executable path
...@@ -80,7 +81,7 @@ sub _gdb { ...@@ -80,7 +81,7 @@ sub _gdb {
return if $? >> 8; return if $? >> 8;
return unless $gdb_output; return unless $gdb_output;
print <<EOF, $gdb_output, "\n"; resfile_print <<EOF, $gdb_output, "\n";
Output from gdb follows. The first stack trace is from the failing thread. Output from gdb follows. The first stack trace is from the failing thread.
The following stack traces are from all threads (so the failing one is The following stack traces are from all threads (so the failing one is
duplicated). duplicated).
...@@ -124,7 +125,7 @@ sub _dbx { ...@@ -124,7 +125,7 @@ sub _dbx {
return if $? >> 8; return if $? >> 8;
return unless $dbx_output; return unless $dbx_output;
print <<EOF, $dbx_output, "\n"; resfile_print <<EOF . $dbx_output . "\n";
Output from dbx follows. Stack trace is printed for all threads in order, Output from dbx follows. Stack trace is printed for all threads in order,
above this you should see info about which thread was the failing one. above this you should see info about which thread was the failing one.
---------------------------- ----------------------------
...@@ -244,7 +245,7 @@ sub _cdb { ...@@ -244,7 +245,7 @@ sub _cdb {
$cdb_output=~ s/^Child\-SP RetAddr Call Site//gm; $cdb_output=~ s/^Child\-SP RetAddr Call Site//gm;
$cdb_output=~ s/\+0x([0-9a-fA-F]+)//gm; $cdb_output=~ s/\+0x([0-9a-fA-F]+)//gm;
print <<EOF, $cdb_output, "\n"; resfile_print <<EOF, $cdb_output, "\n";
Output from cdb follows. Faulting thread is printed twice,with and without function parameters Output from cdb follows. Faulting thread is printed twice,with and without function parameters
Search for STACK_TEXT to see the stack trace of Search for STACK_TEXT to see the stack trace of
the faulting thread. Callstacks of other threads are printed after it. the faulting thread. Callstacks of other threads are printed after it.
......
# -*- cperl -*- # -*- cperl -*-
# Copyright (C) 2008 MySQL AB # Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. # the Free Software Foundation; version 2 of the License.
...@@ -23,6 +23,7 @@ package My::Test; ...@@ -23,6 +23,7 @@ package My::Test;
use strict; use strict;
use warnings; use warnings;
use Carp; use Carp;
use mtr_results;
sub new { sub new {
...@@ -66,9 +67,26 @@ sub is_failed { ...@@ -66,9 +67,26 @@ sub is_failed {
} }
my %result_names= (
'MTR_RES_PASSED' => 'pass',
'MTR_RES_FAILED' => 'fail',
'MTR_RES_SKIPPED' => 'skipped',
);
sub write_test { sub write_test {
my ($test, $sock, $header)= @_; my ($test, $sock, $header)= @_;
if ($::opt_resfile && defined $test->{'result'}) {
resfile_test_info("result", $result_names{$test->{'result'}});
if ($test->{'timeout'}) {
resfile_test_info("comment", "Timeout");
} elsif (defined $test->{'comment'}) {
resfile_test_info("comment", $test->{'comment'});
}
resfile_test_info("result", "warning") if defined $test->{'check'};
resfile_to_test($test);
}
# Give the test a unique key before serializing it # Give the test a unique key before serializing it
$test->{key}= "$test" unless defined $test->{key}; $test->{key}= "$test" unless defined $test->{key};
...@@ -113,6 +131,7 @@ sub read_test { ...@@ -113,6 +131,7 @@ sub read_test {
$test->{$key}= _decode($value); $test->{$key}= _decode($value);
} }
} }
resfile_from_test($test) if $::opt_resfile;
return $test; return $test;
} }
......
...@@ -34,6 +34,7 @@ use My::Platform; ...@@ -34,6 +34,7 @@ use My::Platform;
use POSIX qw[ _exit ]; use POSIX qw[ _exit ];
use IO::Handle qw[ flush ]; use IO::Handle qw[ flush ];
require "mtr_io.pl"; require "mtr_io.pl";
use mtr_results;
my $tot_real_time= 0; my $tot_real_time= 0;
...@@ -96,6 +97,7 @@ sub mtr_report_test_passed ($) { ...@@ -96,6 +97,7 @@ sub mtr_report_test_passed ($) {
{ {
$timer_str= mtr_fromfile("$::opt_vardir/log/timer"); $timer_str= mtr_fromfile("$::opt_vardir/log/timer");
$tinfo->{timer}= $timer_str; $tinfo->{timer}= $timer_str;
resfile_test_info('duration', $timer_str) if $::opt_resfile;
} }
# Big warning if status already set # Big warning if status already set
...@@ -301,6 +303,7 @@ sub mtr_report_stats ($$;$) { ...@@ -301,6 +303,7 @@ sub mtr_report_stats ($$;$) {
time - $BASETIME, "seconds executing testcases"); time - $BASETIME, "seconds executing testcases");
} }
resfile_global("duration", time - $BASETIME) if $::opt_resfile;
my $warnlog= "$::opt_vardir/log/warnings"; my $warnlog= "$::opt_vardir/log/warnings";
if ( -f $warnlog ) if ( -f $warnlog )
......
# -*- cperl -*-
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
package mtr_results;
use strict;
use IO::Handle qw[ flush ];
use base qw(Exporter);
our @EXPORT= qw(resfile_init resfile_global resfile_new_test resfile_test_info
resfile_output resfile_output_file resfile_print
resfile_print_test resfile_to_test resfile_from_test );
my %curr_result; # Result for current test
my $curr_output; # Output for current test
my $do_resfile;
END {
close RESF if $do_resfile;
}
sub resfile_init($)
{
my $fname= shift;
open (RESF, " > $fname") or die ("Could not open result file $fname");
%curr_result= ();
$curr_output= "";
$do_resfile= 1;
}
# Strings need to be quoted if they start with white space or ",
# or if they contain newlines. Pass a reference to the string.
# If the string is quoted, " must be escaped, thus \ also must be escaped
sub quote_value($)
{
my $stref= shift;
for ($$stref) {
return unless /^[\s"]/ or /\n/;
s/\\/\\\\/g;
s/"/\\"/g;
$_= '"' . $_ . '"';
}
}
# Output global variable setting to result file.
sub resfile_global($$)
{
return unless $do_resfile;
my ($tag, $val) = @_;
$val= join (' ', @$val) if ref($val) eq 'ARRAY';
quote_value(\$val);
print RESF "$tag : $val\n";
}
# Prepare to add results for new test
sub resfile_new_test()
{
%curr_result= ();
$curr_output= "";
}
# Add (or change) one variable setting for current test
sub resfile_test_info($$)
{
my ($tag, $val) = @_;
return unless $do_resfile;
quote_value(\$val);
$curr_result{$tag} = $val;
}
# Add to output value for current test.
# Will be quoted if necessary, truncated if length over 5000.
sub resfile_output($)
{
return unless $do_resfile;
for (shift) {
my $len= length;
if ($len > 5000) {
my $trlen= $len - 5000;
$_= substr($_, 0, 5000) . "\n[TRUNCATED $trlen chars removed]\n";
}
s/\\/\\\\/g;
s/"/\\"/g;
$curr_output .= $_;
}
}
# Add to output, read from named file
sub resfile_output_file($)
{
resfile_output(::mtr_grab_file(shift)) if $do_resfile;
}
# Print text, and also append to current output if we're collecting results
sub resfile_print($)
{
my $txt= shift;
print($txt);
resfile_output($txt) if $do_resfile;
}
# Print results for current test, then reset
# (So calling a second time without having generated new results
# will have no effect)
sub resfile_print_test()
{
return unless %curr_result;
print RESF "{\n";
while (my ($t, $v) = each %curr_result) {
print RESF "$t : $v\n";
}
if ($curr_output) {
chomp($curr_output);
print RESF " output : " . $curr_output . "\"\n";
}
print RESF "}\n";
IO::Handle::flush(\*RESF);
resfile_new_test();
}
# Add current test results to test object (to send from worker)
sub resfile_to_test($)
{
return unless $do_resfile;
my $tinfo= shift;
my @res_array= %curr_result;
$tinfo->{'resfile'}= \@res_array;
$tinfo->{'output'}= $curr_output if $curr_output;
}
# Get test results (from worker) from test object
sub resfile_from_test($)
{
return unless $do_resfile;
my $tinfo= shift;
my $res_array= $tinfo->{'resfile'};
return unless $res_array;
%curr_result= @$res_array;
$curr_output= $tinfo->{'output'} if defined $tinfo->{'output'};
}
1;
...@@ -96,6 +96,7 @@ use mtr_cases; ...@@ -96,6 +96,7 @@ use mtr_cases;
use mtr_report; use mtr_report;
use mtr_match; use mtr_match;
use mtr_unique; use mtr_unique;
use mtr_results;
use IO::Socket::INET; use IO::Socket::INET;
use IO::Select; use IO::Select;
...@@ -245,6 +246,8 @@ my $build_thread= 0; ...@@ -245,6 +246,8 @@ my $build_thread= 0;
my $opt_record; my $opt_record;
my $opt_report_features; my $opt_report_features;
our $opt_resfile= $ENV{'MTR_RESULT_FILE'} || 0;
my $opt_skip_core; my $opt_skip_core;
our $opt_check_testcases= 1; our $opt_check_testcases= 1;
...@@ -322,6 +325,14 @@ my $opt_parallel= $ENV{MTR_PARALLEL} || 1; ...@@ -322,6 +325,14 @@ my $opt_parallel= $ENV{MTR_PARALLEL} || 1;
select(STDOUT); select(STDOUT);
$| = 1; # Automatically flush STDOUT $| = 1; # Automatically flush STDOUT
# Used by --result-file for for formatting times
sub isotime($) {
my ($sec,$min,$hr,$day,$mon,$yr)= gmtime($_[0]);
return sprintf "%d-%02d-%02dT%02d:%02d:%02dZ",
$yr+1900, $mon+1, $day, $hr, $min, $sec;
}
main(); main();
...@@ -426,6 +437,11 @@ sub main { ...@@ -426,6 +437,11 @@ sub main {
my $server_port = $server->sockport(); my $server_port = $server->sockport();
mtr_report("Using server port $server_port"); mtr_report("Using server port $server_port");
if ($opt_resfile) {
resfile_init("$opt_vardir/mtr-results.txt");
print_global_resfile();
}
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Read definitions from include/plugin.defs # Read definitions from include/plugin.defs
# #
...@@ -649,6 +665,7 @@ sub run_test_server ($$$) { ...@@ -649,6 +665,7 @@ sub run_test_server ($$$) {
$savedir); $savedir);
} }
} }
resfile_print_test();
$num_saved_datadir++; $num_saved_datadir++;
$num_failed_test++ unless ($result->{retries} || $num_failed_test++ unless ($result->{retries} ||
$result->{exp_fail}); $result->{exp_fail});
...@@ -671,6 +688,7 @@ sub run_test_server ($$$) { ...@@ -671,6 +688,7 @@ sub run_test_server ($$$) {
} }
} }
resfile_print_test();
# Retry test run after test failure # Retry test run after test failure
my $retries= $result->{retries} || 2; my $retries= $result->{retries} || 2;
my $test_has_failed= $result->{failures} || 0; my $test_has_failed= $result->{failures} || 0;
...@@ -958,6 +976,49 @@ sub set_vardir { ...@@ -958,6 +976,49 @@ sub set_vardir {
} }
sub print_global_resfile {
resfile_global("start_time", isotime $^T);
resfile_global("user_id", $<);
resfile_global("embedded-server", $opt_embedded_server ? 1 : 0);
resfile_global("ps-protocol", $opt_ps_protocol ? 1 : 0);
resfile_global("sp-protocol", $opt_sp_protocol ? 1 : 0);
resfile_global("view-protocol", $opt_view_protocol ? 1 : 0);
resfile_global("cursor-protocol", $opt_cursor_protocol ? 1 : 0);
resfile_global("ssl", $opt_ssl ? 1 : 0);
resfile_global("compress", $opt_compress ? 1 : 0);
resfile_global("parallel", $opt_parallel);
resfile_global("check-testcases", $opt_check_testcases ? 1 : 0);
resfile_global("mysqld", \@opt_extra_mysqld_opt);
resfile_global("debug", $opt_debug ? 1 : 0);
resfile_global("gcov", $opt_gcov ? 1 : 0);
resfile_global("gprof", $opt_gprof ? 1 : 0);
resfile_global("valgrind", $opt_valgrind ? 1 : 0);
resfile_global("callgrind", $opt_callgrind ? 1 : 0);
resfile_global("mem", $opt_mem ? 1 : 0);
resfile_global("tmpdir", $opt_tmpdir);
resfile_global("vardir", $opt_vardir);
resfile_global("fast", $opt_fast ? 1 : 0);
resfile_global("force-restart", $opt_force_restart ? 1 : 0);
resfile_global("reorder", $opt_reorder ? 1 : 0);
resfile_global("sleep", $opt_sleep);
resfile_global("repeat", $opt_repeat);
resfile_global("user", $opt_user);
resfile_global("testcase-timeout", $opt_testcase_timeout);
resfile_global("suite-timeout", $opt_suite_timeout);
resfile_global("shutdown-timeout", $opt_shutdown_timeout ? 1 : 0);
resfile_global("warnings", $opt_warnings ? 1 : 0);
resfile_global("max-connections", $opt_max_connections);
# resfile_global("default-myisam", $opt_default_myisam ? 1 : 0);
resfile_global("product", "MySQL");
# Somewhat hacky code to convert numeric version back to dot notation
my $v1= int($mysql_version_id / 10000);
my $v2= int(($mysql_version_id % 10000)/100);
my $v3= $mysql_version_id % 100;
resfile_global("version", "$v1.$v2.$v3");
}
sub command_line_setup { sub command_line_setup {
my $opt_comment; my $opt_comment;
my $opt_usage; my $opt_usage;
...@@ -1100,6 +1161,7 @@ sub command_line_setup { ...@@ -1100,6 +1161,7 @@ sub command_line_setup {
'max-connections=i' => \$opt_max_connections, 'max-connections=i' => \$opt_max_connections,
'default-myisam!' => \&collect_option, 'default-myisam!' => \&collect_option,
'report-times' => \$opt_report_times, 'report-times' => \$opt_report_times,
'result-file' => \$opt_resfile,
'unit-tests!' => \$opt_ctest, 'unit-tests!' => \$opt_ctest,
'help|h' => \$opt_usage, 'help|h' => \$opt_usage,
...@@ -3650,6 +3712,18 @@ sub timezone { ...@@ -3650,6 +3712,18 @@ sub timezone {
# Storage for changed environment variables # Storage for changed environment variables
my %old_env; my %old_env;
sub resfile_report_test ($) {
my $tinfo= shift;
resfile_new_test();
resfile_test_info("name", $tinfo->{name});
resfile_test_info("variation", $tinfo->{combination})
if $tinfo->{combination};
resfile_test_info("start_time", isotime time);
}
# #
# Run a single test case # Run a single test case
# #
...@@ -3662,6 +3736,7 @@ sub run_testcase ($) { ...@@ -3662,6 +3736,7 @@ sub run_testcase ($) {
my $tinfo= shift; my $tinfo= shift;
mtr_verbose("Running test:", $tinfo->{name}); mtr_verbose("Running test:", $tinfo->{name});
resfile_report_test($tinfo) if $opt_resfile;
# Allow only alpanumerics pluss _ - + . in combination names, # Allow only alpanumerics pluss _ - + . in combination names,
# or anything beginning with -- (the latter comes from --combination) # or anything beginning with -- (the latter comes from --combination)
...@@ -3867,6 +3942,7 @@ sub run_testcase ($) { ...@@ -3867,6 +3942,7 @@ sub run_testcase ($) {
# Test case suceeded, but it has produced unexpected # Test case suceeded, but it has produced unexpected
# warnings, continue in $res == 1 # warnings, continue in $res == 1
$res= 1; $res= 1;
resfile_output($tinfo->{'warnings'}) if $opt_resfile;
} }
if ( $res == 0 ) if ( $res == 0 )
...@@ -3883,6 +3959,7 @@ sub run_testcase ($) { ...@@ -3883,6 +3959,7 @@ sub run_testcase ($) {
# Test case had sideeffects, not fatal error, just continue # Test case had sideeffects, not fatal error, just continue
stop_all_servers($opt_shutdown_timeout); stop_all_servers($opt_shutdown_timeout);
mtr_report("Resuming tests...\n"); mtr_report("Resuming tests...\n");
resfile_output($tinfo->{'check'}) if $opt_resfile;
} }
else { else {
# Test case check failed fatally, probably a server crashed # Test case check failed fatally, probably a server crashed
...@@ -3944,6 +4021,9 @@ sub run_testcase ($) { ...@@ -3944,6 +4021,9 @@ sub run_testcase ($) {
# Save info from this testcase run to mysqltest.log # Save info from this testcase run to mysqltest.log
if( -f $path_current_testlog) if( -f $path_current_testlog)
{ {
if ($opt_resfile && $res && $res != 62) {
resfile_output_file($path_current_testlog);
}
mtr_appendfile_to_file($path_current_testlog, $path_testlog); mtr_appendfile_to_file($path_current_testlog, $path_testlog);
unlink($path_current_testlog); unlink($path_current_testlog);
} }
......
...@@ -1389,6 +1389,15 @@ NULL ...@@ -1389,6 +1389,15 @@ NULL
SELECT DATE_FORMAT('0000-00-11', '%w'); SELECT DATE_FORMAT('0000-00-11', '%w');
DATE_FORMAT('0000-00-11', '%w') DATE_FORMAT('0000-00-11', '%w')
NULL NULL
#
# Bug#12403504 AFTER FIX FOR #11889186 : ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0
#
SELECT MAKEDATE(11111111,1);
MAKEDATE(11111111,1)
NULL
SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1);
WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1)
NULL
End of 5.1 tests End of 5.1 tests
# #
# Bug#57039: constant subtime expression returns incorrect result. # Bug#57039: constant subtime expression returns incorrect result.
......
DROP TABLE IF EXISTS t5;
CREATE TABLE t5(c1 BIT(2) PRIMARY KEY) ENGINE = <default_engine>;
INSERT INTO t5 VALUES (0), (1), (2);
SELECT HEX(c1) FROM t5 ORDER BY c1;
HEX(c1)
0
1
2
SELECT HEX(c1) FROM t5 WHERE c1 = b'1' ORDER BY c1;
HEX(c1)
1
SELECT HEX(c1) FROM t5 WHERE c1 <=> b'1' ORDER BY c1;
HEX(c1)
1
SELECT HEX(c1) FROM t5 WHERE c1 != b'1' ORDER BY c1;
HEX(c1)
0
2
SELECT HEX(c1) FROM t5 WHERE c1 >= '1' ORDER BY c1;
HEX(c1)
1
2
SELECT HEX(c1) FROM t5 WHERE c1 <= '1' ORDER BY c1;
HEX(c1)
0
1
SELECT HEX(c1) FROM t5 WHERE c1 < '1' ORDER BY c1;
HEX(c1)
0
SELECT HEX(c1) FROM t5 WHERE c1 > '0' ORDER BY c1;
HEX(c1)
1
2
DROP TABLE t5;
CREATE TABLE t5(c1 FLOAT(5,2) PRIMARY KEY) ENGINE = <default_engine>;
INSERT INTO t5 VALUES (95.95), (-10.10), (1), (0);
SELECT c1 FROM t5 ORDER BY c1;
c1
-10.10
0.00
1.00
95.95
SELECT c1 FROM t5 WHERE c1 >= '95' ORDER BY c1;
c1
95.95
SELECT c1 FROM t5 WHERE c1 <= '10.10' ORDER BY c1;
c1
-10.10
0.00
1.00
SELECT c1 FROM t5 WHERE c1 != '1' ORDER BY c1;
c1
-10.10
0.00
95.95
SELECT c1 FROM t5 WHERE c1 < '1' ORDER BY c1;
c1
-10.10
0.00
SELECT c1 FROM t5 WHERE c1 > '0' ORDER BY c1;
c1
1.00
95.95
DROP TABLE t5;
CREATE TABLE t5(c1 TINYINT PRIMARY KEY) ENGINE = <default_engine>;
INSERT INTO t5 VALUES (95), (10),(11),(-8);
SELECT c1 FROM t5 ORDER BY c1;
c1
-8
10
11
95
SELECT c1 FROM t5 WHERE c1 = '10' ORDER BY c1;
c1
10
SELECT c1 FROM t5 WHERE c1 <=> '10' ORDER BY c1;
c1
10
SELECT c1 FROM t5 WHERE c1 >= '95' ORDER BY c1;
c1
95
SELECT c1 FROM t5 WHERE c1 <= '11' ORDER BY c1;
c1
-8
10
11
SELECT c1 FROM t5 WHERE c1 != '-8' ORDER BY c1;
c1
10
11
95
SELECT c1 FROM t5 WHERE c1 < '11' ORDER BY c1;
c1
-8
10
SELECT c1 FROM t5 WHERE c1 > '10' ORDER BY c1;
c1
11
95
DROP TABLE t5;
CREATE TABLE t5(c1 SMALLINT PRIMARY KEY) ENGINE = <default_engine>;
INSERT INTO t5 VALUES (395), (-200), (100), (111);
SELECT c1 FROM t5 ORDER BY c1;
c1
-200
100
111
395
SELECT c1 FROM t5 WHERE c1 = '100' ORDER BY c1;
c1
100
SELECT c1 FROM t5 WHERE c1 <=> '100' ORDER BY c1;
c1
100
SELECT c1 FROM t5 WHERE c1 >= '395' ORDER BY c1;
c1
395
SELECT c1 FROM t5 WHERE c1 <= '-200' ORDER BY c1;
c1
-200
SELECT c1 FROM t5 WHERE c1 != '100' ORDER BY c1;
c1
-200
111
395
SELECT c1 FROM t5 WHERE c1 < '111' ORDER BY c1;
c1
-200
100
SELECT c1 FROM t5 WHERE c1 > '111' ORDER BY c1;
c1
395
DROP TABLE t5;
CREATE TABLE t5(c1 MEDIUMINT PRIMARY KEY) ENGINE = <default_engine>;
INSERT INTO t5 VALUES (-8388607), (311),(215),(88608);
SELECT c1 FROM t5 ORDER BY c1;
c1
-8388607
215
311
88608
SELECT c1 FROM t5 WHERE c1 = '311' ORDER BY c1;
c1
311
SELECT c1 FROM t5 WHERE c1 <=> '311' ORDER BY c1;
c1
311
SELECT c1 FROM t5 WHERE c1 >= '215' ORDER BY c1;
c1
215
311
88608
SELECT c1 FROM t5 WHERE c1 <= '88608' ORDER BY c1;
c1
-8388607
215
311
88608
SELECT c1 FROM t5 WHERE c1 != '-8388607' ORDER BY c1;
c1
215
311
88608
SELECT c1 FROM t5 WHERE c1 < '215' ORDER BY c1;
c1
-8388607
SELECT c1 FROM t5 WHERE c1 > '215' ORDER BY c1;
c1
311
88608
DROP TABLE t5;
CREATE TABLE t5(c1 INT PRIMARY KEY) ENGINE = <default_engine>;
INSERT INTO t5 VALUES (-2147483647), (1011),(15),(9388607);
SELECT c1 FROM t5 ORDER BY c1;
c1
-2147483647
15
1011
9388607
SELECT c1 FROM t5 WHERE c1 = '9388607' ORDER BY c1;
c1
9388607
SELECT c1 FROM t5 WHERE c1 <=> '9388607' ORDER BY c1;
c1
9388607
SELECT c1 FROM t5 WHERE c1 >= '15' ORDER BY c1;
c1
15
1011
9388607
SELECT c1 FROM t5 WHERE c1 <= '1011' ORDER BY c1;
c1
-2147483647
15
1011
SELECT c1 FROM t5 WHERE c1 != '-2147483647' ORDER BY c1;
c1
15
1011
9388607
SELECT c1 FROM t5 WHERE c1 < '15' ORDER BY c1;
c1
-2147483647
SELECT c1 FROM t5 WHERE c1 > '15' ORDER BY c1;
c1
1011
9388607
DROP TABLE t5;
CREATE TABLE t5(c1 BIGINT PRIMARY KEY) ENGINE = <default_engine>;
INSERT INTO t5 VALUES (-9223372036854775807), (12011),(500),(3372036854775808);
SELECT c1 FROM t5 ORDER BY c1;
c1
-9223372036854775807
500
12011
3372036854775808
SELECT c1 FROM t5 WHERE c1 = '-9223372036854775807' ORDER BY c1;
c1
-9223372036854775807
SELECT c1 FROM t5 WHERE c1 <=> '-9223372036854775807' ORDER BY c1;
c1
-9223372036854775807
SELECT c1 FROM t5 WHERE c1 >= '12011' ORDER BY c1;
c1
12011
3372036854775808
SELECT c1 FROM t5 WHERE c1 <= '500' ORDER BY c1;
c1
-9223372036854775807
500
SELECT c1 FROM t5 WHERE c1 != '3372036854775808' ORDER BY c1;
c1
-9223372036854775807
500
12011
SELECT c1 FROM t5 WHERE c1 < '12011' ORDER BY c1;
c1
-9223372036854775807
500
SELECT c1 FROM t5 WHERE c1 > '12011' ORDER BY c1;
c1
3372036854775808
DROP TABLE t5;
CREATE TABLE t5(c1 DOUBLE(5,2) PRIMARY KEY) ENGINE = <default_engine>;
INSERT INTO t5 VALUES (95.95), (11.11),(5),(-908.92);
SELECT c1 FROM t5 ORDER BY c1;
c1
-908.92
5.00
11.11
95.95
SELECT c1 FROM t5 WHERE c1 = '11.11' ORDER BY c1;
c1
11.11
SELECT c1 FROM t5 WHERE c1 <=> '11.11' ORDER BY c1;
c1
11.11
SELECT c1 FROM t5 WHERE c1 >= '5' ORDER BY c1;
c1
5.00
11.11
95.95
SELECT c1 FROM t5 WHERE c1 <= '95.95' ORDER BY c1;
c1
-908.92
5.00
11.11
95.95
SELECT c1 FROM t5 WHERE c1 != '-908.92' ORDER BY c1;
c1
5.00
11.11
95.95
SELECT c1 FROM t5 WHERE c1 < '95.95' ORDER BY c1;
c1
-908.92
5.00
11.11
SELECT c1 FROM t5 WHERE c1 > '-908.92' ORDER BY c1;
c1
5.00
11.11
95.95
DROP TABLE t5;
CREATE TABLE t5(c1 NUMERIC(5,2) PRIMARY KEY) ENGINE = <default_engine>;
INSERT INTO t5 VALUES (95.95), (11.11),(5),(-908.92);
SELECT c1 FROM t5 ORDER BY c1;
c1
-908.92
5.00
11.11
95.95
SELECT c1 FROM t5 WHERE c1 = '11.11' ORDER BY c1;
c1
11.11
SELECT c1 FROM t5 WHERE c1 <=> '11.11' ORDER BY c1;
c1
11.11
SELECT c1 FROM t5 WHERE c1 >= '5' ORDER BY c1;
c1
5.00
11.11
95.95
SELECT c1 FROM t5 WHERE c1 <= '95.95' ORDER BY c1;
c1
-908.92
5.00
11.11
95.95
SELECT c1 FROM t5 WHERE c1 != '-908.92' ORDER BY c1;
c1
5.00
11.11
95.95
SELECT c1 FROM t5 WHERE c1 < '95.95' ORDER BY c1;
c1
-908.92
5.00
11.11
SELECT c1 FROM t5 WHERE c1 > '-908.92' ORDER BY c1;
c1
5.00
11.11
95.95
DROP TABLE t5;
CREATE TABLE t5(c1 DECIMAL(5,2) PRIMARY KEY) ENGINE = <default_engine>;
INSERT INTO t5 VALUES (95.95), (11.11),(5),(-908.92);
SELECT c1 FROM t5 ORDER BY c1;
c1
-908.92
5.00
11.11
95.95
SELECT c1 FROM t5 WHERE c1 = '11.11' ORDER BY c1;
c1
11.11
SELECT c1 FROM t5 WHERE c1 <=> '11.11' ORDER BY c1;
c1
11.11
SELECT c1 FROM t5 WHERE c1 >= '5' ORDER BY c1;
c1
5.00
11.11
95.95
SELECT c1 FROM t5 WHERE c1 <= '95.95' ORDER BY c1;
c1
-908.92
5.00
11.11
95.95
SELECT c1 FROM t5 WHERE c1 != '-908.92' ORDER BY c1;
c1
5.00
11.11
95.95
SELECT c1 FROM t5 WHERE c1 < '95.95' ORDER BY c1;
c1
-908.92
5.00
11.11
SELECT c1 FROM t5 WHERE c1 > '-908.92' ORDER BY c1;
c1
5.00
11.11
95.95
DROP TABLE t5;
...@@ -902,6 +902,13 @@ SELECT DATE_FORMAT('0000-00-11', '%W'); ...@@ -902,6 +902,13 @@ SELECT DATE_FORMAT('0000-00-11', '%W');
SELECT DATE_FORMAT('0000-00-11', '%a'); SELECT DATE_FORMAT('0000-00-11', '%a');
SELECT DATE_FORMAT('0000-00-11', '%w'); SELECT DATE_FORMAT('0000-00-11', '%w');
--echo #
--echo # Bug#12403504 AFTER FIX FOR #11889186 : ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0
--echo #
SELECT MAKEDATE(11111111,1);
SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1);
--echo End of 5.1 tests --echo End of 5.1 tests
--echo # --echo #
......
########### implicit_char_to_num_conversion.test #######################
# #
# This test aims at using string/char literal in comparison operators #
# without explicit type-cast. This is a bug test for Bug#11766521 #
# - Incorrect result is returned if string/char literal is used with #
# comparision operator and bit data type column. Test is extended to #
# include numeric data type comparison with string/char literal #
# #
# #
# Creation: #
# 2011-05-10 vfisrekar Implement this test as part of Bug#11766521 #
# #
########################################################################
--disable_warnings
DROP TABLE IF EXISTS t5;
--enable_warnings
let $default_engine = `select @@SESSION.default_storage_engine`;
# Bug#11766521 - BIT Datatype comparison in where clause return incorrect
# result for '=' , '<=>' operators
--replace_result $default_engine <default_engine>
eval CREATE TABLE t5(c1 BIT(2) PRIMARY KEY) ENGINE = $default_engine;
INSERT INTO t5 VALUES (0), (1), (2);
SELECT HEX(c1) FROM t5 ORDER BY c1;
# Enable Following two select after Bug#11766521 fix
# SELECT HEX(c1) FROM t5 WHERE c1 = '1' ORDER BY c1;
# SELECT HEX(c1) FROM t5 WHERE c1 <=> '1' ORDER BY c1;
SELECT HEX(c1) FROM t5 WHERE c1 = b'1' ORDER BY c1;
SELECT HEX(c1) FROM t5 WHERE c1 <=> b'1' ORDER BY c1;
SELECT HEX(c1) FROM t5 WHERE c1 != b'1' ORDER BY c1;
SELECT HEX(c1) FROM t5 WHERE c1 >= '1' ORDER BY c1;
SELECT HEX(c1) FROM t5 WHERE c1 <= '1' ORDER BY c1;
SELECT HEX(c1) FROM t5 WHERE c1 < '1' ORDER BY c1;
SELECT HEX(c1) FROM t5 WHERE c1 > '0' ORDER BY c1;
DROP TABLE t5;
# FLOAT Data-type
--replace_result $default_engine <default_engine>
eval CREATE TABLE t5(c1 FLOAT(5,2) PRIMARY KEY) ENGINE = $default_engine;
INSERT INTO t5 VALUES (95.95), (-10.10), (1), (0);
SELECT c1 FROM t5 ORDER BY c1;
# Compare with string literal
# Following two queries does not return result may be due to Bug#11766521.
# Enable them after Bug#11766521 fix.
# SELECT c1 FROM t5 WHERE c1 = '10.10' ORDER BY c1;
# SELECT c1 FROM t5 WHERE c2 <=> '11.11' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 >= '95' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <= '10.10' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 != '1' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 < '1' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 > '0' ORDER BY c1;
DROP TABLE t5;
# TINYINT Datatype
--replace_result $default_engine <default_engine>
eval CREATE TABLE t5(c1 TINYINT PRIMARY KEY) ENGINE = $default_engine;
INSERT INTO t5 VALUES (95), (10),(11),(-8);
SELECT c1 FROM t5 ORDER BY c1;
# Compare with string literal
SELECT c1 FROM t5 WHERE c1 = '10' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <=> '10' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 >= '95' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <= '11' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 != '-8' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 < '11' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 > '10' ORDER BY c1;
DROP TABLE t5;
# SMALLINT Datatype
--replace_result $default_engine <default_engine>
eval CREATE TABLE t5(c1 SMALLINT PRIMARY KEY) ENGINE = $default_engine;
INSERT INTO t5 VALUES (395), (-200), (100), (111);
SELECT c1 FROM t5 ORDER BY c1;
# Compare with string literal
SELECT c1 FROM t5 WHERE c1 = '100' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <=> '100' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 >= '395' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <= '-200' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 != '100' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 < '111' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 > '111' ORDER BY c1;
DROP TABLE t5;
# MEDIUMINT Datatype
--replace_result $default_engine <default_engine>
eval CREATE TABLE t5(c1 MEDIUMINT PRIMARY KEY) ENGINE = $default_engine;
INSERT INTO t5 VALUES (-8388607), (311),(215),(88608);
SELECT c1 FROM t5 ORDER BY c1;
# Compare with string literal
SELECT c1 FROM t5 WHERE c1 = '311' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <=> '311' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 >= '215' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <= '88608' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 != '-8388607' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 < '215' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 > '215' ORDER BY c1;
DROP TABLE t5;
# INT Datatype
--replace_result $default_engine <default_engine>
eval CREATE TABLE t5(c1 INT PRIMARY KEY) ENGINE = $default_engine;
INSERT INTO t5 VALUES (-2147483647), (1011),(15),(9388607);
SELECT c1 FROM t5 ORDER BY c1;
# Compare with string literal
SELECT c1 FROM t5 WHERE c1 = '9388607' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <=> '9388607' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 >= '15' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <= '1011' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 != '-2147483647' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 < '15' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 > '15' ORDER BY c1;
DROP TABLE t5;
# BIGINT Data-type
--replace_result $default_engine <default_engine>
eval CREATE TABLE t5(c1 BIGINT PRIMARY KEY) ENGINE = $default_engine;
INSERT INTO t5 VALUES (-9223372036854775807), (12011),(500),(3372036854775808);
SELECT c1 FROM t5 ORDER BY c1;
# Compare with string literal
SELECT c1 FROM t5 WHERE c1 = '-9223372036854775807' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <=> '-9223372036854775807' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 >= '12011' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <= '500' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 != '3372036854775808' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 < '12011' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 > '12011' ORDER BY c1;
DROP TABLE t5;
# DOUBLE Datatype
--replace_result $default_engine <default_engine>
eval CREATE TABLE t5(c1 DOUBLE(5,2) PRIMARY KEY) ENGINE = $default_engine;
INSERT INTO t5 VALUES (95.95), (11.11),(5),(-908.92);
SELECT c1 FROM t5 ORDER BY c1;
# Compare with string literal
SELECT c1 FROM t5 WHERE c1 = '11.11' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <=> '11.11' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 >= '5' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <= '95.95' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 != '-908.92' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 < '95.95' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 > '-908.92' ORDER BY c1;
DROP TABLE t5;
# NUMERIC Datatype
--replace_result $default_engine <default_engine>
eval CREATE TABLE t5(c1 NUMERIC(5,2) PRIMARY KEY) ENGINE = $default_engine;
INSERT INTO t5 VALUES (95.95), (11.11),(5),(-908.92);
SELECT c1 FROM t5 ORDER BY c1;
# Compare with string literal
SELECT c1 FROM t5 WHERE c1 = '11.11' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <=> '11.11' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 >= '5' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <= '95.95' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 != '-908.92' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 < '95.95' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 > '-908.92' ORDER BY c1;
DROP TABLE t5;
# DECIMAL Datatype
--replace_result $default_engine <default_engine>
eval CREATE TABLE t5(c1 DECIMAL(5,2) PRIMARY KEY) ENGINE = $default_engine;
INSERT INTO t5 VALUES (95.95), (11.11),(5),(-908.92);
SELECT c1 FROM t5 ORDER BY c1;
# Compare with string literal
SELECT c1 FROM t5 WHERE c1 = '11.11' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <=> '11.11' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 >= '5' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 <= '95.95' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 != '-908.92' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 < '95.95' ORDER BY c1;
SELECT c1 FROM t5 WHERE c1 > '-908.92' ORDER BY c1;
DROP TABLE t5;
...@@ -146,6 +146,7 @@ void lf_pinbox_destroy(LF_PINBOX *pinbox) ...@@ -146,6 +146,7 @@ void lf_pinbox_destroy(LF_PINBOX *pinbox)
*/ */
LF_PINS *_lf_pinbox_get_pins(LF_PINBOX *pinbox) LF_PINS *_lf_pinbox_get_pins(LF_PINBOX *pinbox)
{ {
struct st_my_thread_var *var;
uint32 pins, next, top_ver; uint32 pins, next, top_ver;
LF_PINS *el; LF_PINS *el;
/* /*
...@@ -188,7 +189,12 @@ LF_PINS *_lf_pinbox_get_pins(LF_PINBOX *pinbox) ...@@ -188,7 +189,12 @@ LF_PINS *_lf_pinbox_get_pins(LF_PINBOX *pinbox)
el->link= pins; el->link= pins;
el->purgatory_count= 0; el->purgatory_count= 0;
el->pinbox= pinbox; el->pinbox= pinbox;
el->stack_ends_here= & my_thread_var->stack_ends_here; var= my_thread_var;
/*
Threads that do not call my_thread_init() should still be
able to use the LF_HASH.
*/
el->stack_ends_here= (var ? & var->stack_ends_here : NULL);
return el; return el;
} }
...@@ -327,34 +333,36 @@ static int match_pins(LF_PINS *el, void *addr) ...@@ -327,34 +333,36 @@ static int match_pins(LF_PINS *el, void *addr)
*/ */
static void _lf_pinbox_real_free(LF_PINS *pins) static void _lf_pinbox_real_free(LF_PINS *pins)
{ {
int npins, alloca_size; int npins;
void *list, **addr; void *list;
void **addr= NULL;
void *first= NULL, *last= NULL; void *first= NULL, *last= NULL;
LF_PINBOX *pinbox= pins->pinbox; LF_PINBOX *pinbox= pins->pinbox;
npins= pinbox->pins_in_array+1; npins= pinbox->pins_in_array+1;
#ifdef HAVE_ALLOCA #ifdef HAVE_ALLOCA
alloca_size= sizeof(void *)*LF_PINBOX_PINS*npins; if (pins->stack_ends_here != NULL)
/* create a sorted list of pinned addresses, to speed up searches */
if (available_stack_size(&pinbox, *pins->stack_ends_here) > alloca_size)
{ {
struct st_harvester hv; int alloca_size= sizeof(void *)*LF_PINBOX_PINS*npins;
addr= (void **) alloca(alloca_size); /* create a sorted list of pinned addresses, to speed up searches */
hv.granary= addr; if (available_stack_size(&pinbox, *pins->stack_ends_here) > alloca_size)
hv.npins= npins; {
/* scan the dynarray and accumulate all pinned addresses */ struct st_harvester hv;
_lf_dynarray_iterate(&pinbox->pinarray, addr= (void **) alloca(alloca_size);
(lf_dynarray_func)harvest_pins, &hv); hv.granary= addr;
hv.npins= npins;
npins= hv.granary-addr; /* scan the dynarray and accumulate all pinned addresses */
/* and sort them */ _lf_dynarray_iterate(&pinbox->pinarray,
if (npins) (lf_dynarray_func)harvest_pins, &hv);
qsort(addr, npins, sizeof(void *), (qsort_cmp)ptr_cmp);
npins= hv.granary-addr;
/* and sort them */
if (npins)
qsort(addr, npins, sizeof(void *), (qsort_cmp)ptr_cmp);
}
} }
else
#endif #endif
addr= 0;
list= pins->purgatory; list= pins->purgatory;
pins->purgatory= 0; pins->purgatory= 0;
......
...@@ -13,15 +13,43 @@ ...@@ -13,15 +13,43 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
INCLUDE_DIRECTORIES(${WIX_DIR}/../SDK/inc) INCLUDE_DIRECTORIES(${WIX_DIR}/../SDK/inc ${WIX_DIR}/SDK/inc)
LINK_DIRECTORIES(${WIX_DIR}/../SDK/lib) LINK_DIRECTORIES(${WIX_DIR}/../SDK/lib ${WIX_DIR}/SDK/lib)
SET(WIXCA_SOURCES CustomAction.cpp CustomAction.def) SET(WIXCA_SOURCES CustomAction.cpp CustomAction.def)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8) IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
LINK_LIBRARIES(wcautil_x64 dutil_x64 msi version) SET(WIX_ARCH_SUFFIX "_x64")
ELSE() ELSE()
LINK_LIBRARIES(wcautil dutil msi version) SET(WIX_ARCH_SUFFIX)
ENDIF() ENDIF()
ADD_LIBRARY(wixca SHARED ${WIXCA_SOURCES}) IF(MSVC_VERSION EQUAL 1400)
SET(WIX35_MSVC_SUFFIX "_2005")
ELSEIF(MSVC_VERSION EQUAL 1500)
SET(WIX35_MSVC_SUFFIX "_2008")
ELSEIF(MSVC_VERSION EQUAL 1600)
SET(WIX35_MSVC_SUFFIX "_2010")
ELSE()
# When next VS is out, add the correct version here
MESSAGE(FATAL_ERROR "Unknown VS version")
ENDIF()
MESSAGE(STATUS "Searching for wcautil${WIX_ARCH_SUFFIX} or wcautil${WIX35_MSVC_SUFFIX}${WIX_ARCH_SUFFIX} in ${WIX_DIR}/../SDK/lib ${WIX_DIR}/SDK/lib")
MESSAGE(STATUS "Searching for dutil${WIX_ARCH_SUFFIX} or dutil${WIX35_MSVC_SUFFIX}${WIX_ARCH_SUFFIX} in ${WIX_DIR}/../SDK/lib ${WIX_DIR}/SDK/lib")
FIND_LIBRARY(WIX_WCAUTIL_LIBRARY
NAMES wcautil${WIX_ARCH_SUFFIX} wcautil${WIX35_MSVC_SUFFIX}${WIX_ARCH_SUFFIX}
HINTS ${WIX_DIR}/../SDK/lib ${WIX_DIR}/SDK/lib)
FIND_LIBRARY(WIX_DUTIL_LIBRARY
NAMES dutil${WIX_ARCH_SUFFIX} dutil${WIX35_MSVC_SUFFIX}${WIX_ARCH_SUFFIX}
PATHS ${WIX_DIR}/../SDK/lib ${WIX_DIR}/SDK/lib)
MESSAGE(STATUS "Found: ${WIX_WCAUTIL_LIBRARY}")
MESSAGE(STATUS "Found: ${WIX_DUTIL_LIBRARY}")
ADD_VERSION_INFO(wixca SHARED WIXCA_SOURCES)
ADD_LIBRARY(wixca SHARED EXCLUDE_FROM_ALL ${WIXCA_SOURCES})
TARGET_LINK_LIBRARIES(wixca ${WIX_WCAUTIL_LIBRARY} ${WIX_DUTIL_LIBRARY}
msi version )
...@@ -15,6 +15,28 @@ SET(COPYING_RTF "@COPYING_RTF@") ...@@ -15,6 +15,28 @@ SET(COPYING_RTF "@COPYING_RTF@")
SET(CPACK_WIX_CONFIG "@CPACK_WIX_CONFIG@") SET(CPACK_WIX_CONFIG "@CPACK_WIX_CONFIG@")
SET(CPACK_WIX_INCLUDE "@CPACK_WIX_INCLUDE@") SET(CPACK_WIX_INCLUDE "@CPACK_WIX_INCLUDE@")
LIST(APPEND EXCLUDE_DIRS
bin/debug
data/test
lib/plugin/debug
mysql-test
scripts
sql-bench
)
LIST(APPEND EXCLUDE_FILES
bin/echo.exe
bin/mysql_client_test_embedded.exe
bin/mysqld-debug.exe
bin/mysqltest_embedded.exe
bin/replace.exe
lib/debug/mysqlserver.lib
lib/libmysqld.dll
lib/libmysqld.lib
lib/mysqlserver.lib
lib/mysqlservices.lib
)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8) IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(Win64 " Win64='yes'") SET(Win64 " Win64='yes'")
SET(Platform x64) SET(Platform x64)
...@@ -197,11 +219,18 @@ ENDMACRO() ...@@ -197,11 +219,18 @@ ENDMACRO()
FUNCTION(TRAVERSE_FILES dir topdir file file_comp dir_root) FUNCTION(TRAVERSE_FILES dir topdir file file_comp dir_root)
FILE(RELATIVE_PATH dir_rel ${topdir} ${dir})
IF(dir_rel)
LIST(FIND EXCLUDE_DIRS ${dir_rel} TO_EXCLUDE)
IF(NOT TO_EXCLUDE EQUAL -1)
MESSAGE(STATUS "excluding directory: ${dir_rel}")
RETURN()
ENDIF()
ENDIF()
FILE(GLOB all_files ${dir}/*) FILE(GLOB all_files ${dir}/*)
IF(NOT all_files) IF(NOT all_files)
RETURN() RETURN()
ENDIF() ENDIF()
FILE(RELATIVE_PATH dir_rel ${topdir} ${dir})
IF(dir_rel) IF(dir_rel)
MAKE_DIRECTORY(${dir_root}/${dir_rel}) MAKE_DIRECTORY(${dir_root}/${dir_rel})
MAKE_WIX_IDENTIFIER("${dir_rel}" id) MAKE_WIX_IDENTIFIER("${dir_rel}" id)
...@@ -215,18 +244,31 @@ FUNCTION(TRAVERSE_FILES dir topdir file file_comp dir_root) ...@@ -215,18 +244,31 @@ FUNCTION(TRAVERSE_FILES dir topdir file file_comp dir_root)
FOREACH(f ${all_files}) FOREACH(f ${all_files})
IF(NOT IS_DIRECTORY ${f}) IF(NOT IS_DIRECTORY ${f})
FILE(RELATIVE_PATH rel ${topdir} ${f}) FILE(RELATIVE_PATH rel ${topdir} ${f})
MAKE_WIX_IDENTIFIER("${rel}" id) SET(TO_EXCLUDE)
FILE(TO_NATIVE_PATH ${f} f_native) IF(rel MATCHES "\\.pdb$")
GET_FILENAME_COMPONENT(f_ext "${f}" EXT) SET(TO_EXCLUDE TRUE)
# According to MSDN each DLL or EXE should be in the own component ELSE()
IF(f_ext MATCHES ".exe" OR f_ext MATCHES ".dll") LIST(FIND EXCLUDE_FILES ${rel} RES)
IF(NOT RES EQUAL -1)
FILE(APPEND ${file} " <Component Id='C.${id}' Guid='*' ${Win64}>\n") SET(TO_EXCLUDE TRUE)
FILE(APPEND ${file} " <File Id='F.${id}' KeyPath='yes' Source='${f_native}'/>\n") ENDIF()
FILE(APPEND ${file} " </Component>\n") ENDIF()
FILE(APPEND ${file_comp} " <ComponentRef Id='C.${id}'/>\n") IF(TO_EXCLUDE)
ELSE() MESSAGE(STATUS "excluding file: ${rel}")
SET(NONEXEFILES "${NONEXEFILES}\n<File Id='F.${id}' Source='${f_native}'/>" ) ELSE()
MAKE_WIX_IDENTIFIER("${rel}" id)
FILE(TO_NATIVE_PATH ${f} f_native)
GET_FILENAME_COMPONENT(f_ext "${f}" EXT)
# According to MSDN each DLL or EXE should be in the own component
IF(f_ext MATCHES ".exe" OR f_ext MATCHES ".dll")
FILE(APPEND ${file} " <Component Id='C.${id}' Guid='*' ${Win64}>\n")
FILE(APPEND ${file} " <File Id='F.${id}' KeyPath='yes' Source='${f_native}'/>\n")
FILE(APPEND ${file} " </Component>\n")
FILE(APPEND ${file_comp} " <ComponentRef Id='C.${id}'/>\n")
ELSE()
SET(NONEXEFILES "${NONEXEFILES}\n<File Id='F.${id}' Source='${f_native}'/>" )
ENDIF()
ENDIF() ENDIF()
ENDIF() ENDIF()
ENDFOREACH() ENDFOREACH()
...@@ -247,18 +289,18 @@ ENDFUNCTION() ...@@ -247,18 +289,18 @@ ENDFUNCTION()
FUNCTION(TRAVERSE_DIRECTORIES dir topdir file prefix) FUNCTION(TRAVERSE_DIRECTORIES dir topdir file prefix)
FILE(RELATIVE_PATH rel ${topdir} ${dir}) FILE(RELATIVE_PATH rel ${topdir} ${dir})
IF(rel AND IS_DIRECTORY "${f}") IF(rel)
MAKE_WIX_IDENTIFIER("${rel}" id) MAKE_WIX_IDENTIFIER("${rel}" id)
GET_FILENAME_COMPONENT(name ${dir} NAME) GET_FILENAME_COMPONENT(name ${dir} NAME)
FILE(APPEND ${file} "${prefix}<Directory Id='D.${id}' Name='${name}'>\n") FILE(APPEND ${file} "${prefix}<Directory Id='D.${id}' Name='${name}'>\n")
ENDIF() ENDIF()
FILE(GLOB all_files ${dir}/*) FILE(GLOB all_files ${dir}/*)
FOREACH(f ${all_files}) FOREACH(f ${all_files})
IF(IS_DIRECTORY ${f}) IF(IS_DIRECTORY ${f})
TRAVERSE_DIRECTORIES(${f} ${topdir} ${file} "${prefix} ") TRAVERSE_DIRECTORIES(${f} ${topdir} ${file} "${prefix} ")
ENDIF() ENDIF()
ENDFOREACH() ENDFOREACH()
IF(rel AND IS_DIRECTORY "${f}") IF(rel)
FILE(APPEND ${file} "${prefix}</Directory>\n") FILE(APPEND ${file} "${prefix}</Directory>\n")
ENDIF() ENDIF()
ENDFUNCTION() ENDFUNCTION()
...@@ -317,16 +359,25 @@ ENDIF() ...@@ -317,16 +359,25 @@ ENDIF()
FILE(REMOVE mysql_server.wixobj) FILE(REMOVE mysql_server.wixobj)
EXECUTE_PROCESS( EXECUTE_PROCESS(
COMMAND ${CANDLE_EXECUTABLE} -ext WixUtilExtension mysql_server.wxs ${EXTRA_CANDLE_ARGS} COMMAND ${CANDLE_EXECUTABLE} -ext WixUtilExtension mysql_server.wxs ${EXTRA_CANDLE_ARGS}
RESULT_VARIABLE CANDLE_RESULT
) )
IF(CANDLE_RESULT)
MESSAGE(FATAL_ERROR "ERROR: can't run candle")
ENDIF()
EXECUTE_PROCESS( EXECUTE_PROCESS(
COMMAND ${LIGHT_EXECUTABLE} -ext WixUIExtension -ext WixUtilExtension COMMAND ${LIGHT_EXECUTABLE} -ext WixUIExtension -ext WixUtilExtension
mysql_server.wixobj -out ${CPACK_PACKAGE_FILE_NAME}.msi mysql_server.wixobj -out ${CPACK_PACKAGE_FILE_NAME}.msi
${EXTRA_LIGHT_ARGS} ${EXTRA_LIGHT_ARGS}
RESULT_VARIABLE LIGHT_RESULT
) )
IF(LIGHT_RESULT)
MESSAGE(FATAL_ERROR "ERROR: can't run light")
ENDIF()
# Switch monolithic install on again # Switch monolithic install on again
EXECUTE_PROCESS( EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -DCPACK_MONOLITHIC_INSTALL=1 ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -DCPACK_MONOLITHIC_INSTALL=1 ${CMAKE_BINARY_DIR}
OUTPUT_QUIET
) )
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi" <Include xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<WixVariable Id="WixUICostingPopupOptOut" Value="1" Overridable="yes" />
<UI Id="WixUI_Mondo_Custom"> <UI Id="WixUI_Mondo_Custom">
<Dialog Id="CustomWelcomeDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="Next" Type="PushButton" X="220" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
<Publish Event="NewDialog" Value="LicenseAgreementDlg">NOT OLDERVERSIONBEINGUPGRADED</Publish>
<Publish Event="NewDialog" Value="UpgradeDlg">OLDERVERSIONBEINGUPGRADED</Publish>
</Control>
<Control Id="Back" Type="PushButton" X="156" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" Disabled="yes" />
<Control Id="Description" Type="Text" X="135" Y="80" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.WelcomeDlgDescription)" />
<Control Id="Title" Type="Text" X="135" Y="20" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.WelcomeDlgTitle)" />
<Control Id="CopyrightText" Type="Text" X="135" Y="200" Width="220" Height="40" Transparent="yes" Text="Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved." />
<Control Id="Bitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="234" TabSkip="no" Text="!(loc.WelcomeDlgBitmap)" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
</Dialog>
<Dialog Id="UpgradeDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes"> <Dialog Id="UpgradeDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
<Control Id="Install" Type="PushButton" ElevationShield="yes" X="212" Y="243" Width="80" Height="17" Default="yes" Text="Upgrade"> <Control Id="Install" Type="PushButton" ElevationShield="yes" X="212" Y="243" Width="80" Height="17" Default="yes" Text="Upgrade">
<Publish Event="EndDialog" Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish> <Publish Event="EndDialog" Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish>
...@@ -47,10 +62,7 @@ ...@@ -47,10 +62,7 @@
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish> <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg" Order="1">NOT OLDERVERSIONBEINGUPGRADED</Publish> <Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="CustomWelcomeDlg">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="UpgradeDlg" Order="2">OLDERVERSIONBEINGUPGRADED</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="SetupTypeDlg" Order="2">LicenseAccepted = "1"</Publish> <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="SetupTypeDlg" Order="2">LicenseAccepted = "1"</Publish>
<Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish> <Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
...@@ -74,7 +86,11 @@ ...@@ -74,7 +86,11 @@
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish> <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish> <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
<Publish Dialog="UpgradeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish> <Publish Dialog="UpgradeDlg" Control="Back" Event="NewDialog" Value="CustomWelcomeDlg">1</Publish>
<InstallUISequence>
<Show Dialog="CustomWelcomeDlg" Before="ProgressDlg">NOT Installed</Show>
</InstallUISequence>
</UI> </UI>
<UIRef Id="WixUI_Common" /> <UIRef Id="WixUI_Common" />
......
...@@ -1591,6 +1591,11 @@ bool Item_func_from_days::get_date(MYSQL_TIME *ltime, uint fuzzy_date) ...@@ -1591,6 +1591,11 @@ bool Item_func_from_days::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
return 1; return 1;
bzero(ltime, sizeof(MYSQL_TIME)); bzero(ltime, sizeof(MYSQL_TIME));
get_date_from_daynr((long) value, &ltime->year, &ltime->month, &ltime->day); get_date_from_daynr((long) value, &ltime->year, &ltime->month, &ltime->day);
if ((null_value= (fuzzy_date & TIME_NO_ZERO_DATE) &&
(ltime->year == 0 || ltime->month == 0 || ltime->day == 0)))
return TRUE;
ltime->time_type= MYSQL_TIMESTAMP_DATE; ltime->time_type= MYSQL_TIMESTAMP_DATE;
return 0; return 0;
} }
...@@ -2779,7 +2784,7 @@ String *Item_func_makedate::val_str(String *str) ...@@ -2779,7 +2784,7 @@ String *Item_func_makedate::val_str(String *str)
long days; long days;
if (args[0]->null_value || args[1]->null_value || if (args[0]->null_value || args[1]->null_value ||
year < 0 || daynr <= 0) year < 0 || year > 9999 || daynr <= 0)
goto err; goto err;
if (year < 100) if (year < 100)
...@@ -2822,7 +2827,7 @@ longlong Item_func_makedate::val_int() ...@@ -2822,7 +2827,7 @@ longlong Item_func_makedate::val_int()
long days; long days;
if (args[0]->null_value || args[1]->null_value || if (args[0]->null_value || args[1]->null_value ||
year < 0 || daynr <= 0) year < 0 || year > 9999 || daynr <= 0)
goto err; goto err;
if (year < 100) if (year < 100)
......
...@@ -216,6 +216,10 @@ extern char err_shared_dir[]; ...@@ -216,6 +216,10 @@ extern char err_shared_dir[];
extern TYPELIB thread_handling_typelib; extern TYPELIB thread_handling_typelib;
extern my_decimal decimal_zero; extern my_decimal decimal_zero;
/*
THR_MALLOC is a key which will be used to set/get MEM_ROOT** for a thread,
using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
*/
extern pthread_key(MEM_ROOT**,THR_MALLOC); extern pthread_key(MEM_ROOT**,THR_MALLOC);
#ifdef HAVE_PSI_INTERFACE #ifdef HAVE_PSI_INTERFACE
...@@ -503,6 +507,10 @@ get_thread_running() ...@@ -503,6 +507,10 @@ get_thread_running()
extern "C" THD *_current_thd_noinline(); extern "C" THD *_current_thd_noinline();
#define _current_thd() _current_thd_noinline() #define _current_thd() _current_thd_noinline()
#else #else
/*
THR_THD is a key which will be used to set/get THD* for a thread,
using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
*/
extern pthread_key(THD*, THR_THD); extern pthread_key(THD*, THR_THD);
inline THD *_current_thd(void) inline THD *_current_thd(void)
{ {
......
...@@ -3644,6 +3644,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, ...@@ -3644,6 +3644,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
{ // Should never happen { // Should never happen
/* Restore the state of binlog format */ /* Restore the state of binlog format */
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
thd->lex->restore_backup_query_tables_list(&backup);
if (save_binlog_row_based) if (save_binlog_row_based)
thd->set_current_stmt_binlog_format_row(); thd->set_current_stmt_binlog_format_row();
DBUG_RETURN(TRUE); /* purecov: deadcode */ DBUG_RETURN(TRUE); /* purecov: deadcode */
......
...@@ -1600,6 +1600,25 @@ bool THD::store_globals() ...@@ -1600,6 +1600,25 @@ bool THD::store_globals()
return 0; return 0;
} }
/*
Remove the thread specific info (THD and mem_root pointer) stored during
store_global call for this thread.
*/
bool THD::restore_globals()
{
/*
Assert that thread_stack is initialized: it's necessary to be able
to track stack overrun.
*/
DBUG_ASSERT(thread_stack);
/* Undocking the thread specific data. */
my_pthread_setspecific_ptr(THR_THD, NULL);
my_pthread_setspecific_ptr(THR_MALLOC, NULL);
return 0;
}
/* /*
Cleanup after query. Cleanup after query.
......
...@@ -2199,6 +2199,7 @@ class THD :public Statement, ...@@ -2199,6 +2199,7 @@ class THD :public Statement,
void cleanup(void); void cleanup(void);
void cleanup_after_query(); void cleanup_after_query();
bool store_globals(); bool store_globals();
bool restore_globals();
#ifdef SIGNAL_WITH_VIO_CLOSE #ifdef SIGNAL_WITH_VIO_CLOSE
inline void set_active_vio(Vio* vio) inline void set_active_vio(Vio* vio)
{ {
......
...@@ -27,6 +27,8 @@ int32 inserts= 0, N; ...@@ -27,6 +27,8 @@ int32 inserts= 0, N;
LF_ALLOCATOR lf_allocator; LF_ALLOCATOR lf_allocator;
LF_HASH lf_hash; LF_HASH lf_hash;
int with_my_thread_init=0;
/* /*
pin allocator - alloc and release an element in a loop pin allocator - alloc and release an element in a loop
*/ */
...@@ -36,7 +38,8 @@ pthread_handler_t test_lf_pinbox(void *arg) ...@@ -36,7 +38,8 @@ pthread_handler_t test_lf_pinbox(void *arg)
int32 x= 0; int32 x= 0;
LF_PINS *pins; LF_PINS *pins;
my_thread_init(); if (with_my_thread_init)
my_thread_init();
pins= lf_pinbox_get_pins(&lf_allocator.pinbox); pins= lf_pinbox_get_pins(&lf_allocator.pinbox);
...@@ -49,7 +52,10 @@ pthread_handler_t test_lf_pinbox(void *arg) ...@@ -49,7 +52,10 @@ pthread_handler_t test_lf_pinbox(void *arg)
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
if (!--running_threads) pthread_cond_signal(&cond); if (!--running_threads) pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
my_thread_end();
if (with_my_thread_init)
my_thread_end();
return 0; return 0;
} }
...@@ -68,7 +74,8 @@ pthread_handler_t test_lf_alloc(void *arg) ...@@ -68,7 +74,8 @@ pthread_handler_t test_lf_alloc(void *arg)
int32 x,y= 0; int32 x,y= 0;
LF_PINS *pins; LF_PINS *pins;
my_thread_init(); if (with_my_thread_init)
my_thread_init();
pins= lf_alloc_get_pins(&lf_allocator); pins= lf_alloc_get_pins(&lf_allocator);
...@@ -101,7 +108,9 @@ pthread_handler_t test_lf_alloc(void *arg) ...@@ -101,7 +108,9 @@ pthread_handler_t test_lf_alloc(void *arg)
} }
if (!--running_threads) pthread_cond_signal(&cond); if (!--running_threads) pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
my_thread_end();
if (with_my_thread_init)
my_thread_end();
return 0; return 0;
} }
...@@ -112,7 +121,8 @@ pthread_handler_t test_lf_hash(void *arg) ...@@ -112,7 +121,8 @@ pthread_handler_t test_lf_hash(void *arg)
int32 x,y,z,sum= 0, ins= 0; int32 x,y,z,sum= 0, ins= 0;
LF_PINS *pins; LF_PINS *pins;
my_thread_init(); if (with_my_thread_init)
my_thread_init();
pins= lf_hash_get_pins(&lf_hash); pins= lf_hash_get_pins(&lf_hash);
...@@ -152,14 +162,15 @@ pthread_handler_t test_lf_hash(void *arg) ...@@ -152,14 +162,15 @@ pthread_handler_t test_lf_hash(void *arg)
} }
if (!--running_threads) pthread_cond_signal(&cond); if (!--running_threads) pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
my_thread_end(); if (with_my_thread_init)
my_thread_end();
return 0; return 0;
} }
void do_tests() void do_tests()
{ {
plan(4); plan(7);
lf_alloc_init(&lf_allocator, sizeof(TLA), offsetof(TLA, not_used)); lf_alloc_init(&lf_allocator, sizeof(TLA), offsetof(TLA, not_used));
lf_hash_init(&lf_hash, sizeof(int), LF_HASH_UNIQUE, 0, sizeof(int), 0, lf_hash_init(&lf_hash, sizeof(int), LF_HASH_UNIQUE, 0, sizeof(int), 0,
...@@ -168,9 +179,15 @@ void do_tests() ...@@ -168,9 +179,15 @@ void do_tests()
bad= my_atomic_initialize(); bad= my_atomic_initialize();
ok(!bad, "my_atomic_initialize() returned %d", bad); ok(!bad, "my_atomic_initialize() returned %d", bad);
test_concurrently("lf_pinbox", test_lf_pinbox, N= THREADS, CYCLES); with_my_thread_init= 1;
test_concurrently("lf_alloc", test_lf_alloc, N= THREADS, CYCLES); test_concurrently("lf_pinbox (with my_thread_init)", test_lf_pinbox, N= THREADS, CYCLES);
test_concurrently("lf_hash", test_lf_hash, N= THREADS, CYCLES/10); test_concurrently("lf_alloc (with my_thread_init)", test_lf_alloc, N= THREADS, CYCLES);
test_concurrently("lf_hash (with my_thread_init)", test_lf_hash, N= THREADS, CYCLES/10);
with_my_thread_init= 0;
test_concurrently("lf_pinbox (without my_thread_init)", test_lf_pinbox, N= THREADS, CYCLES);
test_concurrently("lf_alloc (without my_thread_init)", test_lf_alloc, N= THREADS, CYCLES);
test_concurrently("lf_hash (without my_thread_init)", test_lf_hash, N= THREADS, CYCLES/10);
lf_hash_destroy(&lf_hash); lf_hash_destroy(&lf_hash);
lf_alloc_destroy(&lf_allocator); lf_alloc_destroy(&lf_allocator);
......
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