Commit e3c25c50 authored by unknown's avatar unknown

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

into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1
parents a3184baf 7602fec8
......@@ -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+
......
......@@ -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)
{
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......
......@@ -417,7 +417,7 @@ row_create_prebuilt(
prebuilt->sel_graph = NULL;
prebuilt->search_tuple = dtuple_create(heap,
dict_table_get_n_cols(table));
2 * dict_table_get_n_cols(table));
clust_index = dict_table_get_first_index(table);
......
......@@ -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 */
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
......@@ -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
......
......@@ -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%";
......
......@@ -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;
......@@ -1173,3 +1173,25 @@ show columns from t4;
Field Type Null Key Default Extra
sdate date YES NULL
drop table t1, t2, t3, t4;
create table t1 (a int not null, b char (10) not null);
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
select * from ((select * from t1 limit 1)) a;
a b
1 a
select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a;
a b
1 a
select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union (select * from t1 limit 1)) a;
a b
1 a
select * from ((((select * from t1))) union (select * from t1) union (select * from t1)) a;
a b
1 a
2 b
3 c
select * from ((select * from t1) union (((select * from t1))) union (select * from t1)) a;
a b
1 a
2 b
3 c
drop table t1;
......@@ -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;
......@@ -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;
......@@ -699,3 +699,15 @@ union
order by sdate;
show columns from t4;
drop table t1, t2, t3, t4;
#
# Bug #2435 UNION with parentheses not supported
#
create table t1 (a int not null, b char (10) not null);
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
select * from ((select * from t1 limit 1)) a;
select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a;
select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union (select * from t1 limit 1)) a;
select * from ((((select * from t1))) union (select * from t1) union (select * from t1)) a;
select * from ((select * from t1) union (((select * from t1))) union (select * from t1)) a;
drop table t1;
......@@ -163,9 +163,7 @@ then
INSERT INTO user (host,user) values ('localhost','');"
else
i_u="$i_u
INSERT INTO user VALUES ('%','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
INSERT INTO user VALUES ('%','','','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0);"
INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);"
fi
fi
fi
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -2797,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.
......
......@@ -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));
......
......@@ -1421,7 +1421,7 @@ ulong Query_cache::init_cache()
init();
approx_additional_data_size = (sizeof(Query_cache) +
sizeof(gptr)*(def_query_hash_size+
def_query_hash_size));
def_table_hash_size));
if (query_cache_size < approx_additional_data_size)
goto err;
......
......@@ -2389,7 +2389,10 @@ select:
select_init:
SELECT_SYM select_init2
|
'(' SELECT_SYM select_part2 ')'
'(' select_paren ')' union_opt;
select_paren:
SELECT_SYM select_part2
{
LEX *lex= Lex;
SELECT_LEX * sel= lex->current_select;
......@@ -2408,7 +2411,8 @@ select_init:
if (sel->master_unit()->fake_select_lex)
sel->master_unit()->global_parameters=
sel->master_unit()->fake_select_lex;
} union_opt;
}
| '(' select_paren ')';
select_init2:
select_part2
......@@ -3404,8 +3408,7 @@ when_list2:
};
join_table_list:
'(' join_table_list ')' { $$=$2; }
| join_table { $$=$1; }
join_table { $$=$1; }
| join_table_list ',' join_table_list { $$=$3; }
| join_table_list normal_join join_table_list { $$=$3; }
| join_table_list STRAIGHT_JOIN join_table_list
......@@ -3482,7 +3485,7 @@ join_table:
}
| '{' ident join_table LEFT OUTER JOIN_SYM join_table ON expr '}'
{ add_join_on($7,$9); $7->outer_join|=JOIN_TYPE_LEFT; $$=$7; }
| '(' SELECT_SYM select_derived ')' opt_table_alias
| '(' select_derived union_opt ')' opt_table_alias
{
LEX *lex=Lex;
SELECT_LEX_UNIT *unit= lex->current_select->master_unit();
......@@ -3493,9 +3496,27 @@ join_table:
(List<String> *)0)))
YYABORT;
};
}
| '(' join_table_list ')' { $$=$2; };
select_derived:
SELECT_SYM select_derived2
| '(' select_derived ')'
{
LEX *lex= Lex;
SELECT_LEX * sel= lex->current_select;
if (sel->set_braces(1))
{
yyerror(ER(ER_SYNTAX_ERROR));
YYABORT;
}
/* select in braces, can't contain global parameters */
if (sel->master_unit()->fake_select_lex)
sel->master_unit()->global_parameters=
sel->master_unit()->fake_select_lex;
};
select_derived2:
{
LEX *lex= Lex;
lex->derived_tables= 1;
......@@ -3517,7 +3538,7 @@ select_derived:
{
Select->parsing_place= NO_MATTER;
}
opt_select_from union_opt
opt_select_from
;
opt_outer:
......
......@@ -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)))
......
......@@ -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
};
......
......@@ -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 }
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment