Automerge

This commit is contained in:
Kristofer Pettersson 2011-05-10 18:12:48 +02:00
commit 8c5ce977c6
132 changed files with 2167 additions and 1613 deletions

View File

@ -42,6 +42,10 @@
*.vcxproj *.vcxproj
*.vcxproj.filters *.vcxproj.filters
*/*.dir/* */*.dir/*
*.dir
Debug
MySql.sdf
Win32
*/*_pure_*warnings */*_pure_*warnings
*/.deps */.deps
*/.libs/* */.libs/*
@ -611,6 +615,7 @@ include/mysql_h.ic
include/mysql_version.h include/mysql_version.h
include/mysqld_ername.h include/mysqld_ername.h
include/mysqld_error.h include/mysqld_error.h
include/mysqld_error.h.rule
include/openssl include/openssl
include/readline include/readline
include/readline/*.h include/readline/*.h
@ -1883,7 +1888,9 @@ scripts/mysql_find_rows
scripts/mysql_fix_extensions scripts/mysql_fix_extensions
scripts/mysql_fix_privilege_tables scripts/mysql_fix_privilege_tables
scripts/mysql_fix_privilege_tables.sql scripts/mysql_fix_privilege_tables.sql
scripts/mysql_fix_privilege_tables.sql.rule
scripts/mysql_fix_privilege_tables_sql.c scripts/mysql_fix_privilege_tables_sql.c
scripts/mysql_fix_privilege_tables_sql.c.rule
scripts/mysql_install_db scripts/mysql_install_db
scripts/mysql_secure_installation scripts/mysql_secure_installation
scripts/mysql_setpermission scripts/mysql_setpermission
@ -2120,6 +2127,7 @@ sql/handlerton.cc
sql/html sql/html
sql/latex sql/latex
sql/lex_hash.h sql/lex_hash.h
sql/lex_hash.h.rule
sql/link_sources sql/link_sources
sql/max/* sql/max/*
sql/message.h sql/message.h
@ -2151,6 +2159,7 @@ sql/sql_builtin.cc
sql/sql_select.cc.orig sql/sql_select.cc.orig
sql/sql_yacc.cc sql/sql_yacc.cc
sql/sql_yacc.h sql/sql_yacc.h
sql/sql_yacc.h.rule
sql/sql_yacc.output sql/sql_yacc.output
sql/sql_yacc.yy.orig sql/sql_yacc.yy.orig
sql/test_time sql/test_time

View File

@ -116,10 +116,10 @@ link_sources:
@LN_CP_F@ $(top_srcdir)/sql/$$f $$f; \ @LN_CP_F@ $(top_srcdir)/sql/$$f $$f; \
done; \ done; \
for f in $(strings_src) ; do \ for f in $(strings_src) ; do \
rm -f $(srcdir)/$$f; \ rm -f $$f; \
@LN_CP_F@ $(top_srcdir)/strings/$$f $$f; \ @LN_CP_F@ $(top_srcdir)/strings/$$f $$f; \
done; \ done; \
rm -f $(srcdir)/my_user.c; \ rm -f my_user.c; \
@LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c; @LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c;
echo timestamp > link_sources; echo timestamp > link_sources;

View File

@ -951,7 +951,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
passed --short-form, because --short-form disables printing passed --short-form, because --short-form disables printing
row events. row events.
*/ */
if (!print_event_info->printed_fd_event && !short_form) if (!print_event_info->printed_fd_event && !short_form &&
opt_base64_output_mode != BASE64_OUTPUT_DECODE_ROWS)
{ {
const char* type_str= ev->get_type_str(); const char* type_str= ev->get_type_str();
if (opt_base64_output_mode == BASE64_OUTPUT_NEVER) if (opt_base64_output_mode == BASE64_OUTPUT_NEVER)

View File

@ -4461,13 +4461,14 @@ static int my_kill(int pid, int sig)
command called command command called command
DESCRIPTION DESCRIPTION
shutdown [<timeout>] shutdown_server [<timeout>]
*/ */
void do_shutdown_server(struct st_command *command) void do_shutdown_server(struct st_command *command)
{ {
int timeout=60, pid; long timeout=60;
int pid;
DYNAMIC_STRING ds_pidfile_name; DYNAMIC_STRING ds_pidfile_name;
MYSQL* mysql = &cur_con->mysql; MYSQL* mysql = &cur_con->mysql;
static DYNAMIC_STRING ds_timeout; static DYNAMIC_STRING ds_timeout;
@ -4482,8 +4483,9 @@ void do_shutdown_server(struct st_command *command)
if (ds_timeout.length) if (ds_timeout.length)
{ {
timeout= atoi(ds_timeout.str); char* endptr;
if (timeout == 0) timeout= strtol(ds_timeout.str, &endptr, 10);
if (*endptr != '\0')
die("Illegal argument for timeout: '%s'", ds_timeout.str); die("Illegal argument for timeout: '%s'", ds_timeout.str);
} }
dynstr_free(&ds_timeout); dynstr_free(&ds_timeout);
@ -4525,7 +4527,7 @@ void do_shutdown_server(struct st_command *command)
DBUG_PRINT("info", ("Process %d does not exist anymore", pid)); DBUG_PRINT("info", ("Process %d does not exist anymore", pid));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
DBUG_PRINT("info", ("Sleeping, timeout: %d", timeout)); DBUG_PRINT("info", ("Sleeping, timeout: %ld", timeout));
my_sleep(1000000L); my_sleep(1000000L);
} }
@ -9737,7 +9739,7 @@ int find_set(REP_SETS *sets,REP_SET *find)
return i; return i;
} }
} }
return i; /* return new postion */ return i; /* return new position */
} }
/* find if there is a found_set with same table_offset & found_offset /* find if there is a found_set with same table_offset & found_offset
@ -9757,7 +9759,7 @@ int find_found(FOUND_SET *found_set,uint table_offset, int found_offset)
found_set[i].table_offset=table_offset; found_set[i].table_offset=table_offset;
found_set[i].found_offset=found_offset; found_set[i].found_offset=found_offset;
found_sets++; found_sets++;
return -i-2; /* return new postion */ return -i-2; /* return new position */
} }
/* Return 1 if regexp starts with \b or ends with \b*/ /* Return 1 if regexp starts with \b or ends with \b*/

View File

@ -478,7 +478,13 @@ el_source(EditLine *el, const char *fname)
fp = NULL; fp = NULL;
if (fname == NULL) { if (fname == NULL) {
#ifdef HAVE_ISSETUGID /* XXXMYSQL: Bug#49967 */
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID) && \
defined(HAVE_GETGID) && defined(HAVE_GETEGID)
#define HAVE_IDENTITY_FUNCS 1
#endif
#if (defined(HAVE_ISSETUGID) || defined(HAVE_IDENTITY_FUNCS))
static const char elpath[] = "/.editrc"; static const char elpath[] = "/.editrc";
/* XXXMYSQL: Portability fix (for which platforms?) */ /* XXXMYSQL: Portability fix (for which platforms?) */
#ifdef MAXPATHLEN #ifdef MAXPATHLEN
@ -486,9 +492,13 @@ el_source(EditLine *el, const char *fname)
#else #else
char path[4096]; char path[4096];
#endif #endif
#ifdef HAVE_ISSETUGID
if (issetugid()) if (issetugid())
return (-1); return (-1);
#elif defined(HAVE_IDENTITY_FUNCS)
if (getuid() != geteuid() || getgid() != getegid())
return (-1);
#endif
if ((ptr = getenv("HOME")) == NULL) if ((ptr = getenv("HOME")) == NULL)
return (-1); return (-1);
if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path)) if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path))
@ -498,9 +508,10 @@ el_source(EditLine *el, const char *fname)
fname = path; fname = path;
#else #else
/* /*
* If issetugid() is missing, always return an error, in order * If issetugid() or the above mentioned get[e][u|g]id()
* to keep from inadvertently opening up the user to a security * functions are missing, always return an error, in order
* hole. * to keep from inadvertently opening up the user to a
* security hole.
*/ */
return (-1); return (-1);
#endif #endif

View File

@ -1012,8 +1012,10 @@ vi_histedit(EditLine *el, int c __attribute__((__unused__)))
if (fd < 0) if (fd < 0)
return CC_ERROR; return CC_ERROR;
cp = el->el_line.buffer; cp = el->el_line.buffer;
write(fd, cp, el->el_line.lastchar - cp +0u); if (write(fd, cp, el->el_line.lastchar - cp +0u) == -1)
write(fd, "\n", 1); goto error;
if (write(fd, "\n", 1) == -1)
goto error;
pid = fork(); pid = fork();
switch (pid) { switch (pid) {
case -1: case -1:
@ -1041,6 +1043,12 @@ vi_histedit(EditLine *el, int c __attribute__((__unused__)))
unlink(tempfile); unlink(tempfile);
/* return CC_REFRESH; */ /* return CC_REFRESH; */
return ed_newline(el, 0); return ed_newline(el, 0);
/* XXXMYSQL: Avoid compiler warnings. */
error:
close(fd);
unlink(tempfile);
return CC_ERROR;
} }
/* vi_history_word(): /* vi_history_word():

View File

@ -1963,7 +1963,7 @@ AC_CHECK_HEADER(vis.h,
[AC_DEFINE([HAVE_VIS_H], [1],[Found vis.h and the strvis() function])])]) [AC_DEFINE([HAVE_VIS_H], [1],[Found vis.h and the strvis() function])])])
AC_CHECK_FUNCS(strlcat strlcpy) AC_CHECK_FUNCS(strlcat strlcpy)
AC_CHECK_FUNCS(issetugid) AC_CHECK_FUNCS(issetugid getuid geteuid getgid getegid)
AC_CHECK_FUNCS(fgetln) AC_CHECK_FUNCS(fgetln)
AC_CHECK_FUNCS(getline flockfile) AC_CHECK_FUNCS(getline flockfile)

View File

@ -1,17 +1,19 @@
/* Copyright (C) 2000 MySQL AB /* Copyright (c) 2000, 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
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License
the Free Software Foundation; version 2 of the 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, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA */
/* /*
Replace strings in textfile Replace strings in textfile
@ -819,7 +821,7 @@ static short find_set(REP_SETS *sets,REP_SET *find)
return (short) i; return (short) i;
} }
} }
return (short) i; /* return new postion */ return (short) i; /* return new position */
} }
@ -842,7 +844,7 @@ static short find_found(FOUND_SET *found_set,uint table_offset,
found_set[i].table_offset=table_offset; found_set[i].table_offset=table_offset;
found_set[i].found_offset=found_offset; found_set[i].found_offset=found_offset;
found_sets++; found_sets++;
return (short) (-i-2); /* return new postion */ return (short) (-i-2); /* return new position */
} }
/* Return 1 if regexp starts with \b or ends with \b*/ /* Return 1 if regexp starts with \b or ends with \b*/

View File

@ -2,6 +2,8 @@
# in alphabetical order. This also helps with merge conflict resolution. # in alphabetical order. This also helps with merge conflict resolution.
binlog.binlog_multi_engine # joro : NDB tests marked as experimental as agreed with bochklin binlog.binlog_multi_engine # joro : NDB tests marked as experimental as agreed with bochklin
binlog.binlog_bug23533 # skozlov: BUG#12371924
funcs_1.charset_collation_1 # depends on compile-time decisions funcs_1.charset_collation_1 # depends on compile-time decisions
funcs_1.is_cml_ndb # joro : NDB tests marked as experimental as agreed with bochklin funcs_1.is_cml_ndb # joro : NDB tests marked as experimental as agreed with bochklin
@ -22,7 +24,8 @@ main.outfile_loaddata @solaris # joro : Bug #46895
ndb.* # joro : NDB tests marked as experimental as agreed with bochklin ndb.* # joro : NDB tests marked as experimental as agreed with bochklin
rpl.rpl_innodb_bug28430 @solaris # Bug#46029 rpl.rpl_innodb_bug28430 @solaris # Bug#46029
rpl.rpl_row_sp011 @solaris # Joro : Bug #54138 rpl.rpl_row_sp011 @solaris # Joro : Bug #45445
rpl.rpl_stop_slave # Sven : BUG#12345981
rpl_ndb.* # joro : NDB tests marked as experimental as agreed with bochklin rpl_ndb.* # joro : NDB tests marked as experimental as agreed with bochklin
rpl_ndb.rpl_ndb_log # Bug#38998 rpl_ndb.rpl_ndb_log # Bug#38998

View File

