diff options
author | unknown <monty@donna.mysql.fi> | 2001-03-06 15:24:08 +0200 |
---|---|---|
committer | unknown <monty@donna.mysql.fi> | 2001-03-06 15:24:08 +0200 |
commit | 869c89feaaf82d0f44b2a48db0099aae87b4732f (patch) | |
tree | 54c7bf220f9e21e9f04e2ff2e8a018cf4e33e837 /sql/handler.cc | |
parent | ec5e2f589f09e9c261487a577dcddef3cdb994a5 (diff) | |
download | mariadb-git-869c89feaaf82d0f44b2a48db0099aae87b4732f.tar.gz |
Merged some functions and removed some unused client functions.
Remember UNION for ALTER TABLE
Added test for if we are supporting transactions.
Don't allow REPLACE to replace a row when we have generated an auto_increment key
Fixed bug when using BLOB keys
Fixed bug in SET @variable=user.
Docs/manual.texi:
Added some examples and moved the Error access denied section to the
error section.
client/mysqltest.c:
Changed to use the new mysql_send_query()
include/mysql.h:
Changed mysql_reap_query() to mysql_send_query().
libmysql/libmysql.c:
Changed mysql_reap_query() to mysql_send_query()
Merged some functions and removed some unused functions.
mysql-test/r/bdb.result:
New test case
mysql-test/r/distinct.result:
New test case
mysql-test/r/key.result:
New test case
mysql-test/r/merge.result:
New test case
mysql-test/r/replace.result:
New test case
mysql-test/t/bdb.test:
New test case
mysql-test/t/key.test:
New test case
mysql-test/t/merge.test:
New test case
mysql-test/t/replace.test:
New test case
mysys/my_lock.c:
Moved global lock variable to static
sql-bench/test-insert.sh:
Added test case for index-read only
sql/field.h:
Fixed that one can optimize ORDER BY with ISAM and GEMINI
sql/ha_berkeley.cc:
Added type casts needed for Windows
sql/ha_innobase.cc:
Removed reference to manual from comment.
sql/ha_myisammrg.cc:
Remember UNION for ALTER TABLE
sql/ha_myisammrg.h:
Remember UNION for ALTER TABLE
sql/handler.cc:
Added test for if we are supporting transactions.
Don't allow REPLACE to replace a row when we have generated an auto_increment key.
sql/handler.h:
Remember UNION for ALTER TABLE
sql/key.cc:
Fixed bug when using BLOB keys
sql/mysql_priv.h:
Added new variables
sql/mysqld.cc:
Added new variables
sql/opt_range.cc:
Fixed problem with BLOB keys
sql/opt_sum.cc:
Fix for BLOB keys
sql/sql_class.cc:
Added test if we need to init/clean transaction variables
sql/sql_insert.cc:
Fix for REPLACE and auto_increment keys
sql/sql_parse.cc:
Fixed bug in max_user_connections
sql/sql_select.cc:
Fixed problem with key on BLOB
sql/sql_yacc.yy:
Fixed bug in SET @variable=user.
sql/table.cc:
Fixed problem with keys on BLOB
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 112 |
1 files changed, 65 insertions, 47 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 240b1ded5e7..96c19c904fe 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -133,6 +133,8 @@ int ha_init() int error; if ((error=berkeley_init())) return error; + if (!berkeley_skip) // If we couldn't use handler + opt_using_transactions=1; } #endif #ifdef HAVE_INNOBASE_DB @@ -140,6 +142,8 @@ int ha_init() { if (innobase_init()) return -1; + if (!innobase_skip) // If we couldn't use handler + opt_using_transactions=1; } #endif return 0; @@ -190,13 +194,16 @@ int ha_autocommit_or_rollback(THD *thd, int error) { DBUG_ENTER("ha_autocommit_or_rollback"); #ifdef USING_TRANSACTIONS - if (!error) + if (opt_using_transactions) { - if (ha_commit_stmt(thd)) - error=1; + if (!error) + { + if (ha_commit_stmt(thd)) + error=1; + } + else + (void) ha_rollback_stmt(thd); } - else - (void) ha_rollback_stmt(thd); #endif DBUG_RETURN(error); } @@ -207,73 +214,80 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans) int error=0; DBUG_ENTER("ha_commit"); #ifdef USING_TRANSACTIONS - /* Update the binary log if we have cached some queries */ - if (trans == &thd->transaction.all && mysql_bin_log.is_open() && - my_b_tell(&thd->transaction.trans_log)) + if (opt_using_transactions) { - mysql_bin_log.write(&thd->transaction.trans_log); - reinit_io_cache(&thd->transaction.trans_log, - WRITE_CACHE, (my_off_t) 0, 0, 1); - thd->transaction.trans_log.end_of_file= max_binlog_cache_size; - } + /* Update the binary log if we have cached some queries */ + if (trans == &thd->transaction.all && mysql_bin_log.is_open() && + my_b_tell(&thd->transaction.trans_log)) + { + mysql_bin_log.write(&thd->transaction.trans_log); + reinit_io_cache(&thd->transaction.trans_log, + WRITE_CACHE, (my_off_t) 0, 0, 1); + thd->transaction.trans_log.end_of_file= max_binlog_cache_size; + } #ifdef HAVE_BERKELEY_DB - if (trans->bdb_tid) - { - if ((error=berkeley_commit(thd,trans->bdb_tid))) + if (trans->bdb_tid) { - my_error(ER_ERROR_DURING_COMMIT, MYF(0), error); - error=1; + if ((error=berkeley_commit(thd,trans->bdb_tid))) + { + my_error(ER_ERROR_DURING_COMMIT, MYF(0), error); + error=1; + } + trans->bdb_tid=0; } - trans->bdb_tid=0; - } #endif #ifdef HAVE_INNOBASE_DB - if (trans->innobase_tid) - { - if ((error=innobase_commit(thd,trans->innobase_tid))) + if (trans->innobase_tid) { - my_error(ER_ERROR_DURING_COMMIT, MYF(0), error); - error=1; + if ((error=innobase_commit(thd,trans->innobase_tid))) + { + my_error(ER_ERROR_DURING_COMMIT, MYF(0), error); + error=1; + } } - } #endif - if (error && trans == &thd->transaction.all && mysql_bin_log.is_open()) - sql_print_error("Error: Got error during commit; Binlog is not up to date!"); + if (error && trans == &thd->transaction.all && mysql_bin_log.is_open()) + sql_print_error("Error: Got error during commit; Binlog is not up to date!"); + } #endif // using transactions DBUG_RETURN(error); } + int ha_rollback_trans(THD *thd, THD_TRANS *trans) { int error=0; DBUG_ENTER("ha_rollback"); -#ifdef HAVE_BERKELEY_DB - if (trans->bdb_tid) +#ifdef USING_TRANSACTIONS + if (opt_using_transactions) { - if ((error=berkeley_rollback(thd, trans->bdb_tid))) +#ifdef HAVE_BERKELEY_DB + if (trans->bdb_tid) { - my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), error); - error=1; + if ((error=berkeley_rollback(thd, trans->bdb_tid))) + { + my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), error); + error=1; + } + trans->bdb_tid=0; } - trans->bdb_tid=0; - } #endif #ifdef HAVE_INNOBASE_DB - if (trans->innobase_tid) - { - if ((error=innobase_rollback(thd, trans->innobase_tid))) + if (trans->innobase_tid) { - my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), error); - error=1; + if ((error=innobase_rollback(thd, trans->innobase_tid))) + { + my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), error); + error=1; + } } - } -#endif -#ifdef USING_TRANSACTIONS - if (trans == &thd->transaction.all) - reinit_io_cache(&thd->transaction.trans_log, - WRITE_CACHE, (my_off_t) 0, 0, 1); - thd->transaction.trans_log.end_of_file= max_binlog_cache_size; #endif + if (trans == &thd->transaction.all) + reinit_io_cache(&thd->transaction.trans_log, + WRITE_CACHE, (my_off_t) 0, 0, 1); + thd->transaction.trans_log.end_of_file= max_binlog_cache_size; + } +#endif /* USING_TRANSACTIONS */ DBUG_RETURN(error); } @@ -493,7 +507,10 @@ void handler::update_auto_increment() THD *thd; DBUG_ENTER("update_auto_increment"); if (table->next_number_field->val_int() != 0) + { + auto_increment_column_changed=0; DBUG_VOID_RETURN; + } thd=current_thd; if ((nr=thd->next_insert_id)) thd->next_insert_id=0; // Clear after use @@ -501,6 +518,7 @@ void handler::update_auto_increment() nr=get_auto_increment(); thd->insert_id((ulonglong) nr); table->next_number_field->store(nr); + auto_increment_column_changed=1; DBUG_VOID_RETURN; } |