diff options
author | unknown <guilhem@gbichot3.local> | 2007-06-08 16:03:39 +0200 |
---|---|---|
committer | unknown <guilhem@gbichot3.local> | 2007-06-08 16:03:39 +0200 |
commit | e30e21f070b998a0a932f2dbc4da91e05108045a (patch) | |
tree | 73e14964fdda0502528849a1194b583d85ad6ea4 | |
parent | f5f2a8a11223e87c28e1386bdf840af088fc7248 (diff) | |
download | mariadb-git-e30e21f070b998a0a932f2dbc4da91e05108045a.tar.gz |
- if table is not transactional, we don't create a transaction
- if table is temporary it's not crash-safe so we declare it
non-transactional (saves trnman calls, REDO/UNDO log writing,
and fixes the assertion failure at the first line of trnman_destroy()).
storage/maria/ha_maria.cc:
if table is not transactional, no need to create a transaction:
- it saves trnman calls (mutex locks etc)
- it saves REDO and UNDO log writing
- it closes a bug: if this is a temporary table, external_lock(F_RD|WRLCK)
is not always paired with external_lock(F_UNLCK), which confuses the
transaction logic in external_lock. As temp tables are not crash-safe
and so not transactional in this Maria version, we skip transactions
and de-confuse. Note that maria_lock_database(F_UNLCK) is
properly called, so if the transaction logic moves from external_lock()
to maria_lock_database() (probably TODO), transactional temp tables
will be possible.
storage/maria/ma_create.c:
temporary tables cannot be crash-safe as they are dropped at restart
storage/maria/maria_def.h:
comment
-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; |