1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00
BitKeeper/etc/ignore:
  auto-union
BitKeeper/etc/logging_ok:
  auto-union
client/mysqldump.c:
  Auto merged
include/my_sys.h:
  Auto merged
include/mysql_com.h:
  Auto merged
isam/open.c:
  Auto merged
libmysql/libmysql.c:
  Auto merged
mysql-test/r/isam.result:
  Auto merged
mysql-test/r/myisam.result:
  Auto merged
mysql-test/r/rpl_loaddata.result:
  Auto merged
mysql-test/r/rpl_log.result:
  Auto merged
mysql-test/r/show_check.result:
  Auto merged
mysql-test/t/myisam.test:
  Auto merged
sql/ha_myisam.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/repl_failsafe.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/slave.h:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_repl.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/share/portuguese/errmsg.txt:
  Auto merged
sql/share/spanish/errmsg.txt:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_union.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/handler.cc:
  Merge
sql/sql_acl.cc:
  Merge and code cleanup of acl_getroot()
This commit is contained in:
unknown
2003-09-03 19:53:08 +03:00
194 changed files with 3950 additions and 3232 deletions

View File

@@ -361,7 +361,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
{
if (wait_if_global_read_lock(thd, 0))
DBUG_RETURN(1);
mysql_bin_log.write(thd, &thd->transaction.trans_log);
mysql_bin_log.write(thd, &thd->transaction.trans_log, 1);
start_waiting_global_read_lock(thd);
reinit_io_cache(&thd->transaction.trans_log,
WRITE_CACHE, (my_off_t) 0, 0, 1);
@@ -445,9 +445,21 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
}
#endif
if (trans == &thd->transaction.all)
{
/*
Update the binary log with a BEGIN/ROLLBACK block if we have cached some
queries and we updated some non-transactional table. Such cases should
be rare (updating a non-transactional table inside a transaction...).
*/
if (unlikely((thd->options & OPTION_STATUS_NO_TRANS_UPDATE) &&
mysql_bin_log.is_open() &&
my_b_tell(&thd->transaction.trans_log)))
mysql_bin_log.write(thd, &thd->transaction.trans_log, 0);
/* Flushed or not, empty the binlog cache */
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;
WRITE_CACHE, (my_off_t) 0, 0, 1);
thd->transaction.trans_log.end_of_file= max_binlog_cache_size;
}
thd->variables.tx_isolation=thd->session_tx_isolation;
if (operation_done)
{
@@ -461,9 +473,27 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
/*
Rolls the current transaction back to a savepoint.
Return value: 0 if success, 1 if there was not a savepoint of the given
name.
Rolls the current transaction back to a savepoint.
Return value: 0 if success, 1 if there was not a savepoint of the given
name.
NOTE: how do we handle this (unlikely but legal) case:
[transaction] + [update to non-trans table] + [rollback to savepoint] ?
The problem occurs when a savepoint is before the update to the
non-transactional table. Then when there's a rollback to the savepoint, if we
simply truncate the binlog cache, we lose the part of the binlog cache where
the update is. If we want to not lose it, we need to write the SAVEPOINT
command and the ROLLBACK TO SAVEPOINT command to the binlog cache. The latter
is easy: it's just write at the end of the binlog cache, but the former should
be *inserted* to the place where the user called SAVEPOINT. The solution is
that when the user calls SAVEPOINT, we write it to the binlog cache (so no
need to later insert it). As transactions are never intermixed in the binary log
(i.e. they are serialized), we won't have conflicts with savepoint names when
using mysqlbinlog or in the slave SQL thread.
Then when ROLLBACK TO SAVEPOINT is called, if we updated some
non-transactional table, we don't truncate the binlog cache but instead write
ROLLBACK TO SAVEPOINT to it; otherwise we truncate the binlog cache (which
will chop the SAVEPOINT command from the binlog cache, which is good as in
that case there is no need to have it in the binlog).
*/
int ha_rollback_to_savepoint(THD *thd, char *savepoint_name)
@@ -488,8 +518,24 @@ int ha_rollback_to_savepoint(THD *thd, char *savepoint_name)
error=1;
}
else
reinit_io_cache(&thd->transaction.trans_log, WRITE_CACHE,
binlog_cache_pos, 0, 0);
{
/*
Write ROLLBACK TO SAVEPOINT to the binlog cache if we have updated some
non-transactional table. Otherwise, truncate the binlog cache starting
from the SAVEPOINT command.
*/
if (unlikely((thd->options & OPTION_STATUS_NO_TRANS_UPDATE) &&
mysql_bin_log.is_open() &&
my_b_tell(&thd->transaction.trans_log)))
{
Query_log_event qinfo(thd, thd->query, thd->query_length, TRUE);
if (mysql_bin_log.write(&qinfo))
error= 1;
}
else
reinit_io_cache(&thd->transaction.trans_log, WRITE_CACHE,
binlog_cache_pos, 0, 0);
}
operation_done=1;
#endif
if (operation_done)
@@ -518,6 +564,13 @@ int ha_savepoint(THD *thd, char *savepoint_name)
#ifdef HAVE_INNOBASE_DB
innobase_savepoint(thd,savepoint_name, binlog_cache_pos);
#endif
/* Write it to the binary log (see comments of ha_rollback_to_savepoint). */
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query, thd->query_length, TRUE);
if (mysql_bin_log.write(&qinfo))
error= 1;
}
}
#endif /* USING_TRANSACTIONS */
DBUG_RETURN(error);
@@ -1054,14 +1107,25 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
void ha_key_cache(void)
{
if (keybuff_size)
(void) init_key_cache((ulong) keybuff_size);
/*
The following mutex is not really needed as long as keybuff_size is
treated as a long value, but we use the mutex here to guard for future
changes.
*/
pthread_mutex_lock(&LOCK_global_system_variables);
long tmp= (long) keybuff_size;
pthread_mutex_unlock(&LOCK_global_system_variables);
if (tmp)
(void) init_key_cache(tmp);
}
void ha_resize_key_cache(void)
{
(void) resize_key_cache((ulong) keybuff_size);
pthread_mutex_lock(&LOCK_global_system_variables);
long tmp= (long) keybuff_size;
pthread_mutex_unlock(&LOCK_global_system_variables);
(void) resize_key_cache(tmp);
}