summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--innobase/include/row0mysql.h4
-rw-r--r--innobase/row/row0mysql.c2
-rw-r--r--sql/ha_innodb.cc23
-rw-r--r--sql/handler.h1
-rw-r--r--sql/sql_table.cc1
5 files changed, 20 insertions, 11 deletions
diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h
index c72c905edf5..44b470fe7ea 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 f228a75ad3a..9ce86b5d487 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 58b99a5329f..95bf8e8eb75 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 a018af29806..b9209d087a0 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 1e7614ccc95..aa0946113c9 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))