@ -7,7 +7,7 @@ let $counter= 500;
let $mysql_errno= 0; let $mysql_errno= 0;
while (!$mysql_errno) while (!$mysql_errno)
{ {
--error 0,1053,2002,2006,2013 --error 0,1040,1053,2002,2003,2006,2013
show status; show status;
dec $counter; dec $counter;

View File

@ -1,5 +1,5 @@
# -*- cperl -*- # -*- cperl -*-
# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public # modify it under the terms of the GNU Library General Public
@ -141,7 +141,11 @@ sub fix_tmpdir {
sub fix_log_error { sub fix_log_error {
my ($self, $config, $group_name, $group)= @_; my ($self, $config, $group_name, $group)= @_;
my $dir= $self->{ARGS}->{vardir}; my $dir= $self->{ARGS}->{vardir};
return "$dir/log/$group_name.err"; if ( $::opt_valgrind and $::opt_debug ) {
return "$dir/log/$group_name.trace";
} else {
return "$dir/log/$group_name.err";
}
} }
sub fix_log { sub fix_log {

View File

@ -1,5 +1,5 @@
# -*- cperl -*- # -*- cperl -*-
# Copyright (C) 2008 MySQL AB # Copyright (c) 2004, 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
@ -28,8 +28,6 @@ use My::Platform;
use base qw(Exporter); use base qw(Exporter);
our @EXPORT= qw(my_find_bin my_find_dir my_find_file NOT_REQUIRED); our @EXPORT= qw(my_find_bin my_find_dir my_find_file NOT_REQUIRED);
our $vs_config_dir;
my $bin_extension= ".exe" if IS_WINDOWS; my $bin_extension= ".exe" if IS_WINDOWS;
# Helper function to be used for fourth parameter to find functions # Helper function to be used for fourth parameter to find functions
@ -158,7 +156,7 @@ sub my_find_paths {
# User can select to look in a special build dir # User can select to look in a special build dir
# which is a subdirectory of any of the paths # which is a subdirectory of any of the paths
my @extra_dirs; my @extra_dirs;
my $build_dir= $vs_config_dir || $ENV{MTR_VS_CONFIG} || $ENV{MTR_BUILD_DIR}; my $build_dir= $::opt_vs_config || $ENV{MTR_VS_CONFIG} || $ENV{MTR_BUILD_DIR};
push(@extra_dirs, $build_dir) if defined $build_dir; push(@extra_dirs, $build_dir) if defined $build_dir;
if (defined $extension){ if (defined $extension){

View File

@ -94,7 +94,7 @@ eval {
local $SIG{INT}= \&handle_signal; local $SIG{INT}= \&handle_signal;
local $SIG{CHLD}= sub { local $SIG{CHLD}= sub {
message("Got signal @_"); message("Got signal @_");
kill(9, -$child_pid); kill('KILL', -$child_pid);
my $ret= waitpid($child_pid, 0); my $ret= waitpid($child_pid, 0);
if ($? & 127){ if ($? & 127){
exit(65); # Killed by signal exit(65); # Killed by signal
@ -134,7 +134,7 @@ if ( $@ ) {
# Use negative pid in order to kill the whole # Use negative pid in order to kill the whole
# process group # process group
# #
my $ret= kill(9, -$child_pid); my $ret= kill('KILL', -$child_pid);
message("Killed child: $child_pid, ret: $ret"); message("Killed child: $child_pid, ret: $ret");
if ($ret > 0) { if ($ret > 0) {
message("Killed child: $child_pid"); message("Killed child: $child_pid");

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl #!/usr/bin/perl
# -*- cperl -*- # -*- cperl -*-
# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public # modify it under the terms of the GNU Library General Public
@ -256,7 +256,7 @@ my $opt_strace_client;
our $opt_user = "root"; our $opt_user = "root";
my $opt_valgrind= 0; our $opt_valgrind= 0;
my $opt_valgrind_mysqld= 0; my $opt_valgrind_mysqld= 0;
my $opt_valgrind_mysqltest= 0; my $opt_valgrind_mysqltest= 0;
my @default_valgrind_args= ("--show-reachable=yes"); my @default_valgrind_args= ("--show-reachable=yes");
@ -893,7 +893,7 @@ sub command_line_setup {
'ssl|with-openssl' => \$opt_ssl, 'ssl|with-openssl' => \$opt_ssl,
'skip-ssl' => \$opt_skip_ssl, 'skip-ssl' => \$opt_skip_ssl,
'compress' => \$opt_compress, 'compress' => \$opt_compress,
'vs-config' => \$opt_vs_config, 'vs-config=s' => \$opt_vs_config,
# Max number of parallel threads to use # Max number of parallel threads to use
'parallel=s' => \$opt_parallel, 'parallel=s' => \$opt_parallel,
@ -1123,7 +1123,7 @@ sub command_line_setup {
chomp; chomp;
# remove comments (# foo) at the beginning of the line, or after a # remove comments (# foo) at the beginning of the line, or after a
# blank at the end of the line # blank at the end of the line
s/( +|^)#.*$//; s/(\s+|^)#.*$//;
# If @ platform specifier given, use this entry only if it contains # If @ platform specifier given, use this entry only if it contains
# @<platform> or @!<xxx> where xxx != platform # @<platform> or @!<xxx> where xxx != platform
if (/\@.*/) if (/\@.*/)
@ -1134,8 +1134,8 @@ sub command_line_setup {
s/\@.*$//; s/\@.*$//;
} }
# remove whitespace # remove whitespace
s/^ +//; s/^\s+//;
s/ +$//; s/\s+$//;
# if nothing left, don't need to remember this line # if nothing left, don't need to remember this line
if ( $_ eq "" ) { if ( $_ eq "" ) {
next; next;
@ -4544,13 +4544,6 @@ sub mysqld_start ($$) {
unlink($mysqld->value('pid-file')); unlink($mysqld->value('pid-file'));
my $output= $mysqld->value('#log-error'); my $output= $mysqld->value('#log-error');
if ( $opt_valgrind and $opt_debug )
{
# When both --valgrind and --debug is selected, send
# all output to the trace file, making it possible to
# see the exact location where valgrind complains
$output= "$opt_vardir/log/".$mysqld->name().".trace";
}
# Remember this log file for valgrind error report search # Remember this log file for valgrind error report search
$mysqld_logs{$output}= 1 if $opt_valgrind; $mysqld_logs{$output}= 1 if $opt_valgrind;
# Remember data dir for gmon.out files if using gprof # Remember data dir for gmon.out files if using gprof

View File

@ -135,4 +135,17 @@ SELECT * FROM t1 PROCEDURE ANALYSE();
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.a e e- 1 2 0 0 1.3333 NULL ENUM('e','e-') NOT NULL test.t1.a e e- 1 2 0 0 1.3333 NULL ENUM('e','e-') NOT NULL
DROP TABLE t1; DROP TABLE t1;
#
# Bug#11756242 48137: PROCEDURE ANALYSE() LEAKS MEMORY WHEN RETURNING NULL
#
CREATE TABLE t1(f1 INT) ENGINE=MYISAM;
CREATE TABLE t2(f2 INT) ENGINE=INNODB;
INSERT INTO t2 VALUES (1);
SELECT DISTINCTROW f1 FROM t1 NATURAL RIGHT OUTER JOIN t2 PROCEDURE ANALYSE();
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.f1 NULL NULL 0 0 0 1 0.0 0.0 CHAR(0)
SELECT * FROM t2 LIMIT 1 PROCEDURE ANALYSE();
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t2.f2 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL
DROP TABLE t1, t2;
End of 5.1 tests End of 5.1 tests

View File

@ -1,3 +1,4 @@
call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted");
drop database if exists events_test; drop database if exists events_test;
drop database if exists db_x; drop database if exists db_x;
drop database if exists mysqltest_db2; drop database if exists mysqltest_db2;
@ -259,33 +260,36 @@ events_test intact_check root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLE
Try to alter mysql.event: the server should fail to load Try to alter mysql.event: the server should fail to load
event information after mysql.event was tampered with. event information after mysql.event was tampered with.
First, let's add a column to the end and make sure everything First, let's add a column to the end and check the error is emitted.
works as before
ALTER TABLE mysql.event ADD dummy INT; ALTER TABLE mysql.event ADD dummy INT;
SHOW EVENTS; SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation ERROR HY000: Failed to open mysql.event
events_test intact_check root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
SELECT event_name FROM INFORMATION_SCHEMA.events; SELECT event_name FROM INFORMATION_SCHEMA.events;
event_name ERROR HY000: Failed to open mysql.event
intact_check
SHOW CREATE EVENT intact_check; SHOW CREATE EVENT intact_check;
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation ERROR HY000: Failed to open mysql.event
intact_check SYSTEM CREATE EVENT `intact_check` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO SELECT "nothing" latin1 latin1_swedish_ci latin1_swedish_ci
DROP EVENT no_such_event; DROP EVENT no_such_event;
ERROR HY000: Unknown event 'no_such_event' ERROR HY000: Failed to open mysql.event
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
ERROR HY000: Failed to open mysql.event
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
ERROR HY000: Failed to open mysql.event
ALTER EVENT intact_check_1 RENAME TO intact_check_2; ALTER EVENT intact_check_1 RENAME TO intact_check_2;
ERROR HY000: Failed to open mysql.event
DROP EVENT intact_check_1; DROP EVENT intact_check_1;
ERROR HY000: Unknown event 'intact_check_1' ERROR HY000: Failed to open mysql.event
DROP EVENT intact_check_2; DROP EVENT intact_check_2;
ERROR HY000: Failed to open mysql.event
DROP EVENT intact_check; DROP EVENT intact_check;
ERROR HY000: Failed to open mysql.event
DROP DATABASE IF EXISTS mysqltest_no_such_database; DROP DATABASE IF EXISTS mysqltest_no_such_database;
Warnings: Warnings:
Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist
CREATE DATABASE mysqltest_db2; CREATE DATABASE mysqltest_db2;
DROP DATABASE mysqltest_db2; DROP DATABASE mysqltest_db2;
Warnings:
Error 1545 Failed to open mysql.event
SELECT @@event_scheduler; SELECT @@event_scheduler;
@@event_scheduler @@event_scheduler
OFF OFF
@ -294,6 +298,7 @@ Variable_name Value
event_scheduler OFF event_scheduler OFF
SET GLOBAL event_scheduler=OFF; SET GLOBAL event_scheduler=OFF;
ALTER TABLE mysql.event DROP dummy; ALTER TABLE mysql.event DROP dummy;
DROP EVENT intact_check;
CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing"; CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing";
Now let's add a column to the first position: the server Now let's add a column to the first position: the server
@ -301,30 +306,32 @@ expects to see event schema name there
ALTER TABLE mysql.event ADD dummy INT FIRST; ALTER TABLE mysql.event ADD dummy INT FIRST;
SHOW EVENTS; SHOW EVENTS;
ERROR HY000: Cannot load from mysql.event. The table is probably corrupted ERROR HY000: Failed to open mysql.event
SELECT event_name FROM INFORMATION_SCHEMA.events; SELECT event_name FROM INFORMATION_SCHEMA.events;
ERROR HY000: Cannot load from mysql.event. The table is probably corrupted ERROR HY000: Failed to open mysql.event
SHOW CREATE EVENT intact_check; SHOW CREATE EVENT intact_check;
ERROR HY000: Unknown event 'intact_check' ERROR HY000: Failed to open mysql.event
DROP EVENT no_such_event; DROP EVENT no_such_event;
ERROR HY000: Unknown event 'no_such_event' ERROR HY000: Failed to open mysql.event
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
ERROR HY000: Failed to store event name. Error code 2 from storage engine. ERROR HY000: Failed to open mysql.event
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
ERROR HY000: Unknown event 'intact_check_1' ERROR HY000: Failed to open mysql.event
ALTER EVENT intact_check_1 RENAME TO intact_check_2; ALTER EVENT intact_check_1 RENAME TO intact_check_2;
ERROR HY000: Unknown event 'intact_check_1' ERROR HY000: Failed to open mysql.event
DROP EVENT intact_check_1; DROP EVENT intact_check_1;
ERROR HY000: Unknown event 'intact_check_1' ERROR HY000: Failed to open mysql.event
DROP EVENT intact_check_2; DROP EVENT intact_check_2;
ERROR HY000: Unknown event 'intact_check_2' ERROR HY000: Failed to open mysql.event
DROP EVENT intact_check; DROP EVENT intact_check;
ERROR HY000: Unknown event 'intact_check' ERROR HY000: Failed to open mysql.event
DROP DATABASE IF EXISTS mysqltest_no_such_database; DROP DATABASE IF EXISTS mysqltest_no_such_database;
Warnings: Warnings:
Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist
CREATE DATABASE mysqltest_db2; CREATE DATABASE mysqltest_db2;
DROP DATABASE mysqltest_db2; DROP DATABASE mysqltest_db2;
Warnings:
Error 1545 Failed to open mysql.event
SELECT @@event_scheduler; SELECT @@event_scheduler;
@@event_scheduler @@event_scheduler
OFF OFF
@ -345,29 +352,32 @@ Drop some columns and try more checks.
ALTER TABLE mysql.event DROP comment, DROP starts; ALTER TABLE mysql.event DROP comment, DROP starts;
SHOW EVENTS; SHOW EVENTS;
ERROR HY000: Cannot load from mysql.event. The table is probably corrupted ERROR HY000: Failed to open mysql.event
SELECT event_name FROM INFORMATION_SCHEMA.EVENTS; SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
ERROR HY000: Cannot load from mysql.event. The table is probably corrupted ERROR HY000: Failed to open mysql.event
SHOW CREATE EVENT intact_check; SHOW CREATE EVENT intact_check;
ERROR HY000: Cannot load from mysql.event. The table is probably corrupted ERROR HY000: Failed to open mysql.event
DROP EVENT no_such_event; DROP EVENT no_such_event;
ERROR HY000: Unknown event 'no_such_event' ERROR HY000: Failed to open mysql.event
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
ERROR HY000: Column count of mysql.event is wrong. Expected 22, found 20. The table is probably corrupted ERROR HY000: Failed to open mysql.event
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
ERROR HY000: Unknown event 'intact_check_1' ERROR HY000: Failed to open mysql.event
ALTER EVENT intact_check_1 RENAME TO intact_check_2; ALTER EVENT intact_check_1 RENAME TO intact_check_2;
ERROR HY000: Unknown event 'intact_check_1' ERROR HY000: Failed to open mysql.event
DROP EVENT intact_check_1; DROP EVENT intact_check_1;
ERROR HY000: Unknown event 'intact_check_1' ERROR HY000: Failed to open mysql.event
DROP EVENT intact_check_2; DROP EVENT intact_check_2;
ERROR HY000: Unknown event 'intact_check_2' ERROR HY000: Failed to open mysql.event
DROP EVENT intact_check; DROP EVENT intact_check;
ERROR HY000: Failed to open mysql.event
DROP DATABASE IF EXISTS mysqltest_no_such_database; DROP DATABASE IF EXISTS mysqltest_no_such_database;
Warnings: Warnings:
Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist
CREATE DATABASE mysqltest_db2; CREATE DATABASE mysqltest_db2;
DROP DATABASE mysqltest_db2; DROP DATABASE mysqltest_db2;
Warnings:
Error 1545 Failed to open mysql.event
SELECT @@event_scheduler; SELECT @@event_scheduler;
@@event_scheduler @@event_scheduler
OFF OFF
@ -425,4 +435,42 @@ CREATE TABLE mysql.event like event_like;
DROP TABLE event_like; DROP TABLE event_like;
SHOW EVENTS; SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
#
# Bug#12394306: the sever may crash if mysql.event is corrupted
#
CREATE EVENT ev1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
ALTER EVENT ev1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
CREATE TABLE event_original LIKE mysql.event;
INSERT INTO event_original SELECT * FROM mysql.event;
ALTER TABLE mysql.event MODIFY modified CHAR(1);
Warnings:
Warning 1265 Data truncated for column 'modified' at row 1
SHOW EVENTS;
ERROR HY000: Failed to open mysql.event
SELECT event_name, created, last_altered FROM information_schema.events;
ERROR HY000: Failed to open mysql.event
CREATE EVENT ev2 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
ERROR HY000: Failed to open mysql.event
ALTER EVENT ev1 ON SCHEDULE EVERY 9 HOUR DO SELECT 9;
ERROR HY000: Failed to open mysql.event
DROP TABLE mysql.event;
RENAME TABLE event_original TO mysql.event;
DROP EVENT ev1;
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
#
# End of tests
#
drop database events_test; drop database events_test;

View File

@ -1,3 +1,4 @@
call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted");
set global event_scheduler=off; set global event_scheduler=off;
drop database if exists events_test; drop database if exists events_test;
create database events_test; create database events_test;
@ -52,6 +53,8 @@ Warnings:
Note 1008 Can't drop database 'mysqltest_database_not_exists'; database doesn't exist Note 1008 Can't drop database 'mysqltest_database_not_exists'; database doesn't exist
create database mysqltest_db1; create database mysqltest_db1;
drop database mysqltest_db1; drop database mysqltest_db1;
Warnings:
Error 1545 Failed to open mysql.event
Restore the original mysql.event table Restore the original mysql.event table
drop table mysql.event; drop table mysql.event;
rename table event_like to mysql.event; rename table event_like to mysql.event;

View File

@ -176,11 +176,12 @@ SELECT @@session.sql_mode INTO @old_sql_mode;
SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
EXPLAIN EXTENDED SELECT 1 FROM t1 EXPLAIN EXTENDED SELECT 1 FROM t1
WHERE f1 > ALL( SELECT t.f1 FROM t1,t1 AS t ); WHERE f1 > ALL( SELECT t.f1 FROM t1,t1 AS t );
ERROR 42000: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause id select_type table type possible_keys key key_len ref rows filtered Extra
SHOW WARNINGS; 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Level Code Message 2 SUBQUERY t1 system NULL NULL NULL NULL 0 0.00 const row not found
Error 1140 Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause 2 SUBQUERY t system NULL NULL NULL NULL 0 0.00 const row not found
Note 1003 select 1 AS `1` from `test`.`t1` where <not>(<exists>(...)) Warnings:
Note 1003 select 1 AS `1` from `test`.`t1` where 0
SET SESSION sql_mode=@old_sql_mode; SET SESSION sql_mode=@old_sql_mode;
DROP TABLE t1; DROP TABLE t1;
End of 5.0 tests. End of 5.0 tests.

View File

@ -1746,4 +1746,15 @@ MAX(LENGTH(a)) LENGTH(MAX(a)) MIN(a) MAX(a) CONCAT(MIN(a)) CONCAT(MAX(a))
20 20 18446668621106209655 18446668621106209655 18446668621106209655 18446668621106209655 20 20 18446668621106209655 18446668621106209655 18446668621106209655 18446668621106209655
DROP TABLE t1; DROP TABLE t1;
# #
# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
#
CREATE TABLE t1(f1 YEAR(4));
INSERT INTO t1 VALUES (0000),(2001);
(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63
MAX(f1)
2001
DROP TABLE t1;
#
End of 5.1 tests End of 5.1 tests

View File

@ -770,4 +770,10 @@ CASE a WHEN a THEN a END
NULL NULL
DROP TABLE t1; DROP TABLE t1;
# #
# Bug #11766212 59270: NOT IN (YEAR( ... ), ... ) PRODUCES MANY VALGRIND WARNINGS
#
SELECT 1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1);
1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1)
1
#
End of 5.1 tests End of 5.1 tests

View File

@ -518,4 +518,26 @@ CREATE TABLE t1 SELECT CEIL(LINESTRINGFROMWKB(1) DIV NULL);
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL); CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
DROP TABLE t1; DROP TABLE t1;
#
# Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
#
CREATE TABLE t1(f1 DECIMAL(22,1));
INSERT INTO t1 VALUES (0),(1);
SELECT ROUND(f1, f1) FROM t1;
ROUND(f1, f1)
0.0
1.0
SELECT ROUND(f1, f1) FROM t1 GROUP BY 1;
ROUND(f1, f1)
0.0
1.0
DROP TABLE t1;
#
# Bug#11764671 57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA
#
SELECT ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'));
ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'))
-4939092.0000
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
End of 5.1 tests End of 5.1 tests

View File

@ -1405,4 +1405,16 @@ NULL
SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR); SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR);
ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR) ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR)
NULL NULL
#
# Bug#11889186 60503: CRASH IN MAKE_DATE_TIME WITH DATE_FORMAT / STR_TO_DATE COMBINATION
#
SELECT DATE_FORMAT('0000-00-11', '%W');
DATE_FORMAT('0000-00-11', '%W')
NULL
SELECT DATE_FORMAT('0000-00-11', '%a');
DATE_FORMAT('0000-00-11', '%a')
NULL
SELECT DATE_FORMAT('0000-00-11', '%w');
DATE_FORMAT('0000-00-11', '%w')
NULL
End of 5.1 tests End of 5.1 tests

View File

@ -545,4 +545,26 @@ FROM t1 JOIN t2 ON t2.f2 LIKE 'x'
HAVING field1 < 7; HAVING field1 < 7;
field1 field1
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause
#
CREATE TABLE t1 (f1 INT, f2 INT);
INSERT INTO t1 VALUES (1, 0), (2, 1), (3, 2);
CREATE TABLE t2 (f1 INT, f2 INT);
SELECT t1.f1
FROM t1
HAVING (3, 2) IN (SELECT f1, f2 FROM t2) AND t1.f1 >= 0
ORDER BY t1.f1;
f1
SELECT t1.f1
FROM t1
HAVING (3, 2) IN (SELECT 4, 2) AND t1.f1 >= 0
ORDER BY t1.f1;
f1
SELECT t1.f1
FROM t1
HAVING 2 IN (SELECT f2 FROM t2) AND t1.f1 >= 0
ORDER BY t1.f1;
f1
DROP TABLE t1,t2;
End of 5.1 tests End of 5.1 tests

View File

@ -532,4 +532,20 @@ a
0 0
1 1
DROP TABLE t1; DROP TABLE t1;
#
# Bug#11765139 58069: LOAD DATA INFILE: VALGRIND REPORTS INVALID MEMORY READS AND WRITES WITH U
#
CREATE TABLE t1(f1 INT);
SELECT 0xE1BB30 INTO OUTFILE 't1.dat';
LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8;
DROP TABLE t1;
#
# Bug#11765141 - 58072: LOAD DATA INFILE: LEAKS IO CACHE MEMORY
# WHEN ERROR OCCURS
#
SELECT '1\n' INTO DUMPFILE 'MYSQLTEST_VARDIR/tmp/bug11735141.txt';
create table t1(a point);
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug11735141.txt' INTO TABLE t1;
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
End of 5.1 tests End of 5.1 tests

View File

@ -109,3 +109,13 @@ count(*)
35840 35840
drop table t1; drop table t1;
drop table t2; drop table t2;
RESET MASTER;
USE test;
SET @old_binlog_format= @@binlog_format;
SET SESSION binlog_format=ROW;
CREATE TABLE t1(c1 INT);
INSERT INTO t1 VALUES (1);
FLUSH LOGS;
DROP TABLE t1;
SET SESSION binlog_format= @old_binlog_format;
RESET MASTER;

View File

@ -79,3 +79,12 @@ a
DROP TABLE t1; DROP TABLE t1;
# Should not be any files left here # Should not be any files left here
# End of bug#30102 test. # End of bug#30102 test.
# Test of post-push fix for bug#11766249/59316
CREATE TABLE t1 (a INT, b VARCHAR(255), PRIMARY KEY (a))
ENGINE = MyISAM
PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (0) MAX_ROWS=100,
PARTITION p1 VALUES LESS THAN (100) MAX_ROWS=100,
PARTITION pMax VALUES LESS THAN MAXVALUE);
INSERT INTO t1 VALUES (1, "Partition p1, first row");
DROP TABLE t1;

View File

@ -0,0 +1,38 @@
CREATE TABLE t1 (c1 longtext);
INSERT INTO t1 values ('a');
SELECT * FROM t1 INTO OUTFILE 'MYSQL_TMP_DIR/B11764517.tmp';
show global variables like 'secure_file_priv';
Variable_name Value
secure_file_priv MYSQL_TMP_DIR/
SELECT load_file('MYSQL_TMP_DIR\\B11764517.tmp') AS x;
x
a
SELECT load_file('MYSQL_TMP_DIR/B11764517.tmp') AS x;
x
a
SELECT load_file('MYSQL_TMP_DIR_UCASE/B11764517.tmp') AS x;
x
a
SELECT load_file('MYSQL_TMP_DIR_LCASE/B11764517.tmp') AS x;
x
a
SELECT load_file('MYSQL_TMP_DIR\\..a..\\..\\..\\B11764517.tmp') AS x;
x
NULL
LOAD DATA INFILE 'MYSQL_TMP_DIR\\B11764517.tmp' INTO TABLE t1;
LOAD DATA INFILE 'MYSQL_TMP_DIR/B11764517.tmp' INTO TABLE t1;
LOAD DATA INFILE 'MYSQL_TMP_DIR_UCASE/B11764517.tmp' INTO TABLE t1;
LOAD DATA INFILE 'MYSQL_TMP_DIR_LCASE/B11764517.tmp' INTO TABLE t1;
LOAD DATA INFILE "MYSQL_TMP_DIR\\..a..\\..\\..\\B11764517.tmp" into table t1;
ERROR HY000: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
SELECT * FROM t1 INTO OUTFILE 'MYSQL_TMP_DIR\\..a..\\..\\..\\B11764517-2.tmp';
ERROR HY000: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
SELECT * FROM t1 INTO OUTFILE 'MYSQL_TMP_DIR\\B11764517-2.tmp';
SELECT * FROM t1 INTO OUTFILE 'MYSQL_TMP_DIR/B11764517-3.tmp';
SELECT * FROM t1 INTO OUTFILE 'MYSQL_TMP_DIR_UCASE/B11764517-4.tmp';
SELECT * FROM t1 INTO OUTFILE 'MYSQL_TMP_DIR_LCASE/B11764517-5.tmp';
DROP TABLE t1;

View File

@ -4435,6 +4435,32 @@ pk int_key
3 3 3 3
7 3 7 3
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# Bug#12329653
# EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY
#
CREATE TABLE t1(a1 int);
INSERT INTO t1 VALUES (1),(2);
SELECT @@session.sql_mode INTO @old_sql_mode;
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
1
1
1
PREPARE stmt FROM
'SELECT 1 UNION ALL
SELECT 1 FROM t1
ORDER BY
(SELECT 1 FROM t1 AS t1_0
WHERE 1 < SOME (SELECT a1 FROM t1)
)' ;
EXECUTE stmt ;
ERROR 21000: Subquery returns more than 1 row
EXECUTE stmt ;
ERROR 21000: Subquery returns more than 1 row
SET SESSION sql_mode=@old_sql_mode;
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
End of 5.0 tests. End of 5.0 tests.
CREATE TABLE t1 (a INT, b INT); CREATE TABLE t1 (a INT, b INT);
INSERT INTO t1 VALUES (2,22),(1,11),(2,22); INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
@ -4734,3 +4760,21 @@ SELECT * FROM t2 UNION SELECT * FROM t2
ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE));
DROP TABLE t1,t2; DROP TABLE t1,t2;
End of 5.1 tests End of 5.1 tests
#
# Bug #11765713 58705:
# OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES
# CREATED BY OPT_SUM_QUERY
#
CREATE TABLE t1(a INT NOT NULL, KEY (a));
INSERT INTO t1 VALUES (0), (1);
SELECT 1 as foo FROM t1 WHERE a < SOME
(SELECT a FROM t1 WHERE a <=>
(SELECT a FROM t1)
);
ERROR 21000: Subquery returns more than 1 row
SELECT 1 as foo FROM t1 WHERE a < SOME
(SELECT a FROM t1 WHERE a <=>
(SELECT a FROM t1 where a is null)
);
foo
DROP TABLE t1;

View File

@ -547,4 +547,67 @@ a
2000-01-01 00:00:01 2000-01-01 00:00:01
2000-01-01 00:00:01 2000-01-01 00:00:01
DROP TABLE t1; DROP TABLE t1;
#
# Bug#50774: failed to get the correct resultset when timestamp values
# are appended with .0
#
CREATE TABLE t1 ( a TIMESTAMP, KEY ( a ) );
INSERT INTO t1 VALUES( '2010-02-01 09:31:01' );
INSERT INTO t1 VALUES( '2010-02-01 09:31:02' );
INSERT INTO t1 VALUES( '2010-02-01 09:31:03' );
INSERT INTO t1 VALUES( '2010-02-01 09:31:04' );
SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
a
2010-02-01 09:31:02
2010-02-01 09:31:03
2010-02-01 09:31:04
SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' <= a;
a
2010-02-01 09:31:02
2010-02-01 09:31:03
2010-02-01 09:31:04
SELECT * FROM t1 WHERE a <= '2010-02-01 09:31:02.0';
a
2010-02-01 09:31:01
2010-02-01 09:31:02
SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' >= a;
a
2010-02-01 09:31:01
2010-02-01 09:31:02
EXPLAIN
SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
id select_type table type possible_keys key key_len ref rows Extra
x x x range x x x x x x
SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
a
2010-02-01 09:31:02
2010-02-01 09:31:03
2010-02-01 09:31:04
CREATE TABLE t2 ( a TIMESTAMP, KEY ( a DESC ) );
INSERT INTO t2 VALUES( '2010-02-01 09:31:01' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:02' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:03' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:04' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:05' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:06' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:07' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:08' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:09' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:10' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:11' );
# The bug would cause the range optimizer's comparison to use an open
# interval here. This reveals itself only in the number of reads
# performed.
FLUSH STATUS;
EXPLAIN
SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0';
id select_type table type possible_keys key key_len ref rows Extra
x x x range x x x x x x
SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0';
a
2010-02-01 09:31:01
SHOW STATUS LIKE 'Handler_read_next';
Variable_name Value
Handler_read_next 1
DROP TABLE t1, t2;
End of 5.1 tests End of 5.1 tests

View File

@ -0,0 +1,15 @@
SET AUTOCOMMIT=0;
CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b TEXT, PRIMARY KEY(a)) ENGINE=InnoDB;
SELECT COUNT(*) FROM t1;
COUNT(*)
1000
SET GLOBAL binlog_cache_size=4096;
SET GLOBAL max_binlog_cache_size=4096;
START TRANSACTION;
CREATE TABLE t2 SELECT * FROM t1;
ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again
COMMIT;
SHOW TABLES LIKE 't%';
Tables_in_test (t%)
t1
DROP TABLE t1;

View File

@ -0,0 +1,10 @@
CREATE TABLE t1(id INT);
SHOW TABLES;
Tables_in_test
t1
FLUSH LOGS;
DROP TABLE t1;
SHOW TABLES;
Tables_in_test
t1
DROP TABLE t1;

View File

@ -4,33 +4,47 @@
############################################################# #############################################################
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/have_log_bin.inc
--source include/have_binlog_format_row.inc --source include/have_binlog_format_row.inc
--source include/master-slave.inc
SET AUTOCOMMIT=0; SET AUTOCOMMIT=0;
SET GLOBAL max_binlog_cache_size=4096;
SHOW VARIABLES LIKE 'max_binlog_cache_size';
# Create 1st table
CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b TEXT, PRIMARY KEY(a)) ENGINE=InnoDB; CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b TEXT, PRIMARY KEY(a)) ENGINE=InnoDB;
--disable_query_log --disable_query_log
let $i= 1000; let $i= 1000;
while ($i) while ($i)
{ {
BEGIN;
eval INSERT INTO t1 VALUES($i, REPEAT('x', 4096)); eval INSERT INTO t1 VALUES($i, REPEAT('x', 4096));
COMMIT;
dec $i; dec $i;
} }
--enable_query_log --enable_query_log
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
# Set small value for max_binlog_cache_size
let $saved_binlog_cache_size= query_get_value(SELECT @@binlog_cache_size AS Value, Value, 1);
let $saved_max_binlog_cache_size= query_get_value(SELECT @@max_binlog_cache_size AS Value, Value, 1);
SET GLOBAL binlog_cache_size=4096;
SET GLOBAL max_binlog_cache_size=4096;
# New value of max_binlog_cache_size will apply to new session
disconnect default;
connect(default,localhost,root,,test);
# Copied data from t1 into t2 large than max_binlog_cache_size # Copied data from t1 into t2 large than max_binlog_cache_size
START TRANSACTION; START TRANSACTION;
--error 1534 --error 1197
CREATE TABLE t2 SELECT * FROM t1; CREATE TABLE t2 SELECT * FROM t1;
COMMIT; COMMIT;
SHOW TABLES LIKE 't%'; SHOW TABLES LIKE 't%';
# 5.1 End of Test # 5.1 End of Test
--source include/rpl_end.inc --disable_query_log
eval SET GLOBAL max_binlog_cache_size=$saved_max_binlog_cache_size;
eval SET GLOBAL binlog_cache_size=$saved_binlog_cache_size;
--enable_query_log
DROP TABLE t1;
disconnect default;
connect(default,localhost,root,,test);

View File

@ -13,17 +13,18 @@
# #
# #
--source include/master-slave.inc --source include/have_log_bin.inc
--source include/have_binlog_format_mixed.inc
create table t1(id int); CREATE TABLE t1(id INT);
let $binlog= query_get_value(SHOW MASTER STATUS, File, 1);
let $binlog_path= `SELECT CONCAT(@@DATADIR, '$binlog')`;
SHOW TABLES;
FLUSH LOGS;
DROP TABLE t1;
show tables; --exec $MYSQL_BINLOG $binlog_path | $MYSQL test
SHOW TABLES;
--source include/show_master_status.inc # Clean up
DROP TABLE t1;
flush logs;
--exec $MYSQL_BINLOG $MYSQL_TEST_DIR/var/log/master-bin.000001 | $MYSQL test
drop table t1;
--source include/rpl_end.inc

View File

@ -1,8 +0,0 @@
[row]
binlog-format=row
[stmt]
binlog-format=statement
[mix]
binlog-format=mixed

View File

@ -1,3 +0,0 @@
a
b
c

View File

@ -1,33 +0,0 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
**** On Master ****
CREATE TABLE t1 (b CHAR(10));
**** On Slave ****
STOP SLAVE;
**** On Master ****
LOAD DATA INFILE FILENAME
SELECT COUNT(*) FROM t1;
COUNT(*)
3
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (b CHAR(10))
master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/rpl_bug12691.dat' INTO TABLE `t1` FIELDS TERMINATED BY '|' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`b`) ;file_id=#
**** On Slave ****
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
START SLAVE;
SELECT COUNT(*) FROM t1;
COUNT(*)
0
**** On Master ****
DROP TABLE t1;

View File

@ -1,23 +0,0 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
DROP TABLE IF EXISTS t1,t2;
SET AUTOCOMMIT=0;
SET GLOBAL max_binlog_cache_size=4096;
SHOW VARIABLES LIKE 'max_binlog_cache_size';
Variable_name Value
max_binlog_cache_size 4096
CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b TEXT, PRIMARY KEY(a)) ENGINE=InnoDB;
SELECT COUNT(*) FROM t1;
COUNT(*)
1000
START TRANSACTION;
CREATE TABLE t2 SELECT * FROM t1;
ERROR HY000: Writing one row to the row-based binary log failed
COMMIT;
SHOW TABLES LIKE 't%';
Tables_in_test (t%)
t1

View File

@ -1,16 +0,0 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('a');
UPDATE t1 SET a = 'MyISAM';
SELECT * FROM t1 ORDER BY a;
a
MyISAM
SELECT * FROM t1 ORDER BY a;
a
MyISAM
DROP TABLE t1;

View File

@ -1,16 +0,0 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE t1 ( a INT, b INT DEFAULT -3 );
INSERT INTO t1 VALUES (1, DEFAULT);
UPDATE t1 SET a = 3;
SELECT * FROM t1 ORDER BY a;
a b
3 -3
SELECT * FROM t1 ORDER BY a;
a b
3 -3
DROP TABLE t1;

View File

@ -1,15 +0,0 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table `t1` (`id` int not null auto_increment primary key);
create trigger `trg` before insert on `t1` for each row begin end;
set @@global.debug="+d,simulate_bug33029";
stop slave;
start slave;
insert into `t1` values ();
select * from t1;
id
1

View File

@ -1,18 +0,0 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
create table t1(id int);
show tables;
Tables_in_test
t1
show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
flush logs;
drop table t1;

View File

@ -1,17 +0,0 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE char128_utf8 (
i1 INT NOT NULL,
c CHAR(128) CHARACTER SET utf8 NOT NULL,
i2 INT NOT NULL);
INSERT INTO char128_utf8 VALUES ( 1, "123", 1 );
SELECT * FROM char128_utf8;
i1 c i2
1 123 1
SELECT * FROM char128_utf8;
i1 c i2
1 123 1

View File

@ -1,56 +0,0 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1i(n int primary key) engine=innodb;
create table t2m(n int primary key) engine=myisam;
begin;
insert into t1i values (1);
insert into t1i values (2);
insert into t1i values (3);
commit;
begin;
insert into t1i values (5);
begin;
insert into t1i values (4);
insert into t2m values (1);
update t1i set n = 5 where n = 4;
commit;
zero
0
*** kill sql thread ***
rollback;
*** sql thread is *not* running: No ***
*** the prove: the killed slave has not finished the current transaction ***
three
3
one
1
zero
0
delete from t2m;
start slave sql_thread;
delete from t1i;
delete from t2m;
begin;
insert into t1i values (5);
begin;
insert into t1i values (4);
update t1i set n = 5 where n = 4;
commit;
zero
0
stop slave sql_thread;
rollback;
*** sql thread is *not* running: No ***
*** the prove: the stopped slave has rolled back the current transaction ***
zero
0
zero
0
one
1
start slave sql_thread;
drop table t1i, t2m;

View File

@ -1,49 +0,0 @@
# Bug#12691: Exec_master_log_pos corrupted with SQL_SLAVE_SKIP_COUNTER
--source include/master-slave.inc
--connection master
--source include/have_binlog_format_mixed_or_statement.inc
--echo
--echo **** On Master ****
CREATE TABLE t1 (b CHAR(10));
--echo
--echo **** On Slave ****
--sync_slave_with_master
STOP SLAVE;
--source include/wait_for_slave_to_stop.inc
--connection master
--echo
--echo **** On Master ****
--exec cp $MYSQL_TEST_DIR/suite/bugs/data/rpl_bug12691.dat $MYSQLTEST_VARDIR/tmp/
--echo LOAD DATA INFILE FILENAME
--disable_query_log
--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/rpl_bug12691.dat' INTO TABLE t1 FIELDS TERMINATED BY '|'
--enable_query_log
--remove_file $MYSQLTEST_VARDIR/tmp/rpl_bug12691.dat
SELECT COUNT(*) FROM t1;
source include/show_binlog_events.inc;
--save_master_pos
--connection slave
--echo
--echo **** On Slave ****
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
START SLAVE;
--source include/wait_for_slave_to_start.inc
--sync_with_master
SELECT COUNT(*) FROM t1;
# Clean up
--connection master
--echo
--echo **** On Master ****
DROP TABLE t1;
--source include/rpl_end.inc

View File

@ -1,25 +0,0 @@
# BUG#31582: 5.1-telco-6.1 -> 5.1.22. Slave crashes when reading
# UPDATE for VARCHAR
# This is a problem for any update statement replicating from an old
# server to a new server. The bug consisted of a new slave trying to
# read two column bitmaps, but there is only one available in the old
# format.
# This test case should be executed replicating from an old server to
# a new server, so make sure you have one handy.
source include/master-slave.inc;
CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('a');
UPDATE t1 SET a = 'MyISAM';
SELECT * FROM t1 ORDER BY a;
sync_slave_with_master;
SELECT * FROM t1 ORDER BY a;
connection master;
DROP TABLE t1;
--source include/rpl_end.inc

View File

@ -1,25 +0,0 @@
#
# BUG#31583: 5.1-telco-6.1 -> 5.1.22. Slave returns Error in unknown event
# This is a problem for any update statement replicating from an old
# server to a new server. The bug consisted of a new slave trying to
# read two column bitmaps, but there is only one available in the old
# format.
# This test case should be executed replicating from an old server to
# a new server, so make sure you have one handy.
source include/master-slave.inc;
CREATE TABLE t1 ( a INT, b INT DEFAULT -3 );
INSERT INTO t1 VALUES (1, DEFAULT);
UPDATE t1 SET a = 3;
SELECT * FROM t1 ORDER BY a;
sync_slave_with_master;
SELECT * FROM t1 ORDER BY a;
connection master;
DROP TABLE t1;
--source include/rpl_end.inc

View File

@ -1,26 +0,0 @@
#
# Bug #36443 Server crashes when executing insert when insert trigger on table
#
# Emulating the former bug#33029 situation to see that there is no crash anymore.
#
source include/master-slave.inc;
create table `t1` (`id` int not null auto_increment primary key);
create trigger `trg` before insert on `t1` for each row begin end;
sync_slave_with_master;
set @@global.debug="+d,simulate_bug33029";
stop slave;
start slave;
connection master;
insert into `t1` values ();
sync_slave_with_master;
select * from t1;
--source include/rpl_end.inc

View File

@ -1,166 +0,0 @@
#
# Bug #38205 Row-based Replication (RBR) causes inconsistencies: HA_ERR_FOUND_DUPP_KEY
# Bug#319 if while a non-transactional slave is replicating a transaction possible problem
#
# Verifying the fact that STOP SLAVE in the middle of a group execution waits
# for the end of the group before the slave sql thread will stop.
# The patch refines STOP SLAVE to not interrupt a transaction or other type of
# the replication events group (the part I).
# Killing the sql thread continues to provide a "hard" stop (the part II).
#
# Non-deterministic tests
#
source include/master-slave.inc;
source include/have_innodb.inc;
#
# Part II, killed sql slave leaves instantly
#
# A. multi-statement transaction as the replication group
connection master;
create table t1i(n int primary key) engine=innodb;
create table t2m(n int primary key) engine=myisam;
sync_slave_with_master;
connection master;
begin;
insert into t1i values (1);
insert into t1i values (2);
insert into t1i values (3);
commit;
sync_slave_with_master;
#
# todo: first challenge is to find out the SQL thread id
# the following is not fully reliable
#
let $id=`SELECT id from information_schema.processlist where user like 'system user' and state like '%Has read all relay log%' or user like 'system user' and state like '%Reading event from the relay log%'`;
connection slave;
begin;
insert into t1i values (5);
connection master;
let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
begin;
insert into t1i values (4);
insert into t2m values (1); # non-ta update
update t1i set n = 5 where n = 4; # to block at. can't be played with killed
commit;
let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
connection slave;
# slave sql thread must be locked out by the conn `slave' explicit lock
let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
--disable_query_log
eval select $pos0_master - $pos0_slave as zero;
--enable_query_log
connection slave1;
let $count= 1;
let $table= t2m;
source include/wait_until_rows_count.inc;
#
# todo: may fail as said above
#
--echo *** kill sql thread ***
--disable_query_log
eval kill connection $id;
--enable_query_log
connection slave;
rollback; # release the sql thread
connection slave1;
source include/wait_for_slave_sql_to_stop.inc;
let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
--echo *** sql thread is *not* running: $sql_status ***
let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
connection slave;
--echo *** the prove: the killed slave has not finished the current transaction ***
--disable_query_log
select count(*) as three from t1i;
eval select $pos1_master > $pos1_slave as one;
eval select $pos1_slave - $pos0_slave as zero;
--enable_query_log
delete from t2m; # remove the row to be able to replay
start slave sql_thread;
#
# Part I: B The homogenous transaction remains interuptable in between
#
connection master;
delete from t1i;
delete from t2m;
sync_slave_with_master;
begin;
insert into t1i values (5);
connection master;
let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
begin;
insert into t1i values (4);
update t1i set n = 5 where n = 4; # to block at. not to be played
commit;
let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
connection slave1;
# slave sql can't advance as must be locked by the conn `slave' trans
let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
--disable_query_log
eval select $pos0_master - $pos0_slave as zero;
--enable_query_log
#
# the replicated trans is blocked by the slave's local.
# However, it's not easy to catch the exact moment when it happens.
# The test issues sleep which makes the test either non-deterministic or
# wasting too much time.
#
--sleep 3
send stop slave sql_thread;
connection slave;
rollback; # release the sql thread
connection slave1;
reap;
source include/wait_for_slave_sql_to_stop.inc;
let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
--echo *** sql thread is *not* running: $sql_status ***
let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
--echo *** the prove: the stopped slave has rolled back the current transaction ***
--disable_query_log
select count(*) as zero from t1i;
eval select $pos0_master - $pos0_slave as zero;
eval select $pos1_master > $pos0_slave as one;
--enable_query_log
start slave sql_thread;
# clean-up
connection master;
drop table t1i, t2m;
--source include/rpl_end.inc

View File

@ -0,0 +1,17 @@
create table `bug59410_1`(`a` int)engine=innodb;
insert into `bug59410_1` values (1),(2),(3);
select 1 from `bug59410_1` where `a` <> any (
select 1 from `bug59410_1` where `a` <> 1 for update)
for update;
1
1
1
drop table bug59410_1;
create table bug59410_2(`a` char(1),`b` int)engine=innodb;
insert into bug59410_2 values('0',0);
set transaction isolation level read uncommitted;
start transaction;
set @a=(select b from bug59410_2 where
(select 1 from bug59410_2 where a group by @a=b)
group by @a:=b);
drop table bug59410_2;

View File

@ -0,0 +1,57 @@
CREATE TABLE t(a INT PRIMARY KEY, b INT)ENGINE=InnoDB;
INSERT INTO t VALUES(2,2),(4,4),(8,8),(16,16),(32,32);
COMMIT;
XA START '123';
INSERT INTO t VALUES(1,1);
XA END '123';
XA PREPARE '123';
XA START '456';
INSERT INTO t VALUES(3,47),(5,67);
UPDATE t SET b=2*b WHERE a BETWEEN 5 AND 8;
XA END '456';
XA PREPARE '456';
XA START '789';
UPDATE t SET b=4*a WHERE a=32;
XA END '789';
XA PREPARE '789';
call mtr.add_suppression("Found 3 prepared XA transactions");
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t;
a b
1 1
2 2
3 47
4 4
5 134
8 16
16 16
32 128
COMMIT;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t;
a b
1 1
2 2
3 47
4 4
5 134
8 16
16 16
32 128
COMMIT;
XA RECOVER;
formatID gtrid_length bqual_length data
1 3 0 789
1 3 0 456
1 3 0 123
XA ROLLBACK '123';
XA ROLLBACK '456';
XA COMMIT '789';
SELECT * FROM t;
a b
2 2
4 4
8 8
16 16
32 128
DROP TABLE t;

View File

@ -0,0 +1,24 @@
#
# Bug#59410 read uncommitted: unlock row could not find a 3 mode lock on the record
#
-- source include/have_innodb.inc
# only interested that the following do not produce something like
# InnoDB: Error: unlock row could not find a 2 mode lock on the record
# in the error log
create table `bug59410_1`(`a` int)engine=innodb;
insert into `bug59410_1` values (1),(2),(3);
select 1 from `bug59410_1` where `a` <> any (
select 1 from `bug59410_1` where `a` <> 1 for update)
for update;
drop table bug59410_1;
create table bug59410_2(`a` char(1),`b` int)engine=innodb;
insert into bug59410_2 values('0',0);
set transaction isolation level read uncommitted;
start transaction;
set @a=(select b from bug59410_2 where
(select 1 from bug59410_2 where a group by @a=b)
group by @a:=b);
drop table bug59410_2;

View File

@ -0,0 +1,66 @@
# Bug #59641 Prepared XA transaction causes shutdown hang after a crash
-- source include/not_embedded.inc
-- source include/have_innodb.inc
CREATE TABLE t(a INT PRIMARY KEY, b INT)ENGINE=InnoDB;
INSERT INTO t VALUES(2,2),(4,4),(8,8),(16,16),(32,32);
COMMIT;
XA START '123';
INSERT INTO t VALUES(1,1);
XA END '123';
XA PREPARE '123';
CONNECT (con1,localhost,root,,);
CONNECTION con1;
XA START '456';
INSERT INTO t VALUES(3,47),(5,67);
UPDATE t SET b=2*b WHERE a BETWEEN 5 AND 8;
XA END '456';
XA PREPARE '456';
CONNECT (con2,localhost,root,,);
CONNECTION con2;
XA START '789';
UPDATE t SET b=4*a WHERE a=32;
XA END '789';
XA PREPARE '789';
# The server would issue this warning on restart.
call mtr.add_suppression("Found 3 prepared XA transactions");
# Kill the server without sending a shutdown command
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- shutdown_server 0
-- source include/wait_until_disconnected.inc
# Restart the server.
-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- enable_reconnect
-- source include/wait_until_connected_again.inc
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t;
COMMIT;
# Shut down the server. This would hang because of the bug.
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- shutdown_server
-- source include/wait_until_disconnected.inc
# Restart the server.
-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- enable_reconnect
-- source include/wait_until_connected_again.inc
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t;
COMMIT;
XA RECOVER;
XA ROLLBACK '123';
XA ROLLBACK '456';
XA COMMIT '789';
SELECT * FROM t;
DROP TABLE t;

View File

@ -0,0 +1,17 @@
create table `bug59410_1`(`a` int)engine=innodb;
insert into `bug59410_1` values (1),(2),(3);
select 1 from `bug59410_1` where `a` <> any (
select 1 from `bug59410_1` where `a` <> 1 for update)
for update;
1
1
1
drop table bug59410_1;
create table bug59410_2(`a` char(1),`b` int)engine=innodb;
insert into bug59410_2 values('0',0);
set transaction isolation level read uncommitted;
start transaction;
set @a=(select b from bug59410_2 where
(select 1 from bug59410_2 where a group by @a=b)
group by @a:=b);
drop table bug59410_2;

View File

@ -0,0 +1,57 @@
CREATE TABLE t(a INT PRIMARY KEY, b INT)ENGINE=InnoDB;
INSERT INTO t VALUES(2,2),(4,4),(8,8),(16,16),(32,32);
COMMIT;
XA START '123';
INSERT INTO t VALUES(1,1);
XA END '123';
XA PREPARE '123';
XA START '456';
INSERT INTO t VALUES(3,47),(5,67);
UPDATE t SET b=2*b WHERE a BETWEEN 5 AND 8;
XA END '456';
XA PREPARE '456';
XA START '789';
UPDATE t SET b=4*a WHERE a=32;
XA END '789';
XA PREPARE '789';
call mtr.add_suppression("Found 3 prepared XA transactions");
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t;
a b
1 1
2 2
3 47
4 4
5 134
8 16
16 16
32 128
COMMIT;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t;
a b
1 1
2 2
3 47
4 4
5 134
8 16
16 16
32 128
COMMIT;
XA RECOVER;
formatID gtrid_length bqual_length data
1 3 0 789
1 3 0 456
1 3 0 123
XA ROLLBACK '123';
XA ROLLBACK '456';
XA COMMIT '789';
SELECT * FROM t;
a b
2 2
4 4
8 8
16 16
32 128
DROP TABLE t;

View File

@ -0,0 +1,24 @@
#
# Bug#59410 read uncommitted: unlock row could not find a 3 mode lock on the record
#
-- source include/have_innodb_plugin.inc
# only interested that the following do not produce something like
# InnoDB: Error: unlock row could not find a 2 mode lock on the record
# in the error log
create table `bug59410_1`(`a` int)engine=innodb;
insert into `bug59410_1` values (1),(2),(3);
select 1 from `bug59410_1` where `a` <> any (
select 1 from `bug59410_1` where `a` <> 1 for update)
for update;
drop table bug59410_1;
create table bug59410_2(`a` char(1),`b` int)engine=innodb;
insert into bug59410_2 values('0',0);
set transaction isolation level read uncommitted;
start transaction;
set @a=(select b from bug59410_2 where
(select 1 from bug59410_2 where a group by @a=b)
group by @a:=b);
drop table bug59410_2;

View File

@ -0,0 +1,70 @@
# Bug #59641 Prepared XA transaction causes shutdown hang after a crash
-- source include/not_embedded.inc
-- source include/have_innodb_plugin.inc
let $innodb_file_format_check_orig=`select @@innodb_file_format_check`;
CREATE TABLE t(a INT PRIMARY KEY, b INT)ENGINE=InnoDB;
INSERT INTO t VALUES(2,2),(4,4),(8,8),(16,16),(32,32);
COMMIT;
XA START '123';
INSERT INTO t VALUES(1,1);
XA END '123';
XA PREPARE '123';
CONNECT (con1,localhost,root,,);
CONNECTION con1;
XA START '456';
INSERT INTO t VALUES(3,47),(5,67);
UPDATE t SET b=2*b WHERE a BETWEEN 5 AND 8;
XA END '456';
XA PREPARE '456';
CONNECT (con2,localhost,root,,);
CONNECTION con2;
XA START '789';
UPDATE t SET b=4*a WHERE a=32;
XA END '789';
XA PREPARE '789';
# The server would issue this warning on restart.
call mtr.add_suppression("Found 3 prepared XA transactions");
# Kill the server without sending a shutdown command
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- shutdown_server 0
-- source include/wait_until_disconnected.inc
# Restart the server.
-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- enable_reconnect
-- source include/wait_until_connected_again.inc
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t;
COMMIT;
# Shut down the server. This would hang because of the bug.
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- shutdown_server
-- source include/wait_until_disconnected.inc
# Restart the server.
-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- enable_reconnect
-- source include/wait_until_connected_again.inc
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t;
COMMIT;
XA RECOVER;
XA ROLLBACK '123';
XA ROLLBACK '456';
XA COMMIT '789';
SELECT * FROM t;
DROP TABLE t;
--disable_query_log
eval set global innodb_file_format_check=$innodb_file_format_check_orig;

View File

@ -0,0 +1,12 @@
include/master-slave.inc
[connection master]
CREATE TABLE char128_utf8 (i1 INT NOT NULL, c CHAR(128) CHARACTER SET utf8 NOT NULL, i2 INT NOT NULL);
INSERT INTO char128_utf8 VALUES ( 1, "123", 1 );
SELECT * FROM char128_utf8;
i1 c i2
1 123 1
SELECT * FROM char128_utf8;
i1 c i2
1 123 1
DROP TABLE char128_utf8;
include/rpl_end.inc

View File

@ -19,7 +19,7 @@ change master to master_port=MASTER_PORT;
start slave until master_log_file='master-bin.000001', master_log_pos=UNTIL_POS; start slave until master_log_file='master-bin.000001', master_log_pos=UNTIL_POS;
include/wait_for_slave_io_to_start.inc include/wait_for_slave_io_to_start.inc
include/wait_for_slave_sql_to_stop.inc include/wait_for_slave_sql_to_stop.inc
*** checking until postion execution: must be only t1 in the list *** *** checking until position execution: must be only t1 in the list ***
show tables; show tables;
Tables_in_test Tables_in_test
t1 t1

View File

@ -7,15 +7,16 @@ source include/master-slave.inc;
source include/have_binlog_format_row.inc; source include/have_binlog_format_row.inc;
connection master; connection master;
CREATE TABLE char128_utf8 ( CREATE TABLE char128_utf8 (i1 INT NOT NULL, c CHAR(128) CHARACTER SET utf8 NOT NULL, i2 INT NOT NULL);
i1 INT NOT NULL,
c CHAR(128) CHARACTER SET utf8 NOT NULL,
i2 INT NOT NULL);
INSERT INTO char128_utf8 VALUES ( 1, "123", 1 ); INSERT INTO char128_utf8 VALUES ( 1, "123", 1 );
SELECT * FROM char128_utf8; SELECT * FROM char128_utf8;
sync_slave_with_master; sync_slave_with_master;
SELECT * FROM char128_utf8; SELECT * FROM char128_utf8;
# Clean up
connection master;
DROP TABLE char128_utf8;
sync_slave_with_master;
--source include/rpl_end.inc --source include/rpl_end.inc

View File

@ -9,29 +9,29 @@ connection master;
CREATE TABLE t1(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY); CREATE TABLE t1(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
INSERT INTO t1 VALUES (1),(2),(3),(4); INSERT INTO t1 VALUES (1),(2),(3),(4);
DROP TABLE t1; DROP TABLE t1;
# Save master log postion for query DROP TABLE t1 # Save master log position for query DROP TABLE t1
save_master_pos; save_master_pos;
let $master_pos_drop_t1= query_get_value(SHOW BINLOG EVENTS, Pos, 7); let $master_pos_drop_t1= query_get_value(SHOW BINLOG EVENTS, Pos, 7);
let $master_log_file= query_get_value(SHOW BINLOG EVENTS, Log_name, 7); let $master_log_file= query_get_value(SHOW BINLOG EVENTS, Log_name, 7);
CREATE TABLE t2(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY); CREATE TABLE t2(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
# Save master log postion for query CREATE TABLE t2 # Save master log position for query CREATE TABLE t2
save_master_pos; save_master_pos;
let $master_pos_create_t2= query_get_value(SHOW BINLOG EVENTS, Pos, 8); let $master_pos_create_t2= query_get_value(SHOW BINLOG EVENTS, Pos, 8);
INSERT INTO t2 VALUES (1),(2); INSERT INTO t2 VALUES (1),(2);
save_master_pos; save_master_pos;
# Save master log postion for query INSERT INTO t2 VALUES (1),(2); # Save master log position for query INSERT INTO t2 VALUES (1),(2);
let $master_pos_insert1_t2= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 12); let $master_pos_insert1_t2= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 12);
sync_slave_with_master; sync_slave_with_master;
# Save relay log postion for query INSERT INTO t2 VALUES (1),(2); # Save relay log position for query INSERT INTO t2 VALUES (1),(2);
let $relay_pos_insert1_t2= query_get_value(show slave status, Relay_Log_Pos, 1); let $relay_pos_insert1_t2= query_get_value(show slave status, Relay_Log_Pos, 1);
connection master; connection master;
INSERT INTO t2 VALUES (3),(4); INSERT INTO t2 VALUES (3),(4);
DROP TABLE t2; DROP TABLE t2;
# Save master log postion for query INSERT INTO t2 VALUES (1),(2); # Save master log position for query INSERT INTO t2 VALUES (1),(2);
let $master_pos_drop_t2= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 17); let $master_pos_drop_t2= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 17);
sync_slave_with_master; sync_slave_with_master;

View File

@ -47,7 +47,7 @@ eval start slave until master_log_file='master-bin.000001', master_log_pos=$unti
--source include/wait_for_slave_io_to_start.inc --source include/wait_for_slave_io_to_start.inc
--source include/wait_for_slave_sql_to_stop.inc --source include/wait_for_slave_sql_to_stop.inc
--echo *** checking until postion execution: must be only t1 in the list *** --echo *** checking until position execution: must be only t1 in the list ***
show tables; show tables;
# cleanup # cleanup

View File

@ -1,6 +1,7 @@
# #
# Test of procedure analyse # Test of procedure analyse
# #
-- source include/have_innodb.inc
--disable_warnings --disable_warnings
drop table if exists t1,t2; drop table if exists t1,t2;
@ -144,4 +145,15 @@ INSERT INTO t1 VALUES ('e'),('e'),('e-');
SELECT * FROM t1 PROCEDURE ANALYSE(); SELECT * FROM t1 PROCEDURE ANALYSE();
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug#11756242 48137: PROCEDURE ANALYSE() LEAKS MEMORY WHEN RETURNING NULL
--echo #
CREATE TABLE t1(f1 INT) ENGINE=MYISAM;
CREATE TABLE t2(f2 INT) ENGINE=INNODB;
INSERT INTO t2 VALUES (1);
SELECT DISTINCTROW f1 FROM t1 NATURAL RIGHT OUTER JOIN t2 PROCEDURE ANALYSE();
SELECT * FROM t2 LIMIT 1 PROCEDURE ANALYSE();
DROP TABLE t1, t2;
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -4,6 +4,8 @@
# Can't test with embedded server that doesn't support grants # Can't test with embedded server that doesn't support grants
-- source include/not_embedded.inc -- source include/not_embedded.inc
call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted");
--disable_warnings --disable_warnings
drop database if exists events_test; drop database if exists events_test;
drop database if exists db_x; drop database if exists db_x;
@ -270,23 +272,28 @@ SHOW EVENTS;
--echo Try to alter mysql.event: the server should fail to load --echo Try to alter mysql.event: the server should fail to load
--echo event information after mysql.event was tampered with. --echo event information after mysql.event was tampered with.
--echo --echo
--echo First, let's add a column to the end and make sure everything --echo First, let's add a column to the end and check the error is emitted.
--echo works as before
--echo --echo
ALTER TABLE mysql.event ADD dummy INT; ALTER TABLE mysql.event ADD dummy INT;
--replace_column 8 # 9 # --error ER_EVENT_OPEN_TABLE_FAILED
SHOW EVENTS; SHOW EVENTS;
--error ER_EVENT_OPEN_TABLE_FAILED
SELECT event_name FROM INFORMATION_SCHEMA.events; SELECT event_name FROM INFORMATION_SCHEMA.events;
--replace_regex /STARTS '[^']+'/STARTS '#'/ --error ER_EVENT_OPEN_TABLE_FAILED
SHOW CREATE EVENT intact_check; SHOW CREATE EVENT intact_check;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT no_such_event; DROP EVENT no_such_event;
--error ER_EVENT_OPEN_TABLE_FAILED
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
--error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
--error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT intact_check_1 RENAME TO intact_check_2; ALTER EVENT intact_check_1 RENAME TO intact_check_2;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check_1; DROP EVENT intact_check_1;
--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check_2; DROP EVENT intact_check_2;
--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check; DROP EVENT intact_check;
DROP DATABASE IF EXISTS mysqltest_no_such_database; DROP DATABASE IF EXISTS mysqltest_no_such_database;
CREATE DATABASE mysqltest_db2; CREATE DATABASE mysqltest_db2;
@ -296,6 +303,7 @@ SHOW VARIABLES LIKE 'event_scheduler';
SET GLOBAL event_scheduler=OFF; SET GLOBAL event_scheduler=OFF;
# Clean up # Clean up
ALTER TABLE mysql.event DROP dummy; ALTER TABLE mysql.event DROP dummy;
DROP EVENT intact_check;
CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing"; CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing";
--echo --echo
--echo Now let's add a column to the first position: the server --echo Now let's add a column to the first position: the server
@ -303,24 +311,26 @@ CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing";
--echo --echo
ALTER TABLE mysql.event ADD dummy INT FIRST; ALTER TABLE mysql.event ADD dummy INT FIRST;
--error ER_CANNOT_LOAD_FROM_TABLE --error ER_CANNOT_LOAD_FROM_TABLE
--error ER_EVENT_OPEN_TABLE_FAILED
SHOW EVENTS; SHOW EVENTS;
--error ER_CANNOT_LOAD_FROM_TABLE --error ER_CANNOT_LOAD_FROM_TABLE
--error ER_EVENT_OPEN_TABLE_FAILED
SELECT event_name FROM INFORMATION_SCHEMA.events; SELECT event_name FROM INFORMATION_SCHEMA.events;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
SHOW CREATE EVENT intact_check; SHOW CREATE EVENT intact_check;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT no_such_event; DROP EVENT no_such_event;
--error ER_EVENT_STORE_FAILED --error ER_EVENT_OPEN_TABLE_FAILED
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT intact_check_1 RENAME TO intact_check_2; ALTER EVENT intact_check_1 RENAME TO intact_check_2;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check_1; DROP EVENT intact_check_1;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check_2; DROP EVENT intact_check_2;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check; DROP EVENT intact_check;
# Should work OK # Should work OK
DROP DATABASE IF EXISTS mysqltest_no_such_database; DROP DATABASE IF EXISTS mysqltest_no_such_database;
@ -341,25 +351,25 @@ INSERT INTO event_like SELECT * FROM mysql.event;
--echo --echo
--echo --echo
ALTER TABLE mysql.event DROP comment, DROP starts; ALTER TABLE mysql.event DROP comment, DROP starts;
--error ER_CANNOT_LOAD_FROM_TABLE --error ER_EVENT_OPEN_TABLE_FAILED
SHOW EVENTS; SHOW EVENTS;
--error ER_CANNOT_LOAD_FROM_TABLE --error ER_EVENT_OPEN_TABLE_FAILED
SELECT event_name FROM INFORMATION_SCHEMA.EVENTS; SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
--error ER_CANNOT_LOAD_FROM_TABLE --error ER_EVENT_OPEN_TABLE_FAILED
SHOW CREATE EVENT intact_check; SHOW CREATE EVENT intact_check;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT no_such_event; DROP EVENT no_such_event;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED --error ER_EVENT_OPEN_TABLE_FAILED
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT intact_check_1 RENAME TO intact_check_2; ALTER EVENT intact_check_1 RENAME TO intact_check_2;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check_1; DROP EVENT intact_check_1;
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check_2; DROP EVENT intact_check_2;
# Should succeed --error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check; DROP EVENT intact_check;
DROP DATABASE IF EXISTS mysqltest_no_such_database; DROP DATABASE IF EXISTS mysqltest_no_such_database;
CREATE DATABASE mysqltest_db2; CREATE DATABASE mysqltest_db2;
@ -407,9 +417,54 @@ CREATE TABLE mysql.event like event_like;
DROP TABLE event_like; DROP TABLE event_like;
--replace_column 8 # 9 # --replace_column 8 # 9 #
SHOW EVENTS; SHOW EVENTS;
#
# End of tests --echo
# --echo #
--echo # Bug#12394306: the sever may crash if mysql.event is corrupted
--echo #
--echo
CREATE EVENT ev1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
ALTER EVENT ev1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
--echo
CREATE TABLE event_original LIKE mysql.event;
INSERT INTO event_original SELECT * FROM mysql.event;
--echo
ALTER TABLE mysql.event MODIFY modified CHAR(1);
--echo
--error ER_EVENT_OPEN_TABLE_FAILED
SHOW EVENTS;
--echo
--error ER_EVENT_OPEN_TABLE_FAILED
SELECT event_name, created, last_altered FROM information_schema.events;
--echo
--error ER_EVENT_OPEN_TABLE_FAILED
CREATE EVENT ev2 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
--echo
--error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT ev1 ON SCHEDULE EVERY 9 HOUR DO SELECT 9;
--echo
DROP TABLE mysql.event;
RENAME TABLE event_original TO mysql.event;
--echo
DROP EVENT ev1;
--echo
SHOW EVENTS;
--echo
--echo #
--echo # End of tests
--echo #
let $wait_condition= let $wait_condition=
select count(*) = 0 from information_schema.processlist select count(*) = 0 from information_schema.processlist

View File

@ -1,6 +1,8 @@
# Can't test with embedded server that doesn't support grants # Can't test with embedded server that doesn't support grants
-- source include/not_embedded.inc -- source include/not_embedded.inc
call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted");
# #
# Test that when the server is restarted, it checks mysql.event table, # Test that when the server is restarted, it checks mysql.event table,
# and disables the scheduler if it's not up to date. # and disables the scheduler if it's not up to date.

View File

@ -1,5 +1,5 @@
# #
# Test of different EXPLAIN's # Test of different EXPLAINs
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
@ -157,11 +157,12 @@ CREATE TABLE t1 (f1 INT);
SELECT @@session.sql_mode INTO @old_sql_mode; SELECT @@session.sql_mode INTO @old_sql_mode;
SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
# EXPLAIN EXTENDED (with subselect). used to crash. should give NOTICE. # EXPLAIN EXTENDED (with subselect). used to crash.
--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS # This is actually a valid query for this sql_mode,
# but it was transformed in such a way that it failed, see
# Bug#12329653 - EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY
EXPLAIN EXTENDED SELECT 1 FROM t1 EXPLAIN EXTENDED SELECT 1 FROM t1
WHERE f1 > ALL( SELECT t.f1 FROM t1,t1 AS t ); WHERE f1 > ALL( SELECT t.f1 FROM t1,t1 AS t );
SHOW WARNINGS;
SET SESSION sql_mode=@old_sql_mode; SET SESSION sql_mode=@old_sql_mode;

View File

@ -1127,6 +1127,18 @@ INSERT INTO t1 VALUES (18446668621106209655);
SELECT MAX(LENGTH(a)), LENGTH(MAX(a)), MIN(a), MAX(a), CONCAT(MIN(a)), CONCAT(MAX(a)) FROM t1; SELECT MAX(LENGTH(a)), LENGTH(MAX(a)), MIN(a), MAX(a), CONCAT(MIN(a)), CONCAT(MAX(a)) FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
--echo #
CREATE TABLE t1(f1 YEAR(4));
INSERT INTO t1 VALUES (0000),(2001);
--enable_metadata
(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
--disable_metadata
DROP TABLE t1;
--echo # --echo #
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -554,6 +554,12 @@ SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug #11766212 59270: NOT IN (YEAR( ... ), ... ) PRODUCES MANY VALGRIND WARNINGS
--echo #
SELECT 1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1);
--echo # --echo #
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -333,4 +333,20 @@ DROP TABLE t1;
CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL); CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
--echo #
CREATE TABLE t1(f1 DECIMAL(22,1));
INSERT INTO t1 VALUES (0),(1);
SELECT ROUND(f1, f1) FROM t1;
SELECT ROUND(f1, f1) FROM t1 GROUP BY 1;
DROP TABLE t1;
--echo #
--echo # Bug#11764671 57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA
--echo #
SELECT ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'));
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -913,4 +913,12 @@ SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025));
SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR); SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR);
--echo #
--echo # Bug#11889186 60503: CRASH IN MAKE_DATE_TIME WITH DATE_FORMAT / STR_TO_DATE COMBINATION
--echo #
SELECT DATE_FORMAT('0000-00-11', '%W');
SELECT DATE_FORMAT('0000-00-11', '%a');
SELECT DATE_FORMAT('0000-00-11', '%w');
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -564,4 +564,30 @@ HAVING field1 < 7;
DROP TABLE t1,t2; DROP TABLE t1,t2;
--echo #
--echo # Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause
--echo #
CREATE TABLE t1 (f1 INT, f2 INT);
INSERT INTO t1 VALUES (1, 0), (2, 1), (3, 2);
CREATE TABLE t2 (f1 INT, f2 INT);
SELECT t1.f1
FROM t1
HAVING (3, 2) IN (SELECT f1, f2 FROM t2) AND t1.f1 >= 0
ORDER BY t1.f1;
SELECT t1.f1
FROM t1
HAVING (3, 2) IN (SELECT 4, 2) AND t1.f1 >= 0
ORDER BY t1.f1;
SELECT t1.f1
FROM t1
HAVING 2 IN (SELECT f2 FROM t2) AND t1.f1 >= 0
ORDER BY t1.f1;
DROP TABLE t1,t2;
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -611,5 +611,33 @@ DROP TABLE t1;
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
remove_file $MYSQLD_DATADIR/test/tmpp2.txt; remove_file $MYSQLD_DATADIR/test/tmpp2.txt;
--echo #
--echo # Bug#11765139 58069: LOAD DATA INFILE: VALGRIND REPORTS INVALID MEMORY READS AND WRITES WITH U
--echo #
CREATE TABLE t1(f1 INT);
EVAL SELECT 0xE1BB30 INTO OUTFILE 't1.dat';
--disable_warnings
LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8;
--enable_warnings
DROP TABLE t1;
let $MYSQLD_DATADIR= `select @@datadir`;
remove_file $MYSQLD_DATADIR/test/t1.dat;
--echo #
--echo # Bug#11765141 - 58072: LOAD DATA INFILE: LEAKS IO CACHE MEMORY
--echo # WHEN ERROR OCCURS
--echo #
--let $file=$MYSQLTEST_VARDIR/tmp/bug11735141.txt
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval SELECT '1\n' INTO DUMPFILE '$file'
create table t1(a point);
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error ER_CANT_CREATE_GEOMETRY_OBJECT
--eval LOAD DATA INFILE '$file' INTO TABLE t1
drop table t1;
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -71,3 +71,32 @@ select count(*) from t2;
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql --remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
drop table t1; drop table t1;
drop table t2; drop table t2;
#
# BUG#12354268
#
# This test verifies that using --start-position with DECODE-ROWS
# does not make mysqlbinlog to output an error stating that it
# does not contain any FD event.
#
RESET MASTER;
USE test;
SET @old_binlog_format= @@binlog_format;
SET SESSION binlog_format=ROW;
CREATE TABLE t1(c1 INT);
--let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
--let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
--let $MYSQLD_DATADIR= `SELECT @@datadir`
INSERT INTO t1 VALUES (1);
FLUSH LOGS;
--disable_result_log
--exec $MYSQL_BINLOG --base64-output=DECODE-ROWS --start-position=$master_pos -v $MYSQLD_DATADIR/$master_binlog
--enable_result_log
DROP TABLE t1;
SET SESSION binlog_format= @old_binlog_format;
RESET MASTER;

