Merge kboortz@bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/Users/kent/mysql/bk/mysql-4.1-perl
This commit is contained in:
kent@mysql.com 2005-02-13 19:52:41 +01:00
commit a983841625
56 changed files with 507 additions and 285 deletions

View file

@ -1007,3 +1007,4 @@ tests/mysql_client_test
libmysqld/examples/mysql_client_test.c
libmysqld/examples/mysql_client_test_embedded
libmysqld/examples/mysqltest_embedded
support-files/ndb-config-2-node.ini

View file

@ -20,14 +20,20 @@ if [ "$BK_STATUS" = OK ]
then
CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet`
BUG=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Bb][Uu][Gg] *# *\([0-9][0-9]*\).*$/ BUG#\1/p'`
BUG=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Bb][Uu][Gg] *# *\([0-9][0-9]*\).*$/\1/p'`
WL=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Ww][Ll] *# *\([0-9][0-9]*\).*$/ WL#\1/p'`
if [ "$BUG" = "" ]
then
TO=dev-public@mysql.com
BS=""
BH=""
else
TO=dev-bugs@mysql.com
BS=" BUG#$BUG"
# need newline here
BH="X-Bug: $BUG
"
fi
#++
# dev-public@ / dev-bugs@
@ -38,8 +44,8 @@ fi
List-ID: <bk.mysql-$VERSION>
From: $FROM
To: $TO
Subject: bk commit - $VERSION tree ($CHANGESET)${BUG}${WL}
Subject: bk commit - $VERSION tree ($CHANGESET)${BS}${WL}
$BH
EOF
bk changes -v -r+
bk cset -r+ -d
@ -54,14 +60,14 @@ EOF
List-ID: <bk.mysql-$VERSION>
From: $FROM
To: $INTERNALS
Subject: bk commit into $VERSION tree ($CHANGESET)
Subject: bk commit into $VERSION tree ($CHANGESET)$BS
$BH
Below is the list of changes that have just been committed into a local
$VERSION repository of $USER. When $USER does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://www.mysql.com/doc/I/n/Installing_source_tree.html
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
EOF
bk changes -v -r+
@ -81,7 +87,7 @@ EOF
List-ID: <bk.mysql-$VERSION>
From: $FROM
To: $DOCS
Subject: bk commit - $VERSION tree (Manual) ($CHANGESET)
Subject: bk commit - $VERSION tree (Manual) ($CHANGESET)$BS
EOF
bk changes -v -r+

View file

@ -806,7 +806,7 @@ sub find
sub rm_all
{
my(@rm_files)=@_;
my($dir,$current_dir,@files,@dirs);
my($dir,$current_dir,@files,@dirs,$removed);
$current_dir = `pwd`; chomp($current_dir);
foreach $dir (@rm_files)
@ -830,7 +830,9 @@ sub rm_all
}
if ($#files >= 0)
{
system("rm -f " . join(" ",@files)) && abort("Can't remove files from $dir");
$removed= unlink @files;
print "rm_all : removed $removed files in $current_dir/$dir\n" if ($opt_debug);
abort("Can't remove all $#files+1 from $current_dir/$dir, just $removed") if $removed != $#files+1;
}
foreach $dir (@dirs)
{

View file

@ -109,6 +109,12 @@ sub add_copyright
$line_copyright= "! ";
$end_copyright= "";
}
elsif ($ARGV =~ /\.sql$/)
{
$start_copyright="-- ";
$line_copyright= "-- ";
$end_copyright= "";
}
elsif ($ARGV =~ /\.asm$/)
{
$start_copyright="; ";

View file

@ -66,18 +66,18 @@ LINK32=link.exe
# PROP Output_Dir ".\Release"
# PROP Intermediate_Dir ".\Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /I "../include" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /GF /Gy /Fp".\Release/client_test.pch" /Fo".\Release/" /Fd".\Release/" /c /GX
# ADD CPP /nologo /MTd /I "../include" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /GF /Gy /Fp".\Release/client_test.pch" /Fo".\Release/" /Fd".\Release/" /c /GX
# ADD BASE MTL /nologo /tlb".\Release\client_test.tlb" /win32
# ADD MTL /nologo /tlb".\Release\client_test.tlb" /win32
# ADD BASE CPP /nologo /MTd /I "../include" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /GF /Gy /Fp".\Release/mysql_client_test.pch" /Fo".\Release/" /Fd".\Release/" /c /GX
# ADD CPP /nologo /MTd /I "../include" /I "../" /W3 /Ob1 /G6 /D "DBUG_OFF" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /D "MYSQL_CLIENT" /D "__WIN__" /D "_WIN32" /GF /Gy /Fp".\Release/mysql_client_test.pch" /Fo".\Release/" /Fd".\Release/" /c /GX
# ADD BASE MTL /nologo /tlb".\Release\mysql_client_test.tlb" /win32
# ADD MTL /nologo /tlb".\Release\mysql_client_test.tlb" /win32
# ADD BASE RSC /l 1033
# ADD RSC /l 1033
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\tests\client_test.exe" /incremental:no /pdb:".\Release\client_test.pdb" /pdbtype:sept /subsystem:console
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\tests\client_test.exe" /incremental:no /pdb:".\Release\client_test.pdb" /pdbtype:sept /subsystem:console
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\tests\mysql_client_test.exe" /incremental:no /pdb:".\Release\mysql_client_test.pdb" /pdbtype:sept /subsystem:console
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\tests\mysql_client_test.exe" /incremental:no /pdb:".\Release\mysql_client_test.pdb" /pdbtype:sept /subsystem:console
!ENDIF

View file

@ -2169,6 +2169,9 @@ static struct my_option my_long_options[] =
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
#include <help_start.h>
static void print_version(void)
{
printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,MTEST_VERSION,
@ -2187,6 +2190,8 @@ void usage()
my_print_variables(my_long_options);
}
#include <help_end.h>
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),

View file

@ -55,6 +55,9 @@ static struct my_option my_long_options[] =
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
#include <help_start.h>
static void usage(my_bool version)
{
printf("%s Ver 1.6 for %s at %s\n",my_progname,SYSTEM_TYPE,
@ -69,6 +72,8 @@ static void usage(my_bool version)
printf("\nExample usage:\n%s --config-file=my client mysql\n", my_progname);
}
#include <help_end.h>
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),

View file

@ -113,12 +113,15 @@ static HA_ERRORS ha_errlist[]=
};
#include <help_start.h>
static void print_version(void)
{
printf("%s Ver %s, for %s (%s)\n",my_progname,PERROR_VERSION,
SYSTEM_TYPE,MACHINE_TYPE);
}
static void usage(void)
{
print_version();
@ -130,6 +133,8 @@ static void usage(void)
my_print_variables(my_long_options);
}
#include <help_end.h>
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),

View file

