Merge willster.(none):/home/stewart/Documents/MySQL/4.1/ndb

into  willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2


sql/ha_ndbcluster.cc:
  Auto merged
sql/ha_ndbcluster.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
This commit is contained in:
unknown 2006-09-20 17:09:53 +10:00
commit d4d3dcacaa
89 changed files with 1405 additions and 503 deletions

View file

@ -1059,3 +1059,4 @@ vio/test-sslserver
vio/viotest-ssl
libmysql/libmysql.ver
libmysqld/sql_locale.cc
mysql-test/mtr

View file

@ -1,6 +1,6 @@
#!/bin/sh
if ! test -f sql/mysqld.cc
if test ! -f sql/mysqld.cc
then
echo "You must run this script from the MySQL top-level directory"
exit 1
@ -109,12 +109,6 @@ fi
# (returns 0 if finds lines)
if ccache -V > /dev/null 2>&1
then
if ! (echo "$CC" | grep "ccache" > /dev/null)
then
CC="ccache $CC"
fi
if ! (echo "$CXX" | grep "ccache" > /dev/null)
then
CXX="ccache $CXX"
fi
echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC"
echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX"
fi

View file

@ -3,203 +3,206 @@
# Check cpu of current machine and find the
# best compiler optimization flags for gcc
#
#
if test -r /proc/cpuinfo ; then
# on Linux (and others?) we can get detailed CPU information out of /proc
cpuinfo="cat /proc/cpuinfo"
check_cpu () {
if test -r /proc/cpuinfo ; then
# on Linux (and others?) we can get detailed CPU information out of /proc
cpuinfo="cat /proc/cpuinfo"
# detect CPU family
cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
if test -z "$cpu_family" ; then
cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
# detect CPU family
cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
if test -z "$cpu_family" ; then
cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
fi
# detect CPU vendor and model
cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1`
if test -z "$model_name" ; then
model_name=`$cpuinfo | grep 'cpu model' | cut -d ':' -f 2 | head -1`
fi
# fallback: get CPU model from uname output
if test -z "$model_name" ; then
model_name=`uname -m`
fi
# parse CPU flags
for flag in `$cpuinfo | grep '^flags' | sed -e 's/^flags.*: //'`; do
eval cpu_flag_$flag=yes
done
else
# Fallback when there is no /proc/cpuinfo
case "`uname -s`" in
FreeBSD|OpenBSD)
cpu_family=`uname -m`;
model_name=`sysctl -n hw.model`
;;
Darwin)
cpu_family=`uname -p`
model_name=`machine`
;;
*)
cpu_family=`uname -m`;
model_name=`uname -p`;
;;
esac
fi
# detect CPU vendor and model
cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1`
if test -z "$model_name" ; then
model_name=`$cpuinfo | grep 'cpu model' | cut -d ':' -f 2 | head -1`
fi
# fallback: get CPU model from uname output
if test -z "$model_name" ; then
model_name=`uname -m`
fi
# parse CPU flags
for flag in `$cpuinfo | grep '^flags' | sed -e 's/^flags.*: //'`; do
eval cpu_flag_$flag=yes
done
else
# Fallback when there is no /proc/cpuinfo
case "`uname -s`" in
FreeBSD|OpenBSD)
cpu_family=`uname -m`;
model_name=`sysctl -n hw.model`
# detect CPU shortname as used by gcc options
# this list is not complete, feel free to add further entries
cpu_arg=""
case "$cpu_family--$model_name" in
# DEC Alpha
Alpha*EV6*)
cpu_arg="ev6";
;;
Darwin)
cpu_family=`uname -p`
model_name=`machine`
# Intel ia32
*Xeon*)
# a Xeon is just another pentium4 ...
# ... unless it has the "lm" (long-mode) flag set,
# in that case it's a Xeon with EM64T support
if [ -z "$cpu_flag_lm" ]; then
cpu_arg="pentium4";
else
cpu_arg="nocona";
fi
;;
*Pentium*4*Mobile*)
cpu_arg="pentium4m";
;;
*Pentium*4*)
cpu_arg="pentium4";
;;
*Pentium*III*Mobile*)
cpu_arg="pentium3m";
;;
*Pentium*III*)
cpu_arg="pentium3";
;;
*Pentium*M*pro*)
cpu_arg="pentium-m";
;;
*Athlon*64*)
cpu_arg="athlon64";
;;
*Athlon*)
cpu_arg="athlon";
;;
# Intel ia64
*Itanium*)
# Don't need to set any flags for itanium(at the moment)
cpu_arg="";
;;
#
*ppc*)
cpu_arg='powerpc'
;;
*powerpc*)
cpu_arg='powerpc'
;;
# unknown
*)
cpu_family=`uname -m`;
model_name=`uname -p`;
cpu_arg="";
;;
esac
fi
# detect CPU shortname as used by gcc options
# this list is not complete, feel free to add further entries
cpu_arg=""
case "$cpu_family--$model_name" in
# DEC Alpha
Alpha*EV6*)
cpu_arg="ev6";
;;
# Intel ia32
*Xeon*)
# a Xeon is just another pentium4 ...
# ... unless it has the "lm" (long-mode) flag set,
# in that case it's a Xeon with EM64T support
if [ -z "$cpu_flag_lm" ]; then
cpu_arg="pentium4";
else
cpu_arg="nocona";
fi
;;
*Pentium*4*Mobile*)
cpu_arg="pentium4m";
;;
*Pentium*4*)
cpu_arg="pentium4";
;;
*Pentium*III*Mobile*)
cpu_arg="pentium3m";
;;
*Pentium*III*)
cpu_arg="pentium3";
;;
*Pentium*M*pro*)
cpu_arg="pentium-m";
;;
*Athlon*64*)
cpu_arg="athlon64";
;;
*Athlon*)
cpu_arg="athlon";
;;
# Intel ia64
*Itanium*)
# Don't need to set any flags for itanium(at the moment)
cpu_arg="";
;;
#
*ppc*)
cpu_arg='powerpc'
;;
*powerpc*)
cpu_arg='powerpc'
;;
# unknown
*)
cpu_arg="";
;;
esac
if test -z "$cpu_arg"; then
echo "BUILD/check-cpu: Oops, could not find out what kind of cpu this machine is using."
check_cpu_cflags=""
return
fi
# different compiler versions have different option names
# for CPU specific command line options
if test -z "$CC" ; then
cc="gcc";
else
cc=$CC
fi
cc_ver=`$cc --version | sed 1q`
cc_verno=`echo $cc_ver | sed -e 's/[^0-9. ]//g; s/^ *//g; s/ .*//g'`
case "$cc_ver--$cc_verno" in
*GCC*)
# different gcc backends (and versions) have different CPU flags
case `gcc -dumpmachine` in
i?86-*)
case "$cc_verno" in
3.4*|3.5*|4.*)
check_cpu_args='-mtune=$cpu_arg -march=$cpu_arg'
;;
*)
check_cpu_args='-mcpu=$cpu_arg -march=$cpu_arg'
;;
esac
;;
ppc-*)
check_cpu_args='-mcpu=$cpu_arg -mtune=$cpu_arg'
;;
*)
check_cpu_cflags=""
return
;;
esac
;;
2.95.*)
# GCC 2.95 doesn't expose its name in --version output
check_cpu_args='-m$cpu_arg'
;;
*)
if test -z "$cpu_arg"; then
echo "BUILD/check-cpu: Oops, could not find out what kind of cpu this machine is using." >&2
check_cpu_cflags=""
return
;;
esac
# now we check whether the compiler really understands the cpu type
touch __test.c
while [ "$cpu_arg" ] ; do
echo -n testing $cpu_arg "... "
# compile check
check_cpu_cflags=`eval echo $check_cpu_args`
if $cc -c $check_cpu_cflags __test.c 2>/dev/null; then
echo ok
break;
fi
echo failed
check_cpu_cflags=""
# different compiler versions have different option names
# for CPU specific command line options
if test -z "$CC" ; then
cc="gcc";
else
cc=$CC
fi
# if compile failed: check whether it supports a predecessor of this CPU
# this list is not complete, feel free to add further entries
case "$cpu_arg" in
# Intel ia32
nocona) cpu_arg=pentium4 ;;
prescott) cpu_arg=pentium4 ;;
pentium4m) cpu_arg=pentium4 ;;
pentium4) cpu_arg=pentium3 ;;
pentium3m) cpu_arg=pentium3 ;;
pentium3) cpu_arg=pentium2 ;;
pentium2) cpu_arg=pentiumpro ;;
pentiumpro) cpu_arg=pentium ;;
pentium) cpu_arg=i486 ;;
i486) cpu_arg=i386 ;;
cc_ver=`$cc --version | sed 1q`
cc_verno=`echo $cc_ver | sed -e 's/[^0-9. ]//g; s/^ *//g; s/ .*//g'`
# power / powerPC
7450) cpu_arg=7400 ;;
*) cpu_arg="" ;;
case "$cc_ver--$cc_verno" in
*GCC*)
# different gcc backends (and versions) have different CPU flags
case `gcc -dumpmachine` in
i?86-*)
case "$cc_verno" in
3.4*|3.5*|4.*)
check_cpu_args='-mtune=$cpu_arg -march=$cpu_arg'
;;
*)
check_cpu_args='-mcpu=$cpu_arg -march=$cpu_arg'
;;
esac
;;
ppc-*)
check_cpu_args='-mcpu=$cpu_arg -mtune=$cpu_arg'
;;
*)
check_cpu_cflags=""
return
;;
esac
;;
2.95.*)
# GCC 2.95 doesn't expose its name in --version output
check_cpu_args='-m$cpu_arg'
;;
*)
check_cpu_cflags=""
return
;;
esac
done
rm __test.*
# now we check whether the compiler really understands the cpu type
touch __test.c
while [ "$cpu_arg" ] ; do
# FIXME: echo -n isn't portable - see contortions autoconf goes through
echo -n testing $cpu_arg "... " >&2
# compile check
check_cpu_cflags=`eval echo $check_cpu_args`
if $cc -c $check_cpu_cflags __test.c 2>/dev/null; then
echo ok >&2
break;
fi
echo failed >&2
check_cpu_cflags=""
# if compile failed: check whether it supports a predecessor of this CPU
# this list is not complete, feel free to add further entries
case "$cpu_arg" in
# Intel ia32
nocona) cpu_arg=pentium4 ;;
prescott) cpu_arg=pentium4 ;;
pentium4m) cpu_arg=pentium4 ;;
pentium4) cpu_arg=pentium3 ;;
pentium3m) cpu_arg=pentium3 ;;
pentium3) cpu_arg=pentium2 ;;
pentium2) cpu_arg=pentiumpro ;;
pentiumpro) cpu_arg=pentium ;;
pentium) cpu_arg=i486 ;;
i486) cpu_arg=i386 ;;
# power / powerPC
7450) cpu_arg=7400 ;;
*) cpu_arg="" ;;
esac
done
rm __test.*
}
check_cpu

19
BUILD/compile-ndb-autotest Executable file
View file

@ -0,0 +1,19 @@
#! /bin/sh
path=`dirname $0`
. "$path/SETUP.sh"
extra_configs="$max_configs --with-ndb-test --with-ndb-ccflags='-DERROR_INSERT'"
if [ "$full_debug" ]
then
extra_flags="$debug_cflags"
c_warnings="$c_warnings $debug_extra_warnings"
cxx_warnings="$cxx_warnings $debug_extra_warnings"
extra_configs="$debug_configs $extra_configs"
else
extra_flags="$fast_cflags"
fi
extra_flags="$extra_flags $max_cflags -g"
. "$path/FINISH.sh"

View file