View File

@ -1,5 +1,4 @@
-- source include/have_partition.inc -- source include/have_partition.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1, t2; DROP TABLE IF EXISTS t1, t2;
--enable_warnings --enable_warnings
@ -51,3 +50,13 @@ DROP TABLE t1;
--list_files $MYSQLD_DATADIR/test t1* --list_files $MYSQLD_DATADIR/test t1*
--list_files $MYSQLD_DATADIR/test t2* --list_files $MYSQLD_DATADIR/test t2*
--echo # End of bug#30102 test. --echo # End of bug#30102 test.
--echo # Test of post-push fix for bug#11766249/59316
CREATE TABLE t1 (a INT, b VARCHAR(255), PRIMARY KEY (a))
ENGINE = MyISAM
PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (0) MAX_ROWS=100,
PARTITION p1 VALUES LESS THAN (100) MAX_ROWS=100,
PARTITION pMax VALUES LESS THAN MAXVALUE);
INSERT INTO t1 VALUES (1, "Partition p1, first row");
DROP TABLE t1;

View File

@ -0,0 +1 @@
--secure_file_priv=$MYSQL_TMP_DIR

View File

@ -0,0 +1,79 @@
#
# Bug58747 breaks secure_file_priv+not secure yet+still accesses other folders
#
# we do the windows specific relative directory testing
--source include/windows.inc
CREATE TABLE t1 (c1 longtext);
INSERT INTO t1 values ('a');
LET $MYSQL_TMP_DIR_UCASE= `SELECT upper('$MYSQL_TMP_DIR')`;
LET $MYSQL_TMP_DIR_LCASE= `SELECT lower('$MYSQL_TMP_DIR')`;
#create the file
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SELECT * FROM t1 INTO OUTFILE '$MYSQL_TMP_DIR/B11764517.tmp';
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
show global variables like 'secure_file_priv';
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SELECT load_file('$MYSQL_TMP_DIR\\\\B11764517.tmp') AS x;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SELECT load_file('$MYSQL_TMP_DIR/B11764517.tmp') AS x;
--replace_result $MYSQL_TMP_DIR_UCASE MYSQL_TMP_DIR_UCASE
eval SELECT load_file('$MYSQL_TMP_DIR_UCASE/B11764517.tmp') AS x;
--replace_result $MYSQL_TMP_DIR_LCASE MYSQL_TMP_DIR_LCASE
eval SELECT load_file('$MYSQL_TMP_DIR_LCASE/B11764517.tmp') AS x;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SELECT load_file('$MYSQL_TMP_DIR\\\\..a..\\\\..\\\\..\\\\B11764517.tmp') AS x;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval LOAD DATA INFILE '$MYSQL_TMP_DIR\\\\B11764517.tmp' INTO TABLE t1;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval LOAD DATA INFILE '$MYSQL_TMP_DIR/B11764517.tmp' INTO TABLE t1;
--replace_result $MYSQL_TMP_DIR_UCASE MYSQL_TMP_DIR_UCASE
eval LOAD DATA INFILE '$MYSQL_TMP_DIR_UCASE/B11764517.tmp' INTO TABLE t1;
--replace_result $MYSQL_TMP_DIR_LCASE MYSQL_TMP_DIR_LCASE
eval LOAD DATA INFILE '$MYSQL_TMP_DIR_LCASE/B11764517.tmp' INTO TABLE t1;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
--error ER_OPTION_PREVENTS_STATEMENT
eval LOAD DATA INFILE "$MYSQL_TMP_DIR\\\\..a..\\\\..\\\\..\\\\B11764517.tmp" into table t1;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
--error ER_OPTION_PREVENTS_STATEMENT
eval SELECT * FROM t1 INTO OUTFILE '$MYSQL_TMP_DIR\\\\..a..\\\\..\\\\..\\\\B11764517-2.tmp';
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SELECT * FROM t1 INTO OUTFILE '$MYSQL_TMP_DIR\\\\B11764517-2.tmp';
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SELECT * FROM t1 INTO OUTFILE '$MYSQL_TMP_DIR/B11764517-3.tmp';
--replace_result $MYSQL_TMP_DIR_UCASE MYSQL_TMP_DIR_UCASE
eval SELECT * FROM t1 INTO OUTFILE '$MYSQL_TMP_DIR_UCASE/B11764517-4.tmp';
--replace_result $MYSQL_TMP_DIR_LCASE MYSQL_TMP_DIR_LCASE
eval SELECT * FROM t1 INTO OUTFILE '$MYSQL_TMP_DIR_LCASE/B11764517-5.tmp';
--error 0,1
--remove_file $MYSQL_TMP_DIR/B11764517.tmp;
--error 0,1
--remove_file $MYSQL_TMP_DIR/B11764517-2.tmp;
--error 0,1
--remove_file $MYSQL_TMP_DIR/B11764517-3.tmp;
--error 0,1
--remove_file $MYSQL_TMP_DIR/B11764517-4.tmp;
--error 0,1
--remove_file $MYSQL_TMP_DIR/B11764517-5.tmp;
DROP TABLE t1;

