Commit d6a7de20 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

Merge branch '5.5' into 10.0

parents a8700998 e7bb8181
...@@ -751,8 +751,7 @@ sub run_test_server ($$$) { ...@@ -751,8 +751,7 @@ sub run_test_server ($$$) {
# Repeat test $opt_repeat number of times # Repeat test $opt_repeat number of times
my $repeat= $result->{repeat} || 1; my $repeat= $result->{repeat} || 1;
# Don't repeat if test was skipped if ($repeat < $opt_repeat)
if ($repeat < $opt_repeat && $result->{'result'} ne 'MTR_RES_SKIPPED')
{ {
$result->{retries}= 0; $result->{retries}= 0;
$result->{rep_failures}++ if $result->{failures}; $result->{rep_failures}++ if $result->{failures};
......
...@@ -106,3 +106,28 @@ count(distinct user_id) ...@@ -106,3 +106,28 @@ count(distinct user_id)
17 17
drop table t1; drop table t1;
set @@tmp_table_size = default; set @@tmp_table_size = default;
create table t1 (
a VARCHAR(1020),
b int
);
insert into t1 values
( 0 , 1 ),
( 1 , 2 ),
( 2 , 3 ),
( 3 , 4 ),
( 4 , 5 ),
( 5 , 6 ),
( 6 , 7 ),
( 7 , 8 ),
( 8 , 9 ),
( 9 , 10 ),
( 0 , 11 ),
( 1 , 12 ),
( 2 , 13 ),
( 3 , 14 );
set @@tmp_table_size=1024;
select count(distinct a) from t1;
count(distinct a)
10
drop table t1;
set @@tmp_table_size = default;
set @log_output.saved = @@global.log_output;
set @@global.log_output = 'TABLE'; set @@global.log_output = 'TABLE';
set session long_query_time=10; set session long_query_time=10;
select get_lock('bug27638', 1); select get_lock('bug27638', 1);
...@@ -7,25 +8,25 @@ set session long_query_time=1; ...@@ -7,25 +8,25 @@ set session long_query_time=1;
select get_lock('bug27638', 2); select get_lock('bug27638', 2);
get_lock('bug27638', 2) get_lock('bug27638', 2)
0 0
select if (query_time >= '00:00:01', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log select if (query_time >= '00:00:01', 'OK', concat('WRONG: ',query_time)) as qt, sql_text from mysql.slow_log
where sql_text = 'select get_lock(\'bug27638\', 2)'; where sql_text = 'select get_lock(\'bug27638\', 2)';
qt sql_text qt sql_text
OK select get_lock('bug27638', 2) OK select get_lock('bug27638', 2)
select get_lock('bug27638', 60); select get_lock('bug27638', 60);
get_lock('bug27638', 60) get_lock('bug27638', 60)
0 0
select if (query_time >= '00:00:59', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log select if (query_time >= '00:00:59', 'OK', concat('WRONG: ',query_time)) as qt, sql_text from mysql.slow_log
where sql_text = 'select get_lock(\'bug27638\', 60)'; where sql_text = 'select get_lock(\'bug27638\', 60)';
qt sql_text qt sql_text
OK select get_lock('bug27638', 60) OK select get_lock('bug27638', 60)
select get_lock('bug27638', 101); select get_lock('bug27638', 101);
get_lock('bug27638', 101) get_lock('bug27638', 101)
0 0
select if (query_time >= '00:01:40', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log select if (query_time >= '00:01:40', 'OK', concat('WRONG: ',query_time)) as qt, sql_text from mysql.slow_log
where sql_text = 'select get_lock(\'bug27638\', 101)'; where sql_text = 'select get_lock(\'bug27638\', 101)';
qt sql_text qt sql_text
OK select get_lock('bug27638', 101) OK select get_lock('bug27638', 101)
select release_lock('bug27638'); select release_lock('bug27638');
release_lock('bug27638') release_lock('bug27638')
1 1
set @@global.log_output=default; set @@global.log_output = @log_output.saved;
...@@ -5627,9 +5627,6 @@ CREATE TABLE t3 (a INT); ...@@ -5627,9 +5627,6 @@ CREATE TABLE t3 (a INT);
CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.a FROM t3 AS t1, t3 AS t2; CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.a FROM t3 AS t1, t3 AS t2;
CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1; CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1;
PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3'; PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3';
EXECUTE stmt;
ERROR HY000: Can not insert into join view 'test.v2' without fields list
EXECUTE stmt;
ERROR HY000: Can not insert into join view 'test.v2' without fields list ERROR HY000: Can not insert into join view 'test.v2' without fields list
drop view v1,v2; drop view v1,v2;
drop table t3; drop table t3;
......
...@@ -120,6 +120,35 @@ select count(distinct user_id) from t1; ...@@ -120,6 +120,35 @@ select count(distinct user_id) from t1;
drop table t1; drop table t1;
set @@tmp_table_size = default; set @@tmp_table_size = default;
#
# MDEV-13457: Wrong result for aggregate function with distinct clause when the value for
# tmp_table_size is small
#
create table t1 (
a VARCHAR(1020),
b int
);
insert into t1 values
( 0 , 1 ),
( 1 , 2 ),
( 2 , 3 ),
( 3 , 4 ),
( 4 , 5 ),
( 5 , 6 ),
( 6 , 7 ),
( 7 , 8 ),
( 8 , 9 ),
( 9 , 10 ),
( 0 , 11 ),
( 1 , 12 ),
( 2 , 13 ),
( 3 , 14 );
set @@tmp_table_size=1024;
select count(distinct a) from t1;
drop table t1;
set @@tmp_table_size = default;
# #
# End of 5.5 tests # End of 5.5 tests
# #
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
# check that CSV engine was compiled in # check that CSV engine was compiled in
--source include/have_csv.inc --source include/have_csv.inc
set @log_output.saved = @@global.log_output;
set @@global.log_output = 'TABLE'; set @@global.log_output = 'TABLE';
connect (con1,localhost,root,,); connect (con1,localhost,root,,);
...@@ -21,13 +22,13 @@ select get_lock('bug27638', 1); ...@@ -21,13 +22,13 @@ select get_lock('bug27638', 1);
connection con2; connection con2;
set session long_query_time=1; set session long_query_time=1;
select get_lock('bug27638', 2); select get_lock('bug27638', 2);
select if (query_time >= '00:00:01', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log select if (query_time >= '00:00:01', 'OK', concat('WRONG: ',query_time)) as qt, sql_text from mysql.slow_log
where sql_text = 'select get_lock(\'bug27638\', 2)'; where sql_text = 'select get_lock(\'bug27638\', 2)';
select get_lock('bug27638', 60); select get_lock('bug27638', 60);
select if (query_time >= '00:00:59', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log select if (query_time >= '00:00:59', 'OK', concat('WRONG: ',query_time)) as qt, sql_text from mysql.slow_log
where sql_text = 'select get_lock(\'bug27638\', 60)'; where sql_text = 'select get_lock(\'bug27638\', 60)';
select get_lock('bug27638', 101); select get_lock('bug27638', 101);
select if (query_time >= '00:01:40', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log select if (query_time >= '00:01:40', 'OK', concat('WRONG: ',query_time)) as qt, sql_text from mysql.slow_log
where sql_text = 'select get_lock(\'bug27638\', 101)'; where sql_text = 'select get_lock(\'bug27638\', 101)';
connection con1; connection con1;
select release_lock('bug27638'); select release_lock('bug27638');
...@@ -36,4 +37,4 @@ connection default; ...@@ -36,4 +37,4 @@ connection default;
disconnect con1; disconnect con1;
disconnect con2; disconnect con2;
set @@global.log_output=default; set @@global.log_output = @log_output.saved;
...@@ -5573,11 +5573,8 @@ drop table t1,t2,t3; ...@@ -5573,11 +5573,8 @@ drop table t1,t2,t3;
CREATE TABLE t3 (a INT); CREATE TABLE t3 (a INT);
CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.a FROM t3 AS t1, t3 AS t2; CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.a FROM t3 AS t1, t3 AS t2;
CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1; CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1;
PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3';
--error ER_VIEW_NO_INSERT_FIELD_LIST
EXECUTE stmt;
--error ER_VIEW_NO_INSERT_FIELD_LIST --error ER_VIEW_NO_INSERT_FIELD_LIST
EXECUTE stmt; PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3';
drop view v1,v2; drop view v1,v2;
drop table t3; drop table t3;
......
...@@ -4617,7 +4617,7 @@ class Unique :public Sql_alloc ...@@ -4617,7 +4617,7 @@ class Unique :public Sql_alloc
{ {
DBUG_ENTER("unique_add"); DBUG_ENTER("unique_add");
DBUG_PRINT("info", ("tree %u - %lu", tree.elements_in_tree, max_elements)); DBUG_PRINT("info", ("tree %u - %lu", tree.elements_in_tree, max_elements));
if (!(tree.flag & TREE_ONLY_DUPS) && if (!(tree.flag & TREE_ONLY_DUPS) &&
tree.elements_in_tree >= max_elements && flush()) tree.elements_in_tree >= max_elements && flush())
DBUG_RETURN(1); DBUG_RETURN(1);
DBUG_RETURN(!tree_insert(&tree, ptr, 0, tree.custom_arg)); DBUG_RETURN(!tree_insert(&tree, ptr, 0, tree.custom_arg));
......
...@@ -520,6 +520,8 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived) ...@@ -520,6 +520,8 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived)
derived->merge_underlying_list != 0)); derived->merge_underlying_list != 0));
if (derived->merged_for_insert) if (derived->merged_for_insert)
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
if (derived->init_derived(thd, FALSE))
DBUG_RETURN(TRUE);
if (derived->is_materialized_derived()) if (derived->is_materialized_derived())
DBUG_RETURN(mysql_derived_prepare(thd, lex, derived)); DBUG_RETURN(mysql_derived_prepare(thd, lex, derived));
if ((thd->lex->sql_command == SQLCOM_UPDATE_MULTI || if ((thd->lex->sql_command == SQLCOM_UPDATE_MULTI ||
...@@ -537,8 +539,6 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived) ...@@ -537,8 +539,6 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived)
DBUG_ASSERT(derived->table); DBUG_ASSERT(derived->table);
} }
} }
else
derived->table= derived->merge_underlying_list->table;
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
......
...@@ -100,6 +100,9 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg, ...@@ -100,6 +100,9 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
*/ */
max_elements= (ulong) (max_in_memory_size / max_elements= (ulong) (max_in_memory_size /
ALIGN_SIZE(sizeof(TREE_ELEMENT)+size)); ALIGN_SIZE(sizeof(TREE_ELEMENT)+size));
if (!max_elements)
max_elements= 1;
(void) open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, (void) open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE,
MYF(MY_WME)); MYF(MY_WME));
} }
...@@ -643,11 +646,12 @@ bool Unique::walk(TABLE *table, tree_walk_action action, void *walk_action_arg) ...@@ -643,11 +646,12 @@ bool Unique::walk(TABLE *table, tree_walk_action action, void *walk_action_arg)
if (flush_io_cache(&file) || reinit_io_cache(&file, READ_CACHE, 0L, 0, 0)) if (flush_io_cache(&file) || reinit_io_cache(&file, READ_CACHE, 0L, 0, 0))
return 1; return 1;
/* /*
merge_buffer must fit at least MERGEBUFF2 keys, because merge_buffer must fit at least MERGEBUFF2 + 1 keys, because
merge_index() can merge that many BUFFPEKs at once. merge_index() can merge that many BUFFPEKs at once. The extra space for one key
is needed when a piece of merge buffer is re-read, see merge_walk()
*/ */
size_t buff_sz= MY_MAX(MERGEBUFF2, max_in_memory_size/full_size+1) * full_size; size_t buff_sz= MY_MAX(MERGEBUFF2+1, max_in_memory_size/full_size+1) * full_size;
if (!(merge_buffer = (uchar *)my_malloc(buff_sz, MYF(MY_THREAD_SPECIFIC|MY_WME)))) if (!(merge_buffer = (uchar *)my_malloc(buff_sz, MYF(MY_WME))))
return 1; return 1;
if (buff_sz < full_size * (file_ptrs.elements + 1UL)) if (buff_sz < full_size * (file_ptrs.elements + 1UL))
res= merge(table, merge_buffer, buff_sz >= full_size * MERGEBUFF2) ; res= merge(table, merge_buffer, buff_sz >= full_size * MERGEBUFF2) ;
...@@ -708,8 +712,8 @@ bool Unique::merge(TABLE *table, uchar *buff, bool without_last_merge) ...@@ -708,8 +712,8 @@ bool Unique::merge(TABLE *table, uchar *buff, bool without_last_merge)
full_size; full_size;
sort_param.min_dupl_count= min_dupl_count; sort_param.min_dupl_count= min_dupl_count;
sort_param.res_length= 0; sort_param.res_length= 0;
sort_param.max_keys_per_buffer= sort_param.keys= (uint) MY_MAX((max_in_memory_size / sort_param.sort_length),
(uint) (max_in_memory_size / sort_param.sort_length); MERGEBUFF2);
sort_param.not_killable= 1; sort_param.not_killable= 1;
sort_param.unique_buff= buff +(sort_param.max_keys_per_buffer * sort_param.unique_buff= buff +(sort_param.max_keys_per_buffer *
......
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