1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge 10.5 into 10.6

This commit is contained in:
Marko Mäkelä
2020-11-28 11:58:03 +02:00
16 changed files with 138 additions and 49 deletions

View File

@@ -211,6 +211,11 @@ this is test
select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c'); select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c');
replace('aaaa','a','b') replace('aaaa','aa','b') replace('aaaa','a','bb') replace('aaaa','','b') replace('bbbb','a','c') replace('aaaa','a','b') replace('aaaa','aa','b') replace('aaaa','a','bb') replace('aaaa','','b') replace('bbbb','a','c')
bbbb bb bbbbbbbb aaaa bbbb bbbb bb bbbbbbbb aaaa bbbb
select replace('aaaa','a','bbbb');
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def replace('aaaa','a','bbbb') 253 16 16 Y 0 39 8
replace('aaaa','a','bbbb')
bbbbbbbbbbbbbbbb
select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ; select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ;
replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL')
this is a REAL test this is a REAL test

View File

@@ -91,6 +91,9 @@ SELECT CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),r
select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es'); select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c'); select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c');
--enable_metadata
select replace('aaaa','a','bbbb');
--disable_metadata
select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ; select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ;
select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb');
select 'mood' sounds like 'mud'; select 'mood' sounds like 'mud';

View File

@@ -267,7 +267,7 @@ t1 CREATE TABLE `t1` (
`c30` varchar(317) CHARACTER SET latin2 DEFAULT NULL, `c30` varchar(317) CHARACTER SET latin2 DEFAULT NULL,
`c31` varchar(192) CHARACTER SET latin2 DEFAULT NULL, `c31` varchar(192) CHARACTER SET latin2 DEFAULT NULL,
`c32` char(0) CHARACTER SET latin2 DEFAULT NULL, `c32` char(0) CHARACTER SET latin2 DEFAULT NULL,
`c33` varchar(3) CHARACTER SET latin2 DEFAULT NULL, `c33` varchar(6) CHARACTER SET latin2 DEFAULT NULL,
`c34` varchar(3) CHARACTER SET latin2 DEFAULT NULL, `c34` varchar(3) CHARACTER SET latin2 DEFAULT NULL,
`c35` varchar(3) CHARACTER SET latin2 DEFAULT NULL, `c35` varchar(3) CHARACTER SET latin2 DEFAULT NULL,
`c36` varchar(3) CHARACTER SET latin2 DEFAULT NULL, `c36` varchar(3) CHARACTER SET latin2 DEFAULT NULL,

View File

@@ -1155,3 +1155,37 @@ count(*)
319 319
drop table t1; drop table t1;
drop table t2; drop table t2;
#
# MDEV-24242: set expression with empty intermediate result
# when tmp_memory_table_size is set to 0
#
create table t1 (a int, b int) engine=MyISAM;
insert into t1 values (1,1), (2,2);
create table t2 (a int, b int) engine=MyISAM;
insert into t2 values (11,11), (12,12), (13,13);
select * from t1
except all
select * from t1
except
select * from t1
union all
select * from t2;
a b
12 12
11 11
13 13
set tmp_memory_table_size=0;
select * from t1
except all
select * from t1
except
select * from t1
union all
select * from t2;
a b
12 12
11 11
13 13
set tmp_memory_table_size=default;
drop table t1,t2;
# End of 10.4 tests

View File

@@ -524,3 +524,31 @@ select count(*) from
drop table t1; drop table t1;
drop table t2; drop table t2;
--echo #
--echo # MDEV-24242: set expression with empty intermediate result
--echo # when tmp_memory_table_size is set to 0
--echo #
create table t1 (a int, b int) engine=MyISAM;
insert into t1 values (1,1), (2,2);
create table t2 (a int, b int) engine=MyISAM;
insert into t2 values (11,11), (12,12), (13,13);
let $q=
select * from t1
except all
select * from t1
except
select * from t1
union all
select * from t2;
eval $q;
set tmp_memory_table_size=0;
eval $q;
set tmp_memory_table_size=default;
drop table t1,t2;
--echo # End of 10.4 tests

View File

@@ -26,11 +26,6 @@ static inline uint32_t DecodeFixed32(const char *ptr)
return uint4korr(ptr); return uint4korr(ptr);
} }
static inline uint64_t DecodeFixed64(const char *ptr)
{
return uint8korr(ptr);
}
#include <stdint.h> #include <stdint.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#include <intrin.h> #include <intrin.h>
@@ -343,6 +338,12 @@ static inline uint32_t LE_LOAD32(const uint8_t *p) {
} }
#if defined(HAVE_SSE42) && (SIZEOF_SIZE_T == 8) #if defined(HAVE_SSE42) && (SIZEOF_SIZE_T == 8)
static inline uint64_t DecodeFixed64(const char *ptr)
{
return uint8korr(ptr);
}
static inline uint64_t LE_LOAD64(const uint8_t *p) { static inline uint64_t LE_LOAD64(const uint8_t *p) {
return DecodeFixed64(reinterpret_cast<const char*>(p)); return DecodeFixed64(reinterpret_cast<const char*>(p));
} }
@@ -364,7 +365,7 @@ static inline void Slow_CRC32(uint64_t* l, uint8_t const **p) {
table0_[c >> 24]; table0_[c >> 24];
} }
static inline void Fast_CRC32(uint64_t* l, uint8_t const **p) { __attribute__((unused)) static inline void Fast_CRC32(uint64_t* l, uint8_t const **p) {
#ifndef HAVE_SSE42 #ifndef HAVE_SSE42
Slow_CRC32(l, p); Slow_CRC32(l, p);
#elif (SIZEOF_SIZE_T == 8) #elif (SIZEOF_SIZE_T == 8)

View File

@@ -1085,7 +1085,7 @@ Field_longstr::make_packed_sort_key_part(uchar *buff,
uchar* uchar*
Field_longstr::pack_sort_string(uchar *to, const SORT_FIELD_ATTR *sort_field) Field_longstr::pack_sort_string(uchar *to, const SORT_FIELD_ATTR *sort_field)
{ {
StringBuffer<LONGLONG_BUFFER_SIZE> buf; StringBuffer<LONGLONG_BUFFER_SIZE+1> buf;
val_str(&buf, &buf); val_str(&buf, &buf);
return to + sort_field->pack_sort_string(to, &buf, field_charset()); return to + sort_field->pack_sort_string(to, &buf, field_charset());
} }

View File

@@ -3634,7 +3634,7 @@ String *Item_int::val_str(String *str)
void Item_int::print(String *str, enum_query_type query_type) void Item_int::print(String *str, enum_query_type query_type)
{ {
StringBuffer<LONGLONG_BUFFER_SIZE> buf; StringBuffer<LONGLONG_BUFFER_SIZE+1> buf;
// my_charset_bin is good enough for numbers // my_charset_bin is good enough for numbers
buf.set_int(value, unsigned_flag, &my_charset_bin); buf.set_int(value, unsigned_flag, &my_charset_bin);
str->append(buf); str->append(buf);

View File

@@ -1962,6 +1962,7 @@ class Item_func_rand :public Item_real_func
bool first_eval; // TRUE if val_real() is called 1st time bool first_eval; // TRUE if val_real() is called 1st time
bool check_arguments() const bool check_arguments() const
{ return check_argument_types_can_return_int(0, arg_count); } { return check_argument_types_can_return_int(0, arg_count); }
void seed_random (Item * val);
public: public:
Item_func_rand(THD *thd, Item *a): Item_func_rand(THD *thd, Item *a):
Item_real_func(thd, a), rand(0), first_eval(TRUE) {} Item_real_func(thd, a), rand(0), first_eval(TRUE) {}
@@ -1974,12 +1975,11 @@ public:
void cleanup() { first_eval= TRUE; Item_real_func::cleanup(); } void cleanup() { first_eval= TRUE; Item_real_func::cleanup(); }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), "()", arg, VCOL_NON_DETERMINISTIC); return mark_unsupported_function(func_name(), "()", arg,
VCOL_NON_DETERMINISTIC);
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_rand>(thd, this); } { return get_item_copy<Item_func_rand>(thd, this); }
private:
void seed_random (Item * val);
}; };

