| 4795 | */ |
| 4796 | |
| 4797 | static bool update_user_table_password(THD *thd, const User_table& user_table, |
| 4798 | const ACL_USER &user) |
| 4799 | { |
| 4800 | char user_key[MAX_KEY_LENGTH]; |
| 4801 | int error; |
| 4802 | DBUG_ENTER("update_user_table_password"); |
| 4803 | |
| 4804 | TABLE *table= user_table.table(); |
| 4805 | table->use_all_columns(); |
| 4806 | user_table.set_host(user.host.hostname, user.hostname_length); |
| 4807 | user_table.set_user(user.user.str, user.user.length); |
| 4808 | key_copy((uchar *) user_key, table->record[0], table->key_info, |
| 4809 | table->key_info->key_length); |
| 4810 | |
| 4811 | if (table->file->ha_index_read_idx_map(table->record[0], 0, |
| 4812 | (uchar *) user_key, HA_WHOLE_KEY, |
| 4813 | HA_READ_KEY_EXACT)) |
| 4814 | { |
| 4815 | my_message(ER_PASSWORD_NO_MATCH, ER_THD(thd, ER_PASSWORD_NO_MATCH), |
| 4816 | MYF(0)); |
| 4817 | DBUG_RETURN(1); |
| 4818 | } |
| 4819 | store_record(table, record[1]); |
| 4820 | |
| 4821 | if (user_table.set_auth(user)) |
| 4822 | { |
| 4823 | my_error(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE, MYF(0), |
| 4824 | user_table.name().str, 3, user_table.num_fields(), |
| 4825 | static_cast<int>(table->s->mysql_version), MYSQL_VERSION_ID); |
| 4826 | DBUG_RETURN(1); |
| 4827 | } |
| 4828 | |
| 4829 | user_table.set_password_expired(user.password_expired); |
| 4830 | user_table.set_password_last_changed(user.password_last_changed); |
| 4831 | |
| 4832 | if (unlikely(error= table->file->ha_update_row(table->record[1], |
| 4833 | table->record[0])) && |
| 4834 | error != HA_ERR_RECORD_IS_THE_SAME) |
| 4835 | { |
| 4836 | table->file->print_error(error,MYF(0)); |
| 4837 | DBUG_RETURN(1); |
| 4838 | } |
| 4839 | |
| 4840 | DBUG_RETURN(0); |
| 4841 | } |
| 4842 | |
| 4843 | |
| 4844 | /* |
no test coverage detected