Commit 4fcb173c authored by Alexander Nozdrin's avatar Alexander Nozdrin

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.
parent 7f038654
...@@ -3023,41 +3023,11 @@ retry_share: ...@@ -3023,41 +3023,11 @@ retry_share:
table->reginfo.lock_type=TL_READ; /* Assume read */ table->reginfo.lock_type=TL_READ; /* Assume read */
reset: reset:
DBUG_ASSERT(table->s->ref_count > 0 || table->s->tmp_table != NO_TMP_TABLE);
if (thd->lex->need_correct_ident())
table->alias_name_used= my_strcasecmp(table_alias_charset,
table->s->table_name.str, alias);
/* Fix alias if table name changes */
if (strcmp(table->alias, alias))
{
uint length=(uint) strlen(alias)+1;
table->alias= (char*) my_realloc((char*) table->alias, length,
MYF(MY_WME));
memcpy((char*) table->alias, alias, length);
}
table->tablenr=thd->current_tablenr++;
table->used_fields=0;
table->const_table=0;
table->null_row= table->maybe_null= 0;
table->force_index= table->force_index_order= table->force_index_group= 0;
table->status=STATUS_NO_RECORD;
table->insert_values= 0;
table->fulltext_searched= 0;
table->file->ft_handler= 0;
table->reginfo.impossible_range= 0;
/* Catch wrong handling of the auto_increment_field_not_null. */
DBUG_ASSERT(!table->auto_increment_field_not_null);
table->auto_increment_field_not_null= FALSE;
if (table->timestamp_field)
table->timestamp_field_type= table->timestamp_field->get_auto_set_type();
table->pos_in_table_list= table_list;
table_list->updatable= 1; // It is not derived table nor non-updatable VIEW table_list->updatable= 1; // It is not derived table nor non-updatable VIEW
table->clear_column_bitmaps();
table_list->table= table; table_list->table= table;
DBUG_ASSERT(table->key_read == 0);
/* Tables may be reused in a sub statement. */ table->init(thd, table_list);
DBUG_ASSERT(! table->file->extra(HA_EXTRA_IS_ATTACHED_CHILDREN));
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
err_lock: err_lock:
......
...@@ -3223,6 +3223,63 @@ bool TABLE_SHARE::wait_for_old_version(THD *thd, struct timespec *abstime, ...@@ -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. Create Item_field for each column in the table.
......
...@@ -1097,6 +1097,7 @@ public: ...@@ -1097,6 +1097,7 @@ public:
#endif #endif
MDL_ticket *mdl_ticket; MDL_ticket *mdl_ticket;
void init(THD *thd, TABLE_LIST *tl);
bool fill_item_list(List<Item> *item_list) const; bool fill_item_list(List<Item> *item_list) const;
void reset_item_list(List<Item> *item_list) const; void reset_item_list(List<Item> *item_list) const;
void clear_column_bitmaps(void); void clear_column_bitmaps(void);
......
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