View File

@@ -1286,10 +1286,10 @@ null:
bool Item_func_replace::fix_length_and_dec() bool Item_func_replace::fix_length_and_dec()
{ {
ulonglong char_length= (ulonglong) args[0]->max_char_length(); ulonglong char_length= (ulonglong) args[0]->max_char_length();
int diff=(int) (args[2]->max_char_length() - args[1]->max_char_length()); int diff=(int) (args[2]->max_char_length() - 1);
if (diff > 0 && args[1]->max_char_length()) if (diff > 0)
{ // Calculate of maxreplaces { // Calculate of maxreplaces
ulonglong max_substrs= char_length / args[1]->max_char_length(); ulonglong max_substrs= char_length;
char_length+= max_substrs * (uint) diff; char_length+= max_substrs * (uint) diff;
} }

View File

@@ -10279,7 +10279,7 @@ bool LEX::sp_proc_stmt_statement_finalize(THD *thd, bool no_lookahead)
It is done by transformer. It is done by transformer.
The extracted condition is saved in cond_pushed_into_where of this select. The extracted condition is saved in cond_pushed_into_where of this select.
cond can remain un empty after the extraction of the condition that can be COND can remain not empty after the extraction of the conditions that can be
pushed into WHERE. It is saved in remaining_cond. pushed into WHERE. It is saved in remaining_cond.
@note @note

View File

@@ -1113,7 +1113,7 @@ public:
*/ */
LEX *parent_lex; LEX *parent_lex;
enum olap_type olap; enum olap_type olap;
/* FROM clause - points to the beginning of the TABLE_LIST::next_local list. */ /* FROM clause - points to the beginning of the TABLE_LIST::next_local list */
SQL_I_List<TABLE_LIST> table_list; SQL_I_List<TABLE_LIST> table_list;
/* /*
@@ -1129,8 +1129,8 @@ public:
List<Item> pre_fix; /* above list before fix_fields */ List<Item> pre_fix; /* above list before fix_fields */
bool is_item_list_lookup; bool is_item_list_lookup;
/* /*
Usualy it is pointer to ftfunc_list_alloc, but in union used to create fake Usually it is pointer to ftfunc_list_alloc, but in union used to create
select_lex for calling mysql_select under results of union fake select_lex for calling mysql_select under results of union
*/ */
List<Item_func_match> *ftfunc_list; List<Item_func_match> *ftfunc_list;
List<Item_func_match> ftfunc_list_alloc; List<Item_func_match> ftfunc_list_alloc;

View File

@@ -3747,14 +3747,16 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
tab->tmp_table_param->skip_create_table= true; tab->tmp_table_param->skip_create_table= true;
TABLE* table= create_tmp_table(thd, tab->tmp_table_param, *table_fields, TABLE* table= create_tmp_table(thd, tab->tmp_table_param, *table_fields,
table_group, distinct, table_group, distinct,
save_sum_fields, select_options, table_rows_limit, save_sum_fields, select_options,
table_rows_limit,
&empty_clex_str, true, keep_row_order); &empty_clex_str, true, keep_row_order);
if (!table) if (!table)
DBUG_RETURN(true); DBUG_RETURN(true);
tmp_table_param.using_outer_summary_function= tmp_table_param.using_outer_summary_function=
tab->tmp_table_param->using_outer_summary_function; tab->tmp_table_param->using_outer_summary_function;
tab->join= this; tab->join= this;
DBUG_ASSERT(tab > tab->join->join_tab || !top_join_tab_count || !tables_list); DBUG_ASSERT(tab > tab->join->join_tab || !top_join_tab_count ||
!tables_list);
if (tab > join_tab) if (tab > join_tab)
(tab - 1)->next_select= sub_select_postjoin_aggr; (tab - 1)->next_select= sub_select_postjoin_aggr;
if (!(tab->aggr= new (thd->mem_root) AGGR_OP(tab))) if (!(tab->aggr= new (thd->mem_root) AGGR_OP(tab)))
@@ -4270,8 +4272,9 @@ void JOIN::exec_inner()
/* /*
Enable LIMIT ROWS EXAMINED during query execution if: Enable LIMIT ROWS EXAMINED during query execution if:
(1) This JOIN is the outermost query (not a subquery or derived table) (1) This JOIN is the outermost query (not a subquery or derived table)
This ensures that the limit is enabled when actual execution begins, and This ensures that the limit is enabled when actual execution begins,
not if a subquery is evaluated during optimization of the outer query. and not if a subquery is evaluated during optimization of the outer
query.
(2) This JOIN is not the result of a UNION. In this case do not apply the (2) This JOIN is not the result of a UNION. In this case do not apply the
limit in order to produce the partial query result stored in the limit in order to produce the partial query result stored in the
UNION temp table. UNION temp table.
@@ -14101,7 +14104,7 @@ static void update_depend_map_for_order(JOIN *join, ORDER *order)
/** /**
Remove all constants and check if ORDER only contains simple Remove all constants from ORDER and check if ORDER only contains simple
expressions. expressions.
We also remove all duplicate expressions, keeping only the first one. We also remove all duplicate expressions, keeping only the first one.
@@ -16646,13 +16649,13 @@ static uint reset_nj_counters(JOIN *join, List<TABLE_LIST> *join_list)
@verbatim @verbatim
IMPLEMENTATION IMPLEMENTATION
LIMITATIONS ON JOIN ORDER LIMITATIONS ON JOIN ORDER
The nested [outer] joins executioner algorithm imposes these limitations The nested [outer] joins executioner algorithm imposes these
on join order: limitations on join order:
1. "Outer tables first" - any "outer" table must be before any 1. "Outer tables first" - any "outer" table must be before any
corresponding "inner" table. corresponding "inner" table.
2. "No interleaving" - tables inside a nested join must form a continuous 2. "No interleaving" - tables inside a nested join must form a
sequence in join order (i.e. the sequence must not be interrupted by continuous sequence in join order (i.e. the sequence must not be
tables that are outside of this nested join). interrupted by tables that are outside of this nested join).
#1 is checked elsewhere, this function checks #2 provided that #1 has #1 is checked elsewhere, this function checks #2 provided that #1 has
been already checked. been already checked.
@@ -16664,34 +16667,36 @@ static uint reset_nj_counters(JOIN *join, List<TABLE_LIST> *join_list)
The join order "t1 t2 t0 t3" is invalid: The join order "t1 t2 t0 t3" is invalid:
table t0 is outside of the nested join, so WHERE condition for t0 is table t0 is outside of the nested join, so WHERE condition
attached directly to t0 (without triggers, and it may be used to access for t0 is attached directly to t0 (without triggers, and it
t0). Applying WHERE(t0) to (t2,t0,t3) record is invalid as we may miss may be used to access t0). Applying WHERE(t0) to (t2,t0,t3)
combinations of (t1, t2, t3) that satisfy condition cond1, and produce a record is invalid as we may miss combinations of (t1, t2, t3)
null-complemented (t1, t2.NULLs, t3.NULLs) row, which should not have that satisfy condition cond1, and produce a null-complemented
been produced. (t1, t2.NULLs, t3.NULLs) row, which should not have been
produced.
If table t0 is not between t2 and t3, the problem doesn't exist: If table t0 is not between t2 and t3, the problem doesn't exist:
If t0 is located after (t2,t3), WHERE(t0) is applied after nested join If t0 is located after (t2,t3), WHERE(t0) is applied after nested
processing has finished. join processing has finished.
If t0 is located before (t2,t3), predicates like WHERE_cond(t0, t2) are If t0 is located before (t2,t3), predicates like WHERE_cond(t0, t2)
wrapped into condition triggers, which takes care of correct nested are wrapped into condition triggers, which takes care of correct
join processing. nested join processing.
HOW IT IS IMPLEMENTED HOW IT IS IMPLEMENTED
The limitations on join order can be rephrased as follows: for valid The limitations on join order can be rephrased as follows: for valid
join order one must be able to: join order one must be able to:
1. write down the used tables in the join order on one line. 1. write down the used tables in the join order on one line.
2. for each nested join, put one '(' and one ')' on the said line 2. for each nested join, put one '(' and one ')' on the said line
3. write "LEFT JOIN" and "ON (...)" where appropriate 3. write "LEFT JOIN" and "ON (...)" where appropriate
4. get a query equivalent to the query we're trying to execute. 4. get a query equivalent to the query we're trying to execute.
Calls to check_interleaving_with_nj() are equivalent to writing the Calls to check_interleaving_with_nj() are equivalent to writing the
above described line from left to right. above described line from left to right.
A single check_interleaving_with_nj(A,B) call is equivalent to writing
table B and appropriate brackets on condition that table A and A single check_interleaving_with_nj(A,B) call is equivalent
appropriate brackets is the last what was written. Graphically the to writing table B and appropriate brackets on condition that
transition is as follows: table A and appropriate brackets is the last what was
written. Graphically the transition is as follows:
+---- current position +---- current position
| |
@@ -21872,8 +21877,8 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
/* /*
@brief @brief
Perform a GROUP BY operation over a stream of rows ordered by their group. The Perform a GROUP BY operation over a stream of rows ordered by their group.
result is sent into join->result. The result is sent into join->result.
@detail @detail
Also applies HAVING, etc. Also applies HAVING, etc.
@@ -22153,7 +22158,9 @@ end:
} }
/** Like end_update, but this is done with unique constraints instead of keys. */ /**
Like end_update, but this is done with unique constraints instead of keys.
*/
static enum_nested_loop_state static enum_nested_loop_state
end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),

