diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2022-08-03 07:12:27 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-08-03 07:12:27 +0200 |
commit | af143474d8925cdbcfc0795a2bc274cbeaad8889 (patch) | |
tree | 790022e64c90ce37310d20f1de25af35b0f722c9 /sql | |
parent | 7b500f04fb0baf56b02583f82982508203e58d38 (diff) | |
parent | 48e35b8cf61cbedb515787762708afe7bd75386b (diff) | |
download | mariadb-git-af143474d8925cdbcfc0795a2bc274cbeaad8889.tar.gz |
Merge branch '10.4' into 10.5
Diffstat (limited to 'sql')
-rw-r--r-- | sql/handler.cc | 37 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 2 | ||||
-rw-r--r-- | sql/item_func.h | 3 | ||||
-rw-r--r-- | sql/item_jsonfunc.cc | 42 | ||||
-rw-r--r-- | sql/share/errmsg-utf8.txt | 4 | ||||
-rw-r--r-- | sql/sql_acl.cc | 39 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 2 |
7 files changed, 87 insertions, 42 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index fe3d3918636..0d5609f753a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4608,17 +4608,32 @@ int handler::ha_check(THD *thd, HA_CHECK_OPT *check_opt) DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK); - if ((table->s->mysql_version >= MYSQL_VERSION_ID) && + const ulong v= table->s->mysql_version; + + if ((v >= MYSQL_VERSION_ID) && (check_opt->sql_flags & TT_FOR_UPGRADE)) return 0; - if (table->s->mysql_version < MYSQL_VERSION_ID) + if (v < MYSQL_VERSION_ID) { if (unlikely((error= check_old_types()))) return error; error= ha_check_for_upgrade(check_opt); if (unlikely(error && (error != HA_ADMIN_NEEDS_CHECK))) return error; + if (table->s->table_category == TABLE_CATEGORY_USER && + (v < 100142 || + (v >= 100200 && v < 100228) || + (v >= 100300 && v < 100319) || + (v >= 100400 && v < 100409))) + { + for (const KEY *key= table->key_info, + *end= table->key_info + table->s->keys; key < end; key++) + { + if (key->flags & HA_BINARY_PACK_KEY && key->flags & HA_VAR_LENGTH_KEY) + return HA_ADMIN_NEEDS_UPGRADE; + } + } if (unlikely(!error && (check_opt->sql_flags & TT_FOR_UPGRADE))) return 0; } @@ -7182,6 +7197,17 @@ int handler::ha_write_row(const uchar *buf) if ((error= ha_check_overlaps(NULL, buf))) DBUG_RETURN(error); + /* + NOTE: this != table->file is true in 3 cases: + + 1. under copy_partitions() (REORGANIZE PARTITION): that does not + require long unique check as it does not introduce new rows or new index. + 2. under partition's ha_write_row() (INSERT): check_duplicate_long_entries() + was already done by ha_partition::ha_write_row(), no need to check it + again for each single partition. + 3. under ha_mroonga::wrapper_write_row() + */ + if (table->s->long_unique_table && this == table->file) { DBUG_ASSERT(inited == NONE || lookup_handler != this); @@ -7235,6 +7261,13 @@ int handler::ha_update_row(const uchar *old_data, const uchar *new_data) uint saved_status= table->status; error= ha_check_overlaps(old_data, new_data); + /* + NOTE: this != table->file is true under partition's ha_update_row(): + check_duplicate_long_entries_update() was already done by + ha_partition::ha_update_row(), no need to check it again for each single + partition. Same applies to ha_mroonga wrapper. + */ + if (!error && table->s->long_unique_table && this == table->file) error= check_duplicate_long_entries_update(new_data); table->status= saved_status; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index f49d17a6ded..8461de9cd36 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -789,7 +789,9 @@ int Arg_comparator::compare_e_string() { String *res1,*res2; res1= (*a)->val_str(&value1); + DBUG_ASSERT((res1 == NULL) == (*a)->null_value); res2= (*b)->val_str(&value2); + DBUG_ASSERT((res2 == NULL) == (*b)->null_value); if (!res1 || !res2) return MY_TEST(res1 == res2); return MY_TEST(sortcmp(res1, res2, compare_collation()) == 0); diff --git a/sql/item_func.h b/sql/item_func.h index a7dbb9ab4bc..8d2a230321e 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1975,8 +1975,7 @@ public: void cleanup() { first_eval= TRUE; Item_real_func::cleanup(); } 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_SESSION_FUNC); } Item *get_copy(THD *thd) { return get_item_copy<Item_func_rand>(thd, this); } diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 7aa9f2917ea..2fd2f459d0b 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -150,10 +150,12 @@ int json_path_parts_compare( { int res, res2; - long arbitrary_var; - long stack_used_up= (available_stack_size(current_thd->thread_stack, &arbitrary_var)); DBUG_EXECUTE_IF("json_check_min_stack_requirement", - {ALLOCATE_MEM_ON_STACK(my_thread_stack_size-stack_used_up-STACK_MIN_SIZE);}); + { + long arbitrary_var; + long stack_used_up= (available_stack_size(current_thd->thread_stack, &arbitrary_var)); + ALLOCATE_MEM_ON_STACK(my_thread_stack_size-stack_used_up-STACK_MIN_SIZE); + }); if (check_stack_overrun(current_thd, STACK_MIN_SIZE , NULL)) return 1; @@ -1096,13 +1098,15 @@ my_decimal *Item_func_json_extract::val_decimal(my_decimal *to) case JSON_VALUE_OBJECT: case JSON_VALUE_ARRAY: case JSON_VALUE_FALSE: - case JSON_VALUE_NULL: case JSON_VALUE_UNINITALIZED: - break; + // TODO: fix: NULL should be NULL + case JSON_VALUE_NULL: + int2my_decimal(E_DEC_FATAL_ERROR, 0, false/*unsigned_flag*/, to); + return to; }; } - int2my_decimal(E_DEC_FATAL_ERROR, 0, false/*unsigned_flag*/, to); - return to; + DBUG_ASSERT(null_value); + return 0; } @@ -1140,10 +1144,12 @@ static int check_contains(json_engine_t *js, json_engine_t *value) { json_engine_t loc_js; bool set_js; - long arbitrary_var; - long stack_used_up= (available_stack_size(current_thd->thread_stack, &arbitrary_var)); DBUG_EXECUTE_IF("json_check_min_stack_requirement", - {ALLOCATE_MEM_ON_STACK(my_thread_stack_size-stack_used_up-STACK_MIN_SIZE);}); + { + long arbitrary_var; + long stack_used_up= (available_stack_size(current_thd->thread_stack, &arbitrary_var)); + ALLOCATE_MEM_ON_STACK(my_thread_stack_size-stack_used_up-STACK_MIN_SIZE); + }); if (check_stack_overrun(current_thd, STACK_MIN_SIZE , NULL)) return 1; @@ -2106,10 +2112,12 @@ err_return: static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2) { - long arbitrary_var; - long stack_used_up= (available_stack_size(current_thd->thread_stack, &arbitrary_var)); DBUG_EXECUTE_IF("json_check_min_stack_requirement", - {ALLOCATE_MEM_ON_STACK(my_thread_stack_size-stack_used_up-STACK_MIN_SIZE);}); + { + long arbitrary_var; + long stack_used_up= (available_stack_size(current_thd->thread_stack, &arbitrary_var)); + ALLOCATE_MEM_ON_STACK(my_thread_stack_size-stack_used_up-STACK_MIN_SIZE); + }); if (check_stack_overrun(current_thd, STACK_MIN_SIZE , NULL)) return 1; @@ -2445,10 +2453,12 @@ static int copy_value_patch(String *str, json_engine_t *je) static int do_merge_patch(String *str, json_engine_t *je1, json_engine_t *je2, bool *empty_result) { - long arbitrary_var; - long stack_used_up= (available_stack_size(current_thd->thread_stack, &arbitrary_var)); DBUG_EXECUTE_IF("json_check_min_stack_requirement", - {ALLOCATE_MEM_ON_STACK(my_thread_stack_size-stack_used_up-STACK_MIN_SIZE);}); + { + long arbitrary_var; + long stack_used_up= (available_stack_size(current_thd->thread_stack, &arbitrary_var)); + ALLOCATE_MEM_ON_STACK(my_thread_stack_size-stack_used_up-STACK_MIN_SIZE); + }); if (check_stack_overrun(current_thd, STACK_MIN_SIZE , NULL)) return 1; diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 07f00a9fa81..718a69e2cc2 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7727,8 +7727,8 @@ ER_INVALID_YEAR_COLUMN_LENGTH rus "Тип YEAR(%lu) более не поддерживается, вместо него будет создана колонка с типом YEAR(4)" ER_NOT_VALID_PASSWORD - chi "您的密码不满足当前的政策要求" - eng "Your password does not satisfy the current policy requirements" + eng "Your password does not satisfy the current policy requirements (%s)" + ukr "Ваш пароль не відповідає поточним правилам (%s)" ER_MUST_CHANGE_PASSWORD bgn "Трябва първо да си смените паролата със SET PASSWORD за да можете да изпълните тази команда" diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index c4e66cf5d73..74241e7d9c2 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2175,7 +2175,12 @@ static my_bool do_validate(THD *, plugin_ref plugin, void *arg) struct validation_data *data= (struct validation_data *)arg; struct st_mariadb_password_validation *handler= (st_mariadb_password_validation *)plugin_decl(plugin)->info; - return handler->validate_password(data->user, data->password); + if (handler->validate_password(data->user, data->password)) + { + my_error(ER_NOT_VALID_PASSWORD, MYF(0), plugin_ref_to_int(plugin)->name.str); + return true; + } + return false; } @@ -2189,7 +2194,6 @@ static bool validate_password(THD *thd, const LEX_CSTRING &user, if (plugin_foreach(NULL, do_validate, MariaDB_PASSWORD_VALIDATION_PLUGIN, &data)) { - my_error(ER_NOT_VALID_PASSWORD, MYF(0)); return true; } } @@ -10746,24 +10750,21 @@ static int handle_grant_data(THD *thd, Grant_tables& tables, bool drop, } /* Handle roles_mapping table. */ - if (tables.roles_mapping_table().table_exists()) + if (tables.roles_mapping_table().table_exists() && + (found= handle_grant_table(thd, tables.roles_mapping_table(), + ROLES_MAPPING_TABLE, drop, user_from, user_to)) < 0) { - if ((found= handle_grant_table(thd, tables.roles_mapping_table(), - ROLES_MAPPING_TABLE, drop, - user_from, user_to)) < 0) - { - /* Handle of table failed, don't touch the in-memory array. */ - result= -1; - } - else - { - /* Handle acl_roles_mappings array */ - if ((handle_grant_struct(ROLES_MAPPINGS_HASH, drop, user_from, user_to) || found) - && ! result) - result= 1; /* At least one record/element found */ - if (search_only) - goto end; - } + /* Handle of table failed, don't touch the in-memory array. */ + result= -1; + } + else + { + /* Handle acl_roles_mappings array */ + if ((handle_grant_struct(ROLES_MAPPINGS_HASH, drop, user_from, user_to) || found) + && ! result) + result= 1; /* At least one record/element found */ + if (search_only) + goto end; } /* Handle user table. */ diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index ee94f2d7d07..db081c5c559 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -2528,7 +2528,7 @@ static bool plugin_dl_foreach_internal(THD *thd, st_plugin_dl *plugin_dl, tmp.plugin_dl= plugin_dl; mysql_mutex_lock(&LOCK_plugin); - if ((plugin= plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN)) && + if ((plugin= plugin_find_internal(&tmp.name, plug->type)) && plugin->plugin == plug) { |