diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/handler.cc | 47 | ||||
-rw-r--r-- | sql/handler.h | 14 | ||||
-rw-r--r-- | sql/item.cc | 87 | ||||
-rw-r--r-- | sql/item.h | 100 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 13 | ||||
-rw-r--r-- | sql/item_sum.h | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 6 | ||||
-rw-r--r-- | sql/mysqld.h | 1 | ||||
-rw-r--r-- | sql/sql_acl.cc | 22 | ||||
-rw-r--r-- | sql/sql_connect.cc | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 1 | ||||
-rw-r--r-- | sql/sql_tvc.cc | 5 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 8 | ||||
-rw-r--r-- | sql/sql_yacc_ora.yy | 8 | ||||
-rw-r--r-- | sql/sys_vars.cc | 2 | ||||
-rw-r--r-- | sql/table.cc | 5 | ||||
-rw-r--r-- | sql/unireg.h | 2 |
19 files changed, 242 insertions, 87 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index aebfeb17b2c..20bf32f3cdc 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7325,7 +7325,6 @@ static Create_field *vers_init_sys_field(THD *thd, const char *field_name, int f f->flags= flags | NOT_NULL_FLAG; if (integer) { - DBUG_ASSERT(0); // Not implemented yet f->set_handler(&type_handler_vers_trx_id); f->length= MY_INT64_NUM_DECIMAL_DIGITS - 1; f->flags|= UNSIGNED_FLAG; @@ -7343,10 +7342,13 @@ static Create_field *vers_init_sys_field(THD *thd, const char *field_name, int f return f; } -static bool vers_create_sys_field(THD *thd, const char *field_name, - Alter_info *alter_info, int flags) +bool Vers_parse_info::create_sys_field(THD *thd, const char *field_name, + Alter_info *alter_info, int flags) { - Create_field *f= vers_init_sys_field(thd, field_name, flags, false); + DBUG_ASSERT(can_native >= 0); /* Requires vers_check_native() called */ + Create_field *f= vers_init_sys_field(thd, field_name, flags, + DBUG_EVALUATE_IF("sysvers_force_trx", + (bool) can_native, false)); if (!f) return true; @@ -7370,8 +7372,8 @@ bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info) period= start_end_t(default_start, default_end); as_row= period; - if (vers_create_sys_field(thd, default_start, alter_info, VERS_ROW_START) || - vers_create_sys_field(thd, default_end, alter_info, VERS_ROW_END)) + if (create_sys_field(thd, default_start, alter_info, VERS_ROW_START) || + create_sys_field(thd, default_end, alter_info, VERS_ROW_END)) { return true; } @@ -7379,14 +7381,25 @@ bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info) } +void Table_scope_and_contents_source_st::vers_check_native() +{ + vers_info.can_native= (db_type->db_type == DB_TYPE_PARTITION_DB || + ha_check_storage_engine_flag(db_type, + HTON_NATIVE_SYS_VERSIONING)); +} + + bool Table_scope_and_contents_source_st::vers_fix_system_fields( THD *thd, Alter_info *alter_info, const TABLE_LIST &create_table) { DBUG_ASSERT(!(alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING)); - DBUG_EXECUTE_IF("sysvers_force", if (!tmp_table()) { - alter_info->flags|= ALTER_ADD_SYSTEM_VERSIONING; - options|= HA_VERSIONED_TABLE; }); + if (DBUG_EVALUATE_IF("sysvers_force", true, false) || + DBUG_EVALUATE_IF("sysvers_force_trx", true, false)) + { + alter_info->flags|= ALTER_ADD_SYSTEM_VERSIONING; + options|= HA_VERSIONED_TABLE; + } if (!vers_info.need_check(alter_info)) return false; @@ -7417,7 +7430,9 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields( { f->flags|= VERS_UPDATE_UNVERSIONED_FLAG; } - } // while (Create_field *f= it++) + } // while + + vers_check_native(); if (vers_info.fix_implicit(thd, alter_info)) return true; @@ -7470,11 +7485,7 @@ bool Table_scope_and_contents_source_st::vers_check_system_fields( if (!(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING) && !versioned_fields) return false; - bool can_native= ha_check_storage_engine_flag(db_type, - HTON_NATIVE_SYS_VERSIONING) - || db_type->db_type == DB_TYPE_PARTITION_DB; - - return vers_info.check_sys_fields(table_name, db, alter_info, can_native); + return vers_info.check_sys_fields(table_name, db, alter_info); } @@ -7487,7 +7498,8 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, if (!need_check(alter_info) && !share->versioned) return false; - if (DBUG_EVALUATE_IF("sysvers_force", 0, share->tmp_table)) + if (DBUG_EVALUATE_IF("sysvers_force", 0, share->tmp_table) || + DBUG_EVALUATE_IF("sysvers_force_trx", 0, share->tmp_table)) { my_error(ER_VERS_NOT_SUPPORTED, MYF(0), "CREATE TEMPORARY TABLE"); return true; @@ -7732,8 +7744,7 @@ bool Create_field::vers_check_bigint(const Lex_table_name &table_name) const bool Vers_parse_info::check_sys_fields(const Lex_table_name &table_name, const Lex_table_name &db, - Alter_info *alter_info, - bool can_native) const + Alter_info *alter_info) const { if (check_conditions(table_name, db)) return true; diff --git a/sql/handler.h b/sql/handler.h index 541c408178b..3f0fc5c897f 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2,7 +2,7 @@ #define HANDLER_INCLUDED /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2009, 2022, MariaDB + Copyright (c) 2009, 2023, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -1984,7 +1984,8 @@ struct Vers_parse_info: public Table_period_info Vers_parse_info() : Table_period_info(STRING_WITH_LEN("SYSTEM_TIME")), versioned_fields(false), - unversioned_fields(false) + unversioned_fields(false), + can_native(-1) {} Table_period_info::start_end_t as_row; @@ -2013,6 +2014,9 @@ protected: bool need_check(const Alter_info *alter_info) const; bool check_conditions(const Lex_table_name &table_name, const Lex_table_name &db) const; + bool create_sys_field(THD *thd, const char *field_name, + Alter_info *alter_info, int flags); + public: static const Lex_ident default_start; static const Lex_ident default_end; @@ -2022,8 +2026,7 @@ public: bool fix_create_like(Alter_info &alter_info, HA_CREATE_INFO &create_info, TABLE_LIST &src_table, TABLE_LIST &table); bool check_sys_fields(const Lex_table_name &table_name, - const Lex_table_name &db, Alter_info *alter_info, - bool can_native) const; + const Lex_table_name &db, Alter_info *alter_info) const; /** At least one field was specified 'WITH/WITHOUT SYSTEM VERSIONING'. @@ -2031,6 +2034,7 @@ public: */ bool versioned_fields : 1; bool unversioned_fields : 1; + int can_native; }; /** @@ -2147,6 +2151,7 @@ struct Table_scope_and_contents_source_st: int select_count= 0); bool check_period_fields(THD *thd, Alter_info *alter_info); + void vers_check_native(); bool vers_fix_system_fields(THD *thd, Alter_info *alter_info, const TABLE_LIST &create_table); @@ -2154,7 +2159,6 @@ struct Table_scope_and_contents_source_st: const Lex_table_name &table_name, const Lex_table_name &db, int select_count= 0); - }; diff --git a/sql/item.cc b/sql/item.cc index 630a408b13f..9276e2998ce 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2010, 2022, MariaDB Corporation. + Copyright (c) 2010, 2023, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,6 +41,7 @@ // find_item_in_list, // RESOLVED_AGAINST_ALIAS, ... #include "sql_expression_cache.h" +#include "sql_lex.h" // empty_clex_str const String my_null_string("NULL", 4, default_charset_info); const String my_default_string("DEFAULT", 7, default_charset_info); @@ -1280,12 +1281,11 @@ Item *Item_cache::safe_charset_converter(THD *thd, CHARSET_INFO *tocs) Item *conv= example->safe_charset_converter(thd, tocs); if (conv == example) return this; - Item_cache *cache; - if (!conv || conv->fix_fields(thd, (Item **) NULL) || - unlikely(!(cache= new (thd->mem_root) Item_cache_str(thd, conv)))) + if (!conv || conv->fix_fields(thd, (Item **) NULL)) return NULL; // Safe conversion is not possible, or OEM - cache->setup(thd, conv); - return cache; + setup(thd, conv); + thd->change_item_tree(&example, conv); + return this; } @@ -2249,7 +2249,8 @@ void Item::split_sum_func2(THD *thd, Ref_ptr_array ref_pointer_array, if (unlikely((!(used_tables() & ~PARAM_TABLE_BIT) || (type() == REF_ITEM && - ((Item_ref*)this)->ref_type() != Item_ref::VIEW_REF)))) + ((Item_ref*)this)->ref_type() != Item_ref::VIEW_REF && + ((Item_ref*)this)->ref_type() != Item_ref::DIRECT_REF)))) return; } @@ -2562,7 +2563,6 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll, safe_args[1]= args[item_sep]; } - bool res= FALSE; uint i; DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare()); @@ -2582,19 +2582,33 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll, args[item_sep]= safe_args[1]; } my_coll_agg_error(args, nargs, fname, item_sep); - res= TRUE; - break; // we cannot return here, we need to restore "arena". + return TRUE; } - thd->change_item_tree(arg, conv); + if (conv->is_fixed()) + return false; + + if (conv->fix_fields(thd, arg)) + return TRUE; - if (conv->fix_fields_if_needed(thd, arg)) + Query_arena backup; + if (Query_arena *arena= thd->activate_stmt_arena_if_needed(&backup)) { - res= TRUE; - break; // we cannot return here, we need to restore "arena". + Item_direct_ref_to_item *ref= + new (thd->mem_root) Item_direct_ref_to_item(thd, *arg); + if ((ref == NULL) || ref->fix_fields(thd, (Item **)&ref)) + { + thd->restore_active_arena(arena, &backup); + return TRUE; + } + *arg= ref; + thd->restore_active_arena(arena, &backup); + ref->change_item(thd, conv); } + else + thd->change_item_tree(arg, conv); } - return res; + return FALSE; } @@ -10791,7 +10805,6 @@ const char *dbug_print(SELECT_LEX_UNIT *x) { return dbug_print_unit(x); } #endif /*DBUG_OFF*/ - void Item::register_in(THD *thd) { next= thd->free_list; @@ -10799,6 +10812,48 @@ void Item::register_in(THD *thd) } +Item_direct_ref_to_item::Item_direct_ref_to_item(THD *thd, Item *item) +: Item_direct_ref(thd, NULL, NULL, "", &empty_clex_str, FALSE) +{ + m_item= item; + ref= (Item**)&m_item; +} + +bool Item_direct_ref_to_item::fix_fields(THD *thd, Item **) +{ + DBUG_ASSERT(m_item != NULL); + if (m_item->fix_fields_if_needed_for_scalar(thd, ref)) + return TRUE; + set_properties(); + return FALSE; +} + +void Item_direct_ref_to_item::print(String *str, enum_query_type query_type) +{ + m_item->print(str, query_type); +} + +Item *Item_direct_ref_to_item::safe_charset_converter(THD *thd, + CHARSET_INFO *tocs) +{ + Item *conv= m_item->safe_charset_converter(thd, tocs); + if (conv != m_item) + { + if (conv== NULL || conv->fix_fields(thd, &conv)) + return NULL; + change_item(thd, conv); + } + return this; +} + +void Item_direct_ref_to_item::change_item(THD *thd, Item *i) +{ + DBUG_ASSERT(i->is_fixed()); + thd->change_item_tree(ref, i); + set_properties(); +} + + bool Item::cleanup_excluding_immutables_processor (void *arg) { if (!(get_extraction_flag() == IMMUTABLE_FL)) diff --git a/sql/item.h b/sql/item.h index 9389250d6ec..26dc13a4b9f 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2,7 +2,7 @@ #define SQL_ITEM_INCLUDED /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2021, MariaDB Corporation. + Copyright (c) 2009, 2023, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -7600,6 +7600,104 @@ inline void Virtual_column_info::print(String* str) expr->print_for_table_def(str); } +class Item_direct_ref_to_item : public Item_direct_ref +{ + Item *m_item; +public: + Item_direct_ref_to_item(THD *thd, Item *item); + + void change_item(THD *thd, Item *); + + bool fix_fields(THD *thd, Item **it); + + void print(String *str, enum_query_type query_type); + + Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs); + Item *get_tmp_table_item(THD *thd) + { return m_item->get_tmp_table_item(thd); } + Item *get_copy(THD *thd) + { return m_item->get_copy(thd); } + COND *build_equal_items(THD *thd, COND_EQUAL *inherited, + bool link_item_fields, + COND_EQUAL **cond_equal_ref) + { + return m_item->build_equal_items(thd, inherited, link_item_fields, + cond_equal_ref); + } + const char *full_name() const { return m_item->full_name(); } + void make_send_field(THD *thd, Send_field *field) + { m_item->make_send_field(thd, field); } + bool eq(const Item *item, bool binary_cmp) const + { + Item *it= ((Item *) item)->real_item(); + return m_item->eq(it, binary_cmp); + } + void fix_after_pullout(st_select_lex *new_parent, Item **refptr, bool merge) + { m_item->fix_after_pullout(new_parent, &m_item, merge); } + void save_val(Field *to) + { return m_item->save_val(to); } + void save_result(Field *to) + { return m_item->save_result(to); } + int save_in_field(Field *to, bool no_conversions) + { return m_item->save_in_field(to, no_conversions); } + const Type_handler *type_handler() const { return m_item->type_handler(); } + table_map used_tables() const { return m_item->used_tables(); } + void update_used_tables() + { m_item->update_used_tables(); } + bool const_item() const { return m_item->const_item(); } + table_map not_null_tables() const { return m_item->not_null_tables(); } + bool walk(Item_processor processor, bool walk_subquery, void *arg) + { + return m_item->walk(processor, walk_subquery, arg) || + (this->*processor)(arg); + } + bool enumerate_field_refs_processor(void *arg) + { return m_item->enumerate_field_refs_processor(arg); } + Item_field *field_for_view_update() + { return m_item->field_for_view_update(); } + + /* Row emulation: forwarding of ROW-related calls to orig_item */ + uint cols() const + { return m_item->cols(); } + Item* element_index(uint i) + { return this; } + Item** addr(uint i) + { return &m_item; } + bool check_cols(uint c) + { return Item::check_cols(c); } + bool null_inside() + { return m_item->null_inside(); } + void bring_value() + {} + + Item_equal *get_item_equal() { return m_item->get_item_equal(); } + void set_item_equal(Item_equal *item_eq) { m_item->set_item_equal(item_eq); } + Item_equal *find_item_equal(COND_EQUAL *cond_equal) + { return m_item->find_item_equal(cond_equal); } + Item *propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond) + { return m_item->propagate_equal_fields(thd, ctx, cond); } + Item *replace_equal_field(THD *thd, uchar *arg) + { return m_item->replace_equal_field(thd, arg); } + + bool excl_dep_on_table(table_map tab_map) + { return m_item->excl_dep_on_table(tab_map); } + bool excl_dep_on_grouping_fields(st_select_lex *sel) + { return m_item->excl_dep_on_grouping_fields(sel); } + bool is_expensive() { return m_item->is_expensive(); } + Item* build_clone(THD *thd) { return get_copy(thd); } + + void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, + List<Item> &fields, uint flags) + { + m_item->split_sum_func(thd, ref_pointer_array, fields, flags); + } + /* + This processor states that this is safe for virtual columns + (because this Item transparency) + */ + bool check_vcol_func_processor(void *arg) { return FALSE;} +}; + inline bool TABLE::mark_column_with_deps(Field *field) { bool res; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index b6509fa8b25..c7b83fae70d 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -418,18 +418,9 @@ bool Item_func::setup_args_and_comparator(THD *thd, Arg_comparator *cmp) if (args[0]->cmp_type() == STRING_RESULT && args[1]->cmp_type() == STRING_RESULT) { - Query_arena *arena, backup; - arena= thd->activate_stmt_arena_if_needed(&backup); - DTCollation tmp; - bool ret= agg_arg_charsets_for_comparison(tmp, args, 2); - - if (arena) - thd->restore_active_arena(arena, &backup); - - if (ret) - return ret; - + if (agg_arg_charsets_for_comparison(tmp, args, 2)) + return true; cmp->m_compare_collation= tmp.collation; } // Convert constants when compared to int/year field diff --git a/sql/item_sum.h b/sql/item_sum.h index f715c80ffaf..724581fc6ec 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -1066,7 +1066,7 @@ class Item_sum_std :public Item_sum_variance enum Sumfunctype sum_func () const { return STD_FUNC; } double val_real(); Item *result_item(THD *thd, Field *field); - const char *func_name() const { return "std("; } + const char *func_name() const { return sample ? "stddev_samp(" : "std("; } Item *copy_or_same(THD* thd); Item *get_copy(THD *thd) { return get_item_copy<Item_sum_std>(thd, this); } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7cfa803c73a..1a55159a0e6 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8548,12 +8548,6 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument) case (int) OPT_SKIP_HOST_CACHE: opt_specialflag|= SPECIAL_NO_HOST_CACHE; break; - case (int) OPT_SKIP_RESOLVE: - if ((opt_skip_name_resolve= (argument != disabled_my_option))) - opt_specialflag|= SPECIAL_NO_RESOLVE; - else - opt_specialflag&= ~SPECIAL_NO_RESOLVE; - break; case (int) OPT_WANT_CORE: test_flags |= TEST_CORE_ON_SIGNAL; break; diff --git a/sql/mysqld.h b/sql/mysqld.h index 8e33d6488e4..60afb0b9dba 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -681,7 +681,6 @@ enum options_mysqld OPT_SERVER_ID, OPT_SILENT, OPT_SKIP_HOST_CACHE, - OPT_SKIP_RESOLVE, OPT_SLAVE_PARALLEL_MODE, OPT_SSL_CA, OPT_SSL_CAPATH, diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index afb1968c73f..211114f0d19 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2009, 2022, MariaDB + Copyright (c) 2009, 2023, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -373,9 +373,9 @@ public: update_hostname(&host, safe_strdup_root(mem, host_arg)); } - bool check_validity(bool check_no_resolve) + bool check_validity() { - if (check_no_resolve && + if (opt_skip_name_resolve && (hostname_requires_resolving(host.hostname) || hostname_requires_resolving(proxied_host.hostname))) { @@ -2398,7 +2398,6 @@ static void push_new_user(const ACL_USER &user) static bool acl_load(THD *thd, const Grant_tables& tables) { READ_RECORD read_record_info; - bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; char tmp_name[SAFE_NAME_LEN+1]; Sql_mode_save old_mode_save(thd); DBUG_ENTER("acl_load"); @@ -2441,7 +2440,8 @@ static bool acl_load(THD *thd, const Grant_tables& tables) host.access= host_table.get_access(); host.access= fix_rights_for_db(host.access); host.sort= get_magic_sort("hd", host.host.hostname, host.db); - if (check_no_resolve && hostname_requires_resolving(host.host.hostname)) + if (opt_skip_name_resolve && + hostname_requires_resolving(host.host.hostname)) { sql_print_warning("'host' entry '%s|%s' " "ignored in --skip-name-resolve mode.", @@ -2511,7 +2511,8 @@ static bool acl_load(THD *thd, const Grant_tables& tables) } else { - if (check_no_resolve && hostname_requires_resolving(user.host.hostname)) + if (opt_skip_name_resolve && + hostname_requires_resolving(user.host.hostname)) { sql_print_warning("'user' entry '%s@%s' " "ignored in --skip-name-resolve mode.", user.user.str, @@ -2569,7 +2570,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables) sql_print_warning("Found an entry in the 'db' table with empty database name; Skipped"); continue; } - if (check_no_resolve && hostname_requires_resolving(db.host.hostname)) + if (opt_skip_name_resolve && hostname_requires_resolving(db.host.hostname)) { sql_print_warning("'db' entry '%s %s@%s' " "ignored in --skip-name-resolve mode.", @@ -2624,7 +2625,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables) { ACL_PROXY_USER proxy; proxy.init(proxies_priv_table, &acl_memroot); - if (proxy.check_validity(check_no_resolve)) + if (proxy.check_validity()) continue; if (push_dynamic(&acl_proxy_users, (uchar*) &proxy)) DBUG_RETURN(TRUE); @@ -7780,7 +7781,6 @@ static bool grant_load(THD *thd, { bool return_val= 1; TABLE *t_table, *c_table, *p_table; - bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; MEM_ROOT *save_mem_root= thd->mem_root; sql_mode_t old_sql_mode= thd->variables.sql_mode; DBUG_ENTER("grant_load"); @@ -7824,7 +7824,7 @@ static bool grant_load(THD *thd, goto end_unlock; } - if (check_no_resolve) + if (opt_skip_name_resolve) { if (hostname_requires_resolving(mem_check->host.hostname)) { @@ -7868,7 +7868,7 @@ static bool grant_load(THD *thd, goto end_unlock_p; } - if (check_no_resolve) + if (opt_skip_name_resolve) { if (hostname_requires_resolving(mem_check->host.hostname)) { diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 0346e70a588..1c267e02839 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -891,7 +891,7 @@ int thd_set_peer_addr(THD *thd, return 1; /* The error is set by my_strdup(). */ } thd->main_security_ctx.host_or_ip = thd->main_security_ctx.ip; - if (!(specialflag & SPECIAL_NO_RESOLVE)) + if (!opt_skip_name_resolve) { int rc; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f76e16153e0..f8974bb9cc0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5376,7 +5376,7 @@ mysql_execute_command(THD *thd) List_iterator <LEX_USER> user_list(lex->users_list); while ((user= user_list++)) { - if (specialflag & SPECIAL_NO_RESOLVE && + if (opt_skip_name_resolve && hostname_requires_resolving(user->host.str)) push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_WARN_HOSTNAME_WONT_WORK, diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1fa0980977d..f780ed9c23a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2501,7 +2501,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet, add_table_options(thd, table, create_info_arg, table_list->schema_table != 0, 0, packet); - if (table->versioned()) + if (DBUG_EVALUATE_IF("sysvers_hide", 0, table->versioned())) packet->append(STRING_WITH_LEN(" WITH SYSTEM VERSIONING")); #ifdef WITH_PARTITION_STORAGE_ENGINE diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c1f7c7fee7a..725af4adb4e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9837,6 +9837,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, if (check_engine(thd, alter_ctx.new_db.str, alter_ctx.new_name.str, create_info)) DBUG_RETURN(true); + create_info->vers_check_native(); if (create_info->vers_info.fix_alter_info(thd, alter_info, create_info, table)) { DBUG_RETURN(true); diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index a25f6522bd9..8461fde3439 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -540,7 +540,7 @@ bool Item_func_in::create_value_list_for_tvc(THD *thd, if (is_list_of_rows) { - Item_row *row_list= (Item_row *)(args[i]->build_clone(thd)); + Item_row *row_list= (Item_row *)(args[i]); if (!row_list) return true; @@ -565,8 +565,7 @@ bool Item_func_in::create_value_list_for_tvc(THD *thd, sprintf(col_name, "_col_%i", 1); args[i]->set_name(thd, col_name, strlen(col_name), thd->charset()); } - Item *arg_clone= args[i]->build_clone(thd); - if (!arg_clone || tvc_value->push_back(arg_clone)) + if (tvc_value->push_back(args[i])) return true; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2682aef14d8..97bf707f7c9 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2022, MariaDB + Copyright (c) 2010, 2023, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -834,7 +834,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); /* We should not introduce any further shift/reduce conflicts. */ -%expect 72 +%expect 83 /* Comments for TOKENS. @@ -1631,7 +1631,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %left PREC_BELOW_NOT -%nonassoc NOT_SYM +%nonassoc LOW_PRIORITY_NOT %left '=' EQUAL_SYM GE '>' LE '<' NE %nonassoc IS %right BETWEEN_SYM @@ -10065,7 +10065,7 @@ expr: MYSQL_YYABORT; } } - | NOT_SYM expr %prec NOT_SYM + | NOT_SYM expr %prec LOW_PRIORITY_NOT { $$= negate_expression(thd, $2); if (unlikely($$ == NULL)) diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index 71f18ec2949..91913020644 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2021, MariaDB + Copyright (c) 2010, 2023, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -310,7 +310,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); /* We should not introduce any further shift/reduce conflicts. */ -%expect 73 +%expect 84 /* Comments for TOKENS. @@ -1107,7 +1107,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %left PREC_BELOW_NOT -%nonassoc NOT_SYM +%nonassoc LOW_PRIORITY_NOT %left '=' EQUAL_SYM GE '>' LE '<' NE %nonassoc IS %right BETWEEN_SYM @@ -10180,7 +10180,7 @@ expr: MYSQL_YYABORT; } } - | NOT_SYM expr %prec NOT_SYM + | NOT_SYM expr %prec LOW_PRIORITY_NOT { $$= negate_expression(thd, $2); if (unlikely($$ == NULL)) diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 56f3bd92bc4..627b6191e51 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2876,7 +2876,7 @@ static Sys_var_mybool Sys_skip_name_resolve( "skip_name_resolve", "Don't resolve hostnames. All hostnames are IP's or 'localhost'.", READ_ONLY GLOBAL_VAR(opt_skip_name_resolve), - CMD_LINE(OPT_ARG, OPT_SKIP_RESOLVE), + CMD_LINE(OPT_ARG), DEFAULT(FALSE)); static Sys_var_mybool Sys_skip_show_database( diff --git a/sql/table.cc b/sql/table.cc index 8bdab4f4fab..a06834afd8b 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3347,7 +3347,7 @@ class Vcol_expr_context bool inited; THD *thd; TABLE *table; - Query_arena backup_arena; + Query_arena backup_arena, *stmt_arena; table_map old_map; Security_context *save_security_ctx; sql_mode_t save_sql_mode; @@ -3357,6 +3357,7 @@ public: inited(false), thd(_thd), table(_table), + stmt_arena(thd->stmt_arena), old_map(table->map), save_security_ctx(thd->security_ctx), save_sql_mode(thd->variables.sql_mode) {} @@ -3377,6 +3378,7 @@ bool Vcol_expr_context::init() thd->security_ctx= tl->security_ctx; thd->set_n_backup_active_arena(table->expr_arena, &backup_arena); + thd->stmt_arena= thd; inited= true; return false; @@ -3390,6 +3392,7 @@ Vcol_expr_context::~Vcol_expr_context() thd->security_ctx= save_security_ctx; thd->restore_active_arena(table->expr_arena, &backup_arena); thd->variables.sql_mode= save_sql_mode; + thd->stmt_arena= stmt_arena; } diff --git a/sql/unireg.h b/sql/unireg.h index dd003cd0b3f..419cf1f17d5 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -62,7 +62,7 @@ #define SPECIAL_WAIT_IF_LOCKED 8 /* Wait if locked database */ #define SPECIAL_SAME_DB_NAME 16 /* form name = file name */ #define SPECIAL_ENGLISH 32 /* English error messages */ -#define SPECIAL_NO_RESOLVE 64 /* Don't use gethostname */ +#define SPECIAL_NO_RESOLVE 64 /* Obsolete */ #define SPECIAL_NO_PRIOR 128 /* Obsolete */ #define SPECIAL_BIG_SELECTS 256 /* Don't use heap tables */ #define SPECIAL_NO_HOST_CACHE 512 /* Don't cache hosts */ |