mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 13:02:28 +01:00
f6f91b9d3b
Fixes: - Bug #18077: InnoDB uses full explicit table locks in stored FUNCTION storage/innobase/btr/btr0btr.c: Apply InnoDB snapshot ss923 Revision r919: btr_page_get_father_for_rec(): Remove bogus comment about removed dict_tree_t. storage/innobase/dict/dict0dict.c: Apply InnoDB snapshot ss923 Revision r892: Merge changes from MySQL AB. dict_col_copy_type_noninline(): Remove the return statement. Some compilers do not allow return expressions of void type. innobase_start_or_create_for_mysql(): Do not cap srv_max_threads to 1000 on Windows. Makefile.am (EXTRA_DIST): Add plug.in Revision r897: dict_index_get_if_in_cache(): Enclose in #ifdef UNIV_DEBUG. Replace the search loop with a call to dict_index_find_on_id_low(). storage/innobase/handler/ha_innodb.cc: Apply InnoDB snapshot ss923 Revision r887: storage/innobase/handler: Merge changes from MySQL AB: ChangeSet 2006/09/30 18:44:42-07:00 brian@zim.(none) Merge zim.(none):/home/brian/mysql/merge-5.1 into zim.(none):/home/brian/mysql/arch-5.1 ChangeSet 2006/09/30 12:49:46-07:00 brian@zim.(none) This patch adds handlerton passing to functions. NDB and Innodb still require a global hanlderton in the main code due to the nature of the sql_cache call back function (should be solveable... another patch). Partitioning now has a flag to allow disabling of engines from being compatible with partitioning. Cleaned up heap naming convention on panic call. ChangeSet 2006/09/29 17:19:02-07:00 brian@zim.(none) This removes the passing of global hton to engine instance. ChangeSet 2006/09/28 13:22:56+02:00 gbichot@dl145h.mysql.com Merge gbichot@bk-internal:/home/bk/mysql-5.1-arch into dl145h.mysql.com:/users/gbichot/mysql-5.1-arch ChangeSet 2006/09/28 13:19:43+02:00 gbichot@dl145h.mysql.com In the handlerton, cursor creation function don't have an argument and so the engine calls current_thd to derive transaction information; instead we now pass THD to those functions, it looks more logical (it makes the implicit current_thd parameter more visible). Approved by Brian and Monty. ChangeSet 2006/09/26 22:51:53-07:00 brian@zim.(none) Merge zim.(none):/home/brian/mysql/merge-5.1 into zim.(none):/home/brian/mysql/arch-5.1 Revision r895: Merge changes from MySQL AB, and remove two compilation warnings. ha_innodb.cc: innodb_mutex_show_status(): Add (ulong) casts to ulonglong expressions being passed to fprintf %lu. The warnings were apparently introduced by MySQL AB developers. mysql_declare_plugin(innobase): Add PLUGIN_LICENSE_GPL. have_innodb.inc: Merge changes from MySQL AB. Revision r923: ha_innobase::store_lock(): When downgrading table locks, do not check thd->in_lock_tables but test if thd->lex->sql_command == SQLCOM_LOCK_TABLES instead. Otherwise, stored functions will use table locks. (Bug #18077) This patch is from Heikki. storage/innobase/include/dict0dict.h: Apply InnoDB snapshot ss923 Revision r897: dict_index_get_if_in_cache(): Enclose in #ifdef UNIV_DEBUG. Replace the search loop with a call to dict_index_find_on_id_low(). storage/innobase/include/mem0dbg.h: Apply InnoDB snapshot ss923 Revision r901: Enclose some mem debug functions in #ifdef UNIV_DEBUG or #ifdef UNIV_MEM_DEBUG. storage/innobase/include/mtr0mtr.h: Apply InnoDB snapshot ss923 Revision r866: mtr_print(), mtr_memo_contains(): Disable unless #ifdef UNIV_DEBUG. storage/innobase/include/mtr0mtr.ic: Apply InnoDB snapshot ss923 Revision r866: mtr_print(), mtr_memo_contains(): Disable unless #ifdef UNIV_DEBUG. storage/innobase/include/sync0rw.h: Apply InnoDB snapshot ss923 Revision r907: Send all SHOW ENGINE INNODB STATUS information to the client also when UNIV_SYNC_DEBUG is defined. rw_lock_list_print_info(): Add parameter "file". mutex_list_print_info(): Add parameter "file". Make the function static. storage/innobase/include/sync0sync.h: Apply InnoDB snapshot ss923 Revision r907: Send all SHOW ENGINE INNODB STATUS information to the client also when UNIV_SYNC_DEBUG is defined. rw_lock_list_print_info(): Add parameter "file". mutex_list_print_info(): Add parameter "file". Make the function static. storage/innobase/include/univ.i: Apply InnoDB snapshot ss923 Revision r894: univ.i: Indent some of the directives, and remove conditions about Windows in the "#else" branch of "#if building on Windows". storage/innobase/mem/mem0dbg.c: Apply InnoDB snapshot ss923 Revision r901: Enclose some mem debug functions in #ifdef UNIV_DEBUG or #ifdef UNIV_MEM_DEBUG. Revision r902: mem0dbg.c: Enclose some more function definitions in #ifdef UNIV_MEM_DEBUG. The declarations were already enclosed in #ifdef UNIV_MEM_DEBUG. storage/innobase/mem/mem0pool.c: Apply InnoDB snapshot ss923 Revision r896: mem0pool.c: Remove obsolete comments about the dictionary cache being managed with an LRU algorithm. storage/innobase/mtr/mtr0mtr.c: Apply InnoDB snapshot ss923 Revision r866: mtr_print(), mtr_memo_contains(): Disable unless #ifdef UNIV_DEBUG. storage/innobase/row/row0purge.c: Apply InnoDB snapshot ss923 Revision r869: row_purge_parse_undo_rec(): Correct a faulty condition. Luckily, this bug would only surface if the InnoDB SQL interpreter were used for updating fixed-length columns. Currently (as the UPD_NODE_NO_SIZE_CHANGE flag is never set), cmpl_info can only be 0 or UPD_NODE_NO_ORD_CHANGE. Luckily, UPD_NODE_NO_ORD_CHANGE is 1, and the condition was simplified to !cmpl_info. storage/innobase/sync/sync0rw.c: Apply InnoDB snapshot ss923 Revision r907: Send all SHOW ENGINE INNODB STATUS information to the client also when UNIV_SYNC_DEBUG is defined. rw_lock_list_print_info(): Add parameter "file". mutex_list_print_info(): Add parameter "file". Make the function static. storage/innobase/sync/sync0sync.c: Apply InnoDB snapshot ss923 Revision r907: Send all SHOW ENGINE INNODB STATUS information to the client also when UNIV_SYNC_DEBUG is defined. rw_lock_list_print_info(): Add parameter "file". mutex_list_print_info(): Add parameter "file". Make the function static.
251 lines
5.3 KiB
Text
251 lines
5.3 KiB
Text
/******************************************************
|
|
Mini-transaction buffer
|
|
|
|
(c) 1995 Innobase Oy
|
|
|
|
Created 11/26/1995 Heikki Tuuri
|
|
*******************************************************/
|
|
|
|
#include "sync0sync.h"
|
|
#include "sync0rw.h"
|
|
#include "mach0data.h"
|
|
|
|
/*******************************************************************
|
|
Starts a mini-transaction and creates a mini-transaction handle
|
|
and a buffer in the memory buffer given by the caller. */
|
|
UNIV_INLINE
|
|
mtr_t*
|
|
mtr_start(
|
|
/*======*/
|
|
/* out: mtr buffer which also acts as
|
|
the mtr handle */
|
|
mtr_t* mtr) /* in: memory buffer for the mtr buffer */
|
|
{
|
|
dyn_array_create(&(mtr->memo));
|
|
dyn_array_create(&(mtr->log));
|
|
|
|
mtr->log_mode = MTR_LOG_ALL;
|
|
mtr->modifications = FALSE;
|
|
mtr->n_log_recs = 0;
|
|
|
|
#ifdef UNIV_DEBUG
|
|
mtr->state = MTR_ACTIVE;
|
|
mtr->magic_n = MTR_MAGIC_N;
|
|
#endif
|
|
return(mtr);
|
|
}
|
|
|
|
/*******************************************************
|
|
Pushes an object to an mtr memo stack. */
|
|
UNIV_INLINE
|
|
void
|
|
mtr_memo_push(
|
|
/*==========*/
|
|
mtr_t* mtr, /* in: mtr */
|
|
void* object, /* in: object */
|
|
ulint type) /* in: object type: MTR_MEMO_S_LOCK, ... */
|
|
{
|
|
dyn_array_t* memo;
|
|
mtr_memo_slot_t* slot;
|
|
|
|
ut_ad(object);
|
|
ut_ad(type >= MTR_MEMO_PAGE_S_FIX);
|
|
ut_ad(type <= MTR_MEMO_X_LOCK);
|
|
ut_ad(mtr);
|
|
ut_ad(mtr->magic_n == MTR_MAGIC_N);
|
|
|
|
memo = &(mtr->memo);
|
|
|
|
slot = dyn_array_push(memo, sizeof(mtr_memo_slot_t));
|
|
|
|
slot->object = object;
|
|
slot->type = type;
|
|
}
|
|
|
|
/**************************************************************
|
|
Sets and returns a savepoint in mtr. */
|
|
UNIV_INLINE
|
|
ulint
|
|
mtr_set_savepoint(
|
|
/*==============*/
|
|
/* out: savepoint */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
dyn_array_t* memo;
|
|
|
|
ut_ad(mtr);
|
|
ut_ad(mtr->magic_n == MTR_MAGIC_N);
|
|
|
|
memo = &(mtr->memo);
|
|
|
|
return(dyn_array_get_data_size(memo));
|
|
}
|
|
|
|
/**************************************************************
|
|
Releases the (index tree) s-latch stored in an mtr memo after a
|
|
savepoint. */
|
|
UNIV_INLINE
|
|
void
|
|
mtr_release_s_latch_at_savepoint(
|
|
/*=============================*/
|
|
mtr_t* mtr, /* in: mtr */
|
|
ulint savepoint, /* in: savepoint */
|
|
rw_lock_t* lock) /* in: latch to release */
|
|
{
|
|
mtr_memo_slot_t* slot;
|
|
dyn_array_t* memo;
|
|
|
|
ut_ad(mtr);
|
|
ut_ad(mtr->magic_n == MTR_MAGIC_N);
|
|
ut_ad(mtr->state == MTR_ACTIVE);
|
|
|
|
memo = &(mtr->memo);
|
|
|
|
ut_ad(dyn_array_get_data_size(memo) > savepoint);
|
|
|
|
slot = dyn_array_get_element(memo, savepoint);
|
|
|
|
ut_ad(slot->object == lock);
|
|
ut_ad(slot->type == MTR_MEMO_S_LOCK);
|
|
|
|
rw_lock_s_unlock(lock);
|
|
|
|
slot->object = NULL;
|
|
}
|
|
|
|
#ifdef UNIV_DEBUG
|
|
/**************************************************************
|
|
Checks if memo contains the given item. */
|
|
UNIV_INLINE
|
|
ibool
|
|
mtr_memo_contains(
|
|
/*==============*/
|
|
/* out: TRUE if contains */
|
|
mtr_t* mtr, /* in: mtr */
|
|
void* object, /* in: object to search */
|
|
ulint type) /* in: type of object */
|
|
{
|
|
mtr_memo_slot_t* slot;
|
|
dyn_array_t* memo;
|
|
ulint offset;
|
|
|
|
ut_ad(mtr);
|
|
ut_ad(mtr->magic_n == MTR_MAGIC_N);
|
|
|
|
memo = &(mtr->memo);
|
|
|
|
offset = dyn_array_get_data_size(memo);
|
|
|
|
while (offset > 0) {
|
|
offset -= sizeof(mtr_memo_slot_t);
|
|
|
|
slot = dyn_array_get_element(memo, offset);
|
|
|
|
if ((object == slot->object) && (type == slot->type)) {
|
|
|
|
return(TRUE);
|
|
}
|
|
}
|
|
|
|
return(FALSE);
|
|
}
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
/*******************************************************************
|
|
Returns the log object of a mini-transaction buffer. */
|
|
UNIV_INLINE
|
|
dyn_array_t*
|
|
mtr_get_log(
|
|
/*========*/
|
|
/* out: log */
|
|
mtr_t* mtr) /* in: mini-transaction */
|
|
{
|
|
ut_ad(mtr);
|
|
ut_ad(mtr->magic_n == MTR_MAGIC_N);
|
|
|
|
return(&(mtr->log));
|
|
}
|
|
|
|
/*******************************************************************
|
|
Gets the logging mode of a mini-transaction. */
|
|
UNIV_INLINE
|
|
ulint
|
|
mtr_get_log_mode(
|
|
/*=============*/
|
|
/* out: logging mode: MTR_LOG_NONE, ... */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ut_ad(mtr);
|
|
ut_ad(mtr->log_mode >= MTR_LOG_ALL);
|
|
ut_ad(mtr->log_mode <= MTR_LOG_SHORT_INSERTS);
|
|
|
|
return(mtr->log_mode);
|
|
}
|
|
|
|
/*******************************************************************
|
|
Changes the logging mode of a mini-transaction. */
|
|
UNIV_INLINE
|
|
ulint
|
|
mtr_set_log_mode(
|
|
/*=============*/
|
|
/* out: old mode */
|
|
mtr_t* mtr, /* in: mtr */
|
|
ulint mode) /* in: logging mode: MTR_LOG_NONE, ... */
|
|
{
|
|
ulint old_mode;
|
|
|
|
ut_ad(mtr);
|
|
ut_ad(mode >= MTR_LOG_ALL);
|
|
ut_ad(mode <= MTR_LOG_SHORT_INSERTS);
|
|
|
|
old_mode = mtr->log_mode;
|
|
|
|
if ((mode == MTR_LOG_SHORT_INSERTS) && (old_mode == MTR_LOG_NONE)) {
|
|
/* Do nothing */
|
|
} else {
|
|
mtr->log_mode = mode;
|
|
}
|
|
|
|
ut_ad(old_mode >= MTR_LOG_ALL);
|
|
ut_ad(old_mode <= MTR_LOG_SHORT_INSERTS);
|
|
|
|
return(old_mode);
|
|
}
|
|
|
|
/*************************************************************************
|
|
Locks a lock in s-mode. */
|
|
UNIV_INLINE
|
|
void
|
|
mtr_s_lock_func(
|
|
/*============*/
|
|
rw_lock_t* lock, /* in: rw-lock */
|
|
const char* file, /* in: file name */
|
|
ulint line, /* in: line number */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ut_ad(mtr);
|
|
ut_ad(lock);
|
|
|
|
rw_lock_s_lock_func(lock, 0, file, line);
|
|
|
|
mtr_memo_push(mtr, lock, MTR_MEMO_S_LOCK);
|
|
}
|
|
|
|
/*************************************************************************
|
|
Locks a lock in x-mode. */
|
|
UNIV_INLINE
|
|
void
|
|
mtr_x_lock_func(
|
|
/*============*/
|
|
rw_lock_t* lock, /* in: rw-lock */
|
|
const char* file, /* in: file name */
|
|
ulint line, /* in: line number */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ut_ad(mtr);
|
|
ut_ad(lock);
|
|
|
|
rw_lock_x_lock_func(lock, 0, file, line);
|
|
|
|
mtr_memo_push(mtr, lock, MTR_MEMO_X_LOCK);
|
|
}
|