diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h index c72c905edf538723816589d253130eae50cc34b2..44b470fe7eaa6b76a63553d056899cc613d1a84e 100644 --- a/innobase/include/row0mysql.h +++ b/innobase/include/row0mysql.h @@ -408,6 +408,10 @@ struct row_prebuilt_struct { an SQL statement: we may have to set an intention lock on the table, create a consistent read view etc. */ + ibool mysql_has_locked; /* this is set TRUE when MySQL + calls external_lock on this handle + with a lock flag, and set FALSE when + with the F_UNLOCK flag */ ibool clust_index_was_generated; /* if the user did not define a primary key in MySQL, then Innobase diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index f228a75ad3aacc27b85f10006e840956ac9a16b0..9ce86b5d4876256ccd36bd2be675a472ab8ee720 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -320,6 +320,8 @@ row_create_prebuilt( prebuilt->sql_stat_start = TRUE; + prebuilt->mysql_has_locked = FALSE; + prebuilt->index = NULL; prebuilt->n_template = 0; prebuilt->mysql_template = NULL; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 58b99a5329f60f5d486bad043864f7196125548f..95bf8e8eb75552cf7fc2b933efb5ac9817854113 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -3077,19 +3077,22 @@ ha_innobase::create( } } - error = row_table_add_foreign_constraints(trx, - create_info->create_statement, norm_name); + if (current_thd->query != NULL) { + + error = row_table_add_foreign_constraints(trx, + current_thd->query, norm_name); - error = convert_error_code_to_mysql(error, NULL); + error = convert_error_code_to_mysql(error, NULL); - if (error) { - innobase_commit_low(trx); + if (error) { + innobase_commit_low(trx); - row_mysql_unlock_data_dictionary(trx); + row_mysql_unlock_data_dictionary(trx); - trx_free_for_mysql(trx); + trx_free_for_mysql(trx); - DBUG_RETURN(error); + DBUG_RETURN(error); + } } innobase_commit_low(trx); @@ -3751,7 +3754,7 @@ ha_innobase::start_stmt( prebuilt->hint_no_need_to_fetch_extra_cols = TRUE; prebuilt->read_just_key = 0; - if (prebuilt->select_lock_type == LOCK_NONE) { + if (!prebuilt->mysql_has_locked) { /* This handle is for a temporary table created inside this same LOCK TABLES; since MySQL does NOT call external_lock in this case, we must use x-row locks inside InnoDB to be @@ -3829,6 +3832,7 @@ ha_innobase::external_lock( thd->transaction.all.innodb_active_trans = 1; trx->n_mysql_tables_in_use++; + prebuilt->mysql_has_locked = TRUE; if (thd->variables.tx_isolation != ISO_REPEATABLE_READ) { trx->isolation_level = innobase_map_isolation_level( @@ -3852,6 +3856,7 @@ ha_innobase::external_lock( } } else { trx->n_mysql_tables_in_use--; + prebuilt->mysql_has_locked = FALSE; auto_inc_counter_for_this_stat = 0; if (trx->n_mysql_tables_in_use == 0) { diff --git a/sql/handler.h b/sql/handler.h index a018af298063d8c18b373fccc1a933f70ee97b69..b9209d087a059fcc3490cada969ac8964851c54e 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -157,7 +157,6 @@ typedef struct st_ha_create_information ulonglong auto_increment_value; char *comment,*password; char *data_file_name, *index_file_name; - char *create_statement; uint options; /* OR of HA_CREATE_ options */ uint raid_type,raid_chunks; ulong raid_chunksize; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1e7614ccc95e05c5f6e714a9582c3fa7dd814423..aa0946113c95fa1cd930c5dcbb7d5300a17fc15e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -695,7 +695,6 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, thd->proc_info="creating table"; - create_info->create_statement = thd->query; create_info->table_options=db_options; if (rea_create_table(path, create_info, fields, key_count, key_info_buffer))