1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge 10.5 into 10.6

This commit is contained in:
Marko Mäkelä
2021-04-08 10:11:36 +03:00
50 changed files with 1264 additions and 204 deletions

View File

@ -3042,6 +3042,15 @@ bool check_duplicates_in_interval(const char *set_or_name,
}
bool Column_definition::
prepare_charset_for_string(const Column_derived_attributes *dattr)
{
if (!charset)
charset= dattr->charset();
return (flags & BINCMP_FLAG) && !(charset= find_bin_collation(charset));
}
bool Column_definition::prepare_stage2_blob(handler *file,
ulonglong table_flags,
uint field_flags)
@ -3122,38 +3131,6 @@ bool Column_definition::prepare_stage2(handler *file,
}
/*
Get character set from field object generated by parser using
default values when not set.
SYNOPSIS
get_sql_field_charset()
sql_field The sql_field object
create_info Info generated by parser
RETURN VALUES
cs Character set
*/
CHARSET_INFO* get_sql_field_charset(Column_definition *sql_field,
HA_CREATE_INFO *create_info)
{
CHARSET_INFO *cs= sql_field->charset;
if (!cs)
cs= create_info->default_table_charset;
/*
table_charset is set only in ALTER TABLE t1 CONVERT TO CHARACTER SET csname
if we want change character set for all varchar/char columns.
But the table charset must not affect the BLOB fields, so don't
allow to change my_charset_bin to somethig else.
*/
if (create_info->table_charset && cs != &my_charset_bin)
cs= create_info->table_charset;
return cs;
}
/**
Modifies the first column definition whose SQL type is TIMESTAMP
by adding the features DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP.
@ -3326,11 +3303,14 @@ bool Column_definition::prepare_stage1_bit(THD *thd,
bool Column_definition::prepare_stage1(THD *thd,
MEM_ROOT *mem_root,
handler *file,
ulonglong table_flags)
ulonglong table_flags,
const Column_derived_attributes
*derived_attr)
{
return type_handler()->Column_definition_prepare_stage1(thd, mem_root,
this, file,
table_flags);
table_flags,
derived_attr);
}
@ -3597,6 +3577,9 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
int select_field_count= C_CREATE_SELECT(create_table_mode);
bool tmp_table= create_table_mode == C_ALTER_TABLE;
bool is_hash_field_needed= false;
const Column_derived_attributes dattr(create_info->default_table_charset);
const Column_bulk_alter_attributes
battr(create_info->alter_table_convert_to_charset);
DBUG_ENTER("mysql_prepare_create_table");
DBUG_EXECUTE_IF("test_pseudo_invisible",{
@ -3652,26 +3635,27 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
for (field_no=0; (sql_field=it++) ; field_no++)
{
/* Virtual fields are always NULL */
if (sql_field->vcol_info)
sql_field->flags&= ~NOT_NULL_FLAG;
/*
Initialize length from its original value (number of characters),
which was set in the parser. This is necessary if we're
executing a prepared statement for the second time.
*/
sql_field->length= sql_field->char_length;
/* Set field charset. */
sql_field->charset= get_sql_field_charset(sql_field, create_info);
if ((sql_field->flags & BINCMP_FLAG) &&
!(sql_field->charset= find_bin_collation(sql_field->charset)))
DBUG_RETURN(true);
/* Virtual fields are always NULL */
if (sql_field->vcol_info)
sql_field->flags&= ~NOT_NULL_FLAG;
if (sql_field->bulk_alter(&dattr, &battr))
DBUG_RETURN(true);
if (sql_field->prepare_stage1(thd, thd->mem_root,
file, file->ha_table_flags()))
file, file->ha_table_flags(),
&dattr))
DBUG_RETURN(true);
DBUG_ASSERT(sql_field->charset);
if (sql_field->real_field_type() == MYSQL_TYPE_BIT &&
file->ha_table_flags() & HA_CAN_BIT_FIELD)
total_uneven_bit_length+= sql_field->length & 7;
@ -3722,7 +3706,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (!(sql_field->flags & NOT_NULL_FLAG))
null_fields--;
if (sql_field->redefine_stage1(dup_field, file, create_info))
if (sql_field->redefine_stage1(dup_field, file))
DBUG_RETURN(true);
it2.remove(); // Remove first (create) definition
@ -4763,7 +4747,9 @@ bool Column_definition::prepare_blob_field(THD *thd)
bool Column_definition::sp_prepare_create_field(THD *thd, MEM_ROOT *mem_root)
{
return prepare_stage1(thd, mem_root, NULL, HA_CAN_GEOMETRY) ||
DBUG_ASSERT(charset);
const Column_derived_attributes dattr(&my_charset_bin);
return prepare_stage1(thd, mem_root, NULL, HA_CAN_GEOMETRY, &dattr) ||
prepare_stage2(NULL, HA_CAN_GEOMETRY);
}
@ -10200,7 +10186,8 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
If such table exists, there must be a corresponding TABLE_SHARE in
THD::all_temp_tables list.
*/
if (thd->find_tmp_table_share(alter_ctx.new_db.str, alter_ctx.new_name.str))
if (thd->find_tmp_table_share(alter_ctx.new_db.str,
alter_ctx.new_name.str))
{
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alter_ctx.new_alias.str);
DBUG_RETURN(true);
@ -10341,6 +10328,17 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
if (table->s->tmp_table == NO_TMP_TABLE)
mysql_audit_alter_table(thd, table_list);
else if (table_creation_was_logged && mysql_bin_log.is_open())
{
/* Protect against MDL error in binary logging */
MDL_request mdl_request;
DBUG_ASSERT(!mdl_ticket);
MDL_REQUEST_INIT(&mdl_request, MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT,
MDL_TRANSACTION);
if (thd->mdl_context.acquire_lock(&mdl_request,
thd->variables.lock_wait_timeout))
DBUG_RETURN(true);
}
THD_STAGE_INFO(thd, stage_setup);
@ -12051,8 +12049,8 @@ bool Sql_cmd_create_table_like::execute(THD *thd)
{
create_info.used_fields&= ~HA_CREATE_USED_CHARSET;
create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
create_info.default_table_charset= create_info.table_charset;
create_info.table_charset= 0;
create_info.default_table_charset= create_info.alter_table_convert_to_charset;
create_info.alter_table_convert_to_charset= 0;
}
/*