@ -376,8 +376,8 @@ static REP_SET *make_new_set(REP_SETS *sets);
static void make_sets_invisible(REP_SETS *sets);
static void free_last_set(REP_SETS *sets);
static void free_sets(REP_SETS *sets);
static void set_bit(REP_SET *set, uint bit);
static void clear_bit(REP_SET *set, uint bit);
static void internal_set_bit(REP_SET *set, uint bit);
static void internal_clear_bit(REP_SET *set, uint bit);
static void or_bits(REP_SET *to,REP_SET *from);
static void copy_bits(REP_SET *to,REP_SET *from);
static int cmp_bits(REP_SET *set1,REP_SET *set2);
@ -454,7 +454,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
{
if (from[i][0] == '\\' && from[i][1] == '^')
{
set_bit(start_states,states+1);
internal_set_bit(start_states,states+1);
if (!from[i][2])
{
start_states->table_offset=i;
@ -463,8 +463,8 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
}
else if (from[i][0] == '\\' && from[i][1] == '$')
{
set_bit(start_states,states);
set_bit(word_states,states);
internal_set_bit(start_states,states);
internal_set_bit(word_states,states);
if (!from[i][2] && start_states->table_offset == (uint) ~0)
{
start_states->table_offset=i;
@ -473,11 +473,11 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
}
else
{
set_bit(word_states,states);
internal_set_bit(word_states,states);
if (from[i][0] == '\\' && (from[i][1] == 'b' && from[i][2]))
set_bit(start_states,states+1);
internal_set_bit(start_states,states+1);
else
set_bit(start_states,states);
internal_set_bit(start_states,states);
}
for (pos=from[i], len=0; *pos ; pos++)
{
@ -583,9 +583,9 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
follow[i].len > found_end)
found_end=follow[i].len;
if (chr && follow[i].chr)
set_bit(new_set,i+1); /* To next set */
internal_set_bit(new_set,i+1); /* To next set */
else
set_bit(new_set,i);
internal_set_bit(new_set,i);
}
}
if (found_end)
@ -602,7 +602,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
if (follow[bit_nr-1].len < found_end ||
(new_set->found_len &&
(chr == 0 || !follow[bit_nr].chr)))
clear_bit(new_set,i);
internal_clear_bit(new_set,i);
else
{
if (chr == 0 || !follow[bit_nr].chr)
@ -751,13 +751,13 @@ static void free_sets(REP_SETS *sets)
return;
}
static void set_bit(REP_SET *set, uint bit)
static void internal_set_bit(REP_SET *set, uint bit)
{
set->bits[bit / WORD_BIT] |= 1 << (bit % WORD_BIT);
return;
}
static void clear_bit(REP_SET *set, uint bit)
static void internal_clear_bit(REP_SET *set, uint bit)
{
set->bits[bit / WORD_BIT] &= ~ (1 << (bit % WORD_BIT));
return;

View file

@ -65,12 +65,16 @@ static struct my_option my_long_options[] =
static void verify_sort();
#include <help_start.h>
static void print_version(void)
{
printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,DUMP_VERSION,
MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
}
static void usage()
{
print_version();
@ -87,6 +91,7 @@ The numeric-dump-file should contain a numeric stack trace from mysqld.\n\
If the numeric-dump-file is not given, the stack trace is read from stdin.\n");
}
#include <help_end.h>
static void die(const char* fmt, ...)

View file

@ -2,5 +2,6 @@
#undef printf
#undef puts
#undef fputs
#undef fputc
#undef putchar
#endif

View file

@ -4,4 +4,6 @@
#define printf consoleprintf
#define puts(s) consoleprintf("%s\n",s)
#define fputs(s,f) puts(s)
#define fputc(s,f) consoleprintf("%c", s)
#define putchar(s) consoleprintf("%c", s)
#endif

View file

@ -637,7 +637,7 @@ extern int pthread_dummy(int);
MySQL can survive with 32K, but some glibc libraries require > 128K stack
To resolve hostnames
*/
#define DEFAULT_THREAD_STACK (192*1024L)
#define DEFAULT_THREAD_STACK (256*1024L)
#else
#define DEFAULT_THREAD_STACK (192*1024)
#endif

View file

@ -260,6 +260,8 @@ static struct my_option my_long_options[] =
};
#include <help_start.h>
static void print_version(void)
{
printf("%s Ver 5.10 for %s on %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
@ -283,6 +285,8 @@ static void usage(void)
my_print_variables(my_long_options);
}
#include <help_end.h>
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),

View file

@ -1788,6 +1788,18 @@ static my_bool my_realloc_str(NET *net, ulong length)
}
/* Clear possible error statee of struct NET */
static void net_clear_error(NET *net)
{
if (net->last_errno)
{
net->last_errno= 0;
net->last_error[0]= '\0';
strmov(net->sqlstate, not_error_sqlstate);
}
}
/*
Set statement error code, sqlstate, and error message
from given errcode and sqlstate.
@ -2467,6 +2479,11 @@ int cli_stmt_execute(MYSQL_STMT *stmt)
set_stmt_error(stmt, CR_PARAMS_NOT_BOUND, unknown_sqlstate);
DBUG_RETURN(1);
}
if (stmt->mysql->status != MYSQL_STATUS_READY)
{
set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
DBUG_RETURN(1);
}
net_clear(net); /* Sets net->write_pos */
/* Reserve place for null-marker bytes */
@ -4501,6 +4518,11 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
if (mysql)
{
mysql->stmts= list_delete(mysql->stmts, &stmt->list);
/*
Clear NET error state: if the following commands come through
successfully, connection will still be usable for other commands.
*/
net_clear_error(&mysql->net);
if ((int) stmt->state > (int) MYSQL_STMT_INIT_DONE)
{
char buff[MYSQL_STMT_HEADER]; /* 4 bytes - stmt id */

View file

@ -71,9 +71,11 @@ void Querycache_stream::store_int(uint i)
cur_data+= 4;
return;
}
memcpy(cur_data, &i, rest_len);
char buf[4];
int4store(buf, i);
memcpy(cur_data, buf, rest_len);
use_next_block();
memcpy(cur_data, ((byte*)&i)+rest_len, 4-rest_len);
memcpy(cur_data, buf+rest_len, 4-rest_len);
cur_data+= 4-rest_len;
}
@ -186,10 +188,12 @@ uint Querycache_stream::load_int()
cur_data+= 4;
return result;
}
memcpy(&result, cur_data, rest_len);
char buf[4];
memcpy(buf, cur_data, rest_len);
use_next_block();
memcpy(((byte*)&result)+rest_len, cur_data, 4-rest_len);
memcpy(buf+rest_len, cur_data, 4-rest_len);
cur_data+= 4-rest_len;
result= uint4korr(buf);
return result;
}
@ -270,10 +274,10 @@ int Querycache_stream::load_column(MEM_ROOT *alloc, char** column)
return 0;
}
len--;
if (!(*column= (char *)alloc_root(alloc, len + 4 + 1)))
if (!(*column= (char *)alloc_root(alloc, len + sizeof(uint) + 1)))
return 1;
int4store(*column, len);
(*column)+= 4;
*((uint*)*column)= len;
(*column)+= sizeof(uint);
load_str_only(*column, len);
return 1;
}

View file

@ -71,15 +71,15 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves)
if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE))
goto err;
do
{
/* Read the next block of index file into the preload buffer */
if ((my_off_t) length > (key_file_length-pos))
length= (ulong) (key_file_length-pos);
if (my_pread(share->kfile, (byte*) buff, length, pos, MYF(MY_FAE)))
if (my_pread(share->kfile, (byte*) buff, length, pos, MYF(MY_FAE|MY_FNABP)))
goto err;
if (ignore_leaves)
{
uchar *end= buff+length;
@ -88,7 +88,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves)
if (mi_test_if_nod(buff))
{
if (key_cache_insert(share->key_cache,
share->kfile, pos, DFLT_INIT_HITS,
share->kfile, pos, DFLT_INIT_HITS,
(byte*) buff, block_length))
goto err;
}

View file

@ -247,6 +247,7 @@ static void get_options(register int *argc, register char ***argv)
/* Fall through */
case 'I':
case '?':
#include <help_start.h>
printf("%s Ver 1.4 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
puts("By Monty, for your professional use\n");
@ -268,6 +269,7 @@ static void get_options(register int *argc, register char ***argv)
puts("If a recover is done all writes and all possibly updates and deletes is done\nand errors are only counted.");
puts("If one gives table names as arguments only these tables will be updated\n");
help=1;
#include <help_end.h>
break;
default:
printf("illegal option: \"-%c\"\n",*pos);

View file

@ -47,7 +47,7 @@ dist-hook:
$(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/t/*.test $(srcdir)/t/*.opt $(srcdir)/t/*.sh $(srcdir)/t/*.slave-mi $(distdir)/t
$(INSTALL_DATA) $(srcdir)/include/*.inc $(distdir)/include
$(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.require $(distdir)/r
$(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.result.es $(srcdir)/r/*.require $(distdir)/r
$(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.dat $(srcdir)/std_data/*.000001 $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(distdir)/std_data
@ -65,7 +65,7 @@ install-data-local:
$(INSTALL_DATA) $(srcdir)/t/*.opt $(DESTDIR)$(testdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.sh $(DESTDIR)$(testdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.slave-mi $(DESTDIR)$(testdir)/t
$(INSTALL_DATA) $(srcdir)/r/*.result $(DESTDIR)$(testdir)/r
$(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.result.es $(DESTDIR)$(testdir)/r
$(INSTALL_DATA) $(srcdir)/r/*.require $(DESTDIR)$(testdir)/r
$(INSTALL_DATA) $(srcdir)/include/*.inc $(DESTDIR)$(testdir)/include
$(INSTALL_DATA) $(srcdir)/std_data/*.dat $(DESTDIR)$(testdir)/std_data

View file

@ -194,8 +194,8 @@ MY_LOG_DIR="$MYSQL_TEST_DIR/var/log"
#
# Set LD_LIBRARY_PATH if we are using shared libraries
#
LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$LD_LIBRARY_PATH"
DYLD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$DYLD_LIBRARY_PATH"
LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$BASEDIR/zlib/.libs:$LD_LIBRARY_PATH"
DYLD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$BASEDIR/zlib/.libs:$DYLD_LIBRARY_PATH"
export LD_LIBRARY_PATH DYLD_LIBRARY_PATH
MASTER_RUNNING=0

View file

@ -613,3 +613,17 @@ ucs2_bin 00610009
ucs2_bin 0061
ucs2_bin 00610020
drop table t1;
SET NAMES latin1;
SET collation_connection='ucs2_swedish_ci';
CREATE TABLE t1 (Field1 int(10) default '0');
INSERT INTO t1 VALUES ('-1');
SELECT * FROM t1;
Field1
-1
DROP TABLE t1;
CREATE TABLE t1 (Field1 int(10) unsigned default '0');
INSERT INTO t1 VALUES ('-1');
Warnings:
Warning 1265 Data truncated for column 'Field1' at row 1
DROP TABLE t1;
SET NAMES latin1;

View file

@ -190,7 +190,7 @@ insert into t3 select * from t4;
explain select distinct t1.a from t1,t3 where t1.a=t3.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 Using index; Using temporary
1 SIMPLE t3 ref a a 5 test.t1.a 10 Using where; Using index; Distinct
1 SIMPLE t3 ref a a 5 test.t1.a 11 Using where; Using index; Distinct
select distinct t1.a from t1,t3 where t1.a=t3.a;
a
1

View file

@ -655,9 +655,9 @@ insert into t1 (a,b) values (1,2),(1,3),(2,5);
select a, 0.1*0+1 r2, sum(1) r1 from t1 where a = 1 group by a having r1>1 and r2=1;
a r2 r1
1 1.0 2
select a, rand()*0+1 r2, sum(1) r1 from t1 where a = 1 group by a having r1>1 and r2=1;
select a, round(rand(100)*10) r2, sum(1) r1 from t1 where a = 1 group by a having r1>1 and r2<=2;
a r2 r1
1 1 2
1 2 2
select a,sum(b) from t1 where a=1 group by c;
a sum(b)
1 5

View file

@ -355,3 +355,13 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref heap_idx heap_idx 20 const 7 Using where
1 SIMPLE t3 ref a a 40 func,const 6 Using where
drop table t1, t2, t3;
create temporary table t1 ( a int, index (a) ) engine=memory;
insert into t1 values (1),(2),(3),(4),(5);
select a from t1 where a in (1,3);
a
1
3
explain select a from t1 where a in (1,3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 2 Using where
drop table t1;

View file

@ -74,15 +74,15 @@ Table Op Msg_type Msg_text
test.t1 preload_keys status OK
show status like "key_read%";
Variable_name Value
Key_read_requests 0
Key_reads 0
Key_read_requests 581
Key_reads 581
select count(*) from t1 where b = 'test1';
count(*)
4181
show status like "key_read%";
Variable_name Value
Key_read_requests 217
Key_reads 45
Key_read_requests 798
Key_reads 581
flush tables;
flush status;
show status like "key_read%";
@ -98,15 +98,15 @@ Table Op Msg_type Msg_text
test.t1 preload_keys status OK
show status like "key_read%";
Variable_name Value
Key_read_requests 0
Key_reads 0
Key_read_requests 10
Key_reads 10
select count(*) from t1 where b = 'test1';
count(*)
4181
show status like "key_read%";
Variable_name Value
Key_read_requests 217
Key_reads 45
Key_read_requests 227
Key_reads 52
flush tables;
flush status;
show status like "key_read%";
@ -123,8 +123,8 @@ test.t1 preload_keys status OK
test.t2 preload_keys status OK
show status like "key_read%";
Variable_name Value
Key_read_requests 0
Key_reads 0
Key_read_requests 587
Key_reads 587
select count(*) from t1 where b = 'test1';
count(*)
4181
@ -133,8 +133,8 @@ count(*)
2584
show status like "key_read%";
Variable_name Value
Key_read_requests 351
Key_reads 73
Key_read_requests 938
Key_reads 613
flush tables;
flush status;
show status like "key_read%";
@ -147,8 +147,8 @@ test.t3 preload_keys error Table 'test.t3' doesn't exist
test.t2 preload_keys status OK
show status like "key_read%";
Variable_name Value
Key_read_requests 0
Key_reads 0
Key_read_requests 355
Key_reads 355
flush tables;
flush status;
show status like "key_read%";

View file

@ -2387,3 +2387,16 @@ EXPLAIN SELECT i FROM t1 WHERE i=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
DROP TABLE t1;
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref a a 23 test.t1.a 2
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref a a 23 test.t1.a 2
DROP TABLE t1, t2;

View file

@ -1425,7 +1425,7 @@ Note 1003 (select test.t1.s1 AS `s1` from test.t1)
s1
tttt
drop table t1;
create table t1 (s1 char(5) not null, index s1(s1));
create table t1 (s1 char(5), index s1(s1));
create table t2 (s1 char(5), index s1(s1));
insert into t1 values ('a1'),('a2'),('a3');
insert into t2 values ('a1'),('a2');
@ -1451,25 +1451,25 @@ a2 1
a3 1
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 5 NULL 3 Using index
1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
Warnings:
Note 1003 select test.t1.s1 AS `s1`,not(<in_optimizer>(test.t1.s1,<exists>(<index_lookup>(<cache>(test.t1.s1) in t2 on s1 chicking NULL)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from test.t1
explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 5 NULL 3 Using index
1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
Warnings:
Note 1003 select test.t1.s1 AS `s1`,<in_optimizer>(test.t1.s1,<exists>(<index_lookup>(<cache>(test.t1.s1) in t2 on s1 chicking NULL))) AS `s1 = ANY (SELECT s1 FROM t2)` from test.t1
explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 5 NULL 3 Using index
1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
Warnings:
Note 1003 select test.t1.s1 AS `s1`,not(<in_optimizer>(test.t1.s1,<exists>(<index_lookup>(<cache>(test.t1.s1) in t2 on s1 chicking NULL)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from test.t1
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 5 NULL 3 Using index
1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 1 Using index; Using where
Warnings:
Note 1003 select test.t1.s1 AS `s1`,not(<in_optimizer>(test.t1.s1,<exists>(<index_lookup>(<cache>(test.t1.s1) in t2 on s1 chicking NULL where (test.t2.s1 < _latin1'a2'))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from test.t1
@ -2125,34 +2125,6 @@ SELECT DISTINCT Continent AS c FROM t1 WHERE Code <> SOME ( SELECT Code FROM t1
c
Oceania
drop table t1;
CREATE TABLE t1 ( f1 BIGINT );
INSERT INTO t1 SET f1= NULL;
INSERT INTO t1 SET f1= 1;
CREATE TABLE t2 ( f1 BIGINT );
SELECT f1 FROM t1
WHERE f1 <> ALL ( SELECT f1 FROM t2 );
f1
NULL
1
INSERT INTO t2 VALUES (1), (2);
SELECT f1 FROM t1
WHERE f1 <> ALL ( SELECT f1 FROM t2 WHERE f1 > 2 );
f1
NULL
1
SELECT f1 FROM t1
WHERE f1 <> ALL ( SELECT f1 FROM t2 WHERE f1 > 2
UNION
SELECT f1 FROM t2 WHERE f1 > 3);
f1
NULL
1
SELECT f1 FROM t1
WHERE f1 <> ALL ( SELECT SUM(f1) AS sf1 FROM t2 HAVING sf1 > 10000);
f1
NULL
1
drop table t1,t2;
create table t1 (a1 int);
create table t2 (b1 int);
select * from t1 where a2 > any(select b1 from t2);

View file

@ -109,8 +109,8 @@ select @a:=0;
select @a, @a:=@a+count(*), count(*), @a from t1 group by i;
@a @a:=@a+count(*) count(*) @a
0 1 1 0
0 3 2 0
0 6 3 0
0 2 2 0
0 3 3 0
select @a:=0;
@a:=0
0

View file

@ -390,3 +390,24 @@ SET collation_connection='ucs2_general_ci';
SET NAMES latin1;
SET collation_connection='ucs2_bin';
-- source include/ctype_filesort.inc
SET NAMES latin1;
#
# Bug#8235
#
# This bug also helped to find another problem that
# INSERT of a UCS2 string containing a negative number
# into a unsigned int column didn't produce warnings.
# This test covers both problems.
#
SET collation_connection='ucs2_swedish_ci';
CREATE TABLE t1 (Field1 int(10) default '0');
# no warnings, negative numbers are allowed
INSERT INTO t1 VALUES ('-1');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (Field1 int(10) unsigned default '0');
# this should generate a "Data truncated" warning
INSERT INTO t1 VALUES ('-1');
DROP TABLE t1;
SET NAMES latin1;

View file

@ -480,7 +480,8 @@ drop table t1;
create table t1 (a integer, b integer, c integer);
insert into t1 (a,b) values (1,2),(1,3),(2,5);
select a, 0.1*0+1 r2, sum(1) r1 from t1 where a = 1 group by a having r1>1 and r2=1;
select a, rand()*0+1 r2, sum(1) r1 from t1 where a = 1 group by a having r1>1 and r2=1;
# rand(100)*10 will be < 2 only for the first row (of 6)
select a, round(rand(100)*10) r2, sum(1) r1 from t1 where a = 1 group by a having r1>1 and r2<=2;
select a,sum(b) from t1 where a=1 group by c;
select a*sum(b) from t1 where a=1 group by c;
select sum(a)*sum(b) from t1 where a=1 group by c;

View file

@ -251,3 +251,9 @@ explain select * from t1 ignore key(btree_idx), t3 where t1.name='matt' and t3.a
drop table t1, t2, t3;
# Fix for BUG#8371: wrong rec_per_key value for hash index on temporary table
create temporary table t1 ( a int, index (a) ) engine=memory;
insert into t1 values (1),(2),(3),(4),(5);
select a from t1 where a in (1,3);
explain select a from t1 where a in (1,3);
drop table t1;

View file

@ -1930,3 +1930,18 @@ INSERT INTO t1 VALUES (3,'c');
EXPLAIN SELECT i FROM t1 WHERE i=1;
DROP TABLE t1;
#
# Test case for bug 7520: a wrong cost of the index for a BLOB field
#
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
DROP TABLE t1, t2;

View file

@ -889,7 +889,7 @@ drop table t1;
#
# IN optimisation test results
#
create table t1 (s1 char(5) not null, index s1(s1));
create table t1 (s1 char(5), index s1(s1));
create table t2 (s1 char(5), index s1(s1));
insert into t1 values ('a1'),('a2'),('a3');
insert into t2 values ('a1'),('a2');
@ -1387,34 +1387,6 @@ INSERT INTO t1 VALUES ('UMI','United States Minor Outlying Islands','Oceania','M
SELECT DISTINCT Continent AS c FROM t1 WHERE Code <> SOME ( SELECT Code FROM t1 WHERE Continent = c AND Population < 200);
drop table t1;
#
# Test cases for bug #7351:
# quantified predicate with subquery returning empty result set
#
CREATE TABLE t1 ( f1 BIGINT );
INSERT INTO t1 SET f1= NULL;
INSERT INTO t1 SET f1= 1;
CREATE TABLE t2 ( f1 BIGINT );
SELECT f1 FROM t1
WHERE f1 <> ALL ( SELECT f1 FROM t2 );
INSERT INTO t2 VALUES (1), (2);
SELECT f1 FROM t1
WHERE f1 <> ALL ( SELECT f1 FROM t2 WHERE f1 > 2 );
SELECT f1 FROM t1
WHERE f1 <> ALL ( SELECT f1 FROM t2 WHERE f1 > 2
UNION
SELECT f1 FROM t2 WHERE f1 > 3);
SELECT f1 FROM t1
WHERE f1 <> ALL ( SELECT SUM(f1) AS sf1 FROM t2 HAVING sf1 > 10000);
drop table t1,t2;
#
# Test for BUG#7885: Server crash when 'any' subselect compared to
# non-existant field.

View file

@ -45,7 +45,7 @@ int my_rename(const char *from, const char *to, myf MyFlags)
}
#endif
#if defined(HAVE_RENAME)
#ifdef __WIN__
#if defined(__WIN__) || defined(__NETWARE__)
/*
On windows we can't rename over an existing file:
Remove any conflicting files:

View file

@ -85,7 +85,7 @@ FastScheduler::activateSendPacked()
void
FastScheduler::doJob()
{
Uint32 init_loopCount = 0;
Uint32 loopCount = 0;
Uint32 TminLoops = getBOccupancy() + EXTRA_SIGNALS_PER_DO_JOB;
Uint32 TloopMax = (Uint32)globalData.loopMax;
if (TminLoops < TloopMax) {
@ -94,10 +94,9 @@ FastScheduler::doJob()
if (TloopMax < MIN_NUMBER_OF_SIG_PER_DO_JOB) {
TloopMax = MIN_NUMBER_OF_SIG_PER_DO_JOB;
}//if
register Signal* signal = getVMSignals();
register Uint32 tHighPrio= globalData.highestAvailablePrio;
do{
Uint32 loopCount = init_loopCount;
register Uint32 tHighPrio = globalData.highestAvailablePrio;
register Signal* signal = getVMSignals();
while ((tHighPrio < LEVEL_IDLE) && (loopCount < TloopMax)) {
// signal->garbage_register();
// To ensure we find bugs quickly
@ -155,24 +154,27 @@ FastScheduler::doJob()
}//if
loopCount++;
}//while
if (globalData.sendPackedActivated == 1) {
Uint32 t1 = theDoJobTotalCounter;
Uint32 t2 = theDoJobCallCounter;
t1 += (loopCount - init_loopCount);
t2++;
theDoJobTotalCounter = t1;
theDoJobCallCounter = t2;
if (t2 == 8192) {
reportDoJobStatistics(t1 >> 13);
theDoJobCallCounter = 0;
theDoJobTotalCounter = 0;
}//if
}//if
init_loopCount = loopCount;
sendPacked();
tHighPrio = globalData.highestAvailablePrio;
if(getBOccupancy() > MAX_OCCUPANCY)
{
if(loopCount != TloopMax)
abort();
assert( loopCount == TloopMax );
TloopMax += 512;
}
} while ((getBOccupancy() > MAX_OCCUPANCY) ||
((init_loopCount < TloopMax) &&
(globalData.highestAvailablePrio < LEVEL_IDLE)));
((loopCount < TloopMax) &&
(tHighPrio < LEVEL_IDLE)));
theDoJobCallCounter ++;
theDoJobTotalCounter += loopCount;
if (theDoJobCallCounter == 8192) {
reportDoJobStatistics(theDoJobTotalCounter >> 13);
theDoJobCallCounter = 0;
theDoJobTotalCounter = 0;
}//if
}//FastScheduler::doJob()
void FastScheduler::sendPacked()

View file

@ -171,15 +171,9 @@ do
rm $file.org
done
# create the libmysql.imp file in netware folder from libmysql/libmysql.def
# file
echo "generating llibmysql.imp file..."
awk 'BEGIN{x=0;} x==1 {print $1;next} /EXPORTS/{x=1}' libmysql/libmysql.def > netware/libmysql.imp
# create the libmysql.imp file in netware folder from libmysql/libmysql.def file
echo "generating llibmysql.imp file..."
awk 'BEGIN{x=0;} x==1 {print $1;next} /EXPORTS/{x=1}' libmysql/libmysql.def > netware/libmysql.imp
awk 'BEGIN{x=0;} END{printf("\n");} x==1 {printf(" %s",$1); x++; next} x>1 {printf(",\n %s", $1);next} /EXPORTS/{x=1}' libmysql/libmysql.def > netware/libmysql.imp
# build linux tools
echo "compiling linux tools..."

View file

@ -192,7 +192,7 @@ void install_db(char *datadir)
char error[PATH_MAX];
// input file
snprintf(input, PATH_MAX, "%s/bin/init_db.sql", base_dir);
snprintf(input, PATH_MAX, "%s/bin/test_db.sql", base_dir);
snprintf(output, PATH_MAX, "%s/install.out", datadir);
snprintf(error, PATH_MAX, "%s/install.err", datadir);
@ -1160,7 +1160,8 @@ void setup(char *file)
setenv("MASTER_MYPORT", "9306", 1);
setenv("SLAVE_MYPORT", "9307", 1);
setenv("MYSQL_TCP_PORT", "3306", 1);
snprintf(file_path, PATH_MAX*2, "%s/mysql_client_test --no-defaults --testcase--user=root --port=%u ", bin_dir, master_port);
setenv("MYSQL_CLIENT_TEST",file_path,1);
}
/******************************************************************************

View file

@ -493,6 +493,24 @@ sub print_insert_header
}
}
print <<EOF;
-- Copyright (C) 2000-2005 MySQL AB
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
EOF
print "delete from help_topic;\n";
print "delete from help_category;\n";
print "delete from help_keyword;\n";

View file

@ -242,8 +242,12 @@ rm -f $BASE/bin/Makefile* $BASE/bin/*.in $BASE/bin/*.sh $BASE/bin/mysql_install_
# Copy system dependent files
#
if [ $BASE_SYSTEM = "netware" ] ; then
cp ./netware/static_init_db.sql ./netware/init_db.sql
./scripts/fill_help_tables < ./Docs/manual.texi >> ./netware/init_db.sql
echo "CREATE DATABASE mysql;" > $BASE/bin/init_db.sql
echo "CREATE DATABASE test;" >> $BASE/bin/init_db.sql
sh ./scripts/mysql_create_system_tables.sh real "" "%" 0 >> $BASE/bin/init_db.sql
sh ./scripts/mysql_create_system_tables.sh test "" "%" 0 > $BASE/bin/test_db.sql
# cp ./netware/static_init_db.sql ./netware/init_db.sql
# ./scripts/fill_help_tables < ./Docs/manual.texi >> ./netware/init_db.sql
fi
#

View file

@ -114,6 +114,8 @@
data - The data is stored in a "row +blobs" format.
*/
/* If the archive storage engine has been inited */
static bool archive_inited= 0;
/* Variables for archive share methods */
pthread_mutex_t archive_mutex;
static HASH archive_open_tables;
@ -157,6 +159,7 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length,
bool archive_db_init()
{
archive_inited= 1;
VOID(pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST));
return (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0,
(hash_get_key) archive_get_key, 0, 0));
@ -176,8 +179,12 @@ bool archive_db_init()
bool archive_db_end()
{
hash_free(&archive_open_tables);
VOID(pthread_mutex_destroy(&archive_mutex));
if (archive_inited)
{
hash_free(&archive_open_tables);
VOID(pthread_mutex_destroy(&archive_mutex));
}
archive_inited= 0;
return FALSE;
}

View file

@ -1777,6 +1777,14 @@ void Field_medium::sql_type(String &res) const
****************************************************************************/
static bool test_if_minus(CHARSET_INFO *cs,
const char *s, const char *e)
{
my_wc_t wc;
return cs->cset->mb_wc(cs, &wc, (uchar*) s, (uchar*) e) > 0 && wc == '-';
}
int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
{
long tmp;
@ -1790,7 +1798,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
if (unsigned_flag)
{
if (!len || *from == '-')
if (!len || test_if_minus(cs, from, from + len))
{
tmp=0; // Set negative to 0
my_errno=ERANGE;
@ -2086,7 +2094,7 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
my_errno=0;
if (unsigned_flag)
{
if (!len || *from == '-')
if (!len || test_if_minus(cs, from, from + len))
{
tmp=0; // Set negative to 0
my_errno= ERANGE;

View file

@ -60,8 +60,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked)
{
/* Initialize variables for the opened table */
set_keys_for_scanning();
if (table->tmp_table == NO_TMP_TABLE)
update_key_stats();
update_key_stats();
}
return (file ? 0 : 1);
}
@ -103,6 +102,8 @@ void ha_heap::update_key_stats()
for (uint i= 0; i < table->keys; i++)
{
KEY *key=table->key_info+i;
if (!key->rec_per_key)
continue;
if (key->algorithm != HA_KEY_ALG_BTREE)
{
ha_rows hash_buckets= file->s->keydef[i].hash_buckets;
@ -122,8 +123,8 @@ int ha_heap::write_row(byte * buf)
if (table->next_number_field && buf == table->record[0])
update_auto_increment();
res= heap_write(file,buf);
if (!res && table->tmp_table == NO_TMP_TABLE &&
++records_changed*HEAP_STATS_UPDATE_THRESHOLD > file->s->records)
if (!res && ++records_changed*HEAP_STATS_UPDATE_THRESHOLD >
file->s->records)
update_key_stats();
return res;
}
@ -135,8 +136,8 @@ int ha_heap::update_row(const byte * old_data, byte * new_data)
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
table->timestamp_field->set_time();
res= heap_update(file,old_data,new_data);
if (!res && table->tmp_table == NO_TMP_TABLE &&
++records_changed*HEAP_STATS_UPDATE_THRESHOLD > file->s->records)
if (!res && ++records_changed*HEAP_STATS_UPDATE_THRESHOLD >
file->s->records)
update_key_stats();
return res;
}

View file

@ -295,6 +295,58 @@ CHARSET_INFO *Item::default_charset()
}
/*
Move SUM items out from item tree and replace with reference
SYNOPSIS
split_sum_func2()
thd Thread handler
ref_pointer_array Pointer to array of reference fields
fields All fields in select
ref Pointer to item
NOTES
This is from split_sum_func2() for items that should be split
All found SUM items are added FIRST in the fields list and
we replace the item with a reference.
thd->fatal_error() may be called if we are out of memory
*/
void Item::split_sum_func2(THD *thd, Item **ref_pointer_array,
List<Item> &fields, Item **ref)
{
if (type() != SUM_FUNC_ITEM && with_sum_func)
{
/* Will split complicated items and ignore simple ones */
split_sum_func(thd, ref_pointer_array, fields);
}
else if ((type() == SUM_FUNC_ITEM ||
(used_tables() & ~PARAM_TABLE_BIT)) &&
type() != REF_ITEM)
{
/*
Replace item with a reference so that we can easily calculate
it (in case of sum functions) or copy it (in case of fields)
The test above is to ensure we don't do a reference for things
that are constants (PARAM_TABLE_BIT is in effect a constant)
or already referenced (for example an item in HAVING)
*/
uint el= fields.elements;
Item *new_item;
ref_pointer_array[el]= this;
if (!(new_item= new Item_ref(ref_pointer_array + el, 0, name)))
return; // fatal_error is set
fields.push_front(this);
ref_pointer_array[el]= this;
thd->change_item_tree(ref, new_item);
}
}
/*
Aggregate two collations together taking
into account their coercibility (aka derivation):
@ -2745,7 +2797,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item, TABLE *table)
bool use_new_field= 0, use_expression_type= 0;
Item_result new_result_type= type_convertor[item_type][item->result_type()];
Field *field= get_holder_example_field(thd, item, table);
bool item_is_a_field= field;
bool item_is_a_field= (field != NULL);
/*
Check if both items point to fields: in this case we
can adjust column types of result table in the union smartly.

View file

@ -262,6 +262,9 @@ public:
virtual void update_used_tables() {}
virtual void split_sum_func(THD *thd, Item **ref_pointer_array,
List<Item> &fields) {}
/* Called for items that really have to be split */
void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields,
Item **ref);
virtual bool get_date(TIME *ltime,uint fuzzydate);
virtual bool get_time(TIME *ltime);
virtual bool get_date_result(TIME *ltime,uint fuzzydate)

View file

@ -636,13 +636,12 @@ longlong Item_in_optimizer::val_int()
{
DBUG_ASSERT(fixed == 1);
cache->store(args[0]);
longlong tmp= args[1]->val_int_result();
if (cache->null_value)
{
if (tmp)
null_value= 1;
null_value= 1;
return 0;
}
longlong tmp= args[1]->val_int_result();
null_value= args[1]->null_value;
return tmp;
}
@ -1969,10 +1968,10 @@ bool Item_cond::walk(Item_processor processor, byte *arg)
Move SUM items out from item tree and replace with reference
SYNOPSIS
split_sum_func()
thd Thread handler
ref_pointer_array Pointer to array of reference fields
fields All fields in select
split_sum_func()
thd Thread handler
ref_pointer_array Pointer to array of reference fields
fields All fields in select
NOTES
This function is run on all expression (SELECT list, WHERE, HAVING etc)
@ -1982,16 +1981,6 @@ bool Item_cond::walk(Item_processor processor, byte *arg)
so that we can easily find and calculate them.
(Calculation done by update_sum_func() and copy_sum_funcs() in
sql_select.cc)
All found SUM items are added FIRST in the fields list and
we replace the item with a reference.
We also replace all functions without side effects (like RAND() or UDF's)
that uses columns as arguments.
For functions with side effects, we just remember any fields referred
by the function to ensure that we get a copy of the field value for the
first accepted row. This ensures that we can do things like
SELECT a*SUM(b) FROM t1 WHERE a=1
*/
void Item_cond::split_sum_func(THD *thd, Item **ref_pointer_array,
@ -1999,38 +1988,8 @@ void Item_cond::split_sum_func(THD *thd, Item **ref_pointer_array,
{
List_iterator<Item> li(list);
Item *item;
used_tables_cache=0;
const_item_cache=0;
while ((item=li++))
{
/* with_sum_func is set for items that contains a SUM expression */
if (item->type() != SUM_FUNC_ITEM &&
(item->with_sum_func ||
(item->used_tables() & PSEUDO_TABLE_BITS)))
item->split_sum_func(thd, ref_pointer_array, fields);
else if (item->type() == SUM_FUNC_ITEM ||
(item->used_tables() && item->type() != REF_ITEM))
{
/*
Replace item with a reference so that we can easily calculate
it (in case of sum functions) or copy it (in case of fields)
The test above is to ensure we don't do a reference for things
that are constants or are not yet calculated as in:
SELECT RAND() as r1, SUM(a) as r2 FROM t1 HAVING r1 > 1 AND r2 > 0
*/
Item **ref= li.ref();
uint el= fields.elements;
ref_pointer_array[el]= item;
Item *new_item= new Item_ref(ref_pointer_array + el, 0, item->name);
fields.push_front(item);
ref_pointer_array[el]= item;
thd->change_item_tree(ref, new_item);
}
item->update_used_tables();
used_tables_cache|=item->used_tables();
const_item_cache&=item->const_item();
}
while ((item= li++))
item->split_sum_func2(thd, ref_pointer_array, fields, li.ref());
}

View file

@ -352,28 +352,14 @@ bool Item_func::walk (Item_processor processor, byte *argument)
}
/* See comments in Item_cmp_func::split_sum_func() */
void Item_func::split_sum_func(THD *thd, Item **ref_pointer_array,
List<Item> &fields)
{
Item **arg, **arg_end;
for (arg= args, arg_end= args+arg_count; arg != arg_end ; arg++)
{
Item *item=* arg;
if (item->type() != SUM_FUNC_ITEM &&
(item->with_sum_func ||
(item->used_tables() & PSEUDO_TABLE_BITS)))
item->split_sum_func(thd, ref_pointer_array, fields);
else if (item->type() == SUM_FUNC_ITEM ||
(item->used_tables() && item->type() != REF_ITEM))
{
uint el= fields.elements;
ref_pointer_array[el]= item;
Item *new_item= new Item_ref(ref_pointer_array + el, 0, item->name);
fields.push_front(item);
ref_pointer_array[el]= item;
thd->change_item_tree(arg, new_item);
}
}
(*arg)->split_sum_func2(thd, ref_pointer_array, fields, arg);
}

View file

@ -90,25 +90,10 @@ void Item_row::split_sum_func(THD *thd, Item **ref_pointer_array,
{
Item **arg, **arg_end;
for (arg= items, arg_end= items+arg_count; arg != arg_end ; arg++)
{
Item *item= *arg;
if (item->type() != SUM_FUNC_ITEM &&
(item->with_sum_func ||
(item->used_tables() & PSEUDO_TABLE_BITS)))
item->split_sum_func(thd, ref_pointer_array, fields);
else if (item->type() == SUM_FUNC_ITEM ||
(item->used_tables() && item->type() != REF_ITEM))
{
uint el= fields.elements;
ref_pointer_array[el]=*arg;
Item *new_item= new Item_ref(ref_pointer_array + el, 0, (*arg)->name);
fields.push_front(*arg);
ref_pointer_array[el]= *arg;
thd->change_item_tree(arg, new_item);
}
}
(*arg)->split_sum_func2(thd, ref_pointer_array, fields, arg);
}
void Item_row::update_used_tables()
{
used_tables_cache= 0;

View file

@ -1758,20 +1758,7 @@ String *Item_func_elt::val_str(String *str)
void Item_func_make_set::split_sum_func(THD *thd, Item **ref_pointer_array,
List<Item> &fields)
{
if (item->type() != SUM_FUNC_ITEM &&
(item->with_sum_func ||
(item->used_tables() & PSEUDO_TABLE_BITS)))
item->split_sum_func(thd, ref_pointer_array, fields);
else if (item->type() == SUM_FUNC_ITEM ||
(item->used_tables() && item->type() != REF_ITEM))
{
uint el= fields.elements;
ref_pointer_array[el]=item;
Item *new_item= new Item_ref(ref_pointer_array + el, 0, item->name);
fields.push_front(item);
ref_pointer_array[el]= item;
thd->change_item_tree(&item, new_item);
}
item->split_sum_func2(thd, ref_pointer_array, fields, &item);
Item_str_func::split_sum_func(thd, ref_pointer_array, fields);
}

View file

@ -825,8 +825,6 @@ Item_in_subselect::single_value_transformer(JOIN *join,
select_lex->ref_pointer_array,
(char *)"<ref>",
this->full_name()));
if (!abort_on_null && left_expr->maybe_null)
item= new Item_cond_or(new Item_func_isnull(left_expr), item);
/*
AND and comparison functions can't be changed during fix_fields()
we can assign select_lex->having here, and pass 0 as last
@ -872,8 +870,6 @@ Item_in_subselect::single_value_transformer(JOIN *join,
select_lex->having_fix_field= 0;
item= new Item_cond_or(item,
new Item_func_isnull(orig_item));
if (left_expr->maybe_null)
item= new Item_cond_or(new Item_func_isnull(left_expr), item);
}
item->name= (char *)in_additional_cond;
/*
@ -894,13 +890,12 @@ Item_in_subselect::single_value_transformer(JOIN *join,
we can assign select_lex->having here, and pass 0 as last
argument (reference) to fix_fields()
*/
item= func->create(expr,
new Item_null_helper(this, item,
select_lex->having=
join->having=
func->create(expr,
new Item_null_helper(this, item,
(char *)"<no matter>",
(char *)"<result>"));
if (!abort_on_null && left_expr->maybe_null)
item= new Item_cond_or(new Item_func_isnull(left_expr), item);
select_lex->having= join->having= item;
select_lex->having_fix_field= 1;
if (join->having->fix_fields(thd, join->tables_list,
0))

View file

@ -1274,7 +1274,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
binlog_[wild_]{do|ignore}_table?" (WL#1049)"
*/
if ((thd && !(thd->options & OPTION_BIN_LOG)) ||
(local_db && !db_ok(local_db, binlog_do_db, binlog_ignore_db)))
(!db_ok(local_db, binlog_do_db, binlog_ignore_db)))
{
VOID(pthread_mutex_unlock(&LOCK_log));
DBUG_PRINT("error",("!db_ok('%s')", local_db));

View file

@ -147,6 +147,10 @@ int deny_severity = LOG_WARNING;
#include <sys/mman.h>
#endif
#define zVOLSTATE_ACTIVE 6
#define zVOLSTATE_DEACTIVE 2
#define zVOLSTATE_MAINTENANCE 3
#ifdef __NETWARE__
#include <nks/vm.h>
#include <library.h>
@ -1667,7 +1671,9 @@ ulong neb_event_callback(struct EventBlock *eblock)
voldata= (EventChangeVolStateEnter_s *)eblock->EBEventData;
/* Deactivation of a volume */
if ((voldata->oldState == 6 && voldata->newState == 2))
if ((voldata->oldState == zVOLSTATE_ACTIVE &&
voldata->newState == zVOLSTATE_DEACTIVE ||
voldata->newState == zVOLSTATE_MAINTENANCE))
{
/*
Ensure that we bring down MySQL server only for MySQL data

View file

@ -134,6 +134,15 @@ public:
if (!--elements)
last= &first;
}
inline void concat(base_list *list)
{
if (!list->is_empty())
{
*last= list->first;
last= list->last;
elements+= list->elements;
}
}
inline void *pop(void)
{
if (first == &end_of_list) return 0;

View file

@ -5289,6 +5289,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
keyinfo->key_length=(uint16) reclength;
keyinfo->name=(char*) "tmp";
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
keyinfo->rec_per_key=0;
if (null_pack_length)
{
key_part_info->null_bit=0;
@ -8502,6 +8503,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
res_selected_fields.empty();
res_all_fields.empty();
List_iterator_fast<Item> itr(res_all_fields);
List<Item> extra_funcs;
uint i, border= all_fields.elements - elements;
DBUG_ENTER("setup_copy_fields");
@ -8563,7 +8565,12 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
*/
if (!(pos=new Item_copy_string(pos)))
goto err;
if (param->copy_funcs.push_back(pos))
if (i < border) // HAVING, ORDER and GROUP BY
{
if (extra_funcs.push_back(pos))
goto err;
}
else if (param->copy_funcs.push_back(pos))
goto err;
}
res_all_fields.push_back(pos);
@ -8575,6 +8582,12 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
for (i= 0; i < border; i++)
itr++;
itr.sublist(res_selected_fields, elements);
/*
Put elements from HAVING, ORDER BY and GROUP BY last to ensure that any
reference used in these will resolve to a item that is already calculated
*/
param->copy_funcs.concat(&extra_funcs);
DBUG_RETURN(0);
err:

View file

@ -195,7 +195,6 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
goto err_not_open; /* purecov: inspected */
bzero((char*) keyinfo,n_length);
outparam->key_info=keyinfo;
outparam->max_key_length= outparam->total_key_length= 0;
key_part= my_reinterpret_cast(KEY_PART_INFO*) (keyinfo+keys);
strpos=disk_buff+6;
@ -251,11 +250,6 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
}
key_part->store_length=key_part->length;
}
set_if_bigger(outparam->max_key_length,keyinfo->key_length+
keyinfo->key_parts);
outparam->total_key_length+= keyinfo->key_length;
if (keyinfo->flags & HA_NOSAME)
set_if_bigger(outparam->max_unique_length,keyinfo->key_length);
}
keynames=(char*) key_part;
strpos+= (strmov(keynames, (char *) strpos) - keynames)+1;
@ -685,6 +679,12 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
}
}
keyinfo->usable_key_parts=usable_parts; // Filesort
set_if_bigger(outparam->max_key_length,keyinfo->key_length+
keyinfo->key_parts);
outparam->total_key_length+= keyinfo->key_length;
if (keyinfo->flags & HA_NOSAME)
set_if_bigger(outparam->max_unique_length,keyinfo->key_length);
}
if (primary_key < MAX_KEY &&
(outparam->keys_in_use.is_set(primary_key)))

View file

@ -1480,6 +1480,29 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs,
return 0;
}
ulong my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *str, const char *end, int sequence_type)
{
const char *str0= str;
end--; /* for easier loop condition, because of two bytes per character */
switch (sequence_type)
{
case MY_SEQ_SPACES:
for ( ; str < end; str+= 2)
{
if (str[0] != '\0' || str[1] != ' ')
break;
}
return str - str0;
default:
return 0;
}
}
static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler =
{
NULL, /* init */
@ -1534,7 +1557,7 @@ MY_CHARSET_HANDLER my_charset_ucs2_handler=
my_strntoull_ucs2,
my_strntod_ucs2,
my_strtoll10_ucs2,
my_scan_8bit
my_scan_ucs2
};

