diff options
-rw-r--r-- | storage/maria/ha_maria.cc | 13 | ||||
-rw-r--r-- | storage/maria/ma_create.c | 13 | ||||
-rw-r--r-- | storage/maria/maria_def.h | 2 |
3 files changed, 17 insertions, 11 deletions
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index c2f4d621305..f7fd417836a 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1860,6 +1860,8 @@ int ha_maria::external_lock(THD *thd, int lock_type) { TRN *trn= THD_TRN; DBUG_ENTER("ha_maria::external_lock"); + if (!file->s->base.transactional) + goto skip_transaction; if (!trn && lock_type != F_UNLCK) /* no transaction yet - open it now */ { trn= trnman_new_trn(& thd->mysys_var->mutex, @@ -1872,7 +1874,7 @@ int ha_maria::external_lock(THD *thd, int lock_type) DBUG_PRINT("info", ("THD_TRN set to 0x%lx", (ulong)trn)); THD_TRN= trn; if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) - trans_register_ha(thd, true, maria_hton); + trans_register_ha(thd, TRUE, maria_hton); } if (lock_type != F_UNLCK) { @@ -1905,6 +1907,7 @@ int ha_maria::external_lock(THD *thd, int lock_type) } } } +skip_transaction: DBUG_RETURN(maria_lock_database(file, !table->s->tmp_table ? lock_type : ((lock_type == F_UNLCK) ? F_UNLCK : F_EXTRA_LCK))); @@ -1913,11 +1916,11 @@ int ha_maria::external_lock(THD *thd, int lock_type) int ha_maria::start_stmt(THD *thd, thr_lock_type lock_type) { TRN *trn= THD_TRN; - DBUG_ASSERT(trn); // this may be called only after external_lock() - DBUG_ASSERT(lock_type != F_UNLCK); - if (!trnman_increment_locked_tables(trn)) + if (file->s->base.transactional) { - trans_register_ha(thd, false, maria_hton); + DBUG_ASSERT(trn); // this may be called only after external_lock() + DBUG_ASSERT(lock_type != F_UNLCK); + /* As external_lock() was already called, don't increment locked_tables */ trnman_new_statement(trn); } return 0; diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c index 5dd6e0e1f93..d8660dd41cb 100644 --- a/storage/maria/ma_create.c +++ b/storage/maria/ma_create.c @@ -246,6 +246,14 @@ int maria_create(const char *name, enum data_file_type datafile_type, } } } + + if (flags & HA_CREATE_TMP_TABLE) + { + options|= HA_OPTION_TMP_TABLE; + create_mode|= O_EXCL | O_NOFOLLOW; + /* temp tables are not crash-safe (dropped at restart) */ + ci->transactional= FALSE; + } share.base.null_bytes= ci->null_bytes; share.base.original_null_bytes= ci->null_bytes; share.base.transactional= ci->transactional; @@ -255,11 +263,6 @@ int maria_create(const char *name, enum data_file_type datafile_type, if (pack_reclength != INT_MAX32) pack_reclength+= max_field_lengths + long_varchar_count; - if (flags & HA_CREATE_TMP_TABLE) - { - options|= HA_OPTION_TMP_TABLE; - create_mode|= O_EXCL | O_NOFOLLOW; - } if (flags & HA_CREATE_CHECKSUM || (options & HA_OPTION_CHECKSUM)) { options|= HA_OPTION_CHECKSUM; diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index 7a7261d0d6a..46ffac7cbc2 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -168,7 +168,7 @@ typedef struct st_ma_base_info /* The following are from the header */ uint key_parts, all_key_parts; - /* If false, we disable logging, versioning etc */ + /* If false, we disable logging, versioning, transaction etc */ my_bool transactional; } MARIA_BASE_INFO; |