View File

@ -3393,6 +3393,39 @@ ORDER BY outr.pk;
DROP TABLE t1,t2; DROP TABLE t1,t2;
--echo #
--echo # Bug#12329653
--echo # EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY
--echo #
CREATE TABLE t1(a1 int);
INSERT INTO t1 VALUES (1),(2);
SELECT @@session.sql_mode INTO @old_sql_mode;
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
## First a simpler query, illustrating the transformation
## '1 < some (...)' => '1 < max(...)'
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
## The query which made the server crash.
PREPARE stmt FROM
'SELECT 1 UNION ALL
SELECT 1 FROM t1
ORDER BY
(SELECT 1 FROM t1 AS t1_0
WHERE 1 < SOME (SELECT a1 FROM t1)
)' ;
--error ER_SUBQUERY_NO_1_ROW
EXECUTE stmt ;
--error ER_SUBQUERY_NO_1_ROW
EXECUTE stmt ;
SET SESSION sql_mode=@old_sql_mode;
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
--echo End of 5.0 tests. --echo End of 5.0 tests.
@ -3726,3 +3759,25 @@ DROP TABLE t1,t2;
--enable_result_log --enable_result_log
--echo End of 5.1 tests --echo End of 5.1 tests
--echo #
--echo # Bug #11765713 58705:
--echo # OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES
--echo # CREATED BY OPT_SUM_QUERY
--echo #
CREATE TABLE t1(a INT NOT NULL, KEY (a));
INSERT INTO t1 VALUES (0), (1);
--error ER_SUBQUERY_NO_1_ROW
SELECT 1 as foo FROM t1 WHERE a < SOME
(SELECT a FROM t1 WHERE a <=>
(SELECT a FROM t1)
);
SELECT 1 as foo FROM t1 WHERE a < SOME
(SELECT a FROM t1 WHERE a <=>
(SELECT a FROM t1 where a is null)
);
DROP TABLE t1;

