Merge from mysql-5.1-bugteam.

This commit is contained in:
Davi Arnaut 2009-08-11 11:29:07 -03:00
commit 6fe39a9350
16 changed files with 1616 additions and 33 deletions

1249
README

File diff suppressed because it is too large Load diff

View file

@ -70,12 +70,16 @@ AC_CHECK_HEADERS(wctype.h)
AC_CHECK_HEADERS(wchar.h)
AC_CHECK_HEADERS(langinfo.h)
AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE([HAVE_MBSRTOWCS],[],[Define if you have mbsrtowcs]))
AC_CHECK_FUNC(mbrtowc, AC_DEFINE([HAVE_MBRTOWC],[],[Define if you have mbrtowc]))
AC_CHECK_FUNC(mbrlen, AC_DEFINE([HAVE_MBRLEN],[],[Define if you have mbrlen]))
AC_CHECK_FUNC(wctomb, AC_DEFINE([HAVE_WCTOMB],[],[Define if you have wctomb]))
AC_CHECK_FUNC(wcwidth, AC_DEFINE([HAVE_WCWIDTH],[],[Define if you have wcwidth]))
AC_CHECK_FUNC(wcsdup, AC_DEFINE([HAVE_WCSDUP],[],[Define if you check wcsdup]))
AC_CHECK_FUNC(mbrlen, AC_DEFINE(HAVE_MBRLEN,[],[Define if you have mbrlen]))
AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP,[],[Define if you have mbscmp]))
AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS,[],[Define if you have mbsrtowcs]))
AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB,[],[Define if you have wcrtomb]))
AC_CHECK_FUNC(mbrtowc, AC_DEFINE(HAVE_MBRTOWC,[],[Define if you have mbrtowc]))
AC_CHECK_FUNC(wcscoll, AC_DEFINE(HAVE_WCSCOLL,[],[Define if you have wcscoll]))
AC_CHECK_FUNC(wcsdup, AC_DEFINE(HAVE_WCSDUP,[],[Define if you have wcsdup]))
AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH,[],[Define if you have wcwidth]))
AC_CHECK_FUNC(wctype, AC_DEFINE(HAVE_WCTYPE,[],[Define if you have wctype]))
AC_CACHE_CHECK([for mbstate_t], mysql_cv_have_mbstate_t,
[AC_TRY_COMPILE([
@ -88,6 +92,8 @@ if test $mysql_cv_have_mbstate_t = yes; then
AC_DEFINE([HAVE_MBSTATE_T],[],[Define if mysql_cv_have_mbstate_t=yes])
fi
AC_CHECK_FUNCS(iswlower iswupper towlower towupper iswctype)
AC_CACHE_CHECK([for nl_langinfo and CODESET], mysql_cv_langinfo_codeset,
[AC_TRY_LINK(
[#include <langinfo.h>],
@ -97,4 +103,41 @@ if test $mysql_cv_langinfo_codeset = yes; then
AC_DEFINE([HAVE_LANGINFO_CODESET],[],[Define if mysql_cv_langinfo_codeset=yes])
fi
dnl check for wchar_t in <wchar.h>
AC_CACHE_CHECK([for wchar_t in wchar.h], bash_cv_type_wchar_t,
[AC_TRY_COMPILE(
[#include <wchar.h>
],
[
wchar_t foo;
foo = 0;
], bash_cv_type_wchar_t=yes, bash_cv_type_wchar_t=no)])
if test $bash_cv_type_wchar_t = yes; then
AC_DEFINE(HAVE_WCHAR_T, 1, [systems should define this type here])
fi
dnl check for wctype_t in <wctype.h>
AC_CACHE_CHECK([for wctype_t in wctype.h], bash_cv_type_wctype_t,
[AC_TRY_COMPILE(
[#include <wctype.h>],
[
wctype_t foo;
foo = 0;
], bash_cv_type_wctype_t=yes, bash_cv_type_wctype_t=no)])
if test $bash_cv_type_wctype_t = yes; then
AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here])
fi
dnl check for wint_t in <wctype.h>
AC_CACHE_CHECK([for wint_t in wctype.h], bash_cv_type_wint_t,
[AC_TRY_COMPILE(
[#include <wctype.h>],
[
wint_t foo;
foo = 0;
], bash_cv_type_wint_t=yes, bash_cv_type_wint_t=no)])
if test $bash_cv_type_wint_t = yes; then
AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here])
fi
])

View file

@ -165,7 +165,7 @@ CREATE TABLE `good
ERROR HY000: Invalid utf8 character string: 'ÐÌÏÈÏ'
SET NAMES utf8;
CREATE TABLE `goodÐÌÏÈÏ` (a int);
ERROR HY000: Invalid utf8 character string: 'ÐÌÏÈÏ` (a int)'
ERROR HY000: Invalid utf8 character string: 'ÐÌÏÈÏ'
set names latin1;
create table t1 (a char(10) character set koi8r, b text character set koi8r);
insert into t1 values ('test','test');

View file

@ -1500,3 +1500,60 @@ id1
15
16
DROP TABLE t1;
CREATE TABLE t1 (
a INT,
b INT NOT NULL,
c char(100),
KEY (b, c),
KEY (b, a, c)
)
DEFAULT CHARSET = utf8;
INSERT INTO t1 VALUES
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9);
INSERT INTO t1 SELECT a + 10, b, c FROM t1;
INSERT INTO t1 SELECT a + 20, b, c FROM t1;
INSERT INTO t1 SELECT a + 40, b, c FROM t1;
INSERT INTO t1 SELECT a + 80, b, c FROM t1;
INSERT INTO t1 SELECT a + 160, b, c FROM t1;
INSERT INTO t1 SELECT a + 320, b, c FROM t1;
INSERT INTO t1 SELECT a + 640, b, c FROM t1;
INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80;
EXPLAIN
SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b,b_2 b 4 NULL 226 Using where
SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
a
2071
2061
2051
2041
2031
2021
2011
2001
1991
EXPLAIN
SELECT DISTINCT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 0, 9;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b,b_2 b 4 NULL 226 Using where; Using temporary
SELECT DISTINCT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 0, 9;
a
2071
2061
2051
2041
2031
2021
2011
2001
1991
DROP TABLE t1;

View file

@ -1985,4 +1985,23 @@ CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM
PARTITION BY HASH(id) PARTITIONS 2;
DROP TABLE t1;
SET SESSION SQL_MODE=DEFAULT;
#
# BUG#45816 - assertion failure with index containing double
# column on partitioned table
#
CREATE TABLE t1 (
a INT DEFAULT NULL,
b DOUBLE DEFAULT NULL,
c INT DEFAULT NULL,
KEY idx2(b,a)
) PARTITION BY HASH(c) PARTITIONS 3;
INSERT INTO t1 VALUES (6,8,9);
INSERT INTO t1 VALUES (6,8,10);
SELECT 1 FROM t1 JOIN t1 AS t2 USING (a) FOR UPDATE;
1
1
1
1
1
DROP TABLE t1;
End of 5.1 tests

View file

@ -1361,3 +1361,44 @@ DROP TABLE t1;
#
# Bug#46454: MySQL wrong index optimisation leads to incorrect result & crashes
#
CREATE TABLE t1 (
a INT,
b INT NOT NULL,
c char(100),
KEY (b, c),
KEY (b, a, c)
)
DEFAULT CHARSET = utf8;
INSERT INTO t1 VALUES
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9);
INSERT INTO t1 SELECT a + 10, b, c FROM t1;
INSERT INTO t1 SELECT a + 20, b, c FROM t1;
INSERT INTO t1 SELECT a + 40, b, c FROM t1;
INSERT INTO t1 SELECT a + 80, b, c FROM t1;
INSERT INTO t1 SELECT a + 160, b, c FROM t1;
INSERT INTO t1 SELECT a + 320, b, c FROM t1;
INSERT INTO t1 SELECT a + 640, b, c FROM t1;
INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80;
EXPLAIN
SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
EXPLAIN
SELECT DISTINCT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 0, 9;
SELECT DISTINCT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 0, 9;
DROP TABLE t1;

View file

@ -1979,4 +1979,23 @@ CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM
DROP TABLE t1;
SET SESSION SQL_MODE=DEFAULT;
--echo #
--echo # BUG#45816 - assertion failure with index containing double
--echo # column on partitioned table
--echo #
CREATE TABLE t1 (
a INT DEFAULT NULL,
b DOUBLE DEFAULT NULL,
c INT DEFAULT NULL,
KEY idx2(b,a)
) PARTITION BY HASH(c) PARTITIONS 3;
INSERT INTO t1 VALUES (6,8,9);
INSERT INTO t1 VALUES (6,8,10);
SELECT 1 FROM t1 JOIN t1 AS t2 USING (a) FOR UPDATE;
DROP TABLE t1;
--echo End of 5.1 tests

View file

@ -517,3 +517,111 @@
fun:dlopen*
}
#
# BUG#45630
# Suppress valgrind failures within nptl_pthread_exit_hack_handler on Ubuntu 9.04, x86 (but not amd64)
#
{
Mem loss within nptl_pthread_exit_hack_handler 1
Memcheck:Leak
fun:malloc
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/libc-*.so
obj:*/ld-*.so
fun:__libc_dlopen_mode
fun:pthread_cancel_init
fun:_Unwind_ForcedUnwind
fun:__pthread_unwind
fun:pthread_exit
fun:nptl_pthread_exit_hack_handler
fun:start_thread
fun:clone
}
{
Mem loss within nptl_pthread_exit_hack_handler 2
Memcheck:Leak
fun:malloc
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/libc-*.so
obj:*/ld-*.so
fun:__libc_dlopen_mode
fun:pthread_cancel_init
fun:_Unwind_ForcedUnwind
fun:__pthread_unwind
fun:pthread_exit
fun:nptl_pthread_exit_hack_handler
fun:start_thread
fun:clone
}
{
Mem loss within nptl_pthread_exit_hack_handler 3
Memcheck:Leak
fun:calloc
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/libc-*.so
obj:*/ld-*.so
fun:__libc_dlopen_mode
fun:pthread_cancel_init
fun:_Unwind_ForcedUnwind
fun:__pthread_unwind
fun:pthread_exit
fun:nptl_pthread_exit_hack_handler
fun:start_thread
fun:clone
}
{
Mem loss within nptl_pthread_exit_hack_handler 4
Memcheck:Leak
fun:malloc
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/libc-*.so
obj:*/ld-*.so
fun:__libc_dlopen_mode
fun:pthread_cancel_init
fun:_Unwind_ForcedUnwind
fun:__pthread_unwind
fun:pthread_exit
fun:nptl_pthread_exit_hack_handler
fun:start_thread
}
{
Mem loss within nptl_pthread_exit_hack_handler 5
Memcheck:Leak
fun:calloc
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/ld-*.so
obj:*/libc-*.so
obj:*/ld-*.so
fun:__libc_dlopen_mode
fun:pthread_cancel_init
fun:_Unwind_ForcedUnwind
fun:__pthread_unwind
fun:pthread_exit
fun:nptl_pthread_exit_hack_handler
fun:start_thread
}

View file

@ -4598,7 +4598,6 @@ bool Field_double::send_binary(Protocol *protocol)
int Field_double::cmp(const uchar *a_ptr, const uchar *b_ptr)
{
ASSERT_COLUMN_MARKED_FOR_READ;
double a,b;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)

View file

@ -3730,7 +3730,7 @@ int ha_partition::index_init(uint inx, bool sorted)
*/
if (m_lock_type == F_WRLCK)
bitmap_union(table->read_set, &m_part_info->full_part_field_set);
else if (sorted)
if (sorted)
{
/*
An ordered scan is requested. We must make sure all fields of the

View file

@ -4588,15 +4588,28 @@ default_service_handling(char **argv,
const char *account_name)
{
char path_and_service[FN_REFLEN+FN_REFLEN+32], *pos, *end;
const char *opt_delim;
end= path_and_service + sizeof(path_and_service)-3;
/* We have to quote filename if it contains spaces */
pos= add_quoted_string(path_and_service, file_path, end);
if (*extra_opt)
{
/* Add (possible quoted) option after file_path */
/*
Add option after file_path. There will be zero or one extra option. It's
assumed to be --defaults-file=file but isn't checked. The variable (not
the option name) should be quoted if it contains a string.
*/
*pos++= ' ';
pos= add_quoted_string(pos, extra_opt, end);
if (opt_delim= strchr(extra_opt, '='))
{
size_t length= ++opt_delim - extra_opt;
strnmov(pos, extra_opt, length);
}
else
opt_delim= extra_opt;
pos= add_quoted_string(pos, opt_delim, end);
}
/* We must have servicename last */
*pos++= ' ';

View file

@ -1105,9 +1105,12 @@ int MYSQLlex(void *arg, void *yythd)
}
}
#ifdef USE_MB
else if (var_length < 1)
break; // Error
else if (use_mb(cs))
{
if ((var_length= my_ismbchar(cs, lip->get_ptr() - 1,
lip->get_end_of_query())))
lip->skip_binary(var_length-1);
}
#endif
}
if (double_quotes)