@ -2154,9 +2154,14 @@ print_table_data(MYSQL_RES *result)
(void) tee_fputs("|", PAGER);
for (uint off=0; (field = mysql_fetch_field(result)) ; off++)
{
tee_fprintf(PAGER, " %-*s|",(int) min(field->max_length,
uint name_length= (uint) strlen(field->name);
uint numcells= charset_info->cset->numcells(charset_info,
field->name,
field->name + name_length);
uint display_length= field->max_length + name_length - numcells;
tee_fprintf(PAGER, " %-*s|",(int) min(display_length,
MAX_COLUMN_LENGTH),
field->name);
field->name);
num_flag[off]= IS_NUM(field->type);
}
(void) tee_fputs("\n", PAGER);

View file

@ -783,8 +783,8 @@ static int get_options(int *argc, char ***argv)
static void DBerror(MYSQL *mysql, const char *when)
{
DBUG_ENTER("DBerror");
my_printf_error(0,"Got error: %d: %s %s", MYF(0),
mysql_errno(mysql), mysql_error(mysql), when);
fprintf(stderr, "%s: Got error: %d: %s %s\n", my_progname,
mysql_errno(mysql), mysql_error(mysql), when);
safe_exit(EX_MYSQLERR);
DBUG_VOID_RETURN;
} /* DBerror */
@ -811,9 +811,9 @@ static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res,
if (mysql_query(mysql_con, query) ||
(res && !((*res)= mysql_store_result(mysql_con))))
{
my_printf_error(0, "%s: Couldn't execute '%s': %s (%d)",
MYF(0), my_progname, query,
mysql_error(mysql_con), mysql_errno(mysql_con));
fprintf(stderr, "%s: Couldn't execute '%s': %s (%d)\n",
my_progname, query,
mysql_error(mysql_con), mysql_errno(mysql_con));
return 1;
}
return 0;
@ -1705,13 +1705,19 @@ static void dumpTable(uint numFields, char *table)
check_io(md_result_file);
}
if (mysql_query_with_error_report(sock, 0, query))
{
DBerror(sock, "when retrieving data from server");
goto err;
}
if (quick)
res=mysql_use_result(sock);
else
res=mysql_store_result(sock);
if (!res)
{
DBerror(sock, "when retrieving data from server");
goto err;
}
if (verbose)
fprintf(stderr, "-- Retrieving rows...\n");
if (mysql_num_fields(res) != numFields)

View file

@ -26,6 +26,9 @@
#define USERNAME_LENGTH 16
#define SERVER_VERSION_LENGTH 60
#define SQLSTATE_LENGTH 5
#define SYSTEM_CHARSET_MBMAXLEN 3
#define NAME_BYTE_LEN NAME_LEN*SYSTEM_CHARSET_MBMAXLEN
#define USERNAME_BYTE_LENGTH USERNAME_LENGTH*SYSTEM_CHARSET_MBMAXLEN
#define LOCAL_HOST "localhost"
#define LOCAL_HOST_NAMEDPIPE "."

View file

@ -480,13 +480,6 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
if (!got_error)
{
share->state.key_map|=(ulonglong) 1 << sinfo->key;
if (param->testflag & T_STATISTICS)
update_key_parts(sinfo->keyinfo, rec_per_key_part, sinfo->unique,
param->stats_method == MI_STATS_METHOD_IGNORE_NULLS?
sinfo->notnull: NULL,
(ulonglong) info->state->records);
if (!sinfo->buffpek.elements)
{
if (param->testflag & T_VERBOSE)
@ -498,6 +491,11 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
flush_ft_buf(sinfo) || flush_pending_blocks(sinfo))
got_error=1;
}
if (!got_error && param->testflag & T_STATISTICS)
update_key_parts(sinfo->keyinfo, rec_per_key_part, sinfo->unique,
param->stats_method == MI_STATS_METHOD_IGNORE_NULLS?
sinfo->notnull: NULL,
(ulonglong) info->state->records);
}
my_free((gptr) sinfo->sort_keys,MYF(0));
my_free(mi_get_rec_buff_ptr(info, sinfo->rec_buff),

View file

@ -34,7 +34,7 @@ benchdir_root= $(prefix)
testdir = $(benchdir_root)/mysql-test
EXTRA_SCRIPTS = mysql-test-run.sh install_test_db.sh $(PRESCRIPTS)
EXTRA_DIST = $(EXTRA_SCRIPTS)
GENSCRIPTS = mysql-test-run install_test_db
GENSCRIPTS = mysql-test-run install_test_db mtr
PRESCRIPTS = mysql-test-run.pl
test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS)
test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem \
@ -105,6 +105,11 @@ std_data/server-cert.pem:
std_data/server-key.pem:
@CP@ $(top_srcdir)/SSL/$(@F) $(srcdir)/std_data
# mtr - a shortcut for executing mysql-test-run.pl
mtr:
$(RM) -f mtr
$(LN_S) mysql-test-run.pl mtr
SUFFIXES = .sh
.sh:

View file

@ -193,6 +193,28 @@ sub collect_one_test_case($$$$$$) {
$tinfo->{'slave_restart'}= 1;
}
# Cluster is needed by test case if testname contains ndb
if ( defined mtr_match_substring($tname,"ndb") )
{
$tinfo->{'ndb_test'}= 1;
if ( $::opt_skip_ndbcluster )
{
# Skip all ndb tests
$tinfo->{'skip'}= 1;
return;
}
if ( ! $::opt_with_ndbcluster )
{
# Ndb is not supported, skip them
$tinfo->{'skip'}= 1;
return;
}
}
else
{
$tinfo->{'ndb_test'}= 0;
}
# FIXME what about embedded_server + ndbcluster, skip ?!
my $master_opt_file= "$testdir/$tname-master.opt";

View file

@ -50,6 +50,23 @@ sub mtr_match_extension ($$) {
}
# Match a substring anywere in a string
sub mtr_match_substring ($$) {
my $string= shift;
my $substring= shift;
if ( $string =~ /(.*)\Q$substring\E(.*)$/ ) # strncmp
{
return $1;
}
else
{
return undef; # NULL
}
}
sub mtr_match_any_exact ($$) {
my $string= shift;
my $mlist= shift;

View file

@ -82,7 +82,14 @@ sub mtr_path_exists (@) {
sub mtr_script_exists (@) {
foreach my $path ( @_ )
{
return $path if -x $path;
if($::glob_win32)
{
return $path if -f $path;
}
else
{
return $path if -x $path;
}
}
if ( @_ == 1 )
{
@ -99,7 +106,14 @@ sub mtr_exe_exists (@) {
map {$_.= ".exe"} @path if $::glob_win32;
foreach my $path ( @path )
{
return $path if -x $path;
if($::glob_win32)
{
return $path if -f $path;
}
else
{
return $path if -x $path;
}
}
if ( @path == 1 )
{

View file

@ -233,6 +233,7 @@ our $opt_result_ext;
our $opt_skip;
our $opt_skip_rpl;
our $opt_skip_im; # --skip-im on command line will just be ignored
our $opt_skip_test;
our $opt_sleep;
@ -519,6 +520,7 @@ sub command_line_setup () {
'do-test=s' => \$opt_do_test,
'suite=s' => \$opt_suite,
'skip-rpl' => \$opt_skip_rpl,
'skip-im' => \$opt_skip_im,
'skip-test=s' => \$opt_skip_test,
# Specify ports
@ -898,7 +900,8 @@ sub executable_setup () {
$exe_mysqld= mtr_exe_exists ("$path_client_bindir/mysqld-nt",
"$path_client_bindir/mysqld",
"$path_client_bindir/mysqld-debug",
"$path_client_bindir/mysqld-max");
"$path_client_bindir/mysqld-max",
"$path_client_bindir/mysqld-max-nt");
$path_language= mtr_path_exists("$glob_basedir/share/english/");
$path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets");
$exe_my_print_defaults=
@ -1581,6 +1584,16 @@ sub run_testcase ($) {
{
$do_restart= 1; # Always restart if script to run
}
elsif ( $tinfo->{'ndb_test'} and $master->[0]->{'ndbcluster'} == 1 )
{
$do_restart= 1; # Restart with cluster
# print "Restarting because cluster need to be enabled\n";
}
elsif ($tinfo->{'ndb_test'} == 0 and $master->[0]->{'ndbcluster'} == 0)
{
$do_restart= 1; # Restart without cluster
# print "Restarting because cluster need to be disabled\n";
}
elsif ( $master->[0]->{'running_master_is_special'} and
$master->[0]->{'running_master_is_special'}->{'timezone'} eq
$tinfo->{'timezone'} and
@ -1646,7 +1659,7 @@ sub run_testcase ($) {
if ( ! $opt_local_master )
{
if ( $master->[0]->{'ndbcluster'} )
if ( $master->[0]->{'ndbcluster'} && $tinfo->{'ndb_test'})
{
$master->[0]->{'ndbcluster'}= ndbcluster_start();
if ( $master->[0]->{'ndbcluster'} )
@ -1659,8 +1672,22 @@ sub run_testcase ($) {
{
# FIXME not correct location for do_before_start_master()
do_before_start_master($tname,$tinfo->{'master_sh'});
# Save skip_ndbcluster
my $save_opt_skip_ndbcluster= $opt_skip_ndbcluster;
if (!$tinfo->{'ndb_test'})
{
# Modify skip_ndbcluster so cluster is skipped for this
# and subsequent testcases(until we find one that does not cluster)
$opt_skip_ndbcluster= 1;
}
$master->[0]->{'pid'}=
mysqld_start('master',0,$tinfo->{'master_opt'},[]);
# Restore skip_ndbcluster
$opt_skip_ndbcluster= $save_opt_skip_ndbcluster;
if ( ! $master->[0]->{'pid'} )
{
report_failure_and_restart($tinfo);
@ -2026,7 +2053,7 @@ sub mysqld_arguments ($$$$$) {
}
}
if ( $opt_with_ndbcluster )
if ( $opt_with_ndbcluster && !$opt_skip_ndbcluster && $type eq 'master')
{
mtr_add_arg($args, "%s--ndbcluster", $prefix);
mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,

View file

@ -247,3 +247,14 @@ lpad(c1,3,'
select rpad(c1,3,'ö'), rpad('ö',3,c1) from t1;
rpad(c1,3,'ö') rpad('ö',3,c1)
ßöö ößß
drop table t1;
set names koi8r;
create table t1(a char character set cp1251 default _koi8r 0xFF);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` char(1) character set cp1251 default '˙'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1(a char character set latin1 default _cp1251 0xFF);
ERROR 42000: Invalid default value for 'a'

View file

@ -722,3 +722,42 @@ id MIN(s)
1 ZZZ
2 ZZZ
DROP TABLE t1;
drop table if exists bug20536;
set names latin1;
create table bug20536 (id bigint not null auto_increment primary key, name
varchar(255) character set ucs2 not null);
insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'");
select md5(name) from bug20536;
md5(name)
f4b7ce8b45a20e3c4e84bef515d1525c
48d95db0d8305c2fe11548a3635c9385
select sha1(name) from bug20536;
sha1(name)
e0b52f38deddb9f9e8d5336b153592794cb49baf
677d4d505355eb5b0549b865fcae4b7f0c28aef5
select make_set(3, name, upper(name)) from bug20536;
make_set(3, name, upper(name))
test1,TEST1
'test\_2','TEST\_2'
select export_set(5, name, upper(name)) from bug20536;
export_set(5, name, upper(name))
test1,TEST1,test1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1
'test\_2','TEST\_2','test\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2'
select export_set(5, name, upper(name), ",", 5) from bug20536;
export_set(5, name, upper(name), ",", 5)
test1,TEST1,test1,TEST1,TEST1
'test\_2','TEST\_2','test\_2','TEST\_2','TEST\_2'
select password(name) from bug20536;
password(name)
????????????????????
????????????????????
select old_password(name) from bug20536;
old_password(name)
????????
????????
select quote(name) from bug20536;
quote(name)
????????
????????????????
drop table bug20536;
End of 4.1 tests

View file

@ -1,3 +1,6 @@
show variables like 'collation_server';
Variable_name Value
collation_server ucs2_unicode_ci
show variables like "%character_set_ser%";
Variable_name Value
character_set_server ucs2

View file

@ -924,6 +924,37 @@ NULL
select ifnull(NULL, _utf8'string');
ifnull(NULL, _utf8'string')
string
set names utf8;
create table t1 (s1 char(5) character set utf8 collate utf8_lithuanian_ci);
insert into t1 values ('I'),('K'),('Y');
select * from t1 where s1 < 'K' and s1 = 'Y';
s1
I
Y
select * from t1 where 'K' > s1 and s1 = 'Y';
s1
I
Y
drop table t1;
create table t1 (s1 char(5) character set utf8 collate utf8_czech_ci);
insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
select * from t1 where s1 > 'd' and s1 = 'CH';
s1
ch
CH
Ch
select * from t1 where 'd' < s1 and s1 = 'CH';
s1
ch
CH
Ch
select * from t1 where s1 = 'cH' and s1 <> 'ch';
s1
cH
select * from t1 where 'cH' = s1 and s1 <> 'ch';
s1
cH
drop table t1;
create table t1 (a varchar(255)) default character set utf8;
insert into t1 values (1.0);
drop table t1;
@ -1309,3 +1340,15 @@ select a from t1 group by a;
a
e
drop table t1;
set names utf8;
grant select on test.* to юзер_юзер@localhost;
user()
юзер_юзер@localhost
revoke all on test.* from юзер_юзер@localhost;
drop user юзер_юзер@localhost;
create database имя_базы_в_кодировке_утф8_длиной_большеем_45;
use имя_базы_в_кодировке_утф8_длиной_большеем_45;
select database();
database()
имя_базы_в_кодировке_утф8_длиной_большеем_45
drop database имя_базы_в_кодировке_утф8_длиной_большеем_45;

View file

@ -555,3 +555,14 @@ EXPLAIN SELECT DISTINCT a,b,d FROM t2 GROUP BY c,b,d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
DROP TABLE t1,t2;
CREATE TABLE t1 (a int primary key, b int);
INSERT INTO t1 (a,b) values (1,1), (2,3), (3,2);
explain SELECT DISTINCT a, b FROM t1 ORDER BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
SELECT DISTINCT a, b FROM t1 ORDER BY b;
a b
1 1
3 2
2 3
DROP TABLE t1;

View file

@ -93,3 +93,7 @@ SELECT IS_USED_LOCK('bug16501');
IS_USED_LOCK('bug16501')
NULL
DROP TABLE t1;
select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
export_set(3, _latin1'foo', _utf8'bar', ',', 4)
foo,foo,bar,bar
End of 4.1 tests

View file

@ -695,3 +695,24 @@ t1 CREATE TABLE `t1` (
`from_unixtime(1) + 0` double(23,6) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
H
120
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
H
120
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
H
05
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
H
5
End of 4.1 tests

View file

@ -255,27 +255,27 @@ a
3
3
delete from t1 where a < 4;
select a from t1;
select a from t1 order by a;
a
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
select a from t1 where a > 4;
a
delete from t1 where a > 4;
select a from t1;
select a from t1 order by a;
a
3
3
1
3
3
1
2
2
2
3
3
3
3
select a from t1 where a > 3;
a
delete from t1 where a >= 2;
select a from t1;
select a from t1 order by a;
a
1
1

View file

@ -83,3 +83,24 @@ b a
3 3
3 3
DROP TABLE t1, t2, t3;
CREATE TABLE `t1` (`id1` INT) ;
INSERT INTO `t1` (`id1`) VALUES (1),(5),(2);
CREATE TABLE `t2` (
`id1` INT,
`id2` INT NOT NULL,
`id3` INT,
`id4` INT NOT NULL,
UNIQUE (`id2`,`id4`),
KEY (`id1`)
) ENGINE=InnoDB;
INSERT INTO `t2`(`id1`,`id2`,`id3`,`id4`) VALUES
(1,1,1,0),
(1,1,2,1),
(5,1,2,2),
(6,1,2,3),
(1,2,2,2),
(1,2,1,1);
SELECT `id1` FROM `t1` WHERE `id1` NOT IN (SELECT `id1` FROM `t2` WHERE `id2` = 1 AND `id3` = 2);
id1
2
DROP TABLE t1, t2;

View file

@ -76,3 +76,17 @@ a
a
1
drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using temporary
select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
c
7
explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using temporary
select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
c
28

View file

@ -773,12 +773,12 @@ show create table t1;
Table Create Table
t1 CREATE TEMPORARY TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/'
show create table t1;
Table Create Table
t1 CREATE TEMPORARY TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/'
create table t1 (a int) engine=myisam select 42 a;
select * from t1;
a

View file

@ -2,47 +2,3 @@
1
ERROR 1064 (42000) at line 3: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
ERROR at line 1: USE must be followed by a database name
? (\?) Synonym for `help'.
clear (\c) Clear command.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set query delimiter.
edit (\e) Edit command with $EDITOR.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset_name(\C) Switch to another charset. Might be needed for processing binlog.
? (\?) Synonym for `help'.
clear (\c) Clear command.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set query delimiter.
edit (\e) Edit command with $EDITOR.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset_name(\C) Switch to another charset. Might be needed for processing binlog.

View file

@ -1557,4 +1557,31 @@ CREATE TABLE `t2` (
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t1, t2, t3;
create table t1 (a int);
mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1` WHERE xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 (1064)
mysqldump: Got error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 when retrieving data from server
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t1;
End of 4.1 tests

View file

@ -64,17 +64,26 @@ pk u o
insert into t1 values (1,1,1);
drop table t1;
create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb;
insert into t1 values (1,'one',1), (2,'two',2),(3,"three",3);
insert into t1 values (1,'one',1);
begin;
select * from t1 where x = 1 for update;
x y z
1 one 1
begin;
select * from t1 where x = 1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
rollback;
rollback;
insert into t1 values (2,'two',2),(3,"three",3);
begin;
select * from t1 where x = 1 for update;
x y z
1 one 1
select * from t1 where x = 1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t1 where x = 2 for update;
x y z
2 two 2
select * from t1 where x = 1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
rollback;
commit;
begin;

View file

@ -37,3 +37,14 @@ Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 1
test.t1 repair status OK
drop table t1;
CREATE TABLE t1(a INT, KEY(a));
INSERT INTO t1 VALUES(1),(2),(3),(4),(5);
SET myisam_repair_threads=2;
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 a 1 a A 5 NULL NULL YES BTREE
SET myisam_repair_threads=@@global.myisam_repair_threads;
DROP TABLE t1;

View file

@ -2895,3 +2895,25 @@ select * from t1 where NOT(s1 = ALL (select s1/s1 from t1));
s1
2
drop table t1;
create table t1 (
retailerID varchar(8) NOT NULL,
statusID int(10) unsigned NOT NULL,
changed datetime NOT NULL,
UNIQUE KEY retailerID (retailerID, statusID, changed)
);
INSERT INTO t1 VALUES("0026", "1", "2005-12-06 12:18:56");
INSERT INTO t1 VALUES("0026", "2", "2006-01-06 12:25:53");
INSERT INTO t1 VALUES("0037", "1", "2005-12-06 12:18:56");
INSERT INTO t1 VALUES("0037", "2", "2006-01-06 12:25:53");
INSERT INTO t1 VALUES("0048", "1", "2006-01-06 12:37:50");
INSERT INTO t1 VALUES("0059", "1", "2006-01-06 12:37:50");
select * from t1 r1
where (r1.retailerID,(r1.changed)) in
(SELECT r2.retailerId,(max(changed)) from t1 r2
group by r2.retailerId);
retailerID statusID changed
0026 2 2006-01-06 12:25:53
0037 2 2006-01-06 12:25:53
0048 1 2006-01-06 12:37:50
0059 1 2006-01-06 12:37:50
drop table t1;

View file

@ -186,5 +186,17 @@ select rpad(c1,3,'
# TODO
#select case c1 when 'ß' then 'ß' when 'ö' then 'ö' else 'c' end from t1;
#select export_set(5,c1,'ö'), export_set(5,'ö',c1) from t1;
drop table t1;
#
# Bug 20695: problem with field default value's character set
#
set names koi8r;
create table t1(a char character set cp1251 default _koi8r 0xFF);
show create table t1;
drop table t1;
--error 1067
create table t1(a char character set latin1 default _cp1251 0xFF);
# End of 4.1 tests

View file

@ -463,4 +463,37 @@ INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ');
SELECT id, MIN(s) FROM t1 GROUP BY id;
DROP TABLE t1;
# End of 4.1 tests
#
# Bug #20536: md5() with GROUP BY and UCS2 return different results on myisam/innodb
#
--disable_warnings
drop table if exists bug20536;
--enable_warnings
set names latin1;
create table bug20536 (id bigint not null auto_increment primary key, name
varchar(255) character set ucs2 not null);
insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'");
select md5(name) from bug20536;
select sha1(name) from bug20536;
select make_set(3, name, upper(name)) from bug20536;
select export_set(5, name, upper(name)) from bug20536;
select export_set(5, name, upper(name), ",", 5) from bug20536;
# Some broken functions: add these tests just to document current behavior.
# PASSWORD and OLD_PASSWORD don't work with UCS2 strings, but to fix it would
# not be backwards compatible in all cases, so it's best to leave it alone
select password(name) from bug20536;
select old_password(name) from bug20536;
# QUOTE doesn't work with UCS2 data. It would require a total rewrite
# of Item_func_quote::val_str(), which isn't worthwhile until UCS2 is
# supported fully as a client character set.
select quote(name) from bug20536;
drop table bug20536;
--echo End of 4.1 tests

View file

@ -1 +1 @@
--default-character-set=ucs2 --default-collation=ucs2_unicode_ci
--default-collation=ucs2_unicode_ci --default-character-set=ucs2

View file

@ -1,3 +1,8 @@
#
# MySQL Bug#15276: MySQL ignores collation-server
#
show variables like 'collation_server';
#
# Bug#18004 Connecting crashes server when default charset is UCS2
#

View file

@ -727,6 +727,24 @@ drop table t1;
select repeat(_utf8'+',3) as h union select NULL;
select ifnull(NULL, _utf8'string');
#
# Bug#9509 Optimizer: wrong result after AND with comparisons
#
set names utf8;
create table t1 (s1 char(5) character set utf8 collate utf8_lithuanian_ci);
insert into t1 values ('I'),('K'),('Y');
select * from t1 where s1 < 'K' and s1 = 'Y';
select * from t1 where 'K' > s1 and s1 = 'Y';
drop table t1;
create table t1 (s1 char(5) character set utf8 collate utf8_czech_ci);
insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
select * from t1 where s1 > 'd' and s1 = 'CH';
select * from t1 where 'd' < s1 and s1 = 'CH';
select * from t1 where s1 = 'cH' and s1 <> 'ch';
select * from t1 where 'cH' = s1 and s1 <> 'ch';
drop table t1;
#
# Bug#10714: Inserting double value into utf8 column crashes server
#
@ -1054,4 +1072,20 @@ explain select a from t1 group by a;
select a from t1 group by a;
drop table t1;
#
# Bug#20393: User name truncation in mysql client
# Bug#21432: Database/Table name limited to 64 bytes, not chars, problems with multi-byte
#
set names utf8;
#create user юзер_юзер@localhost;
grant select on test.* to юзер_юзер@localhost;
--exec $MYSQL --default-character-set=utf8 --user=юзер_юзер -e "select user()"
revoke all on test.* from юзер_юзер@localhost;
drop user юзер_юзер@localhost;
create database имя_базы_в_кодировке_утф8_длиной_большеем_45;
use имя_базы_в_кодировке_утф8_длиной_большеем_45;
select database();
drop database имя_базы_в_кодировке_утф8_длиной_большеем_45;
# End of 4.1 tests

View file

@ -378,4 +378,15 @@ EXPLAIN SELECT DISTINCT a,b,d FROM t2 GROUP BY c,b,d;
DROP TABLE t1,t2;
#
# Bug 21456: SELECT DISTINCT(x) produces incorrect results when using order by
#
CREATE TABLE t1 (a int primary key, b int);
INSERT INTO t1 (a,b) values (1,1), (2,3), (3,2);
explain SELECT DISTINCT a, b FROM t1 ORDER BY b;
SELECT DISTINCT a, b FROM t1 ORDER BY b;
DROP TABLE t1;
# End of 4.1 tests

View file

@ -83,4 +83,9 @@ connection default;
DROP TABLE t1;
# End of 4.1 tests
#
# Bug #21531: EXPORT_SET() doesn't accept args with coercible character sets
#
select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
--echo End of 4.1 tests

View file

@ -368,4 +368,22 @@ create table t1 select now() - now(), curtime() - curtime(),
show create table t1;
drop table t1;
# End of 4.1 tests
#
# Bug #19844 time_format in Union truncates values
#
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
--echo End of 4.1 tests

View file

@ -1,3 +1,4 @@
-- source include/not_embedded.inc
#
# test of HANDLER ...
#

View file

@ -172,14 +172,14 @@ create table t1(a int not null, key using btree(a)) engine=heap;
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
select a from t1 where a > 2;
delete from t1 where a < 4;
select a from t1;
select a from t1 order by a;
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
select a from t1 where a > 4;
delete from t1 where a > 4;
select a from t1;
select a from t1 order by a;
select a from t1 where a > 3;
delete from t1 where a >= 2;
select a from t1;
select a from t1 order by a;
drop table t1;
--echo End of 4.1 tests

View file

@ -90,3 +90,30 @@ SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
ORDER BY t1.b LIMIT 5;
DROP TABLE t1, t2, t3;
# BUG#21077 (The testcase is not deterministic so correct execution doesn't
# prove anything) For proof one should track if sequence of ha_innodb::* func
# calls is correct.
CREATE TABLE `t1` (`id1` INT) ;
INSERT INTO `t1` (`id1`) VALUES (1),(5),(2);
CREATE TABLE `t2` (
`id1` INT,
`id2` INT NOT NULL,
`id3` INT,
`id4` INT NOT NULL,
UNIQUE (`id2`,`id4`),
KEY (`id1`)
) ENGINE=InnoDB;
INSERT INTO `t2`(`id1`,`id2`,`id3`,`id4`) VALUES
(1,1,1,0),
(1,1,2,1),
(5,1,2,2),
(6,1,2,3),
(1,2,2,2),
(1,2,1,1);
SELECT `id1` FROM `t1` WHERE `id1` NOT IN (SELECT `id1` FROM `t2` WHERE `id2` = 1 AND `id3` = 2);
DROP TABLE t1, t2;

View file

@ -60,4 +60,14 @@ select 1 as a from t1 union all select 1 from dual limit 1;
(select 1 as a from t1) union all (select 1 from dual) limit 1;
drop table t1;
#
# Bug #21787: COUNT(*) + ORDER BY + LIMIT returns wrong result
#
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
# End of 4.1 tests

View file

@ -734,14 +734,20 @@ connect (session2,localhost,root,,);
connection session1;
disable_query_log;
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/tmp" select 9 a;
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/log" select 9 a;
enable_query_log;
# If running test suite with a non standard tmp dir, the "show create table"
# will print "DATA_DIRECTORY=". Use replace_result to mask it out
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
show create table t1;
connection session2;
disable_query_log;
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/tmp" select 99 a;
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/log" select 99 a;
enable_query_log;
# If running test suite with a non standard tmp dir, the "show create table"
# will print "DATA_DIRECTORY=". Use replace_result to mask it out
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
show create table t1;
connection default;

View file

@ -29,7 +29,7 @@
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
#
# Bug #20328: mysql client interprets commands in comments
# Bug #20328: mysql client: dumb about trailing spaces on 'help' command
#
--exec echo 'help' | $MYSQL
--exec echo 'help ' | $MYSQL
--exec echo 'help' | $MYSQL > $MYSQLTEST_VARDIR/tmp/bug20328.tmp
--exec echo 'help ' | $MYSQL > $MYSQLTEST_VARDIR/tmp/bug20328.tmp

View file

@ -694,4 +694,12 @@ create table t3(a int);
--exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2
drop table t1, t2, t3;
#
# Bug #21288: mysqldump segmentation fault when using --where
#
create table t1 (a int);
--error 2
--exec $MYSQL_DUMP --skip-comments --force test t1 --where='xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 2>&1
drop table t1;
--echo End of 4.1 tests

View file

@ -73,7 +73,7 @@ drop table t1;
create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb;
insert into t1 values (1,'one',1), (2,'two',2),(3,"three",3);
insert into t1 values (1,'one',1);
# PK access
connection con1;
@ -82,11 +82,22 @@ select * from t1 where x = 1 for update;
connection con2;
begin;
select * from t1 where x = 2 for update;
--error 1205
select * from t1 where x = 1 for update;
rollback;
connection con1;
rollback;
insert into t1 values (2,'two',2),(3,"three",3);
begin;
select * from t1 where x = 1 for update;
connection con2;
--error 1205
select * from t1 where x = 1 for update;
select * from t1 where x = 2 for update;
rollback;
connection con1;
commit;

View file

@ -34,4 +34,15 @@ repair table t1;
repair table t1 use_frm;
drop table t1;
#
# BUG#18874 - Setting myisam_repair_threads > 1, index cardinality always 1
#
CREATE TABLE t1(a INT, KEY(a));
INSERT INTO t1 VALUES(1),(2),(3),(4),(5);
SET myisam_repair_threads=2;
REPAIR TABLE t1;
SHOW INDEX FROM t1;
SET myisam_repair_threads=@@global.myisam_repair_threads;
DROP TABLE t1;
# End of 4.1 tests

View file

@ -1861,4 +1861,28 @@ select * from t1 where NOT(s1+1 = ANY (select s1 from t1));
select * from t1 where (s1 = ALL (select s1/s1 from t1));
select * from t1 where NOT(s1 = ALL (select s1/s1 from t1));
drop table t1;
#
# Bug #16255: Subquery in where
#
create table t1 (
retailerID varchar(8) NOT NULL,
statusID int(10) unsigned NOT NULL,
changed datetime NOT NULL,
UNIQUE KEY retailerID (retailerID, statusID, changed)
);
INSERT INTO t1 VALUES("0026", "1", "2005-12-06 12:18:56");
INSERT INTO t1 VALUES("0026", "2", "2006-01-06 12:25:53");
INSERT INTO t1 VALUES("0037", "1", "2005-12-06 12:18:56");
INSERT INTO t1 VALUES("0037", "2", "2006-01-06 12:25:53");
INSERT INTO t1 VALUES("0048", "1", "2006-01-06 12:37:50");
INSERT INTO t1 VALUES("0059", "1", "2006-01-06 12:37:50");
select * from t1 r1
where (r1.retailerID,(r1.changed)) in
(SELECT r2.retailerId,(max(changed)) from t1 r2
group by r2.retailerId);
drop table t1;
# End of 4.1 tests

View file

@ -36,48 +36,51 @@
uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags)
{
uint readbytes,save_count;
uint readbytes, save_count;
DBUG_ENTER("my_read");
DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %u MyFlags: %d",
Filedes, Buffer, Count, MyFlags));
save_count=Count;
Filedes, Buffer, Count, MyFlags));
save_count= Count;
for (;;)
{
errno=0; /* Linux doesn't reset this */
if ((readbytes = (uint) read(Filedes, Buffer, Count)) != Count)
errno= 0; /* Linux doesn't reset this */
if ((readbytes= (uint) read(Filedes, Buffer, Count)) != Count)
{
my_errno=errno ? errno : -1;
my_errno= errno ? errno : -1;
DBUG_PRINT("warning",("Read only %ld bytes off %ld from %d, errno: %d",
readbytes,Count,Filedes,my_errno));
readbytes, Count, Filedes, my_errno));
#ifdef THREAD
if (readbytes == 0 && errno == EINTR)
continue; /* Interrupted */
if ((int) readbytes <= 0 && errno == EINTR)
{
DBUG_PRINT("debug", ("my_read() was interrupted and returned %d", (int) readbytes));
continue; /* Interrupted */
}
#endif
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
{
if ((int) readbytes == -1)
my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG),
my_filename(Filedes),my_errno);
else if (MyFlags & (MY_NABP | MY_FNABP))
my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG),
my_filename(Filedes),my_errno);
if ((int) readbytes == -1)
my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG),
my_filename(Filedes),my_errno);
else if (MyFlags & (MY_NABP | MY_FNABP))
my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG),
my_filename(Filedes),my_errno);
}
if ((int) readbytes == -1 ||
((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO)))
DBUG_RETURN(MY_FILE_ERROR); /* Return with error */
((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO)))
DBUG_RETURN(MY_FILE_ERROR); /* Return with error */
if (readbytes > 0 && (MyFlags & MY_FULL_IO))
{
Buffer+=readbytes;
Count-=readbytes;
continue;
Buffer+= readbytes;
Count-= readbytes;
continue;
}
}
if (MyFlags & (MY_NABP | MY_FNABP))
readbytes=0; /* Ok on read */
readbytes= 0; /* Ok on read */
else if (MyFlags & MY_FULL_IO)
readbytes=save_count;
readbytes= save_count;
break;
}
DBUG_RETURN(readbytes);

View file

@ -163,7 +163,8 @@ class NdbConnection
friend class NdbIndexOperation;
friend class NdbIndexScanOperation;
friend class NdbBlob;
friend class ha_ndbcluster;
public:
/**
@ -675,6 +676,7 @@ private:
// optim: any blobs
bool theBlobFlag;
Uint8 thePendingBlobOps;
inline bool hasBlobOperation() { return theBlobFlag; }
static void sendTC_COMMIT_ACK(NdbApiSignal *,
Uint32 transId1, Uint32 transId2,

View file

@ -445,7 +445,7 @@ public:
/**
* Interpreted program instruction:
* Substract RegSource1 from RegSource2 and put the result in RegDest.
* Substract RegSource2 from RegSource1 and put the result in RegDest.
*
* @param RegSource1 First register.
* @param RegSource2 Second register.

View file

@ -6,7 +6,7 @@ Next DBTUP 4014
Next DBLQH 5043
Next DBDICT 6006
Next DBDIH 7174
Next DBTC 8037
Next DBTC 8038
Next CMVMI 9000
Next BACKUP 10022
Next DBUTIL 11002
@ -281,6 +281,7 @@ ABORT OF TCKEYREQ
8032: No free TC records any more
8037 : Invalid schema version in TCINDXREQ
CMVMI
-----

View file

@ -8338,6 +8338,7 @@ Dbdih::resetReplicaSr(TabRecordPtr tabPtr){
}
replicaPtr.i = nextReplicaPtrI;
}//while
updateNodeInfo(fragPtr);
}
}

View file

@ -6435,6 +6435,7 @@ void Dblqh::execACC_ABORTCONF(Signal* signal)
* A NORMAL EVENT DURING CREATION OF A FRAGMENT. WE NOW NEED TO CONTINUE
* WITH NORMAL COMMIT PROCESSING.
* ---------------------------------------------------------------------- */
regTcPtr->totSendlenAi = regTcPtr->totReclenAi;
if (regTcPtr->currTupAiLen == regTcPtr->totReclenAi) {
jam();
regTcPtr->abortState = TcConnectionrec::ABORT_IDLE;
@ -12508,6 +12509,20 @@ void Dblqh::lastWriteInFileLab(Signal* signal)
void Dblqh::writePageZeroLab(Signal* signal)
{
if (logPartPtr.p->logPartState == LogPartRecord::FILE_CHANGE_PROBLEM)
{
if (logPartPtr.p->firstLogQueue == RNIL)
{
jam();
logPartPtr.p->logPartState = LogPartRecord::IDLE;
}
else
{
jam();
logPartPtr.p->logPartState = LogPartRecord::ACTIVE;
}
}
logFilePtr.p->fileChangeState = LogFileRecord::NOT_ONGOING;
/*---------------------------------------------------------------------------*/
/* IT COULD HAVE ARRIVED PAGE WRITES TO THE CURRENT FILE WHILE WE WERE */

View file

@ -718,7 +718,7 @@ public:
// Index data
bool isIndexOp; // Used to mark on-going TcKeyReq as indx table access
Uint8 isIndexOp; // Used to mark on-going TcKeyReq as indx table access
bool indexOpReturn;
UintR noIndexOp; // No outstanding index ops
@ -806,7 +806,7 @@ public:
UintR savedState[LqhKeyConf::SignalLength];
// Index data
bool isIndexOp; // Used to mark on-going TcKeyReq as index table access
Uint8 isIndexOp; // Used to mark on-going TcKeyReq as index table access
UintR indexOp;
UintR currentIndexId;
UintR attrInfoLen;

View file

@ -1757,8 +1757,7 @@ void Dbtc::execKEYINFO(Signal* signal)
apiConnectptr.i = signal->theData[0];
tmaxData = 20;
if (apiConnectptr.i >= capiConnectFilesize) {
jam();
warningHandlerLab(signal);
TCKEY_abort(signal, 18);
return;
}//if
ptrAss(apiConnectptr, apiConnectRecord);
@ -1767,9 +1766,7 @@ void Dbtc::execKEYINFO(Signal* signal)
compare_transid2 = apiConnectptr.p->transid[1] ^ signal->theData[2];
compare_transid1 = compare_transid1 | compare_transid2;
if (compare_transid1 != 0) {
jam();
printState(signal, 10);
sendSignalErrorRefuseLab(signal);
TCKEY_abort(signal, 19);
return;
}//if
switch (apiConnectptr.p->apiConnectstate) {
@ -2467,7 +2464,7 @@ void Dbtc::execTCKEYREQ(Signal* signal)
Uint32 TstartFlag = tcKeyReq->getStartFlag(Treqinfo);
Uint32 TexecFlag = TcKeyReq::getExecuteFlag(Treqinfo);
bool isIndexOp = regApiPtr->isIndexOp;
Uint8 isIndexOp = regApiPtr->isIndexOp;
bool isIndexOpReturn = regApiPtr->indexOpReturn;
regApiPtr->isIndexOp = false; // Reset marker
regApiPtr->m_exec_flag |= TexecFlag;
@ -3210,7 +3207,7 @@ void Dbtc::sendlqhkeyreq(Signal* signal,
sig1 = regCachePtr->fragmentid + (regTcPtr->tcNodedata[1] << 16);
sig2 = regApiPtr->transid[0];
sig3 = regApiPtr->transid[1];
sig4 = regApiPtr->ndbapiBlockref;
sig4 = (regTcPtr->isIndexOp == 2) ? reference() : regApiPtr->ndbapiBlockref;
sig5 = regTcPtr->clientData;
sig6 = regCachePtr->scanInfo;
@ -8551,6 +8548,7 @@ void Dbtc::execSCAN_TABREQ(Signal* signal)
// left over from simple/dirty read
} else {
jam();
jamLine(transP->apiConnectstate);
errCode = ZSTATE_ERROR;
goto SCAN_TAB_error_no_state_change;
}
@ -11915,14 +11913,18 @@ void Dbtc::readIndexTable(Signal* signal,
opType == ZREAD ? ZREAD : ZREAD_EX);
TcKeyReq::setAIInTcKeyReq(tcKeyRequestInfo, 1); // Allways send one AttrInfo
TcKeyReq::setExecutingTrigger(tcKeyRequestInfo, 0);
BlockReference originalReceiver = regApiPtr->ndbapiBlockref;
regApiPtr->ndbapiBlockref = reference(); // Send result to me
tcKeyReq->senderData = indexOp->indexOpId;
indexOp->indexOpState = IOS_INDEX_ACCESS;
regApiPtr->executingIndexOp = regApiPtr->accumulatingIndexOp;
regApiPtr->accumulatingIndexOp = RNIL;
regApiPtr->isIndexOp = true;
regApiPtr->isIndexOp = 2;
if (ERROR_INSERTED(8037))
{
ndbout_c("shifting index version");
tcKeyReq->tableSchemaVersion = ~(Uint32)indexOp->tcIndxReq.indexSchemaVersion;
}
Uint32 remainingKey = indexOp->keyInfo.getSize();
bool moreKeyData = indexOp->keyInfo.first(keyIter);
// *********** KEYINFO in TCKEYREQ ***********
@ -11941,21 +11943,13 @@ void Dbtc::readIndexTable(Signal* signal,
ndbassert(TcKeyReq::getDirtyFlag(tcKeyRequestInfo) == 0);
ndbassert(TcKeyReq::getSimpleFlag(tcKeyRequestInfo) == 0);
EXECUTE_DIRECT(DBTC, GSN_TCKEYREQ, signal, tcKeyLength);
/**
* "Fool" TC not to start commiting transaction since it always will
* have one outstanding lqhkeyreq
* This is later decreased when the index read is complete
*/
regApiPtr->lqhkeyreqrec++;
/**
* Remember ptr to index read operation
* (used to set correct save point id on index operation later)
*/
indexOp->indexReadTcConnect = regApiPtr->lastTcConnect;
jamEntry();
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
goto err;
}
// *********** KEYINFO ***********
if (moreKeyData) {
jam();
@ -11975,6 +11969,10 @@ void Dbtc::readIndexTable(Signal* signal,
EXECUTE_DIRECT(DBTC, GSN_KEYINFO, signal,
KeyInfo::HeaderLength + KeyInfo::DataLength);
jamEntry();
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
goto err;
}
dataPos = 0;
dataPtr = (Uint32 *) &keyInfo->keyData;
}
@ -11985,10 +11983,32 @@ void Dbtc::readIndexTable(Signal* signal,
EXECUTE_DIRECT(DBTC, GSN_KEYINFO, signal,
KeyInfo::HeaderLength + dataPos);
jamEntry();
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
goto err;
}
}
}
regApiPtr->ndbapiBlockref = originalReceiver; // reset original receiver
/**
* "Fool" TC not to start commiting transaction since it always will
* have one outstanding lqhkeyreq
* This is later decreased when the index read is complete
*/
regApiPtr->lqhkeyreqrec++;
/**
* Remember ptr to index read operation
* (used to set correct save point id on index operation later)
*/
indexOp->indexReadTcConnect = regApiPtr->lastTcConnect;
done:
return;
err:
jam();
goto done;
}
/**
@ -12039,7 +12059,7 @@ void Dbtc::executeIndexOperation(Signal* signal,
tcKeyReq->transId2 = regApiPtr->transid[1];
tcKeyReq->senderData = tcIndxReq->senderData; // Needed for TRANSID_AI to API
indexOp->indexOpState = IOS_INDEX_OPERATION;
regApiPtr->isIndexOp = true;
regApiPtr->isIndexOp = 1;
regApiPtr->executingIndexOp = indexOp->indexOpId;;
regApiPtr->noIndexOp++; // Increase count
@ -12112,9 +12132,16 @@ void Dbtc::executeIndexOperation(Signal* signal,
const Uint32 currSavePointId = regApiPtr->currSavePointId;
regApiPtr->currSavePointId = tmp.p->savePointId;
EXECUTE_DIRECT(DBTC, GSN_TCKEYREQ, signal, tcKeyLength);
jamEntry();
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
regApiPtr->currSavePointId = currSavePointId;
jamEntry();
// *********** KEYINFO ***********
if (moreKeyData) {
jam();
@ -12135,6 +12162,13 @@ void Dbtc::executeIndexOperation(Signal* signal,
EXECUTE_DIRECT(DBTC, GSN_KEYINFO, signal,
KeyInfo::HeaderLength + KeyInfo::DataLength);
jamEntry();
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
dataPos = 0;
dataPtr = (Uint32 *) &keyInfo->keyData;
}
@ -12145,6 +12179,12 @@ void Dbtc::executeIndexOperation(Signal* signal,
EXECUTE_DIRECT(DBTC, GSN_KEYINFO, signal,
KeyInfo::HeaderLength + dataPos);
jamEntry();
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
}
}
@ -12174,6 +12214,13 @@ void Dbtc::executeIndexOperation(Signal* signal,
EXECUTE_DIRECT(DBTC, GSN_ATTRINFO, signal,
AttrInfo::HeaderLength + AttrInfo::DataLength);
jamEntry();
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
attrInfoPos = 0;
dataPtr = (Uint32 *) &attrInfo->attrData;
}
@ -12573,9 +12620,16 @@ void Dbtc::insertIntoIndexTable(Signal* signal,
const Uint32 currSavePointId = regApiPtr->currSavePointId;
regApiPtr->currSavePointId = opRecord->savePointId;
EXECUTE_DIRECT(DBTC, GSN_TCKEYREQ, signal, tcKeyLength);
jamEntry();
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
regApiPtr->currSavePointId = currSavePointId;
tcConnectptr.p->currentIndexId = indexData->indexId;
jamEntry();
// *********** KEYINFO ***********
if (moreKeyData) {
@ -12605,6 +12659,12 @@ void Dbtc::insertIntoIndexTable(Signal* signal,
KeyInfo::HeaderLength + KeyInfo::DataLength);
jamEntry();
#endif
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
dataPtr = (Uint32 *) &keyInfo->keyData;
dataPos = 0;
}
@ -12640,6 +12700,13 @@ void Dbtc::insertIntoIndexTable(Signal* signal,
KeyInfo::HeaderLength + KeyInfo::DataLength);
jamEntry();
#endif
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
dataPtr = (Uint32 *) &keyInfo->keyData;
dataPos = 0;
}
@ -12657,6 +12724,11 @@ void Dbtc::insertIntoIndexTable(Signal* signal,
KeyInfo::HeaderLength + dataPos);
jamEntry();
#endif
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
}
}
@ -12692,6 +12764,12 @@ void Dbtc::insertIntoIndexTable(Signal* signal,
AttrInfo::HeaderLength + AttrInfo::DataLength);
jamEntry();
#endif
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
dataPtr = (Uint32 *) &attrInfo->attrData;
attrInfoPos = 0;
}
@ -12728,6 +12806,12 @@ void Dbtc::insertIntoIndexTable(Signal* signal,
AttrInfo::HeaderLength + AttrInfo::DataLength);
jamEntry();
#endif
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
dataPtr = (Uint32 *) &attrInfo->attrData;
attrInfoPos = 0;
}
@ -12873,9 +12957,16 @@ void Dbtc::deleteFromIndexTable(Signal* signal,
const Uint32 currSavePointId = regApiPtr->currSavePointId;
regApiPtr->currSavePointId = opRecord->savePointId;
EXECUTE_DIRECT(DBTC, GSN_TCKEYREQ, signal, tcKeyLength);
jamEntry();
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
regApiPtr->currSavePointId = currSavePointId;
tcConnectptr.p->currentIndexId = indexData->indexId;
jamEntry();
// *********** KEYINFO ***********
if (moreKeyData) {
@ -12906,6 +12997,12 @@ void Dbtc::deleteFromIndexTable(Signal* signal,
KeyInfo::HeaderLength + KeyInfo::DataLength);
jamEntry();
#endif
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
dataPtr = (Uint32 *) &keyInfo->keyData;
dataPos = 0;
}
@ -12942,6 +13039,12 @@ void Dbtc::deleteFromIndexTable(Signal* signal,
KeyInfo::HeaderLength + KeyInfo::DataLength);
jamEntry();
#endif
if (unlikely(regApiPtr->apiConnectstate == CS_ABORTING))
{
jam();
return;
}
dataPtr = (Uint32 *) &keyInfo->keyData;
dataPos = 0;
}

View file

@ -1111,14 +1111,16 @@ Dbtup::updateStartLab(Signal* signal,
regOperPtr->pageOffset,
&cinBuffer[0],
regOperPtr->attrinbufLen);
if (retValue == -1) {
tupkeyErrorLab(signal);
return -1;
}//if
} else {
jam();
retValue = interpreterStartLab(signal, pagePtr, regOperPtr->pageOffset);
}//if
if (retValue == -1) {
tupkeyErrorLab(signal);
return -1;
}//if
ndbrequire(regOperPtr->tupVersion != ZNIL);
pagePtr->pageWord[regOperPtr->pageOffset + 1] = regOperPtr->tupVersion;
if (regTabPtr->checksumIndicator) {

View file

@ -184,24 +184,28 @@ void Dbtup::allocConsPages(Uint32 noOfPagesToAllocate,
/* PROPER AMOUNT OF PAGES WERE NOT FOUND. FIND AS MUCH AS */
/* POSSIBLE. */
/* ---------------------------------------------------------------- */
for (Uint32 j = firstListToCheck; (Uint32)~j; j--) {
if (firstListToCheck)
{
ljam();
if (cfreepageList[j] != RNIL) {
for (Uint32 j = firstListToCheck - 1; (Uint32)~j; j--) {
ljam();
if (cfreepageList[j] != RNIL) {
ljam();
/* ---------------------------------------------------------------- */
/* SOME AREA WAS FOUND, ALLOCATE ALL OF IT. */
/* ---------------------------------------------------------------- */
allocPageRef = cfreepageList[j];
removeCommonArea(allocPageRef, j);
noOfPagesAllocated = 1 << j;
findFreeLeftNeighbours(allocPageRef, noOfPagesAllocated,
noOfPagesToAllocate);
findFreeRightNeighbours(allocPageRef, noOfPagesAllocated,
noOfPagesToAllocate);
return;
}//if
}//for
allocPageRef = cfreepageList[j];
removeCommonArea(allocPageRef, j);
noOfPagesAllocated = 1 << j;
findFreeLeftNeighbours(allocPageRef, noOfPagesAllocated,
noOfPagesToAllocate);
findFreeRightNeighbours(allocPageRef, noOfPagesAllocated,
noOfPagesToAllocate);
return;
}//if
}//for
}
/* ---------------------------------------------------------------- */
/* NO FREE AREA AT ALL EXISTED. RETURN ZERO PAGES */
/* ---------------------------------------------------------------- */

View file

@ -177,13 +177,12 @@ void Ndbcntr::execSYSTEM_ERROR(Signal* signal)
"the state of a fragment scan was out of sync.",
killingNode);
break;
case SystemError::CopyFragRefError:
BaseString::snprintf(buf, sizeof(buf),
"Node %d killed this node because "
"it could not copy a fragment during node restart. "
"Copy fragment error code: %u.",
killingNode, data1);
"Killed by node %d as "
"copyfrag failed, error: %u",
killingNode, data1);
break;
default:
@ -2037,6 +2036,11 @@ void Ndbcntr::execSET_VAR_REQ(Signal* signal) {
void Ndbcntr::updateNodeState(Signal* signal, const NodeState& newState) const{
NodeStateRep * const stateRep = (NodeStateRep *)&signal->theData[0];
if (newState.startLevel == NodeState::SL_STARTED)
{
CRASH_INSERTION(1000);
}
stateRep->nodeState = newState;
stateRep->nodeState.masterNodeId = cmasterNodeId;
stateRep->nodeState.setNodeGroup(c_nodeGroup);
@ -2827,7 +2831,7 @@ void Ndbcntr::Missra::sendNextSTTOR(Signal* signal){
cntr.sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 3, JBB);
}
}
signal->theData[0] = EventReport::NDBStartCompleted;
signal->theData[1] = NDB_VERSION;
cntr.sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);

View file

@ -504,6 +504,8 @@ int NdbScanOperation::nextResult(bool fetchAllowed, bool forceSend)
idx = m_current_api_receiver;
last = m_api_receivers_count;
Uint32 timeout = tp->m_waitfor_timeout;
do {
if(theError.code){
@ -531,7 +533,7 @@ int NdbScanOperation::nextResult(bool fetchAllowed, bool forceSend)
*/
theNdb->theImpl->theWaiter.m_node = nodeId;
theNdb->theImpl->theWaiter.m_state = WAIT_SCAN;
int return_code = theNdb->receiveResponse(WAITFOR_SCAN_TIMEOUT);
int return_code = theNdb->receiveResponse(3*timeout);
if (return_code == 0 && seq == tp->getNodeSequence(nodeId)) {
continue;
} else {
@ -1372,6 +1374,7 @@ NdbIndexScanOperation::next_result_ordered(bool fetchAllowed,
return -1;
Uint32 seq = theNdbCon->theNodeSequence;
Uint32 nodeId = theNdbCon->theDBnode;
Uint32 timeout = tp->m_waitfor_timeout;
if(seq == tp->getNodeSequence(nodeId) &&
!send_next_scan_ordered(s_idx, forceSend)){
Uint32 tmp = m_sent_receivers_count;
@ -1379,7 +1382,7 @@ NdbIndexScanOperation::next_result_ordered(bool fetchAllowed,
while(m_sent_receivers_count > 0 && !theError.code){
theNdb->theImpl->theWaiter.m_node = nodeId;
theNdb->theImpl->theWaiter.m_state = WAIT_SCAN;
int return_code = theNdb->receiveResponse(WAITFOR_SCAN_TIMEOUT);
int return_code = theNdb->receiveResponse(3*timeout);
if (return_code == 0 && seq == tp->getNodeSequence(nodeId)) {
continue;
}
@ -1520,6 +1523,8 @@ NdbScanOperation::close_impl(TransporterFacade* tp, bool forceSend){
return -1;
}
Uint32 timeout = tp->m_waitfor_timeout;
/**
* Wait for outstanding
*/
@ -1527,7 +1532,7 @@ NdbScanOperation::close_impl(TransporterFacade* tp, bool forceSend){
{
theNdb->theImpl->theWaiter.m_node = nodeId;
theNdb->theImpl->theWaiter.m_state = WAIT_SCAN;
int return_code = theNdb->receiveResponse(WAITFOR_SCAN_TIMEOUT);
int return_code = theNdb->receiveResponse(3*timeout);
switch(return_code){
case 0:
break;
@ -1597,7 +1602,7 @@ NdbScanOperation::close_impl(TransporterFacade* tp, bool forceSend){
{
theNdb->theImpl->theWaiter.m_node = nodeId;
theNdb->theImpl->theWaiter.m_state = WAIT_SCAN;
int return_code = theNdb->receiveResponse(WAITFOR_SCAN_TIMEOUT);
int return_code = theNdb->receiveResponse(3*timeout);
switch(return_code){
case 0:
break;

View file

@ -1201,6 +1201,48 @@ int runLQHKEYREF(NDBT_Context* ctx, NDBT_Step* step){
return NDBT_OK;
}
int
runBug21384(NDBT_Context* ctx, NDBT_Step* step)
{
Ndb* pNdb = GETNDB(step);
HugoTransactions hugoTrans(*ctx->getTab());
NdbRestarter restarter;
int loops = ctx->getNumLoops();
const int rows = ctx->getNumRecords();
const int batchsize = ctx->getProperty("BatchSize", 50);
while (loops--)
{
if(restarter.insertErrorInAllNodes(8037) != 0)
{
g_err << "Failed to error insert(8037)" << endl;
return NDBT_FAILED;
}
if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchsize) == 0)
{
g_err << "Index succeded (it should have failed" << endl;
return NDBT_FAILED;
}
if(restarter.insertErrorInAllNodes(0) != 0)
{
g_err << "Failed to error insert(0)" << endl;
return NDBT_FAILED;
}
if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchsize) != 0){
g_err << "Index read failed" << endl;
return NDBT_FAILED;
}
}
return NDBT_OK;
}
NDBT_TESTSUITE(testIndex);
TESTCASE("CreateAll",
"Test that we can create all various indexes on each table\n"
@ -1507,6 +1549,16 @@ TESTCASE("UniqueNull",
FINALIZER(createPkIndex_Drop);
FINALIZER(runClearTable);
}
TESTCASE("Bug21384",
"Test that unique indexes and nulls"){
TC_PROPERTY("LoggedIndexes", (unsigned)0);
INITIALIZER(runClearTable);
INITIALIZER(createPkIndex);
INITIALIZER(runLoadTable);
STEP(runBug21384);
FINALIZER(createPkIndex_Drop);
FINALIZER(runClearTable);
}
NDBT_TESTSUITE_END(testIndex);
int main(int argc, const char** argv){

View file

@ -1121,6 +1121,46 @@ int runClearTable(NDBT_Context* ctx, NDBT_Step* step){
return NDBT_OK;
}
int
runBug21536(NDBT_Context* ctx, NDBT_Step* step)
{
NdbRestarter restarter;
const Uint32 nodeCount = restarter.getNumDbNodes();
if(nodeCount != 2){
g_info << "Bug21536 - 2 nodes to test" << endl;
return NDBT_OK;
}
int node1 = restarter.getDbNodeId(rand() % nodeCount);
int node2 = restarter.getRandomNodeSameNodeGroup(node1, rand());
if (node1 == -1 || node2 == -1)
return NDBT_OK;
int result = NDBT_OK;
do {
CHECK(restarter.restartOneDbNode(node1, false, true, true) == 0);
CHECK(restarter.waitNodesNoStart(&node1, 1) == 0);
CHECK(restarter.insertErrorInNode(node1, 1000) == 0);
int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
CHECK(restarter.dumpStateOneNode(node1, val2, 2) == 0);
CHECK(restarter.startNodes(&node1, 1) == 0);
restarter.waitNodesStartPhase(&node1, 1, 3, 120);
CHECK(restarter.waitNodesNoStart(&node1, 1) == 0);
CHECK(restarter.restartOneDbNode(node2, true, true, true) == 0);
CHECK(restarter.waitNodesNoStart(&node2, 1) == 0);
CHECK(restarter.startNodes(&node1, 1) == 0);
CHECK(restarter.waitNodesStarted(&node1, 1) == 0);
CHECK(restarter.startNodes(&node2, 1) == 0);
CHECK(restarter.waitClusterStarted() == 0);
} while(0);
g_info << "Bug21536 finished" << endl;
return result;
}
NDBT_TESTSUITE(testSystemRestart);
TESTCASE("SR1",
@ -1287,6 +1327,13 @@ TESTCASE("Bug18385",
STEP(runBug18385);
FINALIZER(runClearTable);
}
TESTCASE("Bug21536",
"Perform partition system restart with other nodes with higher GCI"){
INITIALIZER(runWaitStarted);
INITIALIZER(runClearTable);
STEP(runBug21536);
FINALIZER(runClearTable);
}
NDBT_TESTSUITE_END(testSystemRestart);
int main(int argc, const char** argv){

View file

@ -474,6 +474,10 @@ max-time: 1000
cmd: testNodeRestart
args: -n Bug20185 T1
max-time: 1000
cmd: testIndex
args: -n Bug21384
# OLD FLEX
max-time: 500
cmd: flexBench

View file

@ -1544,11 +1544,18 @@ C_MODE_START
int mysql_init_character_set(MYSQL *mysql)
{
NET *net= &mysql->net;
const char *default_collation_name;
/* Set character set */
if (!mysql->options.charset_name &&
!(mysql->options.charset_name=
if (!mysql->options.charset_name)
{
default_collation_name= MYSQL_DEFAULT_COLLATION_NAME;
if (!(mysql->options.charset_name=
my_strdup(MYSQL_DEFAULT_CHARSET_NAME,MYF(MY_WME))))
return 1;
}
else
default_collation_name= NULL;
{
const char *save= charsets_dir;
@ -1556,6 +1563,28 @@ int mysql_init_character_set(MYSQL *mysql)
charsets_dir=mysql->options.charset_dir;
mysql->charset=get_charset_by_csname(mysql->options.charset_name,
MY_CS_PRIMARY, MYF(MY_WME));
if (mysql->charset && default_collation_name)
{
CHARSET_INFO *collation;
if ((collation=
get_charset_by_name(default_collation_name, MYF(MY_WME))))
{
if (!my_charset_same(mysql->charset, collation))
{
my_printf_error(ER_UNKNOWN_ERROR,
"COLLATION %s is not valid for CHARACTER SET %s",
MYF(0),
default_collation_name, mysql->options.charset_name);
mysql->charset= NULL;
}
else
{
mysql->charset= collation;
}
}
else
mysql->charset= NULL;
}
charsets_dir= save;
}
@ -1589,7 +1618,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db,
uint port, const char *unix_socket,ulong client_flag)
{
char buff[NAME_LEN+USERNAME_LENGTH+100];
char buff[NAME_BYTE_LEN+USERNAME_BYTE_LENGTH+100];
char *end,*host_info;
my_socket sock;
in_addr_t ip_addr;
@ -2034,7 +2063,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
mysql->server_status, client_flag));
/* This needs to be changed as it's not useful with big packets */
if (user && user[0])
strmake(end,user,USERNAME_LENGTH); /* Max user name */
strmake(end,user,USERNAME_BYTE_LENGTH); /* Max user name */
else
read_user_name((char*) end);
@ -2064,7 +2093,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
/* Add database if needed */
if (db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB))
{
end= strmake(end, db, NAME_LEN) + 1;
end= strmake(end, db, NAME_BYTE_LEN) + 1;
mysql->db= my_strdup(db,MYF(MY_WME));
db= 0;
}

View file

@ -161,6 +161,7 @@ int execute_no_commit(ha_ndbcluster *h, NdbConnection *trans)
if (m_batch_execute)
return 0;
#endif
h->release_completed_operations(trans);
return trans->execute(NoCommit,AbortOnError,h->m_force_send);
}
@ -194,6 +195,7 @@ int execute_no_commit_ie(ha_ndbcluster *h, NdbConnection *trans)
if (m_batch_execute)
return 0;
#endif
h->release_completed_operations(trans);
return trans->execute(NoCommit, AO_IgnoreError,h->m_force_send);
}
@ -2749,6 +2751,25 @@ int ha_ndbcluster::close_scan()
if (!cursor)
DBUG_RETURN(1);
if (m_lock_tuple)
{
/*
Lock level m_lock.type either TL_WRITE_ALLOW_WRITE
(SELECT FOR UPDATE) or TL_READ_WITH_SHARED_LOCKS (SELECT
LOCK WITH SHARE MODE) and row was not explictly unlocked
with unlock_row() call
*/
NdbOperation *op;
// Lock row
DBUG_PRINT("info", ("Keeping lock on scanned row"));
if (!(op= m_active_cursor->lockTuple()))
{
m_lock_tuple= false;
ERR_RETURN(trans->getNdbError());
}
m_ops_pending++;
}
m_lock_tuple= false;
if (m_ops_pending)
{
@ -5357,6 +5378,19 @@ int ha_ndbcluster::write_ndb_file()
DBUG_RETURN(error);
}
void
ha_ndbcluster::release_completed_operations(NdbConnection *trans)
{
if (trans->hasBlobOperation())
{
/* We are reading/writing BLOB fields,
releasing operation records is unsafe
*/
return;
}
trans->releaseCompletedOperations();
}
int
ndbcluster_show_status(THD* thd)
{

View file

@ -262,6 +262,8 @@ class ha_ndbcluster: public handler
void no_uncommitted_rows_init(THD *);
void no_uncommitted_rows_reset(THD *);
void release_completed_operations(NdbConnection*);
friend int execute_no_commit(ha_ndbcluster*, NdbConnection*);
friend int execute_commit(ha_ndbcluster*, NdbConnection*);
friend int execute_no_commit_ie(ha_ndbcluster*, NdbConnection*);

View file

@ -159,8 +159,7 @@ public:
return agg_item_collations_for_comparison(c, func_name(),
items, nitems, flags);
}
bool agg_arg_charsets(DTCollation &c, Item **items, uint nitems,
uint flags= 0)
bool agg_arg_charsets(DTCollation &c, Item **items, uint nitems, uint flags)
{
return agg_item_charsets(c, func_name(), items, nitems, flags);
}

View file

@ -88,6 +88,7 @@ String *Item_func_md5::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
String * sptr= args[0]->val_str(str);
str->set_charset(&my_charset_bin);
if (sptr)
{
my_MD5_CTX context;
@ -134,6 +135,7 @@ String *Item_func_sha::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
String * sptr= args[0]->val_str(str);
str->set_charset(&my_charset_bin);
if (sptr) /* If we got value different from NULL */
{
SHA1_CONTEXT context; /* Context used to generate SHA1 hash */
@ -1546,7 +1548,7 @@ String *Item_func_encrypt::val_str(String *str)
null_value= 1;
return 0;
}
str->set(tmp,(uint) strlen(tmp),res->charset());
str->set(tmp, (uint) strlen(tmp), &my_charset_bin);
str->copy();
pthread_mutex_unlock(&LOCK_crypt);
return str;
@ -1943,7 +1945,7 @@ String *Item_func_make_set::val_str(String *str)
return &my_empty_string;
result= &tmp_str;
}
if (tmp_str.append(',') || tmp_str.append(*res))
if (tmp_str.append(",", 1, &my_charset_bin) || tmp_str.append(*res))
return &my_empty_string;
}
}
@ -2609,8 +2611,12 @@ String* Item_func_export_set::val_str(String* str)
}
break;
case 3:
sep_buf.set(",", 1, default_charset());
sep = &sep_buf;
{
/* errors is not checked - assume "," can always be converted */
uint errors;
sep_buf.copy(",", 1, &my_charset_bin, collation.collation, &errors);
sep = &sep_buf;
}
break;
default:
DBUG_ASSERT(0); // cannot happen
@ -2635,8 +2641,8 @@ void Item_func_export_set::fix_length_and_dec()
uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
max_length=length*64+sep_length*63;
if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1),
MY_COLL_ALLOW_CONV)
if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
MY_COLL_ALLOW_CONV))
return;
}

View file

@ -41,7 +41,10 @@ class Item_func_md5 :public Item_str_func
{
String tmp_value;
public:
Item_func_md5(Item *a) :Item_str_func(a) {}
Item_func_md5(Item *a) :Item_str_func(a)
{
collation.set(&my_charset_bin);
}
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "md5"; }
@ -51,7 +54,10 @@ public:
class Item_func_sha :public Item_str_func
{
public:
Item_func_sha(Item *a) :Item_str_func(a) {}
Item_func_sha(Item *a) :Item_str_func(a)
{
collation.set(&my_charset_bin);
}
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "sha"; }
@ -310,9 +316,21 @@ public:
class Item_func_encrypt :public Item_str_func
{
String tmp_value;
/* Encapsulate common constructor actions */
void constructor_helper()
{
collation.set(&my_charset_bin);
}
public:
Item_func_encrypt(Item *a) :Item_str_func(a) {}
Item_func_encrypt(Item *a, Item *b): Item_str_func(a,b) {}
Item_func_encrypt(Item *a) :Item_str_func(a)
{
constructor_helper();
}
Item_func_encrypt(Item *a, Item *b): Item_str_func(a,b)
{
constructor_helper();
}
String *val_str(String *);
void fix_length_and_dec() { maybe_null=1; max_length = 13; }
const char *func_name() const { return "ecrypt"; }

View file

@ -976,18 +976,18 @@ Item_in_subselect::row_value_transformer(JOIN *join)
DBUG_RETURN(RES_ERROR);
Item *item_eq=
new Item_func_eq(new
Item_direct_ref((*optimizer->get_cache())->
Item_ref((*optimizer->get_cache())->
addr(i),
(char *)"<no matter>",
(char *)in_left_expr_name),
new
Item_direct_ref(select_lex->ref_pointer_array + i,
Item_ref(select_lex->ref_pointer_array + i,
(char *)"<no matter>",
(char *)"<list ref>")
);
Item *item_isnull=
new Item_func_isnull(new
Item_direct_ref( select_lex->
Item_ref( select_lex->
ref_pointer_array+i,
(char *)"<no matter>",
(char *)"<list ref>")
@ -1000,7 +1000,7 @@ Item_in_subselect::row_value_transformer(JOIN *join)
new
Item_is_not_null_test(this,
new
Item_direct_ref(select_lex->
Item_ref(select_lex->
ref_pointer_array + i,
(char *)"<no matter>",
(char *)"<list ref>")
@ -1057,7 +1057,7 @@ Item_in_subselect::row_value_transformer(JOIN *join)
new
Item_is_not_null_test(this,
new
Item_direct_ref(select_lex->
Item_ref(select_lex->
ref_pointer_array + i,
(char *)"<no matter>",
(char *)"<list ref>")

View file

@ -1600,14 +1600,12 @@ uint Item_func_date_format::format_length(const String *format)
case 'u': /* week (00..52), where week starts with Monday */
case 'V': /* week 1..53 used with 'x' */
case 'v': /* week 1..53 used with 'x', where week starts with Monday */
case 'H': /* hour (00..23) */
case 'y': /* year, numeric, 2 digits */
case 'm': /* month, numeric */
case 'd': /* day (of the month), numeric */
case 'h': /* hour (01..12) */
case 'I': /* --||-- */
case 'i': /* minutes, numeric */
case 'k': /* hour ( 0..23) */
case 'l': /* hour ( 1..12) */
case 'p': /* locale's AM or PM */
case 'S': /* second (00..61) */
@ -1616,6 +1614,10 @@ uint Item_func_date_format::format_length(const String *format)
case 'e': /* day (0..31) */
size += 2;
break;
case 'k': /* hour ( 0..23) */
case 'H': /* hour (00..23; value > 23 OK, padding always 2-digit) */
size += 7; /* docs allow > 23, range depends on sizeof(unsigned int) */
break;
case 'r': /* time, 12-hour (hh:mm:ss [AP]M) */
size += 11;
break;

View file

@ -409,12 +409,17 @@ shutdown the MySQL server and restart it.", log_name, errno);
int MYSQL_LOG::get_current_log(LOG_INFO* linfo)
{
pthread_mutex_lock(&LOCK_log);
strmake(linfo->log_file_name, log_file_name, sizeof(linfo->log_file_name)-1);
linfo->pos = my_b_tell(&log_file);
int ret = raw_get_current_log(linfo);
pthread_mutex_unlock(&LOCK_log);
return 0;
return ret;
}
int MYSQL_LOG::raw_get_current_log(LOG_INFO* linfo)
{
strmake(linfo->log_file_name, log_file_name, sizeof(linfo->log_file_name)-1);
linfo->pos = my_b_tell(&log_file);
return 0;
}
/*
Move all data up in a file in an filename index file
@ -2321,6 +2326,12 @@ void print_buffer_to_nt_eventlog(enum loglevel level, char *buff,
void
*/
#ifdef EMBEDDED_LIBRARY
void vprint_msg_to_log(enum loglevel level __attribute__((unused)),
const char *format __attribute__((unused)),
va_list argsi __attribute__((unused)))
{}
#else /*!EMBEDDED_LIBRARY*/
void vprint_msg_to_log(enum loglevel level, const char *format, va_list args)
{
char buff[1024];
@ -2336,6 +2347,7 @@ void vprint_msg_to_log(enum loglevel level, const char *format, va_list args)
DBUG_VOID_RETURN;
}
#endif /*EMBEDDED_LIBRARY*/
void sql_print_error(const char *format, ...)

View file

@ -378,6 +378,7 @@ key_map key_map_full(0); // Will be initialized later
const char *opt_date_time_formats[3];
char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME;
char *language_ptr, *default_collation_name, *default_character_set_name;
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
struct passwd *user_info;
@ -5936,7 +5937,7 @@ static void mysql_init_variables(void)
/* Variables in libraries */
charsets_dir= 0;
default_character_set_name= (char*) MYSQL_DEFAULT_CHARSET_NAME;
default_collation_name= (char*) MYSQL_DEFAULT_COLLATION_NAME;
default_collation_name= compiled_default_collation_name;
sys_charset_system.value= (char*) system_charset_info->csname;
@ -6091,7 +6092,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
strmake(mysql_home,argument,sizeof(mysql_home)-1);
break;
case 'C':
default_collation_name= 0;
if (default_collation_name == compiled_default_collation_name)
default_collation_name= 0;
break;
case 'l':
opt_log=1;

View file

@ -747,7 +747,7 @@ my_real_read(NET *net, ulong *complen)
#endif /* EXTRA_DEBUG */
}
#if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER)
if (vio_should_retry(net->vio))
if (vio_errno(net->vio) == SOCKET_EINTR)
{
DBUG_PRINT("warning",("Interrupted read. Retrying..."));
continue;

View file

@ -86,7 +86,7 @@ public:
QUICK_SELECT(THD *thd, TABLE *table,uint index_arg,bool no_alloc=0);
virtual ~QUICK_SELECT();
void reset(void) { next=0; it.rewind(); }
void reset(void) { next=0; it.rewind(); range= NULL;}
int init()
{
key_part_info= head->key_info[index].key_part;

View file

@ -738,8 +738,8 @@ struct show_var_st init_vars[]= {
{"have_geometry", (char*) &have_geometry, SHOW_HAVE},
{"have_innodb", (char*) &have_innodb, SHOW_HAVE},
{"have_isam", (char*) &have_isam, SHOW_HAVE},
{"have_ndbcluster", (char*) &have_ndbcluster, SHOW_HAVE},
{"have_merge_engine", (char*) &have_merge_db, SHOW_HAVE},
{"have_ndbcluster", (char*) &have_ndbcluster, SHOW_HAVE},
{"have_openssl", (char*) &have_openssl, SHOW_HAVE},
{"have_query_cache", (char*) &have_query_cache, SHOW_HAVE},
{"have_raid", (char*) &have_raid, SHOW_HAVE},

View file

@ -2946,7 +2946,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
rli->is_until_satisfied())
{
char buf[22];
sql_print_error("Slave SQL thread stopped because it reached its"
sql_print_information("Slave SQL thread stopped because it reached its"
" UNTIL position %s", llstr(rli->until_pos(), buf));
/*
Setting abort_slave flag because we do not want additional message about

View file

@ -2640,7 +2640,11 @@ int mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
while ((Str = str_list++))
{
if (Str->host.length > HOSTNAME_LENGTH ||
Str->user.length > USERNAME_LENGTH)
system_charset_info->cset->charpos(system_charset_info,
Str->user.str,
Str->user.str +
Str->user.length,
USERNAME_LENGTH) < Str->user.length)
{
my_error(ER_GRANT_WRONG_HOST_OR_USER,MYF(0));
result= -1;
@ -3671,17 +3675,11 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list)
{
if (!(acl_user= check_acl_user(user_name, &counter)))
{
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; No such user",
user_name->user.str,
user_name->host.str);
result= -1;
continue;
}
if ((acl_user->access & ~0))
{
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Global privileges exists",
user_name->user.str,
user_name->host.str);
result= -1;
continue;
}
@ -3702,9 +3700,6 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list)
}
if (counter != acl_dbs.elements)
{
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Database privileges exists",
user_name->user.str,
user_name->host.str);
result= -1;
continue;
}
@ -3725,9 +3720,6 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list)
}
if (counter != column_priv_hash.records)
{
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Table privileges exists",
user_name->user.str,
user_name->host.str);
result= -1;
continue;
}
@ -3793,9 +3785,6 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list)
{
if (!check_acl_user(lex_user, &counter))
{
sql_print_error("REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' not exists",
lex_user->user.str,
lex_user->host.str);
result= -1;
continue;
}

View file

@ -177,6 +177,7 @@ public:
bool need_mutex);
int find_next_log(LOG_INFO* linfo, bool need_mutex);
int get_current_log(LOG_INFO* linfo);
int raw_get_current_log(LOG_INFO* linfo);
uint next_file_id();
inline bool is_open() { return log_type != LOG_CLOSED; }
inline char* get_index_fname() { return index_file_name;}

View file

@ -643,8 +643,9 @@ int yylex(void *arg, void *yythd)
*/
if ((yylval->lex_str.str[0]=='_') &&
(lex->charset=get_charset_by_csname(yylval->lex_str.str+1,
MY_CS_PRIMARY,MYF(0))))
(lex->underscore_charset=
get_charset_by_csname(yylval->lex_str.str + 1,
MY_CS_PRIMARY,MYF(0))))
return(UNDERSCORE_CHARSET);
return(result_state); // IDENT or IDENT_QUOTED

View file

@ -613,7 +613,7 @@ typedef struct st_lex
LEX_USER *grant_user;
gptr yacc_yyss,yacc_yyvs;
THD *thd;
CHARSET_INFO *charset;
CHARSET_INFO *charset, *underscore_charset;
List<key_part_spec> col_list;
List<key_part_spec> ref_list;

View file

@ -902,8 +902,8 @@ static int check_connection(THD *thd)
char *user= end;
char *passwd= strend(user)+1;
char *db= passwd;
char db_buff[NAME_LEN+1]; // buffer to store db in utf8
char user_buff[USERNAME_LENGTH+1]; // buffer to store user in utf8
char db_buff[NAME_BYTE_LEN + 1]; // buffer to store db in utf8
char user_buff[USERNAME_BYTE_LENGTH + 1]; // buffer to store user in utf8
uint dummy_errors;
/*

View file

@ -1359,10 +1359,14 @@ int show_binlogs(THD* thd)
MYSQL_TYPE_LONGLONG));
if (protocol->send_fields(&field_list, 1))
DBUG_RETURN(1);
pthread_mutex_lock(mysql_bin_log.get_log_lock());
mysql_bin_log.lock_index();
index_file=mysql_bin_log.get_index_file();
mysql_bin_log.get_current_log(&cur);
mysql_bin_log.raw_get_current_log(&cur); // dont take mutex
pthread_mutex_unlock(mysql_bin_log.get_log_lock()); // lockdep, OK
cur_dir_len= dirname_length(cur.log_file_name);
reinit_io_cache(index_file, READ_CACHE, (my_off_t) 0, 0, 0);

View file

@ -650,6 +650,36 @@ JOIN::optimize()
if (!order && org_order)
skip_sort_order= 1;
}
/*
Check if we can optimize away GROUP BY/DISTINCT.
We can do that if there are no aggregate functions and the
fields in DISTINCT clause (if present) and/or columns in GROUP BY
(if present) contain direct references to all key parts of
an unique index (in whatever order).
Note that the unique keys for DISTINCT and GROUP BY should not
be the same (as long as they are unique).
The FROM clause must contain a single non-constant table.
*/
if (tables - const_tables == 1 && (group_list || select_distinct) &&
!tmp_table_param.sum_func_count)
{
if (group_list &&
list_contains_unique_index(join_tab[const_tables].table,
find_field_in_order_list,
(void *) group_list))
{
group_list= 0;
group= 0;
}
if (select_distinct &&
list_contains_unique_index(join_tab[const_tables].table,
find_field_in_item_list,
(void *) &fields_list))
{
select_distinct= 0;
}
}
if (group_list || tmp_table_param.sum_func_count)
{
if (! hidden_group_fields && rollup.state == ROLLUP::STATE_NONE)
@ -719,36 +749,6 @@ JOIN::optimize()
if (old_group_list && !group_list)
select_distinct= 0;
}
/*
Check if we can optimize away GROUP BY/DISTINCT.
We can do that if there are no aggregate functions and the
fields in DISTINCT clause (if present) and/or columns in GROUP BY
(if present) contain direct references to all key parts of
an unique index (in whatever order).
Note that the unique keys for DISTINCT and GROUP BY should not
be the same (as long as they are unique).
The FROM clause must contain a single non-constant table.
*/
if (tables - const_tables == 1 && (group_list || select_distinct) &&
!tmp_table_param.sum_func_count)
{
if (group_list &&
list_contains_unique_index(join_tab[const_tables].table,
find_field_in_order_list,
(void *) group_list))
{
group_list= 0;
group= 0;
}
if (select_distinct &&
list_contains_unique_index(join_tab[const_tables].table,
find_field_in_item_list,
(void *) &fields_list))
{
select_distinct= 0;
}
}
if (!group_list && group)
{
order=0; // The output has only one row
@ -4551,6 +4551,8 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
left_item->collation.collation == value->collation.collation))
{
Item *tmp=value->new_item();
tmp->collation.set(right_item->collation);
if (tmp)
{
thd->change_item_tree(args + 1, tmp);
@ -4572,6 +4574,8 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
right_item->collation.collation == value->collation.collation))
{
Item *tmp=value->new_item();
tmp->collation.set(left_item->collation);
if (tmp)
{
thd->change_item_tree(args, tmp);
@ -5574,10 +5578,11 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
keyinfo->key_length=0;
keyinfo->rec_per_key=0;
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
for (; group ; group=group->next,key_part_info++)
ORDER *cur_group= group;
for (; cur_group ; cur_group= cur_group->next, key_part_info++)
{
Field *field=(*group->item)->get_tmp_table_field();
bool maybe_null=(*group->item)->maybe_null;
Field *field=(*cur_group->item)->get_tmp_table_field();
bool maybe_null=(*cur_group->item)->maybe_null;
key_part_info->null_bit=0;
key_part_info->field= field;
key_part_info->offset= field->offset();
@ -5589,8 +5594,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
0 : FIELDFLAG_BINARY;
if (!using_unique_constraint)
{
group->buff=(char*) group_buff;
if (!(group->field=field->new_field(thd->mem_root,table)))
cur_group->buff=(char*) group_buff;
if (!(cur_group->field=field->new_field(thd->mem_root,table)))
goto err; /* purecov: inspected */
if (maybe_null)
{
@ -5604,21 +5609,16 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
key_part_info->null_bit=field->null_bit;
key_part_info->null_offset= (uint) (field->null_ptr -
(uchar*) table->record[0]);
group->field->move_field((char*) ++group->buff);
cur_group->field->move_field((char*) ++cur_group->buff);
group_buff++;
}
else
group->field->move_field((char*) group_buff);
cur_group->field->move_field((char*) group_buff);
group_buff+= key_part_info->length;
}
keyinfo->key_length+= key_part_info->length;
}
}
else
{
set_if_smaller(table->max_rows, rows_limit);
param->end_write_records= rows_limit;
}
if (distinct && field_count != param->hidden_field_count)
{
@ -5681,6 +5681,20 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
0 : FIELDFLAG_BINARY;
}
}
/*
Push the LIMIT clause to the temporary table creation, so that we
materialize only up to 'rows_limit' records instead of all result records.
This optimization is not applicable when there is GROUP BY or there is
no GROUP BY, but there are aggregate functions, because both must be
computed for all result rows.
*/
if (!group && !thd->lex->current_select->with_sum_func)
{
set_if_smaller(table->max_rows, rows_limit);
param->end_write_records= rows_limit;
}
if (thd->is_fatal_error) // If end of memory
goto err; /* purecov: inspected */
table->db_record_offset=1;

View file

@ -516,6 +516,40 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
DBUG_RETURN(-1);
}
/*
Convert the default value character
set into the column character set if necessary.
*/
if (sql_field->def &&
savecs != sql_field->def->collation.collation &&
(sql_field->sql_type == FIELD_TYPE_VAR_STRING ||
sql_field->sql_type == FIELD_TYPE_STRING ||
sql_field->sql_type == FIELD_TYPE_SET ||
sql_field->sql_type == FIELD_TYPE_ENUM))
{
Item_arena backup_arena;
bool need_to_change_arena=
!thd->current_arena->is_conventional_execution();
if (need_to_change_arena)
{
/* Assert that we don't do that at every PS execute */
DBUG_ASSERT(thd->current_arena->is_first_stmt_execute());
thd->set_n_backup_item_arena(thd->current_arena, &backup_arena);
}
sql_field->def= sql_field->def->safe_charset_converter(savecs);
if (need_to_change_arena)
thd->restore_backup_item_arena(thd->current_arena, &backup_arena);
if (sql_field->def == NULL)
{
/* Could not convert */
my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
DBUG_RETURN(-1);
}
}
if (sql_field->sql_type == FIELD_TYPE_SET ||
sql_field->sql_type == FIELD_TYPE_ENUM)
{
@ -580,35 +614,6 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field->interval_list.empty(); // Don't need interval_list anymore
}
/*
Convert the default value from client character
set into the column character set if necessary.
*/
if (sql_field->def && cs != sql_field->def->collation.collation)
{
Item_arena backup_arena;
bool need_to_change_arena=
!thd->current_arena->is_conventional_execution();
if (need_to_change_arena)
{
/* Asser that we don't do that at every PS execute */
DBUG_ASSERT(thd->current_arena->is_first_stmt_execute());
thd->set_n_backup_item_arena(thd->current_arena, &backup_arena);
}
sql_field->def= sql_field->def->safe_charset_converter(cs);
if (need_to_change_arena)
thd->restore_backup_item_arena(thd->current_arena, &backup_arena);
if (sql_field->def == NULL)
{
/* Could not convert */
my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
DBUG_RETURN(-1);
}
}
if (sql_field->sql_type == FIELD_TYPE_SET)
{
if (sql_field->def != NULL)

View file

@ -4896,7 +4896,7 @@ text_literal:
| NCHAR_STRING
{ $$= new Item_string($1.str,$1.length,national_charset_info); }
| UNDERSCORE_CHARSET TEXT_STRING
{ $$ = new Item_string($2.str,$2.length,Lex->charset); }
{ $$ = new Item_string($2.str,$2.length,Lex->underscore_charset); }
| text_literal TEXT_STRING_literal
{ ((Item_string*) $1)->append($2.str,$2.length); }
;
@ -4963,7 +4963,7 @@ literal:
(String*) 0;
$$= new Item_string(str ? str->ptr() : "",
str ? str->length() : 0,
Lex->charset);
Lex->underscore_charset);
}
| DATE_SYM text_literal { $$ = $2; }
| TIME_SYM text_literal { $$ = $2; }

View file

@ -1413,7 +1413,7 @@ char *get_field(MEM_ROOT *mem, Field *field)
bool check_db_name(char *name)
{
char *start=name;
uint name_length= 0; // name length in symbols
/* Used to catch empty names and names with end space */
bool last_char_is_space= TRUE;
@ -1430,6 +1430,7 @@ bool check_db_name(char *name)
name+system_charset_info->mbmaxlen);
if (len)
{
name_length++;
name += len;
continue;
}
@ -1437,12 +1438,13 @@ bool check_db_name(char *name)
#else
last_char_is_space= *name==' ';
#endif
name_length++;
if (*name == '/' || *name == '\\' || *name == FN_LIBCHAR ||
*name == FN_EXTCHAR)
return 1;
name++;
}
return last_char_is_space || (uint) (name - start) > NAME_LEN;
return (last_char_is_space || name_length > NAME_LEN);
}

View file

@ -649,6 +649,8 @@ fi
%attr(755, root, root) %{_bindir}/ndb_show_tables
%attr(755, root, root) %{_bindir}/ndb_test_platform
%attr(755, root, root) %{_bindir}/ndb_config
%attr(755, root, root) %{_bindir}/ndb_size.pl
%attr(-, root, root) %{_datadir}/mysql/ndb_size.tmpl
%files ndb-extra
%defattr(-,root,root,0755)

View file

@ -9952,8 +9952,9 @@ static void test_ps_i18n()
const char *stmt_text;
MYSQL_BIND bind_array[2];
const char *koi8= "îÕ, ÚÁ ÒÙÂÁÌËÕ";
const char *cp1251= "Íó, çà ðûáàëêó";
/* Represented as numbers to keep UTF8 tools from clobbering them. */
const char *koi8= "\xee\xd5\x2c\x20\xda\xc1\x20\xd2\xd9\xc2\xc1\xcc\xcb\xd5";
const char *cp1251= "\xcd\xf3\x2c\x20\xe7\xe0\x20\xf0\xfb\xe1\xe0\xeb\xea\xf3";
char buf1[16], buf2[16];
ulong buf1_len, buf2_len;

View file

@ -333,16 +333,30 @@ my_bool vio_poll_read(Vio *vio,uint timeout)
}
void vio_timeout(Vio *vio __attribute__((unused)),
uint which __attribute__((unused)),
uint timeout __attribute__((unused)))
void vio_timeout(Vio *vio, uint which, uint timeout)
{
/* TODO: some action should be taken if socket timeouts are not supported. */
#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO)
#ifdef __WIN__
ulong wait_timeout= (ulong) timeout * 1000;
(void) setsockopt(vio->sd, SOL_SOCKET,
which ? SO_SNDTIMEO : SO_RCVTIMEO, (char*) &wait_timeout,
sizeof(wait_timeout));
#endif /* __WIN__ */
/* Windows expects time in milliseconds as int. */
int wait_timeout= (int) timeout * 1000;
#else /* ! __WIN__ */
/* POSIX specifies time as struct timeval. */
struct timeval wait_timeout;
wait_timeout.tv_sec= timeout;
wait_timeout.tv_usec= 0;
#endif /* ! __WIN__ */
/* TODO: return value should be checked. */
(void) setsockopt(vio->sd, SOL_SOCKET, which ? SO_SNDTIMEO : SO_RCVTIMEO,
(char*) &wait_timeout, sizeof(wait_timeout));
#endif /* defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) */
}