View File

@ -373,4 +373,51 @@ SELECT a FROM t1 WHERE a >= '20000101000000';
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug#50774: failed to get the correct resultset when timestamp values
--echo # are appended with .0
--echo #
CREATE TABLE t1 ( a TIMESTAMP, KEY ( a ) );
INSERT INTO t1 VALUES( '2010-02-01 09:31:01' );
INSERT INTO t1 VALUES( '2010-02-01 09:31:02' );
INSERT INTO t1 VALUES( '2010-02-01 09:31:03' );
INSERT INTO t1 VALUES( '2010-02-01 09:31:04' );
SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' <= a;
SELECT * FROM t1 WHERE a <= '2010-02-01 09:31:02.0';
SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' >= a;
--replace_column 1 x 2 x 3 x 5 x 6 x 7 x 8 x 9 x 10 x
EXPLAIN
SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
CREATE TABLE t2 ( a TIMESTAMP, KEY ( a DESC ) );
INSERT INTO t2 VALUES( '2010-02-01 09:31:01' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:02' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:03' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:04' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:05' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:06' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:07' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:08' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:09' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:10' );
INSERT INTO t2 VALUES( '2010-02-01 09:31:11' );
--echo # The bug would cause the range optimizer's comparison to use an open
--echo # interval here. This reveals itself only in the number of reads
--echo # performed.
FLUSH STATUS;
--replace_column 1 x 2 x 3 x 5 x 6 x 7 x 8 x 9 x 10 x
EXPLAIN
SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0';
SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0';
SHOW STATUS LIKE 'Handler_read_next';
DROP TABLE t1, t2;
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -144,24 +144,23 @@ int my_realpath(char *to, const char *filename, myf MyFlags)
result= -1; result= -1;
} }
DBUG_RETURN(result); DBUG_RETURN(result);
#else #elif defined(_WIN32)
#ifdef _WIN32 int ret= GetFullPathName(filename,FN_REFLEN, to, NULL);
int ret= GetFullPathName(filename,FN_REFLEN,
to,
NULL);
if (ret == 0 || ret > FN_REFLEN) if (ret == 0 || ret > FN_REFLEN)
{ {
if (ret > FN_REFLEN) my_errno= (ret > FN_REFLEN) ? ENAMETOOLONG : GetLastError();
my_errno= ENAMETOOLONG;
else
my_errno= EACCES;
if (MyFlags & MY_WME) if (MyFlags & MY_WME)
my_error(EE_REALPATH, MYF(0), filename, my_errno); my_error(EE_REALPATH, MYF(0), filename, my_errno);
return -1; /*
GetFullPathName didn't work : use my_load_path() which is a poor
substitute original name but will at least be able to resolve
paths that starts with '.'.
*/
my_load_path(to, filename, NullS);
return -1;
} }
#else #else
my_load_path(to, filename, NullS); my_load_path(to, filename, NullS);
#endif #endif
return 0; return 0;
#endif
} }

View File