View File

@@ -880,6 +880,10 @@ bool select_unit_ext::send_eof()
table->file->ha_rnd_end(); table->file->ha_rnd_end();
} }
/* Clean up table buffers for the next set operation from pipeline */
if (next_sl)
restore_record(table,s->default_values);
if (unlikely(error)) if (unlikely(error))
table->file->print_error(error, MYF(0)); table->file->print_error(error, MYF(0));

View File

@@ -6555,6 +6555,11 @@ opt_compressed:
| compressed { } | compressed { }
; ;
opt_enable:
/* empty */ {}
| ENABLE_SYM { }
;
compressed: compressed:
COMPRESSED_SYM opt_compression_method COMPRESSED_SYM opt_compression_method
{ {
@@ -6581,7 +6586,7 @@ compressed_deprecated_column_attribute:
; ;
asrow_attribute: asrow_attribute:
not NULL_SYM not NULL_SYM opt_enable
{ {
Lex->last_field->flags|= NOT_NULL_FLAG; Lex->last_field->flags|= NOT_NULL_FLAG;
} }

View File

@@ -305,8 +305,10 @@ public:
std::unique_lock<std::mutex> lk(m_mtx); std::unique_lock<std::mutex> lk(m_mtx);
if (m_on) if (m_on)
{ {
DBUG_PUSH_EMPTY;
thr_timer_end(this); thr_timer_end(this);
thr_timer_settime(this, 1000ULL * m_period); thr_timer_settime(this, 1000ULL * m_period);
DBUG_POP_EMPTY;
} }
} }
} }