View file

@ -1190,7 +1190,7 @@ public:
Get a character, and advance in the stream.
@return the next character to parse.
*/
char yyGet()
unsigned char yyGet()
{
char c= *m_ptr++;
if (m_echo)
@ -1202,7 +1202,7 @@ public:
Get the last character accepted.
@return the last character accepted.
*/
char yyGetLast()
unsigned char yyGetLast()
{
return m_ptr[-1];
}
@ -1210,7 +1210,7 @@ public:
/**
Look at the next character to parse, but do not accept it.
*/
char yyPeek()
unsigned char yyPeek()
{
return m_ptr[0];
}
@ -1219,7 +1219,7 @@ public:
Look ahead at some character to parse.
@param n offset of the character to look up
*/
char yyPeekn(int n)
unsigned char yyPeekn(int n)
{
return m_ptr[n];
}

View file

@ -6151,7 +6151,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
}
}
if (tmp || !cond)
if (tmp || !cond || tab->type == JT_REF)
{
DBUG_EXECUTE("where",print_where(tmp,tab->table->alias, QT_ORDINARY););
SQL_SELECT *sel= tab->select= ((SQL_SELECT*)
@ -6165,7 +6165,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
The guard will turn the predicate on only after
the first match for outer tables is encountered.
*/
if (cond)
if (cond && tmp)
{
/*
Because of QUICK_GROUP_MIN_MAX_SELECT there may be a select without
@ -12946,6 +12946,8 @@ find_field_in_item_list (Field *field, void *data)
The index must cover all fields in <order>, or it will not be considered.
@param no_changes No changes will be made to the query plan.
@todo
- sergeyp: Results of all index merge selects actually are ordered
by clustered PK values.
@ -13280,6 +13282,15 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
}
if (!no_changes)
{
/*
If ref_key used index tree reading only ('Using index' in EXPLAIN),
and best_key doesn't, then revert the decision.
*/
if (!table->covering_keys.is_set(best_key) && table->key_read)
{
table->key_read= 0;
table->file->extra(HA_EXTRA_NO_KEYREAD);
}
if (!quick_created)
{
tab->index= best_key;
@ -13296,16 +13307,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
table->key_read=1;
table->file->extra(HA_EXTRA_KEYREAD);
}
else if (table->key_read)
{
/*
Clear the covering key read flags that might have been
previously set for some key other than the current best_key.
*/
table->key_read= 0;
table->file->extra(HA_EXTRA_NO_KEYREAD);
}
table->file->ha_index_or_rnd_end();
if (join->select_options & SELECT_DESCRIBE)
{

View file

@ -755,7 +755,13 @@ struct st_table {
*/
my_bool force_index;
my_bool distinct,const_table,no_rows;
my_bool key_read, no_keyread;
/**
If set, the optimizer has found that row retrieval should access index
tree only.
*/
my_bool key_read;
my_bool no_keyread;
/*
Placeholder for an open table which prevents other connections
from taking name-locks on this table. Typically used with

View file

@ -17947,6 +17947,34 @@ static void test_bug41078(void)
DBUG_VOID_RETURN;
}
/**
Bug#45010: invalid memory reads during parsing some strange statements
*/
static void test_bug45010()
{
int rc;
const char query1[]= "select a.\x80",
query2[]= "describe `table\xef";
DBUG_ENTER("test_bug45010");
myheader("test_bug45010");
rc= mysql_query(mysql, "set names utf8");
myquery(rc);
/* \x80 (-128) could be used as a index of ident_map. */
rc= mysql_real_query(mysql, query1, sizeof(query1) - 1);
DIE_UNLESS(rc);
/* \xef (-17) could be used to skip 3 bytes past the buffer end. */
rc= mysql_real_query(mysql, query2, sizeof(query2) - 1);
DIE_UNLESS(rc);
rc= mysql_query(mysql, "set names default");
myquery(rc);
DBUG_VOID_RETURN;
}
/**
Bug#44495: Prepared Statement:
@ -18301,6 +18329,7 @@ static struct my_tests_st my_tests[]= {
{ "test_change_user", test_change_user },
{ "test_bug30472", test_bug30472 },
{ "test_bug20023", test_bug20023 },
{ "test_bug45010", test_bug45010 },
{ "test_bug31418", test_bug31418 },
{ "test_bug31669", test_bug31669 },
{ "test_bug28386", test_bug28386 },