@ -772,7 +772,7 @@ long calc_daynr(uint year,uint month,uint day)
int y= year; /* may be < 0 temporarily */ int y= year; /* may be < 0 temporarily */
DBUG_ENTER("calc_daynr"); DBUG_ENTER("calc_daynr");
if (y == 0 && month == 0 && day == 0) if (y == 0 && month == 0)
DBUG_RETURN(0); /* Skip errors */ DBUG_RETURN(0); /* Skip errors */
/* Cast to int to be able to handle month == 0 */ /* Cast to int to be able to handle month == 0 */
delsum= (long) (365 * y + 31 *((int) month - 1) + (int) day); delsum= (long) (365 * y + 31 *((int) month - 1) + (int) day);
@ -783,6 +783,7 @@ long calc_daynr(uint year,uint month,uint day)
temp=(int) ((y/100+1)*3)/4; temp=(int) ((y/100+1)*3)/4;
DBUG_PRINT("exit",("year: %d month: %d day: %d -> daynr: %ld", DBUG_PRINT("exit",("year: %d month: %d day: %d -> daynr: %ld",
y+(month <= 2),month,day,delsum+y/4-temp)); y+(month <= 2),month,day,delsum+y/4-temp));
DBUG_ASSERT(delsum+(int) y/4-temp > 0);
DBUG_RETURN(delsum+(int) y/4-temp); DBUG_RETURN(delsum+(int) y/4-temp);
} /* calc_daynr */ } /* calc_daynr */

View File

