1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Merge 10.3 into 10.4

This commit is contained in:
Marko Mäkelä
2019-08-31 06:53:45 +03:00
103 changed files with 2674 additions and 632 deletions

View File

@ -64,7 +64,7 @@ const char *primary_key_name="PRIMARY";
static int check_if_keyname_exists(const char *name,KEY *start, KEY *end);
static char *make_unique_key_name(THD *, const char *, KEY *, KEY *);
static void make_unique_constraint_name(THD *, LEX_CSTRING *, const char *,
static bool make_unique_constraint_name(THD *, LEX_CSTRING *, const char *,
List<Virtual_column_info> *, uint *);
static const char *make_unique_invisible_field_name(THD *, const char *,
List<Create_field> *);
@ -76,6 +76,9 @@ static int copy_data_between_tables(THD *, TABLE *,TABLE *,
static int mysql_prepare_create_table(THD *, HA_CREATE_INFO *, Alter_info *,
uint *, handler *, KEY **, uint *, int);
static uint blob_length_by_type(enum_field_types type);
static bool fix_constraints_names(THD *thd, List<Virtual_column_info>
*check_constraint_list,
const HA_CREATE_INFO *create_info);
/**
@brief Helper function for explain_filename
@ -4311,20 +4314,13 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
/* Check table level constraints */
create_info->check_constraint_list= &alter_info->check_constraint_list;
{
uint nr= 1;
List_iterator_fast<Virtual_column_info> c_it(alter_info->check_constraint_list);
Virtual_column_info *check;
while ((check= c_it++))
{
if (!check->name.length)
{
const char *own_name_base= create_info->period_info.constr == check
? create_info->period_info.name.str : NULL;
if (!check->name.length || check->automatic_name)
continue;
make_unique_constraint_name(thd, &check->name, own_name_base,
&alter_info->check_constraint_list,
&nr);
}
{
/* Check that there's no repeating constraint names. */
List_iterator_fast<Virtual_column_info>
@ -4869,6 +4865,10 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db,
DBUG_PRINT("enter", ("db: '%s' table: '%s' tmp: %d path: %s",
db.str, table_name.str, internal_tmp_table, path));
if (fix_constraints_names(thd, &alter_info->check_constraint_list,
create_info))
DBUG_RETURN(1);
if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)
{
if (create_info->data_file_name)
@ -5367,7 +5367,7 @@ make_unique_key_name(THD *thd, const char *field_name,KEY *start,KEY *end)
Make an unique name for constraints without a name
*/
static void make_unique_constraint_name(THD *thd, LEX_CSTRING *name,
static bool make_unique_constraint_name(THD *thd, LEX_CSTRING *name,
const char *own_name_base,
List<Virtual_column_info> *vcol,
uint *nr)
@ -5395,9 +5395,10 @@ static void make_unique_constraint_name(THD *thd, LEX_CSTRING *name,
{
name->length= (size_t) (real_end - buff);
name->str= thd->strmake(buff, name->length);
return;
return (name->str == NULL);
}
}
return FALSE;
}
/**
@ -6020,10 +6021,11 @@ static bool is_candidate_key(KEY *key)
from the list if existing found.
RETURN VALUES
NONE
TRUE error
FALSE OK
*/
static void
static bool
handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info,
Table_period_info *period_info)
{
@ -6469,6 +6471,7 @@ remove_key:
Virtual_column_info *check;
TABLE_SHARE *share= table->s;
uint c;
while ((check=it++))
{
if (!(check->flags & Alter_info::CHECK_CONSTRAINT_IF_NOT_EXISTS) &&
@ -6516,7 +6519,48 @@ remove_key:
*period_info= {};
}
DBUG_VOID_RETURN;
DBUG_RETURN(false);
}
static bool fix_constraints_names(THD *thd, List<Virtual_column_info>
*check_constraint_list,
const HA_CREATE_INFO *create_info)
{
List_iterator<Virtual_column_info> it((*check_constraint_list));
Virtual_column_info *check;
uint nr= 1;
DBUG_ENTER("fix_constraints_names");
if (!check_constraint_list)
DBUG_RETURN(FALSE);
// Prevent accessing freed memory during generating unique names
while ((check=it++))
{
if (check->automatic_name)
{
check->name.str= NULL;
check->name.length= 0;
}
}
it.rewind();
// Generate unique names if needed
while ((check=it++))
{
if (!check->name.length)
{
check->automatic_name= TRUE;
const char *own_name_base= create_info->period_info.constr == check
? create_info->period_info.name.str : NULL;
if (make_unique_constraint_name(thd, &check->name,
own_name_base,
check_constraint_list,
&nr))
DBUG_RETURN(TRUE);
}
}
DBUG_RETURN(FALSE);
}
@ -9657,7 +9701,11 @@ do_continue:;
}
}
handle_if_exists_options(thd, table, alter_info, &create_info->period_info);
if (handle_if_exists_options(thd, table, alter_info,
&create_info->period_info) ||
fix_constraints_names(thd, &alter_info->check_constraint_list,
create_info))
DBUG_RETURN(true);
/*
Look if we have to do anything at all.