diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-10-10 10:36:51 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-10-10 10:36:51 +0300 |
commit | 2a955c7a834aca8ae966a2922cd289bf2f9d67d9 (patch) | |
tree | ab2d03766f65b2dffe4d1ac043395548f108f5ef /sql | |
parent | 5646c4315918c1e4127bfb68b70d1c5333bfc2c7 (diff) | |
parent | 61b32df93119635570f42a96d0b99c7ea398430b (diff) | |
download | mariadb-git-2a955c7a834aca8ae966a2922cd289bf2f9d67d9.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_strfunc.cc | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 4 | ||||
-rw-r--r-- | sql/sql_acl.cc | 2 | ||||
-rw-r--r-- | sql/sql_class.cc | 5 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 8 | ||||
-rw-r--r-- | sql/sql_string.cc | 23 | ||||
-rw-r--r-- | sql/sql_string.h | 1 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 26 | ||||
-rw-r--r-- | sql/sql_yacc_ora.yy | 26 |
10 files changed, 78 insertions, 21 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index d0727293c5f..6c82c580858 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -603,7 +603,7 @@ String *Item_func_concat::val_str(String *str) goto null; if (res != str) - str->copy(res->ptr(), res->length(), res->charset()); + str->copy_or_move(res->ptr(), res->length(), res->charset()); for (uint i= 1 ; i < arg_count ; i++) { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0e517b28018..76455177a6e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2847,10 +2847,6 @@ static bool cache_thread(THD *thd) _db_pop_(); #endif - /* Clear warnings. */ - if (!thd->get_stmt_da()->is_warning_info_empty()) - thd->get_stmt_da()->clear_warning_info(thd->query_id); - set_timespec(abstime, THREAD_CACHE_TIMEOUT); while (!abort_loop && ! wake_thread && ! kill_cached_threads) { diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 5b38420223e..bf18581de4f 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -12285,7 +12285,7 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio, const char *client_auth_plugin= ((st_mysql_auth *) (plugin_decl(mpvio->plugin)->info))->client_auth_plugin; - DBUG_EXECUTE_IF("auth_disconnect", { vio_close(net->vio); DBUG_RETURN(1); }); + DBUG_EXECUTE_IF("auth_disconnect", { DBUG_RETURN(1); }); DBUG_ASSERT(client_auth_plugin); /* diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7f64a45fac4..a4ecdfb1297 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1363,6 +1363,11 @@ void THD::change_user(void) cleanup_done= 0; reset_killed(); thd_clear_errors(this); + + /* Clear warnings. */ + if (!get_stmt_da()->is_warning_info_empty()) + get_stmt_da()->clear_warning_info(0); + init(); stmt_map.reset(); my_hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0, diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index ebe841daf6f..09d31470a00 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -3214,7 +3214,7 @@ static void mysql_stmt_execute_common(THD *thd, sp_cache_enforce_limit(thd->sp_package_body_cache, stored_program_cache_size); /* Close connection socket; for use with client testing (Bug#43560). */ - DBUG_EXECUTE_IF("close_conn_after_stmt_execute", vio_close(thd->net.vio);); + DBUG_EXECUTE_IF("close_conn_after_stmt_execute", vio_shutdown(thd->net.vio,SHUT_RD);); DBUG_VOID_RETURN; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 33c8f529aea..ec2a2b1df0e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11672,7 +11672,15 @@ uint check_join_cache_usage(JOIN_TAB *tab, effort now. */ if (tab->table->pos_in_table_list->is_materialized_derived()) + { no_bka_cache= true; + /* + Don't use hash join algorithm if the temporary table for the rows + of the derived table will be created with an equi-join key. + */ + if (tab->table->s->keys) + no_hashed_cache= true; + } /* Don't use join buffering if we're dictated not to by no_jbuf_after diff --git a/sql/sql_string.cc b/sql/sql_string.cc index e7acabe8bee..39d9438d5bf 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -237,9 +237,9 @@ bool String::copy(const String &str) bool String::copy(const char *str,size_t arg_length, CHARSET_INFO *cs) { + DBUG_ASSERT(arg_length < UINT_MAX32); if (alloc(arg_length)) return TRUE; - DBUG_ASSERT(arg_length < UINT_MAX32); if (Ptr == str && arg_length == uint32(str_length)) { /* @@ -256,6 +256,24 @@ bool String::copy(const char *str,size_t arg_length, CHARSET_INFO *cs) return FALSE; } +/* + Copy string, where strings may overlap. + Same as String::copy, but use memmove instead of memcpy to avoid warnings + from valgrind +*/ + +bool String::copy_or_move(const char *str,size_t arg_length, CHARSET_INFO *cs) +{ + DBUG_ASSERT(arg_length < UINT_MAX32); + if (alloc(arg_length)) + return TRUE; + if ((str_length=uint32(arg_length))) + memmove(Ptr,str,arg_length); + Ptr[arg_length]=0; + str_charset=cs; + return FALSE; +} + /* Checks that the source string can be just copied to the destination string @@ -389,8 +407,9 @@ bool String::set_or_copy_aligned(const char *str, size_t arg_length, /* How many bytes are in incomplete character */ size_t offset= (arg_length % cs->mbminlen); - if (!offset) /* All characters are complete, just copy */ + if (!offset) { + /* All characters are complete, just use given string */ set(str, arg_length, cs); return FALSE; } diff --git a/sql/sql_string.h b/sql/sql_string.h index d9d3f10777c..0ae68cb3796 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -437,6 +437,7 @@ public: bool copy(); // Alloc string if not alloced bool copy(const String &s); // Allocate new string bool copy(const char *s,size_t arg_length, CHARSET_INFO *cs); // Allocate new string + bool copy_or_move(const char *s,size_t arg_length, CHARSET_INFO *cs); static bool needs_conversion(size_t arg_length, CHARSET_INFO *cs_from, CHARSET_INFO *cs_to, uint32 *offset); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 03d0b212364..b1fe5cbf7ad 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -817,10 +817,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %parse-param { THD *thd } %lex-param { THD *thd } /* - Currently there are 58 shift/reduce conflicts. + Currently there are 52 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 58 +%expect 52 /* Comments for TOKENS. @@ -1582,6 +1582,16 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %left JOIN_SYM INNER_SYM STRAIGHT_JOIN CROSS LEFT RIGHT /* A dummy token to force the priority of table_ref production in a join. */ %left TABLE_REF_PRIORITY + +/* + Give ESCAPE (in LIKE) a very low precedence. + This allows the concatenation operator || to be used on the right + side of "LIKE" with sql_mode=PIPES_AS_CONCAT (without ORACLE): + SELECT 'ab' LIKE 'a'||'b'||'c'; +*/ +%left PREC_BELOW_ESCAPE +%left ESCAPE_SYM + %left SET_VAR %left OR_SYM OR2_SYM %left XOR @@ -1591,7 +1601,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %left NOT_SYM %left BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE -%left '=' EQUAL_SYM GE '>' LE '<' NE IS LIKE REGEXP IN_SYM +%left '=' EQUAL_SYM GE '>' LE '<' NE IS LIKE SOUNDS_SYM REGEXP IN_SYM %left '|' %left '&' %left SHIFT_LEFT SHIFT_RIGHT @@ -1623,6 +1633,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); SELECT system FROM t1; ALTER TABLE DROP SYSTEM VERSIONIONG; + - USER: identifier, user: + SELECT user FROM t1; + KILL USER foo; + Note, we need here only tokens that cause shirt/reduce conflicts with keyword identifiers. For example: opt_clause1: %empty | KEYWORD ... ; @@ -1661,7 +1675,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); and until NEXT_SYM / PREVIOUS_SYM. */ %left PREC_BELOW_IDENTIFIER_OPT_SPECIAL_CASE -%left TRANSACTION_SYM TIMESTAMP PERIOD_SYM SYSTEM +%left TRANSACTION_SYM TIMESTAMP PERIOD_SYM SYSTEM USER /* @@ -12114,7 +12128,7 @@ opt_escape: Lex->escape_used= TRUE; $$= $2; } - | /* empty */ + | /* empty */ %prec PREC_BELOW_ESCAPE { Lex->escape_used= FALSE; $$= ((thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) ? @@ -15842,7 +15856,7 @@ keyword_sp_var_and_label: | UNDOFILE_SYM | UNKNOWN_SYM | UNTIL_SYM - | USER_SYM + | USER_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 | USE_FRM | VARIABLES | VERSIONING_SYM diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index 71689535fdc..5a789ac6fec 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -296,10 +296,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %parse-param { THD *thd } %lex-param { THD *thd } /* - Currently there are 59 shift/reduce conflicts. + Currently there are 53 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 59 +%expect 53 /* Comments for TOKENS. @@ -1061,6 +1061,16 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %left JOIN_SYM INNER_SYM STRAIGHT_JOIN CROSS LEFT RIGHT /* A dummy token to force the priority of table_ref production in a join. */ %left TABLE_REF_PRIORITY + +/* + Give ESCAPE (in LIKE) a very low precedence. + This allows the concatenation operator || to be used on the right + side of "LIKE" with sql_mode=PIPES_AS_CONCAT (without ORACLE): + SELECT 'ab' LIKE 'a'||'b'||'c'; +*/ +%left PREC_BELOW_ESCAPE +%left ESCAPE_SYM + %left SET_VAR %left OR_SYM OR2_SYM %left XOR @@ -1070,7 +1080,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %left NOT_SYM %left BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE -%left '=' EQUAL_SYM GE '>' LE '<' NE IS LIKE REGEXP IN_SYM +%left '=' EQUAL_SYM GE '>' LE '<' NE IS LIKE SOUNDS_SYM REGEXP IN_SYM %left '|' %left '&' %left SHIFT_LEFT SHIFT_RIGHT @@ -1102,6 +1112,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); SELECT system FROM t1; ALTER TABLE DROP SYSTEM VERSIONIONG; + - USER: identifier, user: + SELECT user FROM t1; + KILL USER foo; + Note, we need here only tokens that cause shirt/reduce conflicts with keyword identifiers. For example: opt_clause1: %empty | KEYWORD ... ; @@ -1140,7 +1154,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); and until NEXT_SYM / PREVIOUS_SYM. */ %left PREC_BELOW_IDENTIFIER_OPT_SPECIAL_CASE -%left TRANSACTION_SYM TIMESTAMP PERIOD_SYM SYSTEM +%left TRANSACTION_SYM TIMESTAMP PERIOD_SYM SYSTEM USER /* @@ -12326,7 +12340,7 @@ opt_escape: Lex->escape_used= TRUE; $$= $2; } - | /* empty */ + | /* empty */ %prec PREC_BELOW_ESCAPE { Lex->escape_used= FALSE; $$= ((thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) ? @@ -16121,7 +16135,7 @@ keyword_sp_var_and_label: | UNDOFILE_SYM | UNKNOWN_SYM | UNTIL_SYM - | USER_SYM + | USER_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 | USE_FRM | VARIABLES | VIEW_SYM |