@ -582,6 +582,14 @@ Event_db_repository::open_event_table(THD *thd, enum thr_lock_type lock_type,
*table= tables.table; *table= tables.table;
tables.table->use_all_columns(); tables.table->use_all_columns();
if (table_intact.check(*table, &event_table_def))
{
close_thread_tables(thd);
my_error(ER_EVENT_OPEN_TABLE_FAILED, MYF(0));
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }

View File

@ -5467,6 +5467,7 @@ double Field_year::val_real(void)
longlong Field_year::val_int(void) longlong Field_year::val_int(void)
{ {
ASSERT_COLUMN_MARKED_FOR_READ; ASSERT_COLUMN_MARKED_FOR_READ;
DBUG_ASSERT(field_length == 2 || field_length == 4);
int tmp= (int) ptr[0]; int tmp= (int) ptr[0];
if (field_length != 4) if (field_length != 4)
tmp%=100; // Return last 2 char tmp%=100; // Return last 2 char
@ -5479,6 +5480,7 @@ longlong Field_year::val_int(void)
String *Field_year::val_str(String *val_buffer, String *Field_year::val_str(String *val_buffer,
String *val_ptr __attribute__((unused))) String *val_ptr __attribute__((unused)))
{ {
DBUG_ASSERT(field_length < 5);
val_buffer->alloc(5); val_buffer->alloc(5);
val_buffer->length(field_length); val_buffer->length(field_length);
char *to=(char*) val_buffer->ptr(); char *to=(char*) val_buffer->ptr();

View File

@ -163,8 +163,7 @@ const uint ha_partition::NO_CURRENT_PART_ID= 0xFFFFFFFF;
*/ */
ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share) ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share)
:handler(hton, share), m_part_info(NULL), m_create_handler(FALSE), :handler(hton, share)
m_is_sub_partitioned(0)
{ {
DBUG_ENTER("ha_partition::ha_partition(table)"); DBUG_ENTER("ha_partition::ha_partition(table)");
init_handler_variables(); init_handler_variables();
@ -184,15 +183,44 @@ ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share)
*/ */
ha_partition::ha_partition(handlerton *hton, partition_info *part_info) ha_partition::ha_partition(handlerton *hton, partition_info *part_info)
:handler(hton, NULL), m_part_info(part_info), m_create_handler(TRUE), :handler(hton, NULL)
m_is_sub_partitioned(m_part_info->is_sub_partitioned())
{ {
DBUG_ENTER("ha_partition::ha_partition(part_info)"); DBUG_ENTER("ha_partition::ha_partition(part_info)");
DBUG_ASSERT(part_info);
init_handler_variables(); init_handler_variables();
DBUG_ASSERT(m_part_info); m_part_info= part_info;
m_create_handler= TRUE;
m_is_sub_partitioned= m_part_info->is_sub_partitioned();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/**
ha_partition constructor method used by ha_partition::clone()
@param hton Handlerton (partition_hton)
@param share Table share object
@param part_info_arg partition_info to use
@param clone_arg ha_partition to clone
@param clme_mem_root_arg MEM_ROOT to use
@return New partition handler
*/
ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share,
partition_info *part_info_arg,
ha_partition *clone_arg,
MEM_ROOT *clone_mem_root_arg)
:handler(hton, share)
{
DBUG_ENTER("ha_partition::ha_partition(clone)");
init_handler_variables();
m_part_info= part_info_arg;
m_create_handler= TRUE;
m_is_sub_partitioned= m_part_info->is_sub_partitioned();
m_is_clone_of= clone_arg;
m_clone_mem_root= clone_mem_root_arg;
DBUG_VOID_RETURN;
}
/* /*
Initialize handler object Initialize handler object
@ -244,7 +272,6 @@ void ha_partition::init_handler_variables()
m_rec0= 0; m_rec0= 0;
m_curr_key_info[0]= NULL; m_curr_key_info[0]= NULL;
m_curr_key_info[1]= NULL; m_curr_key_info[1]= NULL;
is_clone= FALSE,
m_part_func_monotonicity_info= NON_MONOTONIC; m_part_func_monotonicity_info= NON_MONOTONIC;
auto_increment_lock= FALSE; auto_increment_lock= FALSE;
auto_increment_safe_stmt_log_lock= FALSE; auto_increment_safe_stmt_log_lock= FALSE;
@ -252,6 +279,11 @@ void ha_partition::init_handler_variables()
this allows blackhole to work properly this allows blackhole to work properly
*/ */
m_no_locks= 0; m_no_locks= 0;
m_part_info= NULL;
m_create_handler= FALSE;
m_is_sub_partitioned= 0;
m_is_clone_of= NULL;
m_clone_mem_root= NULL;
#ifdef DONT_HAVE_TO_BE_INITALIZED #ifdef DONT_HAVE_TO_BE_INITALIZED
m_start_key.flag= 0; m_start_key.flag= 0;
@ -359,7 +391,8 @@ bool ha_partition::initialize_partition(MEM_ROOT *mem_root)
*/ */
DBUG_RETURN(0); DBUG_RETURN(0);
} }
else if (get_from_handler_file(table_share->normalized_path.str, mem_root)) else if (get_from_handler_file(table_share->normalized_path.str,
mem_root, false))
{ {
my_message(ER_UNKNOWN_ERROR, "Failed to read from the .par file", MYF(0)); my_message(ER_UNKNOWN_ERROR, "Failed to read from the .par file", MYF(0));
DBUG_RETURN(1); DBUG_RETURN(1);
@ -1848,7 +1881,7 @@ uint ha_partition::del_ren_cre_table(const char *from,
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
if (get_from_handler_file(from, ha_thd()->mem_root)) if (get_from_handler_file(from, ha_thd()->mem_root, false))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
DBUG_ASSERT(m_file_buffer); DBUG_ASSERT(m_file_buffer);
DBUG_PRINT("enter", ("from: (%s) to: (%s)", from, to)); DBUG_PRINT("enter", ("from: (%s) to: (%s)", from, to));
@ -2064,18 +2097,16 @@ static uint name_add(char *dest, const char *first_name, const char *sec_name)
} }
/* /**
Create the special .par file Create the special .par file
SYNOPSIS @param name Full path of table name
create_handler_file()
name Full path of table name
RETURN VALUE @return Operation status
>0 Error code @retval FALSE Error code
0 Success @retval TRUE Success
DESCRIPTION @note
Method used to create handler file with names of partitions, their Method used to create handler file with names of partitions, their
engine types and the number of partitions. engine types and the number of partitions.
*/ */
@ -2139,19 +2170,22 @@ bool ha_partition::create_handler_file(const char *name)
Array of engine types n * 4 bytes where Array of engine types n * 4 bytes where
n = (m_tot_parts + 3)/4 n = (m_tot_parts + 3)/4
Length of name part in bytes 4 bytes Length of name part in bytes 4 bytes
(Names in filename format)
Name part m * 4 bytes where Name part m * 4 bytes where
m = ((length_name_part + 3)/4)*4 m = ((length_name_part + 3)/4)*4
All padding bytes are zeroed All padding bytes are zeroed
*/ */
tot_partition_words= (tot_parts + 3) / 4; tot_partition_words= (tot_parts + PAR_WORD_SIZE - 1) / PAR_WORD_SIZE;
tot_name_words= (tot_name_len + 3) / 4; tot_name_words= (tot_name_len + PAR_WORD_SIZE - 1) / PAR_WORD_SIZE;
/* 4 static words (tot words, checksum, tot partitions, name length) */
tot_len_words= 4 + tot_partition_words + tot_name_words; tot_len_words= 4 + tot_partition_words + tot_name_words;
tot_len_byte= 4 * tot_len_words; tot_len_byte= PAR_WORD_SIZE * tot_len_words;
if (!(file_buffer= (uchar *) my_malloc(tot_len_byte, MYF(MY_ZEROFILL)))) if (!(file_buffer= (uchar *) my_malloc(tot_len_byte, MYF(MY_ZEROFILL))))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
engine_array= (file_buffer + 12); engine_array= (file_buffer + PAR_ENGINES_OFFSET);
name_buffer_ptr= (char*) (file_buffer + ((4 + tot_partition_words) * 4)); name_buffer_ptr= (char*) (engine_array + tot_partition_words * PAR_WORD_SIZE
+ PAR_WORD_SIZE);
part_it.rewind(); part_it.rewind();
for (i= 0; i < no_parts; i++) for (i= 0; i < no_parts; i++)
{ {
@ -2189,13 +2223,15 @@ bool ha_partition::create_handler_file(const char *name)
} }
chksum= 0; chksum= 0;
int4store(file_buffer, tot_len_words); int4store(file_buffer, tot_len_words);
int4store(file_buffer + 8, tot_parts); int4store(file_buffer + PAR_NUM_PARTS_OFFSET, tot_parts);
int4store(file_buffer + 12 + (tot_partition_words * 4), tot_name_len); int4store(file_buffer + PAR_ENGINES_OFFSET +
(tot_partition_words * PAR_WORD_SIZE),
tot_name_len);
for (i= 0; i < tot_len_words; i++) for (i= 0; i < tot_len_words; i++)
chksum^= uint4korr(file_buffer + 4 * i); chksum^= uint4korr(file_buffer + PAR_WORD_SIZE * i);
int4store(file_buffer + 4, chksum); int4store(file_buffer + PAR_CHECKSUM_OFFSET, chksum);
/* /*
Remove .frm extension and replace with .par Add .par extension to the file name.
Create and write and close file Create and write and close file
to be used at open, delete_table and rename_table to be used at open, delete_table and rename_table
*/ */
@ -2213,14 +2249,9 @@ bool ha_partition::create_handler_file(const char *name)
DBUG_RETURN(result); DBUG_RETURN(result);
} }
/*
/**
Clear handler variables and free some memory Clear handler variables and free some memory
SYNOPSIS
clear_handler_file()
RETURN VALUE
NONE
*/ */
void ha_partition::clear_handler_file() void ha_partition::clear_handler_file()
@ -2233,16 +2264,15 @@ void ha_partition::clear_handler_file()
m_engine_array= NULL; m_engine_array= NULL;
} }
/*
/**
Create underlying handler objects Create underlying handler objects
SYNOPSIS @param mem_root Allocate memory through this
create_handlers()
mem_root Allocate memory through this
RETURN VALUE @return Operation status
TRUE Error @retval TRUE Error
FALSE Success @retval FALSE Success
*/ */
bool ha_partition::create_handlers(MEM_ROOT *mem_root) bool ha_partition::create_handlers(MEM_ROOT *mem_root)
@ -2280,6 +2310,7 @@ bool ha_partition::create_handlers(MEM_ROOT *mem_root)
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
/* /*
Create underlying handler objects from partition info Create underlying handler objects from partition info
@ -2351,100 +2382,164 @@ error_end:
} }
/* /**
Get info about partition engines and their names from the .par file Read the .par file to get the partitions engines and names
SYNOPSIS @param name Name of table file (without extention)
get_from_handler_file()
name Full path of table name
mem_root Allocate memory through this
RETURN VALUE @return Operation status
TRUE Error @retval true Failure
FALSE Success @retval false Success
DESCRIPTION @note On success, m_file_buffer is allocated and must be
Open handler file to get partition names, engine types and number of freed by the caller. m_name_buffer_ptr and m_tot_parts is also set.
partitions.
*/ */
bool ha_partition::get_from_handler_file(const char *name, MEM_ROOT *mem_root) bool ha_partition::read_par_file(const char *name)
{ {
char buff[FN_REFLEN], *address_tot_name_len; char buff[FN_REFLEN], *tot_name_len_offset;
File file; File file;
char *file_buffer, *name_buffer_ptr; char *file_buffer;
handlerton **engine_array;
uint i, len_bytes, len_words, tot_partition_words, tot_name_words, chksum; uint i, len_bytes, len_words, tot_partition_words, tot_name_words, chksum;
DBUG_ENTER("ha_partition::get_from_handler_file"); DBUG_ENTER("ha_partition::read_par_file");
DBUG_PRINT("enter", ("table name: '%s'", name)); DBUG_PRINT("enter", ("table name: '%s'", name));
if (m_file_buffer) if (m_file_buffer)
DBUG_RETURN(FALSE); DBUG_RETURN(false);
fn_format(buff, name, "", ha_par_ext, MY_APPEND_EXT); fn_format(buff, name, "", ha_par_ext, MY_APPEND_EXT);
/* Following could be done with my_stat to read in whole file */ /* Following could be done with my_stat to read in whole file */
if ((file= my_open(buff, O_RDONLY | O_SHARE, MYF(0))) < 0) if ((file= my_open(buff, O_RDONLY | O_SHARE, MYF(0))) < 0)
DBUG_RETURN(TRUE); DBUG_RETURN(true);
if (my_read(file, (uchar *) & buff[0], 8, MYF(MY_NABP))) if (my_read(file, (uchar *) & buff[0], PAR_WORD_SIZE, MYF(MY_NABP)))
goto err1; goto err1;
len_words= uint4korr(buff); len_words= uint4korr(buff);
len_bytes= 4 * len_words; len_bytes= PAR_WORD_SIZE * len_words;
if (my_seek(file, 0, MY_SEEK_SET, MYF(0)) == MY_FILEPOS_ERROR)
goto err1;
if (!(file_buffer= (char*) my_malloc(len_bytes, MYF(0)))) if (!(file_buffer= (char*) my_malloc(len_bytes, MYF(0))))
goto err1; goto err1;
VOID(my_seek(file, 0, MY_SEEK_SET, MYF(0)));
if (my_read(file, (uchar *) file_buffer, len_bytes, MYF(MY_NABP))) if (my_read(file, (uchar *) file_buffer, len_bytes, MYF(MY_NABP)))
goto err2; goto err2;
chksum= 0; chksum= 0;
for (i= 0; i < len_words; i++) for (i= 0; i < len_words; i++)
chksum ^= uint4korr((file_buffer) + 4 * i); chksum ^= uint4korr((file_buffer) + PAR_WORD_SIZE * i);
if (chksum) if (chksum)
goto err2; goto err2;
m_tot_parts= uint4korr((file_buffer) + 8); m_tot_parts= uint4korr((file_buffer) + PAR_NUM_PARTS_OFFSET);
DBUG_PRINT("info", ("No of parts = %u", m_tot_parts)); DBUG_PRINT("info", ("No of parts = %u", m_tot_parts));
tot_partition_words= (m_tot_parts + 3) / 4; tot_partition_words= (m_tot_parts + PAR_WORD_SIZE - 1) / PAR_WORD_SIZE;
tot_name_len_offset= file_buffer + PAR_ENGINES_OFFSET +
PAR_WORD_SIZE * tot_partition_words;
tot_name_words= (uint4korr(tot_name_len_offset) + PAR_WORD_SIZE - 1) /
PAR_WORD_SIZE;
/*
Verify the total length = tot size word, checksum word, num parts word +
engines array + name length word + name array.
*/
if (len_words != (tot_partition_words + tot_name_words + 4))
goto err2;
VOID(my_close(file, MYF(0)));
m_file_buffer= file_buffer; // Will be freed in clear_handler_file()
m_name_buffer_ptr= tot_name_len_offset + PAR_WORD_SIZE;
DBUG_RETURN(false);
err2:
my_free(file_buffer, MYF(0));
err1:
VOID(my_close(file, MYF(0)));
DBUG_RETURN(true);
}
/**
Setup m_engine_array
@param mem_root MEM_ROOT to use for allocating new handlers
@return Operation status
@retval false Success
@retval true Failure
*/
bool ha_partition::setup_engine_array(MEM_ROOT *mem_root)
{
uint i;
uchar *buff;
handlerton **engine_array;
DBUG_ASSERT(!m_file);
DBUG_ENTER("ha_partition::setup_engine_array");
engine_array= (handlerton **) my_alloca(m_tot_parts * sizeof(handlerton*)); engine_array= (handlerton **) my_alloca(m_tot_parts * sizeof(handlerton*));
if (!engine_array)
DBUG_RETURN(true);
buff= (uchar *) (m_file_buffer + PAR_ENGINES_OFFSET);
for (i= 0; i < m_tot_parts; i++) for (i= 0; i < m_tot_parts; i++)
{ {
engine_array[i]= ha_resolve_by_legacy_type(ha_thd(), engine_array[i]= ha_resolve_by_legacy_type(ha_thd(),
(enum legacy_db_type) (enum legacy_db_type)
*(uchar *) ((file_buffer) + *(buff + i));
12 + i));
if (!engine_array[i]) if (!engine_array[i])
goto err3; goto err;
} }
address_tot_name_len= file_buffer + 12 + 4 * tot_partition_words;
tot_name_words= (uint4korr(address_tot_name_len) + 3) / 4;
if (len_words != (tot_partition_words + tot_name_words + 4))
goto err3;
name_buffer_ptr= file_buffer + 16 + 4 * tot_partition_words;
VOID(my_close(file, MYF(0)));
m_file_buffer= file_buffer; // Will be freed in clear_handler_file()
m_name_buffer_ptr= name_buffer_ptr;
if (!(m_engine_array= (plugin_ref*) if (!(m_engine_array= (plugin_ref*)
my_malloc(m_tot_parts * sizeof(plugin_ref), MYF(MY_WME)))) my_malloc(m_tot_parts * sizeof(plugin_ref), MYF(MY_WME))))
goto err3; goto err;
for (i= 0; i < m_tot_parts; i++) for (i= 0; i < m_tot_parts; i++)
m_engine_array[i]= ha_lock_engine(NULL, engine_array[i]); m_engine_array[i]= ha_lock_engine(NULL, engine_array[i]);
my_afree((gptr) engine_array); my_afree((gptr) engine_array);
if (!m_file && create_handlers(mem_root)) if (create_handlers(mem_root))
{ {
clear_handler_file(); clear_handler_file();
DBUG_RETURN(TRUE); DBUG_RETURN(true);
} }
DBUG_RETURN(FALSE);
err3: DBUG_RETURN(false);
err:
my_afree((gptr) engine_array); my_afree((gptr) engine_array);
err2: DBUG_RETURN(true);
my_free(file_buffer, MYF(0)); }
err1:
VOID(my_close(file, MYF(0)));
DBUG_RETURN(TRUE); /**
Get info about partition engines and their names from the .par file
@param name Full path of table name
@param mem_root Allocate memory through this
@param is_clone If it is a clone, don't create new handlers
@return Operation status
@retval true Error
@retval false Success
@note Open handler file to get partition names, engine types and number of
partitions.
*/
bool ha_partition::get_from_handler_file(const char *name, MEM_ROOT *mem_root,
bool is_clone)
{
DBUG_ENTER("ha_partition::get_from_handler_file");
DBUG_PRINT("enter", ("table name: '%s'", name));
if (m_file_buffer)
DBUG_RETURN(false);
if (read_par_file(name))
DBUG_RETURN(true);
if (!is_clone && setup_engine_array(mem_root))
DBUG_RETURN(true);
DBUG_RETURN(false);
} }
@ -2491,13 +2586,13 @@ void ha_data_partition_destroy(void *ha_data)
int ha_partition::open(const char *name, int mode, uint test_if_locked) int ha_partition::open(const char *name, int mode, uint test_if_locked)
{ {
char *name_buffer_ptr= m_name_buffer_ptr; char *name_buffer_ptr;
int error; int error= HA_ERR_INITIALIZATION;
uint alloc_len; uint alloc_len;
handler **file; handler **file;
char name_buff[FN_REFLEN]; char name_buff[FN_REFLEN];
bool is_not_tmp_table= (table_share->tmp_table == NO_TMP_TABLE); bool is_not_tmp_table= (table_share->tmp_table == NO_TMP_TABLE);
ulonglong check_table_flags= 0; ulonglong check_table_flags;
DBUG_ENTER("ha_partition::open"); DBUG_ENTER("ha_partition::open");
DBUG_ASSERT(table->s == table_share); DBUG_ASSERT(table->s == table_share);
@ -2505,8 +2600,9 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
m_mode= mode; m_mode= mode;
m_open_test_lock= test_if_locked; m_open_test_lock= test_if_locked;
m_part_field_array= m_part_info->full_part_field_array; m_part_field_array= m_part_info->full_part_field_array;
if (get_from_handler_file(name, &table->mem_root)) if (get_from_handler_file(name, &table->mem_root, test(m_is_clone_of)))
DBUG_RETURN(1); DBUG_RETURN(error);
name_buffer_ptr= m_name_buffer_ptr;
m_start_key.length= 0; m_start_key.length= 0;
m_rec0= table->record[0]; m_rec0= table->record[0];
m_rec_length= table_share->reclength; m_rec_length= table_share->reclength;
@ -2516,7 +2612,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
{ {
if (!(m_ordered_rec_buffer= (uchar*)my_malloc(alloc_len, MYF(MY_WME)))) if (!(m_ordered_rec_buffer= (uchar*)my_malloc(alloc_len, MYF(MY_WME))))
{ {
DBUG_RETURN(1); DBUG_RETURN(error);
} }
{ {
/* /*
@ -2539,48 +2635,84 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
/* Initialize the bitmap we use to minimize ha_start_bulk_insert calls */ /* Initialize the bitmap we use to minimize ha_start_bulk_insert calls */
if (bitmap_init(&m_bulk_insert_started, NULL, m_tot_parts + 1, FALSE)) if (bitmap_init(&m_bulk_insert_started, NULL, m_tot_parts + 1, FALSE))
DBUG_RETURN(1); DBUG_RETURN(error);
bitmap_clear_all(&m_bulk_insert_started); bitmap_clear_all(&m_bulk_insert_started);
/* Initialize the bitmap we use to determine what partitions are used */ /* Initialize the bitmap we use to determine what partitions are used */
if (!is_clone) if (!m_is_clone_of)
{ {
DBUG_ASSERT(!m_clone_mem_root);
if (bitmap_init(&(m_part_info->used_partitions), NULL, m_tot_parts, TRUE)) if (bitmap_init(&(m_part_info->used_partitions), NULL, m_tot_parts, TRUE))
{ {
bitmap_free(&m_bulk_insert_started); bitmap_free(&m_bulk_insert_started);
DBUG_RETURN(1); DBUG_RETURN(error);
} }
bitmap_set_all(&(m_part_info->used_partitions)); bitmap_set_all(&(m_part_info->used_partitions));
} }
file= m_file; if (m_is_clone_of)
do
{ {
create_partition_name(name_buff, name, name_buffer_ptr, NORMAL_PART_NAME, uint i;
FALSE); DBUG_ASSERT(m_clone_mem_root);
if ((error= (*file)->ha_open(table, (const char*) name_buff, mode, /* Allocate an array of handler pointers for the partitions handlers. */
test_if_locked))) alloc_len= (m_tot_parts + 1) * sizeof(handler*);
goto err_handler; if (!(m_file= (handler **) alloc_root(m_clone_mem_root, alloc_len)))
m_no_locks+= (*file)->lock_count(); goto err_alloc;
name_buffer_ptr+= strlen(name_buffer_ptr) + 1; memset(m_file, 0, alloc_len);
/*
Populate them by cloning the original partitions. This also opens them.
Note that file->ref is allocated too.
*/
file= m_is_clone_of->m_file;
for (i= 0; i < m_tot_parts; i++)
{
create_partition_name(name_buff, name, name_buffer_ptr, NORMAL_PART_NAME,
FALSE);
if (!(m_file[i]= file[i]->clone(name_buff, m_clone_mem_root)))
{
error= HA_ERR_INITIALIZATION;
file= &m_file[i];
goto err_handler;
}
name_buffer_ptr+= strlen(name_buffer_ptr) + 1;
}
}
else
{
file= m_file;
do
{
create_partition_name(name_buff, name, name_buffer_ptr, NORMAL_PART_NAME,
FALSE);
if ((error= (*file)->ha_open(table, name_buff, mode, test_if_locked)))
goto err_handler;
m_no_locks+= (*file)->lock_count();
name_buffer_ptr+= strlen(name_buffer_ptr) + 1;
} while (*(++file));
}
file= m_file;
ref_length= (*file)->ref_length;
check_table_flags= (((*file)->ha_table_flags() &
~(PARTITION_DISABLED_TABLE_FLAGS)) |
(PARTITION_ENABLED_TABLE_FLAGS));
while (*(++file))
{
/* MyISAM can have smaller ref_length for partitions with MAX_ROWS set */
set_if_bigger(ref_length, ((*file)->ref_length)); set_if_bigger(ref_length, ((*file)->ref_length));
/* /*
Verify that all partitions have the same set of table flags. Verify that all partitions have the same set of table flags.
Mask all flags that partitioning enables/disables. Mask all flags that partitioning enables/disables.
*/ */
if (!check_table_flags) if (check_table_flags != (((*file)->ha_table_flags() &
{ ~(PARTITION_DISABLED_TABLE_FLAGS)) |
check_table_flags= (((*file)->ha_table_flags() & (PARTITION_ENABLED_TABLE_FLAGS)))
~(PARTITION_DISABLED_TABLE_FLAGS)) |
(PARTITION_ENABLED_TABLE_FLAGS));
}
else if (check_table_flags != (((*file)->ha_table_flags() &
~(PARTITION_DISABLED_TABLE_FLAGS)) |
(PARTITION_ENABLED_TABLE_FLAGS)))
{ {
error= HA_ERR_INITIALIZATION; error= HA_ERR_INITIALIZATION;
/* set file to last handler, so all of them is closed */
file = &m_file[m_tot_parts - 1];
goto err_handler; goto err_handler;
} }
} while (*(++file)); }
key_used_on_scan= m_file[0]->key_used_on_scan; key_used_on_scan= m_file[0]->key_used_on_scan;
implicit_emptied= m_file[0]->implicit_emptied; implicit_emptied= m_file[0]->implicit_emptied;
/* /*
@ -2589,6 +2721,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
*/ */
ref_length+= PARTITION_BYTES_IN_POS; ref_length+= PARTITION_BYTES_IN_POS;
m_ref_length= ref_length; m_ref_length= ref_length;
/* /*
Release buffer read from .par file. It will not be reused again after Release buffer read from .par file. It will not be reused again after
being opened once. being opened once.
@ -2646,25 +2779,54 @@ err_handler:
DEBUG_SYNC(ha_thd(), "partition_open_error"); DEBUG_SYNC(ha_thd(), "partition_open_error");
while (file-- != m_file) while (file-- != m_file)
(*file)->close(); (*file)->close();
err_alloc:
bitmap_free(&m_bulk_insert_started); bitmap_free(&m_bulk_insert_started);
if (!is_clone) if (!m_is_clone_of)
bitmap_free(&(m_part_info->used_partitions)); bitmap_free(&(m_part_info->used_partitions));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
handler *ha_partition::clone(MEM_ROOT *mem_root)
/**
Clone the open and locked partitioning handler.
@param mem_root MEM_ROOT to use.
@return Pointer to the successfully created clone or NULL
@details
This function creates a new ha_partition handler as a clone/copy. The
original (this) must already be opened and locked. The clone will use
the originals m_part_info.
It also allocates memory for ref + ref_dup.
In ha_partition::open() it will clone its original handlers partitions
which will allocate then on the correct MEM_ROOT and also open them.
*/
handler *ha_partition::clone(const char *name, MEM_ROOT *mem_root)
{ {
handler *new_handler= get_new_handler(table->s, mem_root, ha_partition *new_handler;
table->s->db_type());
((ha_partition*)new_handler)->m_part_info= m_part_info; DBUG_ENTER("ha_partition::clone");
((ha_partition*)new_handler)->is_clone= TRUE; new_handler= new (mem_root) ha_partition(ht, table_share, m_part_info,
if (new_handler && !new_handler->ha_open(table, this, mem_root);
table->s->normalized_path.str, /*
table->db_stat, Allocate new_handler->ref here because otherwise ha_open will allocate it
HA_OPEN_IGNORE_IF_LOCKED)) on this->table->mem_root and we will not be able to reclaim that memory
return new_handler; when the clone handler object is destroyed.
return NULL; */
if (new_handler &&
!(new_handler->ref= (uchar*) alloc_root(mem_root,
ALIGN_SIZE(m_ref_length)*2)))
new_handler= NULL;
if (new_handler &&
new_handler->ha_open(table, name,
table->db_stat, HA_OPEN_IGNORE_IF_LOCKED))
new_handler= NULL;
DBUG_RETURN((handler*) new_handler);
} }
@ -2695,7 +2857,7 @@ int ha_partition::close(void)
DBUG_ASSERT(table->s == table_share); DBUG_ASSERT(table->s == table_share);
delete_queue(&m_queue); delete_queue(&m_queue);
bitmap_free(&m_bulk_insert_started); bitmap_free(&m_bulk_insert_started);
if (!is_clone) if (!m_is_clone_of)
bitmap_free(&(m_part_info->used_partitions)); bitmap_free(&(m_part_info->used_partitions));
file= m_file; file= m_file;
@ -3795,19 +3957,16 @@ end_dont_reset_start_part:
void ha_partition::position(const uchar *record) void ha_partition::position(const uchar *record)
{ {
handler *file= m_file[m_last_part]; handler *file= m_file[m_last_part];
uint pad_length;
DBUG_ENTER("ha_partition::position"); DBUG_ENTER("ha_partition::position");
file->position(record); file->position(record);
int2store(ref, m_last_part); int2store(ref, m_last_part);
memcpy((ref + PARTITION_BYTES_IN_POS), file->ref, memcpy((ref + PARTITION_BYTES_IN_POS), file->ref, file->ref_length);
(ref_length - PARTITION_BYTES_IN_POS)); pad_length= m_ref_length - PARTITION_BYTES_IN_POS - file->ref_length;
if (pad_length)
memset((ref + PARTITION_BYTES_IN_POS + file->ref_length), 0, pad_length);
#ifdef SUPPORTING_PARTITION_OVER_DIFFERENT_ENGINES
#ifdef HAVE_purify
bzero(ref + PARTITION_BYTES_IN_POS + ref_length,
max_ref_length-ref_length);
#endif /* HAVE_purify */
#endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -4317,7 +4476,8 @@ int ha_partition::index_read_idx_map(uchar *buf, uint index,
break; break;
} }
} }
m_last_part= part; if (part <= m_part_spec.end_part)
m_last_part= part;
} }
else else
{ {
@ -6237,7 +6397,14 @@ void ha_partition::print_error(int error, myf errflag)
{ {
/* In case m_file has not been initialized, like in bug#42438 */ /* In case m_file has not been initialized, like in bug#42438 */
if (m_file) if (m_file)
{
if (m_last_part >= m_tot_parts)
{
DBUG_ASSERT(0);
m_last_part= 0;
}
m_file[m_last_part]->print_error(error, errflag); m_file[m_last_part]->print_error(error, errflag);
}
else else
handler::print_error(error, errflag); handler::print_error(error, errflag);
} }

View File

@ -55,6 +55,16 @@ typedef struct st_ha_data_partition
HA_DUPLICATE_POS | \ HA_DUPLICATE_POS | \
HA_CAN_SQL_HANDLER | \ HA_CAN_SQL_HANDLER | \
HA_CAN_INSERT_DELAYED) HA_CAN_INSERT_DELAYED)
/* First 4 bytes in the .par file is the number of 32-bit words in the file */
#define PAR_WORD_SIZE 4
/* offset to the .par file checksum */
#define PAR_CHECKSUM_OFFSET 4
/* offset to the total number of partitions */
#define PAR_NUM_PARTS_OFFSET 8
/* offset to the engines array */
#define PAR_ENGINES_OFFSET 12
class ha_partition :public handler class ha_partition :public handler
{ {
private: private:
@ -71,7 +81,7 @@ private:
/* Data for the partition handler */ /* Data for the partition handler */
int m_mode; // Open mode int m_mode; // Open mode
uint m_open_test_lock; // Open test_if_locked uint m_open_test_lock; // Open test_if_locked
char *m_file_buffer; // Buffer with names char *m_file_buffer; // Content of the .par file
char *m_name_buffer_ptr; // Pointer to first partition name char *m_name_buffer_ptr; // Pointer to first partition name
plugin_ref *m_engine_array; // Array of types of the handlers plugin_ref *m_engine_array; // Array of types of the handlers
handler **m_file; // Array of references to handler inst. handler **m_file; // Array of references to handler inst.
@ -133,6 +143,13 @@ private:
bool m_is_sub_partitioned; // Is subpartitioned bool m_is_sub_partitioned; // Is subpartitioned
bool m_ordered_scan_ongoing; bool m_ordered_scan_ongoing;
/*
If set, this object was created with ha_partition::clone and doesn't
"own" the m_part_info structure.
*/
ha_partition *m_is_clone_of;
MEM_ROOT *m_clone_mem_root;
/* /*
We keep track if all underlying handlers are MyISAM since MyISAM has a We keep track if all underlying handlers are MyISAM since MyISAM has a
great number of extra flags not needed by other handlers. great number of extra flags not needed by other handlers.
@ -169,11 +186,6 @@ private:
PARTITION_SHARE *share; /* Shared lock info */ PARTITION_SHARE *share; /* Shared lock info */
#endif #endif
/*
TRUE <=> this object was created with ha_partition::clone and doesn't
"own" the m_part_info structure.
*/
bool is_clone;
bool auto_increment_lock; /**< lock reading/updating auto_inc */ bool auto_increment_lock; /**< lock reading/updating auto_inc */
/** /**
Flag to keep the auto_increment lock through out the statement. Flag to keep the auto_increment lock through out the statement.
@ -186,7 +198,7 @@ private:
/** used for prediction of start_bulk_insert rows */ /** used for prediction of start_bulk_insert rows */
enum_monotonicity_info m_part_func_monotonicity_info; enum_monotonicity_info m_part_func_monotonicity_info;
public: public:
handler *clone(MEM_ROOT *mem_root); handler *clone(const char *name, MEM_ROOT *mem_root);
virtual void set_part_info(partition_info *part_info) virtual void set_part_info(partition_info *part_info)
{ {
m_part_info= part_info; m_part_info= part_info;
@ -205,6 +217,10 @@ public:
*/ */
ha_partition(handlerton *hton, TABLE_SHARE * table); ha_partition(handlerton *hton, TABLE_SHARE * table);
ha_partition(handlerton *hton, partition_info * part_info); ha_partition(handlerton *hton, partition_info * part_info);
ha_partition(handlerton *hton, TABLE_SHARE *share,
partition_info *part_info_arg,
ha_partition *clone_arg,
MEM_ROOT *clone_mem_root_arg);
~ha_partition(); ~ha_partition();
/* /*
A partition handler has no characteristics in itself. It only inherits A partition handler has no characteristics in itself. It only inherits
@ -275,7 +291,10 @@ private:
And one method to read it in. And one method to read it in.
*/ */
bool create_handler_file(const char *name); bool create_handler_file(const char *name);
bool get_from_handler_file(const char *name, MEM_ROOT *mem_root); bool setup_engine_array(MEM_ROOT *mem_root);
bool read_par_file(const char *name);
bool get_from_handler_file(const char *name, MEM_ROOT *mem_root,
bool is_clone);
bool new_handlers_from_part_info(MEM_ROOT *mem_root); bool new_handlers_from_part_info(MEM_ROOT *mem_root);
bool create_handlers(MEM_ROOT *mem_root); bool create_handlers(MEM_ROOT *mem_root);
void clear_handler_file(); void clear_handler_file();

View File

@ -2037,22 +2037,29 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
/**************************************************************************** /****************************************************************************
** General handler functions ** General handler functions
****************************************************************************/ ****************************************************************************/
handler *handler::clone(MEM_ROOT *mem_root) handler *handler::clone(const char *name, MEM_ROOT *mem_root)
{ {
handler *new_handler= get_new_handler(table->s, mem_root, table->s->db_type()); handler *new_handler= get_new_handler(table->s, mem_root, ht);
/* /*
Allocate handler->ref here because otherwise ha_open will allocate it Allocate handler->ref here because otherwise ha_open will allocate it
on this->table->mem_root and we will not be able to reclaim that memory on this->table->mem_root and we will not be able to reclaim that memory
when the clone handler object is destroyed. when the clone handler object is destroyed.
*/ */
if (!(new_handler->ref= (uchar*) alloc_root(mem_root, ALIGN_SIZE(ref_length)*2))) if (new_handler &&
return NULL; !(new_handler->ref= (uchar*) alloc_root(mem_root,
if (new_handler && !new_handler->ha_open(table, ALIGN_SIZE(ref_length)*2)))
table->s->normalized_path.str, new_handler= NULL;
table->db_stat, /*
HA_OPEN_IGNORE_IF_LOCKED)) TODO: Implement a more efficient way to have more than one index open for
return new_handler; the same table instance. The ha_open call is not cachable for clone.
return NULL; */
if (new_handler && new_handler->ha_open(table,
name,
table->db_stat,
HA_OPEN_IGNORE_IF_LOCKED))
new_handler= NULL;
return new_handler;
} }

View File

@ -1,18 +1,19 @@
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. /* Copyright (c) 2000, 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
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License
the Free Software Foundation; version 2 of the 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, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA */
/* Definitions for parameters to do with handler-routines */ /* Definitions for parameters to do with handler-routines */
@ -56,7 +57,7 @@
a table with rnd_next() a table with rnd_next()
- We will see all rows (including deleted ones) - We will see all rows (including deleted ones)
- Row positions are 'table->s->db_record_offset' apart - Row positions are 'table->s->db_record_offset' apart
If this flag is not set, filesort will do a postion() call for each matched If this flag is not set, filesort will do a position() call for each matched
row to be able to find the row later. row to be able to find the row later.
*/ */
#define HA_REC_NOT_IN_SEQ (1 << 3) #define HA_REC_NOT_IN_SEQ (1 << 3)
@ -1165,7 +1166,7 @@ public:
DBUG_ASSERT(locked == FALSE); DBUG_ASSERT(locked == FALSE);
/* TODO: DBUG_ASSERT(inited == NONE); */ /* TODO: DBUG_ASSERT(inited == NONE); */
} }
virtual handler *clone(MEM_ROOT *mem_root); virtual handler *clone(const char *name, MEM_ROOT *mem_root);
/** This is called after create to allow us to set up cached variables */ /** This is called after create to allow us to set up cached variables */
void init() void init()
{ {

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (c) 2000, 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
@ -183,7 +183,7 @@ char * ip_to_hostname(struct in_addr *in, uint *errors)
&tmp_hostent,buff,sizeof(buff),&tmp_errno))) &tmp_hostent,buff,sizeof(buff),&tmp_errno)))
{ {
DBUG_PRINT("error",("gethostbyaddr_r returned %d",tmp_errno)); DBUG_PRINT("error",("gethostbyaddr_r returned %d",tmp_errno));
return 0; DBUG_RETURN(0);
} }
if (!(check=my_gethostbyname_r(hp->h_name,&tmp_hostent2,buff2,sizeof(buff2), if (!(check=my_gethostbyname_r(hp->h_name,&tmp_hostent2,buff2,sizeof(buff2),
&tmp_errno))) &tmp_errno)))

View File

@ -4464,14 +4464,14 @@ mark_non_agg_field:
SELECT_LEX *select_lex= cached_table ? SELECT_LEX *select_lex= cached_table ?
cached_table->select_lex : context->select_lex; cached_table->select_lex : context->select_lex;
if (!thd->lex->in_sum_func) if (!thd->lex->in_sum_func)
select_lex->full_group_by_flag|= NON_AGG_FIELD_USED; select_lex->set_non_agg_field_used(true);
else else
{ {
if (outer_fixed) if (outer_fixed)
thd->lex->in_sum_func->outer_fields.push_back(this); thd->lex->in_sum_func->outer_fields.push_back(this);
else if (thd->lex->in_sum_func->nest_level != else if (thd->lex->in_sum_func->nest_level !=
thd->lex->current_select->nest_level) thd->lex->current_select->nest_level)
select_lex->full_group_by_flag|= NON_AGG_FIELD_USED; select_lex->set_non_agg_field_used(true);
} }
} }
return FALSE; return FALSE;

View File

@ -4000,13 +4000,11 @@ void Item_func_in::fix_length_and_dec()
uint j=0; uint j=0;
for (uint i=1 ; i < arg_count ; i++) for (uint i=1 ; i < arg_count ; i++)
{ {
if (!args[i]->null_value) // Skip NULL values array->set(j,args[i]);
{ if (!args[i]->null_value) // Skip NULL values
array->set(j,args[i]); j++;
j++; else
} have_null= 1;
else
have_null= 1;
} }
if ((array->used_count= j)) if ((array->used_count= j))
array->sort(); array->sort();

View File

@ -2122,10 +2122,7 @@ my_decimal *Item_func_round::decimal_op(my_decimal *decimal_value)
if (!(null_value= (args[0]->null_value || args[1]->null_value || if (!(null_value= (args[0]->null_value || args[1]->null_value ||
my_decimal_round(E_DEC_FATAL_ERROR, value, (int) dec, my_decimal_round(E_DEC_FATAL_ERROR, value, (int) dec,
truncate, decimal_value) > 1))) truncate, decimal_value) > 1)))
{
decimal_value->frac= decimals;
return decimal_value; return decimal_value;
}
return 0; return 0;
} }

