Commit ed39181a authored by Alexander Barkov's avatar Alexander Barkov

MDEV-19533 Add methods make() and append_uniq() to Row_definition_list

parent fae13194
......@@ -4852,6 +4852,14 @@ class Row_definition_list: public List<class Spvar_definition>
}
return 0;
}
static Row_definition_list *make(MEM_ROOT *mem_root, Spvar_definition *var)
{
Row_definition_list *list;
if (!(list= new (mem_root) Row_definition_list()))
return NULL;
return list->push_back(var, mem_root) ? NULL : list;
}
bool append_uniq(MEM_ROOT *thd, Spvar_definition *var);
bool adjust_formal_params_to_actual_params(THD *thd, List<Item> *args);
bool adjust_formal_params_to_actual_params(THD *thd,
Item **args, uint arg_count);
......
......@@ -119,6 +119,19 @@ sp_rcontext *sp_rcontext::create(THD *thd,
}
bool Row_definition_list::append_uniq(MEM_ROOT *mem_root, Spvar_definition *var)
{
DBUG_ASSERT(elements);
uint unused;
if (unlikely(find_row_field_by_name(&var->field_name, &unused)))
{
my_error(ER_DUP_FIELDNAME, MYF(0), var->field_name.str);
return true;
}
return push_back(var, mem_root);
}
bool Row_definition_list::
adjust_formal_params_to_actual_params(THD *thd, List<Item> *args)
{
......
......@@ -10416,3 +10416,19 @@ bool LEX::stmt_create_stored_function_start(const DDL_options_st &options,
return true;
return false;
}
Spvar_definition *LEX::row_field_name(THD *thd, const Lex_ident_sys_st &name)
{
Spvar_definition *res;
if (unlikely(check_string_char_length(&name, 0, NAME_CHAR_LEN,
system_charset_info, 1)))
{
my_error(ER_TOO_LONG_IDENT, MYF(0), name.str);
return NULL;
}
if (unlikely(!(res= new (thd->mem_root) Spvar_definition())))
return NULL;
init_last_field(res, &name, thd->variables.collation_database);
return res;
}
......@@ -4506,6 +4506,7 @@ struct LEX: public Query_tables_list
const Lex_ident_sys_st &name,
Item_result return_type,
const LEX_CSTRING &soname);
Spvar_definition *row_field_name(THD *thd, const Lex_ident_sys_st &name);
};
......
......@@ -3508,12 +3508,8 @@ optionally_qualified_column_ident:
row_field_name:
ident
{
if (unlikely(check_string_char_length(&$1, 0, NAME_CHAR_LEN,
system_charset_info, 1)))
my_yyabort_error((ER_TOO_LONG_IDENT, MYF(0), $1.str));
if (unlikely(!($$= new (thd->mem_root) Spvar_definition())))
if (!($$= Lex->row_field_name(thd, $1)))
MYSQL_YYABORT;
Lex->init_last_field($$, &$1, thd->variables.collation_database);
}
;
......@@ -3524,17 +3520,12 @@ row_field_definition:
row_field_definition_list:
row_field_definition
{
if (unlikely(!($$= new (thd->mem_root) Row_definition_list())) ||
unlikely($$->push_back($1, thd->mem_root)))
if (!($$= Row_definition_list::make(thd->mem_root, $1)))
MYSQL_YYABORT;
}
| row_field_definition_list ',' row_field_definition
{
uint unused;
if (unlikely($1->find_row_field_by_name(&$3->field_name, &unused)))
my_yyabort_error((ER_DUP_FIELDNAME, MYF(0), $3->field_name.str));
$$= $1;
if (unlikely($$->push_back($3, thd->mem_root)))
if (($$= $1)->append_uniq(thd->mem_root, $3))
MYSQL_YYABORT;
}
;
......
......@@ -3411,12 +3411,8 @@ optionally_qualified_column_ident:
row_field_name:
ident_directly_assignable
{
if (unlikely(check_string_char_length(&$1, 0, NAME_CHAR_LEN,
system_charset_info, 1)))
my_yyabort_error((ER_TOO_LONG_IDENT, MYF(0), $1.str));
if (unlikely(!($$= new (thd->mem_root) Spvar_definition())))
if (!($$= Lex->row_field_name(thd, $1)))
MYSQL_YYABORT;
Lex->init_last_field($$, &$1, thd->variables.collation_database);
}
;
......@@ -3427,17 +3423,12 @@ row_field_definition:
row_field_definition_list:
row_field_definition
{
if (unlikely(!($$= new (thd->mem_root) Row_definition_list())) ||
unlikely($$->push_back($1, thd->mem_root)))
if (!($$= Row_definition_list::make(thd->mem_root, $1)))
MYSQL_YYABORT;
}
| row_field_definition_list ',' row_field_definition
{
uint unused;
if (unlikely($1->find_row_field_by_name(&$3->field_name, &unused)))
my_yyabort_error((ER_DUP_FIELDNAME, MYF(0), $3->field_name.str));
$$= $1;
if (unlikely($$->push_back($3, thd->mem_root)))
if (($$= $1)->append_uniq(thd->mem_root, $3))
MYSQL_YYABORT;
}
;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment