Commit 2b599547 authored by unknown's avatar unknown

BUG#19309: Problem with calling proecdures twice

Need to flag when a copy is needed to not overwrite a create_info
object connected to the lex structure


sql/mysql_priv.h:
  Need to flag when a copy is needed to not overwrite a create_info
  object connected to the lex structure
sql/sql_insert.cc:
  Need to flag when a copy is needed to not overwrite a create_info
  object connected to the lex structure
sql/sql_parse.cc:
  Need to flag when a copy is needed to not overwrite a create_info
  object connected to the lex structure
sql/sql_table.cc:
  Need to flag when a copy is needed to not overwrite a create_info
  object connected to the lex structure
parent 68d4c991
...@@ -862,7 +862,8 @@ int prepare_create_field(create_field *sql_field, ...@@ -862,7 +862,8 @@ int prepare_create_field(create_field *sql_field,
bool mysql_create_table(THD *thd,const char *db, const char *table_name, bool mysql_create_table(THD *thd,const char *db, const char *table_name,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<create_field> &fields, List<Key> &keys, List<create_field> &fields, List<Key> &keys,
bool tmp_table, uint select_field_count); bool tmp_table, uint select_field_count,
bool use_copy_create_info);
bool mysql_alter_table(THD *thd, char *new_db, char *new_name, bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
......
...@@ -2657,7 +2657,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, ...@@ -2657,7 +2657,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
tmp_disable_binlog(thd); tmp_disable_binlog(thd);
if (!mysql_create_table(thd, create_table->db, create_table->table_name, if (!mysql_create_table(thd, create_table->db, create_table->table_name,
create_info, *extra_fields, *keys, 0, create_info, *extra_fields, *keys, 0,
select_field_count)) select_field_count, 0))
{ {
/* /*
If we are here in prelocked mode we either create temporary table If we are here in prelocked mode we either create temporary table
......
...@@ -2943,7 +2943,7 @@ mysql_execute_command(THD *thd) ...@@ -2943,7 +2943,7 @@ mysql_execute_command(THD *thd)
res= mysql_create_table(thd, create_table->db, res= mysql_create_table(thd, create_table->db,
create_table->table_name, &lex->create_info, create_table->table_name, &lex->create_info,
lex->create_list, lex->create_list,
lex->key_list, 0, 0); lex->key_list, 0, 0, 1);
} }
if (!res) if (!res)
send_ok(thd); send_ok(thd);
......
...@@ -3034,11 +3034,15 @@ static HA_CREATE_INFO *copy_create_info(HA_CREATE_INFO *lex_create_info) ...@@ -3034,11 +3034,15 @@ static HA_CREATE_INFO *copy_create_info(HA_CREATE_INFO *lex_create_info)
thd Thread object thd Thread object
db Database db Database
table_name Table name table_name Table name
create_info Create information (like MAX_ROWS) lex_create_info Create information (like MAX_ROWS)
fields List of fields to create fields List of fields to create
keys List of keys to create keys List of keys to create
internal_tmp_table Set to 1 if this is an internal temporary table internal_tmp_table Set to 1 if this is an internal temporary table
(From ALTER TABLE) (From ALTER TABLE)
select_field_count
use_copy_create_info Should we make a copy of create info (we do this
when this is called from sql_parse.cc where we
want to ensure lex object isn't manipulated.
DESCRIPTION DESCRIPTION
If one creates a temporary table, this is automatically opened If one creates a temporary table, this is automatically opened
...@@ -3058,7 +3062,8 @@ bool mysql_create_table_internal(THD *thd, ...@@ -3058,7 +3062,8 @@ bool mysql_create_table_internal(THD *thd,
HA_CREATE_INFO *lex_create_info, HA_CREATE_INFO *lex_create_info,
List<create_field> &fields, List<create_field> &fields,
List<Key> &keys,bool internal_tmp_table, List<Key> &keys,bool internal_tmp_table,
uint select_field_count) uint select_field_count,
bool use_copy_create_info)
{ {
char path[FN_REFLEN]; char path[FN_REFLEN];
uint path_length; uint path_length;
...@@ -3070,10 +3075,16 @@ bool mysql_create_table_internal(THD *thd, ...@@ -3070,10 +3075,16 @@ bool mysql_create_table_internal(THD *thd,
bool error= TRUE; bool error= TRUE;
DBUG_ENTER("mysql_create_table_internal"); DBUG_ENTER("mysql_create_table_internal");
if (use_copy_create_info)
{
if (!(create_info= copy_create_info(lex_create_info))) if (!(create_info= copy_create_info(lex_create_info)))
{ {
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
}
else
create_info= lex_create_info;
/* Check for duplicate fields and check type of table to create */ /* Check for duplicate fields and check type of table to create */
if (!fields.elements) if (!fields.elements)
{ {
...@@ -3388,7 +3399,8 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name, ...@@ -3388,7 +3399,8 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<create_field> &fields, List<create_field> &fields,
List<Key> &keys,bool internal_tmp_table, List<Key> &keys,bool internal_tmp_table,
uint select_field_count) uint select_field_count,
bool use_copy_create_info)
{ {
bool result; bool result;
DBUG_ENTER("mysql_create_table"); DBUG_ENTER("mysql_create_table");
...@@ -3412,7 +3424,8 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name, ...@@ -3412,7 +3424,8 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name,
result= mysql_create_table_internal(thd, db, table_name, create_info, result= mysql_create_table_internal(thd, db, table_name, create_info,
fields, keys, internal_tmp_table, fields, keys, internal_tmp_table,
select_field_count); select_field_count,
use_copy_create_info);
pthread_mutex_lock(&LOCK_lock_db); pthread_mutex_lock(&LOCK_lock_db);
if (!--creating_table && creating_database) if (!--creating_table && creating_database)
...@@ -4358,7 +4371,7 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables) ...@@ -4358,7 +4371,7 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables)
*/ */
bool mysql_create_like_table(THD* thd, TABLE_LIST* table, bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *lex_create_info,
Table_ident *table_ident) Table_ident *table_ident)
{ {
TABLE *tmp_table; TABLE *tmp_table;
...@@ -4371,9 +4384,15 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, ...@@ -4371,9 +4384,15 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
int err; int err;
bool res= TRUE; bool res= TRUE;
enum legacy_db_type not_used; enum legacy_db_type not_used;
HA_CREATE_INFO *create_info;
TABLE_LIST src_tables_list; TABLE_LIST src_tables_list;
DBUG_ENTER("mysql_create_like_table"); DBUG_ENTER("mysql_create_like_table");
if (!(create_info= copy_create_info(lex_create_info)))
{
DBUG_RETURN(TRUE);
}
src_db= table_ident->db.str ? table_ident->db.str : thd->db; src_db= table_ident->db.str ? table_ident->db.str : thd->db;
/* /*
...@@ -5721,7 +5740,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -5721,7 +5740,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
*/ */
tmp_disable_binlog(thd); tmp_disable_binlog(thd);
error= mysql_create_table(thd, new_db, tmp_name, error= mysql_create_table(thd, new_db, tmp_name,
create_info,create_list,key_list,1,0); create_info,create_list,key_list,1,0,0);
reenable_binlog(thd); reenable_binlog(thd);
if (error) if (error)
DBUG_RETURN(error); DBUG_RETURN(error);
......
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