diff options
author | Alexander Nozdrin <alik@sun.com> | 2010-08-27 12:39:01 +0400 |
---|---|---|
committer | Alexander Nozdrin <alik@sun.com> | 2010-08-27 12:39:01 +0400 |
commit | 4fcb173c41ea85655b78db7839af1a76503f5084 (patch) | |
tree | 682da117a39e7624ae2c69ad933cc0cf6c9349ac /sql/table.cc | |
parent | 7f0386545b7c6da30c6e050ed80f33b89d14dd72 (diff) | |
download | mariadb-git-4fcb173c41ea85655b78db7839af1a76503f5084.tar.gz |
Bug#27480 (Extend CREATE TEMPORARY TABLES privilege
to allow temp table operations) -- prerequisite patch #1.
Move a piece of code that initialiazes TABLE instance
after it was successfully opened into a separate function.
This function will be reused in the following patches.
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/sql/table.cc b/sql/table.cc index f08a0aa84ca..5cdc0ce9042 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3223,6 +3223,63 @@ bool TABLE_SHARE::wait_for_old_version(THD *thd, struct timespec *abstime, } +/** + Initialize TABLE instance and prepare it to be used further. + Set the 'alias' attribute from the specified TABLE_LIST element. + Remember the TABLE_LIST element in the 'pos_in_table_list' member. + + @param thd Thread context. + @param tl TABLE_LIST element. +*/ + +void TABLE::init(THD *thd, TABLE_LIST *tl) +{ + DBUG_ASSERT(s->ref_count > 0 || s->tmp_table != NO_TMP_TABLE); + + if (thd->lex->need_correct_ident()) + alias_name_used= my_strcasecmp(table_alias_charset, + s->table_name.str, + tl->alias); + /* Fix alias if table name changes. */ + if (strcmp(alias, tl->alias)) + { + uint length= (uint) strlen(tl->alias)+1; + alias= (char*) my_realloc((char*) alias, length, MYF(MY_WME)); + memcpy((char*) alias, tl->alias, length); + } + + tablenr= thd->current_tablenr++; + used_fields= 0; + const_table= 0; + null_row= 0; + maybe_null= 0; + force_index= 0; + force_index_order= 0; + force_index_group= 0; + status= STATUS_NO_RECORD; + insert_values= 0; + fulltext_searched= 0; + file->ft_handler= 0; + reginfo.impossible_range= 0; + + /* Catch wrong handling of the auto_increment_field_not_null. */ + DBUG_ASSERT(!auto_increment_field_not_null); + auto_increment_field_not_null= FALSE; + + if (timestamp_field) + timestamp_field_type= timestamp_field->get_auto_set_type(); + + pos_in_table_list= tl; + + clear_column_bitmaps(); + + DBUG_ASSERT(key_read == 0); + + /* Tables may be reused in a sub statement. */ + DBUG_ASSERT(!file->extra(HA_EXTRA_IS_ATTACHED_CHILDREN)); +} + + /* Create Item_field for each column in the table. |