View file

@ -24,6 +24,7 @@
#include <my_global.h>
#include <my_sys.h>
#include <mysql.h>
#include <errmsg.h>
#include <my_getopt.h>
#include <m_string.h>
@ -11532,6 +11533,78 @@ static void test_bug6761(void)
myquery(rc);
}
/* Bug#8330 - mysql_stmt_execute crashes (libmysql) */
static void test_bug8330()
{
const char *stmt_text;
MYSQL_STMT *stmt[2];
int i, rc;
char *query= "select a,b from t1 where a=?";
MYSQL_BIND bind[2];
long lval[2];
myheader("test_bug8330");
stmt_text= "drop table if exists t1";
/* in case some previos test failed */
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
stmt_text= "create table t1 (a int, b int)";
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
bzero(bind, sizeof(bind));
for (i=0; i < 2; i++)
{
stmt[i]= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt[i], query, strlen(query));
check_execute(stmt[i], rc);
bind[i].buffer_type= MYSQL_TYPE_LONG;
bind[i].buffer= (void*) &lval[i];
bind[i].is_null= 0;
mysql_stmt_bind_param(stmt[i], &bind[i]);
}
rc= mysql_stmt_execute(stmt[0]);
check_execute(stmt[0], rc);
rc= mysql_stmt_execute(stmt[1]);
DIE_UNLESS(rc && mysql_stmt_errno(stmt[1]) == CR_COMMANDS_OUT_OF_SYNC);
rc= mysql_stmt_execute(stmt[0]);
check_execute(stmt[0], rc);
mysql_stmt_close(stmt[0]);
mysql_stmt_close(stmt[1]);
stmt_text= "drop table t1";
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
}
/* Bug#7990 - mysql_stmt_close doesn't reset mysql->net.last_error */
static void test_bug7990()
{
MYSQL_STMT *stmt;
int rc;
myheader("test_bug7990");
stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, "foo", 3);
/*
XXX: the fact that we store errno both in STMT and in
MYSQL is not documented and is subject to change in 5.0
*/
DIE_UNLESS(rc && mysql_stmt_errno(stmt) && mysql_errno(mysql));
mysql_stmt_close(stmt);
DIE_UNLESS(!mysql_errno(mysql));
}
/*
Read and parse arguments and MySQL options from my.cnf
*/
@ -11739,6 +11812,8 @@ static struct my_tests_st my_tests[]= {
{ "test_conversion", test_conversion },
{ "test_rewind", test_rewind },
{ "test_bug6761", test_bug6761 },
{ "test_bug8330", test_bug8330 },
{ "test_bug7990", test_bug7990 },
{ 0, 0 }
};