diff options
author | Alexander Barkov <bar@mariadb.org> | 2017-09-28 17:26:23 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2017-09-28 17:26:23 +0400 |
commit | 596baeb1bfb812ad9b458eba0f6ea7d9bcdf4671 (patch) | |
tree | 04471f0d7548603406c1fd6d03e2e965022bffbf /sql/sp_rcontext.cc | |
parent | 3a6d94428f71171a88f1e7324952c1abbda00295 (diff) | |
download | mariadb-git-596baeb1bfb812ad9b458eba0f6ea7d9bcdf4671.tar.gz |
A cleanup for MDEV-10577 and MDEV-13919: moving a few sp_rcontext methods
Moving a few methods from sp_rcontext to different classes:
- Table_ident::resolve_table_rowtype_ref
- Qualified_column_ident::resolve_type_ref
- Row_definition_list::resolve_table_rowtype_ref
- Row_definition_list::adjust_formal_params_to_actual_params
It easier to reuse these methods this way in the future.
Diffstat (limited to 'sql/sp_rcontext.cc')
-rw-r--r-- | sql/sp_rcontext.cc | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 9fca1d37c1d..e82947835f0 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -73,15 +73,15 @@ sp_rcontext *sp_rcontext::create(THD *thd, if (!ctx) return NULL; - List<Spvar_definition> field_def_lst; + Row_definition_list field_def_lst; ctx->m_root_parsing_ctx->retrieve_field_definitions(&field_def_lst); if (args && - ctx->adjust_formal_params_to_actual_params(thd, field_def_lst, args)) + field_def_lst.adjust_formal_params_to_actual_params(thd, args)) return NULL; if (ctx->alloc_arrays(thd) || - (resolve_type_refs && ctx->resolve_type_refs(thd, field_def_lst)) || + (resolve_type_refs && field_def_lst.resolve_type_refs(thd)) || ctx->init_var_table(thd, field_def_lst) || ctx->init_var_items(thd, field_def_lst)) { @@ -93,13 +93,12 @@ sp_rcontext *sp_rcontext::create(THD *thd, } -bool sp_rcontext::adjust_formal_params_to_actual_params(THD *thd, - List<Spvar_definition> &field_def_lst, - List<Item> *args) +bool Row_definition_list:: + adjust_formal_params_to_actual_params(THD *thd, List<Item> *args) { - List_iterator<Spvar_definition> it(field_def_lst); + List_iterator<Spvar_definition> it(*this); List_iterator<Item> it_args(*args); - DBUG_ASSERT(field_def_lst.elements >= args->elements ); + DBUG_ASSERT(elements >= args->elements ); Spvar_definition *def; Item *arg; while ((def= it++) && (arg= it_args++)) @@ -169,8 +168,7 @@ check_column_grant_for_type_ref(THD *thd, TABLE_LIST *table_list, /** This method implementation is very close to fill_schema_table_by_open(). */ -bool sp_rcontext::resolve_type_ref(THD *thd, Column_definition *def, - Qualified_column_ident *ref) +bool Qualified_column_ident::resolve_type_ref(THD *thd, Column_definition *def) { Open_tables_backup open_tables_state_backup; thd->reset_n_backup_open_tables_state(&open_tables_state_backup); @@ -187,18 +185,18 @@ bool sp_rcontext::resolve_type_ref(THD *thd, Column_definition *def, // Make %TYPE variables see temporary tables that shadow permanent tables thd->temporary_tables= open_tables_state_backup.temporary_tables; - if ((table_list= lex.select_lex.add_table_to_list(thd, ref, NULL, 0, + if ((table_list= lex.select_lex.add_table_to_list(thd, this, NULL, 0, TL_READ_NO_INSERT, MDL_SHARED_READ)) && !check_table_access(thd, SELECT_ACL, table_list, TRUE, UINT_MAX, FALSE) && !open_tables_only_view_structure(thd, table_list, thd->mdl_context.has_locks())) { - if ((src= lex.query_tables->table->find_field_by_name(&ref->m_column))) + if ((src= lex.query_tables->table->find_field_by_name(&m_column))) { if (!(rc= check_column_grant_for_type_ref(thd, table_list, - ref->m_column.str, - ref->m_column.length))) + m_column.str, + m_column.length))) { *def= Column_definition(thd, src, NULL/*No defaults,no constraints*/); def->flags&= (uint) ~NOT_NULL_FLAG; @@ -206,7 +204,7 @@ bool sp_rcontext::resolve_type_ref(THD *thd, Column_definition *def, } } else - my_error(ER_BAD_FIELD_ERROR, MYF(0), ref->m_column.str, ref->table.str); + my_error(ER_BAD_FIELD_ERROR, MYF(0), m_column.str, table.str); } lex.unit.cleanup(); @@ -223,9 +221,8 @@ bool sp_rcontext::resolve_type_ref(THD *thd, Column_definition *def, rec t1%ROWTYPE; It opens the table "t1" and copies its structure to %ROWTYPE variable. */ -bool sp_rcontext::resolve_table_rowtype_ref(THD *thd, - Row_definition_list &defs, - Table_ident *ref) +bool Table_ident::resolve_table_rowtype_ref(THD *thd, + Row_definition_list &defs) { Open_tables_backup open_tables_state_backup; thd->reset_n_backup_open_tables_state(&open_tables_state_backup); @@ -246,7 +243,7 @@ bool sp_rcontext::resolve_table_rowtype_ref(THD *thd, // Make %ROWTYPE variables see temporary tables that shadow permanent tables thd->temporary_tables= open_tables_state_backup.temporary_tables; - if ((table_list= lex.select_lex.add_table_to_list(thd, ref, NULL, 0, + if ((table_list= lex.select_lex.add_table_to_list(thd, this, NULL, 0, TL_READ_NO_INSERT, MDL_SHARED_READ)) && !check_table_access(thd, SELECT_ACL, table_list, TRUE, UINT_MAX, FALSE) && @@ -284,14 +281,14 @@ bool sp_rcontext::resolve_table_rowtype_ref(THD *thd, } -bool sp_rcontext::resolve_type_refs(THD *thd, List<Spvar_definition> &defs) +bool Row_definition_list::resolve_type_refs(THD *thd) { - List_iterator<Spvar_definition> it(defs); + List_iterator<Spvar_definition> it(*this); Spvar_definition *def; while ((def= it++)) { if (def->is_column_type_ref() && - resolve_type_ref(thd, def, def->column_type_ref())) + def->column_type_ref()->resolve_type_ref(thd, def)) return true; } return false; @@ -323,7 +320,7 @@ bool sp_rcontext::init_var_items(THD *thd, Row_definition_list defs; Item_field_row *item= new (thd->mem_root) Item_field_row(thd, field); if (!(m_var_items[idx]= item) || - resolve_table_rowtype_ref(thd, defs, def->table_rowtype_ref()) || + def->table_rowtype_ref()->resolve_table_rowtype_ref(thd, defs) || item->row_create_items(thd, &defs)) return true; } |