View File

@ -1016,6 +1016,14 @@ Item_in_subselect::single_value_transformer(JOIN *join,
it.replace(item); it.replace(item);
} }
DBUG_EXECUTE("where",
print_where(item, "rewrite with MIN/MAX", QT_ORDINARY););
if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY)
{
DBUG_ASSERT(select_lex->non_agg_field_used());
select_lex->set_non_agg_field_used(false);
}
save_allow_sum_func= thd->lex->allow_sum_func; save_allow_sum_func= thd->lex->allow_sum_func;
thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level; thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
/* /*

View File

@ -247,10 +247,10 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
in_sum_func->outer_fields.push_back(field); in_sum_func->outer_fields.push_back(field);
} }
else else
sel->full_group_by_flag|= NON_AGG_FIELD_USED; sel->set_non_agg_field_used(true);
} }
if (sel->nest_level > aggr_level && if (sel->nest_level > aggr_level &&
(sel->full_group_by_flag & SUM_FUNC_USED) && (sel->agg_func_used()) &&
!sel->group_list.elements) !sel->group_list.elements)
{ {
my_message(ER_MIX_OF_GROUP_FUNC_AND_FIELDS, my_message(ER_MIX_OF_GROUP_FUNC_AND_FIELDS,
@ -259,7 +259,7 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
} }
} }
} }
aggr_sel->full_group_by_flag|= SUM_FUNC_USED; aggr_sel->set_agg_func_used(true);
update_used_tables(); update_used_tables();
thd->lex->in_sum_func= in_sum_func; thd->lex->in_sum_func= in_sum_func;
return FALSE; return FALSE;
@ -612,17 +612,13 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
switch (hybrid_type= item->result_type()) { switch (hybrid_type= item->result_type()) {
case INT_RESULT: case INT_RESULT:
max_length= 20;
break;
case DECIMAL_RESULT: case DECIMAL_RESULT:
case STRING_RESULT:
max_length= item->max_length; max_length= item->max_length;
break; break;
case REAL_RESULT: case REAL_RESULT:
max_length= float_length(decimals); max_length= float_length(decimals);
break; break;
case STRING_RESULT:
max_length= item->max_length;
break;
case ROW_RESULT: case ROW_RESULT:
default: default:
DBUG_ASSERT(0); DBUG_ASSERT(0);

View File

@ -648,7 +648,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
system_charset_info); system_charset_info);
break; break;
case 'W': case 'W':
if (type == MYSQL_TIMESTAMP_TIME) if (type == MYSQL_TIMESTAMP_TIME || !(l_time->month || l_time->year))
return 1; return 1;
weekday= calc_weekday(calc_daynr(l_time->year,l_time->month, weekday= calc_weekday(calc_daynr(l_time->year,l_time->month,
l_time->day),0); l_time->day),0);
@ -657,7 +657,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
system_charset_info); system_charset_info);
break; break;
case 'a': case 'a':
if (type == MYSQL_TIMESTAMP_TIME) if (type == MYSQL_TIMESTAMP_TIME || !(l_time->month || l_time->year))
return 1; return 1;
weekday=calc_weekday(calc_daynr(l_time->year,l_time->month, weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
l_time->day),0); l_time->day),0);
@ -816,7 +816,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
} }
break; break;
case 'w': case 'w':
if (type == MYSQL_TIMESTAMP_TIME) if (type == MYSQL_TIMESTAMP_TIME || !(l_time->month || l_time->year))
return 1; return 1;
weekday=calc_weekday(calc_daynr(l_time->year,l_time->month, weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
l_time->day),1); l_time->day),1);

View File

@ -1469,13 +1469,6 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables,
bool allow_null_cond, int *error); bool allow_null_cond, int *error);
extern Item **not_found_item; extern Item **not_found_item;
/*
A set of constants used for checking non aggregated fields and sum
functions mixture in the ONLY_FULL_GROUP_BY_MODE.
*/
#define NON_AGG_FIELD_USED 1
#define SUM_FUNC_USED 2
/* /*
This enumeration type is used only by the function find_item_in_list This enumeration type is used only by the function find_item_in_list
to return the info on how an item has been resolved against a list to return the info on how an item has been resolved against a list

View File

@ -8961,12 +8961,15 @@ fn_format_relative_to_data_home(char * to, const char *name,
bool is_secure_file_path(char *path) bool is_secure_file_path(char *path)
{ {
char buff1[FN_REFLEN], buff2[FN_REFLEN]; char buff1[FN_REFLEN], buff2[FN_REFLEN];
size_t opt_secure_file_priv_len;
/* /*
All paths are secure if opt_secure_file_path is 0 All paths are secure if opt_secure_file_path is 0
*/ */
if (!opt_secure_file_priv) if (!opt_secure_file_priv)
return TRUE; return TRUE;
opt_secure_file_priv_len= strlen(opt_secure_file_priv);
if (strlen(path) >= FN_REFLEN) if (strlen(path) >= FN_REFLEN)
return FALSE; return FALSE;
@ -8984,11 +8987,24 @@ bool is_secure_file_path(char *path)
return FALSE; return FALSE;
} }
convert_dirname(buff2, buff1, NullS); convert_dirname(buff2, buff1, NullS);
if (strncmp(opt_secure_file_priv, buff2, strlen(opt_secure_file_priv))) if (!lower_case_file_system)
return FALSE; {
if (strncmp(opt_secure_file_priv, buff2, opt_secure_file_priv_len))
return FALSE;
}
else
{
if (files_charset_info->coll->strnncoll(files_charset_info,
(uchar *) buff2, strlen(buff2),
(uchar *) opt_secure_file_priv,
opt_secure_file_priv_len,
TRUE))
return FALSE;
}
return TRUE; return TRUE;
} }
static int fix_paths(void) static int fix_paths(void)
{ {
char buff[FN_REFLEN],*pos; char buff[FN_REFLEN],*pos;

View File

@ -1335,7 +1335,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
} }
thd= head->in_use; thd= head->in_use;
if (!(file= head->file->clone(thd->mem_root))) if (!(file= head->file->clone(head->s->normalized_path.str, thd->mem_root)))
{ {
/* /*
Manually set the error flag. Note: there seems to be quite a few Manually set the error flag. Note: there seems to be quite a few

View File

@ -211,6 +211,7 @@ static int get_index_max_value(TABLE *table, TABLE_REF *ref, uint range_fl)
/** /**
Substitutes constants for some COUNT(), MIN() and MAX() functions. Substitutes constants for some COUNT(), MIN() and MAX() functions.
@param thd thread handler
@param tables list of leaves of join table tree @param tables list of leaves of join table tree
@param all_fields All fields to be returned @param all_fields All fields to be returned
@param conds WHERE clause @param conds WHERE clause
@ -228,9 +229,12 @@ static int get_index_max_value(TABLE *table, TABLE_REF *ref, uint range_fl)
HA_ERR_KEY_NOT_FOUND on impossible conditions HA_ERR_KEY_NOT_FOUND on impossible conditions
@retval @retval
HA_ERR_... if a deadlock or a lock wait timeout happens, for example HA_ERR_... if a deadlock or a lock wait timeout happens, for example
@retval
ER_... e.g. ER_SUBQUERY_NO_1_ROW
*/ */
int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) int opt_sum_query(THD *thd,
TABLE_LIST *tables, List<Item> &all_fields, COND *conds)
{ {
List_iterator_fast<Item> it(all_fields); List_iterator_fast<Item> it(all_fields);
int const_result= 1; int const_result= 1;
@ -242,6 +246,8 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
Item *item; Item *item;
int error; int error;
DBUG_ENTER("opt_sum_query");
if (conds) if (conds)
where_tables= conds->used_tables(); where_tables= conds->used_tables();
@ -269,7 +275,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
WHERE t2.field IS NULL; WHERE t2.field IS NULL;
*/ */
if (tl->table->map & where_tables) if (tl->table->map & where_tables)
return 0; DBUG_RETURN(0);
} }
else else
used_tables|= tl->table->map; used_tables|= tl->table->map;
@ -297,7 +303,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
{ {
tl->table->file->print_error(error, MYF(0)); tl->table->file->print_error(error, MYF(0));
tl->table->in_use->fatal_error(); tl->table->in_use->fatal_error();
return error; DBUG_RETURN(error);
} }
count*= tl->table->file->stats.records; count*= tl->table->file->stats.records;
} }
@ -390,10 +396,10 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
if (error) if (error)
{ {
if (error == HA_ERR_KEY_NOT_FOUND || error == HA_ERR_END_OF_FILE) if (error == HA_ERR_KEY_NOT_FOUND || error == HA_ERR_END_OF_FILE)
return HA_ERR_KEY_NOT_FOUND; // No rows matching WHERE DBUG_RETURN(HA_ERR_KEY_NOT_FOUND); // No rows matching WHERE
/* HA_ERR_LOCK_DEADLOCK or some other error */ /* HA_ERR_LOCK_DEADLOCK or some other error */
table->file->print_error(error, MYF(0)); table->file->print_error(error, MYF(0));
return(error); DBUG_RETURN(error);
} }
removed_tables|= table->map; removed_tables|= table->map;
} }
@ -437,6 +443,10 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
const_result= 0; const_result= 0;
} }
} }
if (thd->is_error())
DBUG_RETURN(thd->main_da.sql_errno());
/* /*
If we have a where clause, we can only ignore searching in the If we have a where clause, we can only ignore searching in the
tables if MIN/MAX optimisation replaced all used tables tables if MIN/MAX optimisation replaced all used tables
@ -446,7 +456,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
*/ */
if (removed_tables && used_tables != removed_tables) if (removed_tables && used_tables != removed_tables)
const_result= 0; // We didn't remove all tables const_result= 0; // We didn't remove all tables
return const_result; DBUG_RETURN(const_result);
} }
@ -732,6 +742,12 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
if (is_null || (is_null_safe_eq && args[1]->is_null())) if (is_null || (is_null_safe_eq && args[1]->is_null()))
{ {
/*
If we have a non-nullable index, we cannot use it,
since set_null will be ignored, and we will compare uninitialized data.
*/
if (!part->field->real_maybe_null())
DBUG_RETURN(false);
part->field->set_null(); part->field->set_null();
*key_ptr= (uchar) 1; *key_ptr= (uchar) 1;
} }
@ -802,8 +818,9 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
@param[out] prefix_len Length of prefix for the search range @param[out] prefix_len Length of prefix for the search range
@note @note
This function may set table->key_read to 1, which must be reset after This function may set field->table->key_read to true,
index is used! (This can only happen when function returns 1) which must be reset after index is used!
(This can only happen when function returns 1)
@retval @retval
0 Index can not be used to optimize MIN(field)/MAX(field) 0 Index can not be used to optimize MIN(field)/MAX(field)
@ -818,7 +835,9 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
uint *range_fl, uint *prefix_len) uint *range_fl, uint *prefix_len)
{ {
if (!(field->flags & PART_KEY_FLAG)) if (!(field->flags & PART_KEY_FLAG))
return 0; // Not key field return false; // Not key field
DBUG_ENTER("find_key_for_maxmin");
TABLE *table= field->table; TABLE *table= field->table;
uint idx= 0; uint idx= 0;
@ -843,7 +862,7 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
part++, jdx++, key_part_to_use= (key_part_to_use << 1) | 1) part++, jdx++, key_part_to_use= (key_part_to_use << 1) | 1)
{ {
if (!(table->file->index_flags(idx, jdx, 0) & HA_READ_ORDER)) if (!(table->file->index_flags(idx, jdx, 0) & HA_READ_ORDER))
return 0; DBUG_RETURN(false);
/* Check whether the index component is partial */ /* Check whether the index component is partial */
Field *part_field= table->field[part->fieldnr-1]; Field *part_field= table->field[part->fieldnr-1];
@ -892,12 +911,12 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
*/ */
if (field->part_of_key.is_set(idx)) if (field->part_of_key.is_set(idx))
table->set_keyread(TRUE); table->set_keyread(TRUE);
return 1; DBUG_RETURN(true);
} }
} }
} }
} }
return 0; DBUG_RETURN(false);
} }

View File

@ -97,7 +97,7 @@ static const char *reconnect_messages[SLAVE_RECON_ACT_MAX][SLAVE_RECON_MSG_MAX]=
registration on master", registration on master",
"Reconnecting after a failed registration on master", "Reconnecting after a failed registration on master",
"failed registering on master, reconnecting to try again, \ "failed registering on master, reconnecting to try again, \
log '%s' at postion %s", log '%s' at position %s",
"COM_REGISTER_SLAVE", "COM_REGISTER_SLAVE",
"Slave I/O thread killed during or after reconnect" "Slave I/O thread killed during or after reconnect"
}, },
@ -105,7 +105,7 @@ log '%s' at postion %s",
"Waiting to reconnect after a failed binlog dump request", "Waiting to reconnect after a failed binlog dump request",
"Slave I/O thread killed while retrying master dump", "Slave I/O thread killed while retrying master dump",
"Reconnecting after a failed binlog dump request", "Reconnecting after a failed binlog dump request",
"failed dump request, reconnecting to try again, log '%s' at postion %s", "failed dump request, reconnecting to try again, log '%s' at position %s",
"COM_BINLOG_DUMP", "COM_BINLOG_DUMP",
"Slave I/O thread killed during or after reconnect" "Slave I/O thread killed during or after reconnect"
}, },
@ -114,7 +114,7 @@ log '%s' at postion %s",
"Slave I/O thread killed while waiting to reconnect after a failed read", "Slave I/O thread killed while waiting to reconnect after a failed read",
"Reconnecting after a failed master event read", "Reconnecting after a failed master event read",
"Slave I/O thread: Failed reading log event, reconnecting to retry, \ "Slave I/O thread: Failed reading log event, reconnecting to retry, \
log '%s' at postion %s", log '%s' at position %s",
"", "",
"Slave I/O thread killed during or after a reconnect done to recover from \ "Slave I/O thread killed during or after a reconnect done to recover from \
failed read" failed read"

View File

@ -3383,6 +3383,7 @@ bool xid_cache_insert(XID *xid, enum xa_states xa_state)
xs->xa_state=xa_state; xs->xa_state=xa_state;
xs->xid.set(xid); xs->xid.set(xid);
xs->in_thd=0; xs->in_thd=0;
xs->rm_error=0;
res=my_hash_insert(&xid_cache, (uchar*)xs); res=my_hash_insert(&xid_cache, (uchar*)xs);
} }
pthread_mutex_unlock(&LOCK_xid_cache); pthread_mutex_unlock(&LOCK_xid_cache);

View File

@ -1621,6 +1621,8 @@ void st_select_lex::init_query()
nest_level= 0; nest_level= 0;
link_next= 0; link_next= 0;
lock_option= TL_READ_DEFAULT; lock_option= TL_READ_DEFAULT;
m_non_agg_field_used= false;
m_agg_func_used= false;
} }
void st_select_lex::init_select() void st_select_lex::init_select()
@ -1651,7 +1653,8 @@ void st_select_lex::init_select()
non_agg_fields.empty(); non_agg_fields.empty();
cond_value= having_value= Item::COND_UNDEF; cond_value= having_value= Item::COND_UNDEF;
inner_refs_list.empty(); inner_refs_list.empty();
full_group_by_flag= 0; m_non_agg_field_used= false;
m_agg_func_used= false;
} }
/* /*

Some files were not shown because too many files have changed in this diff Show More