summaryrefslogtreecommitdiff
path: root/innobase/include
diff options
context:
space:
mode:
Diffstat (limited to 'innobase/include')
-rw-r--r--innobase/include/btr0btr.h6
-rw-r--r--innobase/include/dict0mem.h32
-rw-r--r--innobase/include/ibuf0ibuf.h6
-rw-r--r--innobase/include/ibuf0ibuf.ic12
-rw-r--r--innobase/include/os0file.h8
-rw-r--r--innobase/include/os0sync.h5
-rw-r--r--innobase/include/os0sync.ic17
-rw-r--r--innobase/include/row0mysql.h21
-rw-r--r--innobase/include/row0upd.h10
-rw-r--r--innobase/include/sync0sync.h9
-rw-r--r--innobase/include/sync0sync.ic4
-rw-r--r--innobase/include/trx0sys.h2
-rw-r--r--innobase/include/trx0sys.ic1
-rw-r--r--innobase/include/trx0trx.h14
-rw-r--r--innobase/include/univ.i12
15 files changed, 114 insertions, 45 deletions
diff --git a/innobase/include/btr0btr.h b/innobase/include/btr0btr.h
index bea85565125..d22f9d79c1c 100644
--- a/innobase/include/btr0btr.h
+++ b/innobase/include/btr0btr.h
@@ -49,6 +49,12 @@ inserted to the index, at the searched position */
/* This flag ORed to latch mode says that we do the search in query
optimization */
#define BTR_ESTIMATE 1024
+
+/* This flag ORed to latch mode says that we can ignore possible
+UNIQUE definition on secondary indexes when we decide if we can use the
+insert buffer to speed up inserts */
+#define BTR_IGNORE_SEC_UNIQUE 2048
+
/******************************************************************
Gets a buffer page and declares its latching order level. */
UNIV_INLINE
diff --git a/innobase/include/dict0mem.h b/innobase/include/dict0mem.h
index 5ef0103087a..ef15c99fdba 100644
--- a/innobase/include/dict0mem.h
+++ b/innobase/include/dict0mem.h
@@ -249,6 +249,8 @@ struct dict_foreign_struct{
this memory heap */
char* id; /* id of the constraint as a
null-terminated string */
+ ulint type; /* 0 or DICT_FOREIGN_ON_DELETE_CASCADE
+ or DICT_FOREIGN_ON_DELETE_SET_NULL */
char* foreign_table_name;/* foreign table name */
dict_table_t* foreign_table; /* table where the foreign key is */
char** foreign_col_names;/* names of the columns in the
@@ -278,6 +280,9 @@ struct dict_foreign_struct{
table */
};
+#define DICT_FOREIGN_ON_DELETE_CASCADE 1
+#define DICT_FOREIGN_ON_DELETE_SET_NULL 2
+
#define DICT_INDEX_MAGIC_N 76789786
/* Data structure for a database table */
@@ -313,6 +318,12 @@ struct dict_table_struct{
NOT allowed until this count gets to zero;
MySQL does NOT itself check the number of
open handles at drop */
+ ulint n_foreign_key_checks_running;
+ /* count of how many foreign key check
+ operations are currently being performed
+ on the table: we cannot drop the table while
+ there are foreign key checks running on
+ it! */
ibool cached; /* TRUE if the table object has been added
to the dictionary cache */
lock_t* auto_inc_lock;/* a buffer for an auto-inc lock
@@ -359,17 +370,16 @@ struct dict_table_struct{
after database startup or table creation */
ulint stat_modified_counter;
/* when a row is inserted, updated, or deleted,
- we add the row length to this number; we
- calculate new estimates for the stat_...
- values for the table and the indexes at an
- interval of 2 GB or when about 1 / 16 of table
- has been modified; also
- when the estimate operation is called
- for MySQL SHOW TABLE STATUS; the counter is
- reset to zero at statistics calculation;
- this counter
- is not protected by any latch, because this
- is only used for heuristics */
+ we add 1 to this number; we calculate new
+ estimates for the stat_... values for the
+ table and the indexes at an interval of 2 GB
+ or when about 1 / 16 of table has been
+ modified; also when the estimate operation is
+ called for MySQL SHOW TABLE STATUS; the
+ counter is reset to zero at statistics
+ calculation; this counter is not protected by
+ any latch, because this is only used for
+ heuristics */
/*----------------------*/
mutex_t autoinc_mutex;
/* mutex protecting the autoincrement
diff --git a/innobase/include/ibuf0ibuf.h b/innobase/include/ibuf0ibuf.h
index 99fb1595f49..fac28461be4 100644
--- a/innobase/include/ibuf0ibuf.h
+++ b/innobase/include/ibuf0ibuf.h
@@ -127,7 +127,11 @@ UNIV_INLINE
ibool
ibuf_should_try(
/*============*/
- dict_index_t* index); /* in: index where to insert */
+ dict_index_t* index, /* in: index where to insert */
+ ulint ignore_sec_unique); /* in: if != 0, we should
+ ignore UNIQUE constraint on
+ a secondary index when we
+ decide */
/**********************************************************************
Returns TRUE if the current OS thread is performing an insert buffer
routine. */
diff --git a/innobase/include/ibuf0ibuf.ic b/innobase/include/ibuf0ibuf.ic
index e969a0550da..0886c8c02cc 100644
--- a/innobase/include/ibuf0ibuf.ic
+++ b/innobase/include/ibuf0ibuf.ic
@@ -81,10 +81,16 @@ UNIV_INLINE
ibool
ibuf_should_try(
/*============*/
- dict_index_t* index) /* in: index where to insert */
+ dict_index_t* index, /* in: index where to insert */
+ ulint ignore_sec_unique) /* in: if != 0, we should
+ ignore UNIQUE constraint on
+ a secondary index when we
+ decide */
{
- if (!(index->type & (DICT_CLUSTERED | DICT_UNIQUE))
- && ibuf->meter > IBUF_THRESHOLD) {
+ if (!(index->type & DICT_CLUSTERED)
+ && (ignore_sec_unique || !(index->type & DICT_UNIQUE))
+ && ibuf->meter > IBUF_THRESHOLD) {
+
ibuf_flush_count++;
if (ibuf_flush_count % 8 == 0) {
diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h
index 67d76814936..01fa12955ff 100644
--- a/innobase/include/os0file.h
+++ b/innobase/include/os0file.h
@@ -25,12 +25,6 @@ extern ibool os_has_said_disk_full;
#define UNIV_NON_BUFFERED_IO
-#else
-
-#if defined(HAVE_AIO_H) && defined(HAVE_LIBRT)
-#define POSIX_ASYNC_IO
-#endif
-
#endif
#ifdef __WIN__
@@ -347,6 +341,8 @@ os_aio_windows_handle(
void** message2,
ulint* type); /* out: OS_FILE_WRITE or ..._READ */
#endif
+
+/* Currently we do not use Posix async i/o */
#ifdef POSIX_ASYNC_IO
/**************************************************************************
This function is only used in Posix asynchronous i/o. Waits for an aio
diff --git a/innobase/include/os0sync.h b/innobase/include/os0sync.h
index 617f6b036fe..b2d613c4619 100644
--- a/innobase/include/os0sync.h
+++ b/innobase/include/os0sync.h
@@ -149,9 +149,9 @@ void
os_mutex_free(
/*==========*/
os_mutex_t mutex); /* in: mutex to free */
-#ifndef _WIN32
/**************************************************************
-Acquires ownership of a fast mutex. */
+Acquires ownership of a fast mutex. Currently in Windows this is the same
+as os_fast_mutex_lock! */
UNIV_INLINE
ulint
os_fast_mutex_trylock(
@@ -160,7 +160,6 @@ os_fast_mutex_trylock(
was reserved by another
thread */
os_fast_mutex_t* fast_mutex); /* in: mutex to acquire */
-#endif
/**************************************************************
Releases ownership of a fast mutex. */
diff --git a/innobase/include/os0sync.ic b/innobase/include/os0sync.ic
index aa00300dec5..6bff75d8ec6 100644
--- a/innobase/include/os0sync.ic
+++ b/innobase/include/os0sync.ic
@@ -10,9 +10,9 @@ Created 9/6/1995 Heikki Tuuri
#include <winbase.h>
#endif
-#ifndef _WIN32
/**************************************************************
-Acquires ownership of a fast mutex. */
+Acquires ownership of a fast mutex. Currently in Windows this is the same
+as os_fast_mutex_lock! */
UNIV_INLINE
ulint
os_fast_mutex_trylock(
@@ -23,20 +23,11 @@ os_fast_mutex_trylock(
os_fast_mutex_t* fast_mutex) /* in: mutex to acquire */
{
#ifdef __WIN__
- int ret;
+ EnterCriticalSection(fast_mutex);
- /* TODO: TryEnterCriticalSection is probably not found from
- NT versions < 4! */
- ret = TryEnterCriticalSection(fast_mutex);
-
- if (ret) {
- return(0);
- }
-
- return(1);
+ return(0);
#else
return((ulint) pthread_mutex_trylock(fast_mutex));
#endif
}
-#endif
diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h
index 92693319175..13b3dffd874 100644
--- a/innobase/include/row0mysql.h
+++ b/innobase/include/row0mysql.h
@@ -209,6 +209,27 @@ row_update_for_mysql(
row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL
handle */
/*************************************************************************
+Creates an query graph node of 'update' type to be used in the MySQL
+interface. */
+
+upd_node_t*
+row_create_update_node_for_mysql(
+/*=============================*/
+ /* out, own: update node */
+ dict_table_t* table, /* in: table to update */
+ mem_heap_t* heap); /* in: mem heap from which allocated */
+/**************************************************************************
+Does a cascaded delete or set null in a foreign key operation. */
+
+ulint
+row_update_cascade_for_mysql(
+/*=========================*/
+ /* out: error code or DB_SUCCESS */
+ que_thr_t* thr, /* in: query thread */
+ upd_node_t* node, /* in: update node used in the cascade
+ or set null operation */
+ dict_table_t* table); /* in: table where we do the operation */
+/*************************************************************************
Does a table creation operation for MySQL. If the name of the created
table ends to characters INNODB_MONITOR, then this also starts
printing of monitor output by the master thread. */
diff --git a/innobase/include/row0upd.h b/innobase/include/row0upd.h
index 106d3866b25..9a3e2463267 100644
--- a/innobase/include/row0upd.h
+++ b/innobase/include/row0upd.h
@@ -312,6 +312,11 @@ struct upd_node_struct{
ibool in_mysql_interface;
/* TRUE if the update node was created
for the MySQL interface */
+ upd_node_t* cascade_node;/* NULL or an update node template which
+ is used to implement ON DELETE CASCADE
+ or ... SET NULL for foreign keys */
+ mem_heap_t* cascade_heap;/* NULL or a mem heap where the cascade
+ node is created */
sel_node_t* select; /* query graph subtree implementing a base
table cursor: the rows returned will be
updated */
@@ -322,6 +327,11 @@ struct upd_node_struct{
of the MySQL interface */
dict_table_t* table; /* table where updated */
upd_t* update; /* update vector for the row */
+ ulint update_n_fields;
+ /* when this struct is used to implement
+ a cascade operation for foreign keys, we store
+ here the size of the buffer allocated for use
+ as the update vector */
sym_node_list_t columns;/* symbol table nodes for the columns
to retrieve from the table */
ibool has_clust_rec_x_lock;
diff --git a/innobase/include/sync0sync.h b/innobase/include/sync0sync.h
index 6c3bff66e27..4f55709a5d7 100644
--- a/innobase/include/sync0sync.h
+++ b/innobase/include/sync0sync.h
@@ -359,12 +359,17 @@ V
Memory pool mutex */
/* Latching order levels */
+
+/* User transaction locks are higher than any of the latch levels below:
+no latches are allowed when a thread goes to wait for a normal table
+or row lock! */
+#define SYNC_USER_TRX_LOCK 9999
#define SYNC_NO_ORDER_CHECK 3000 /* this can be used to suppress
latching order checking */
#define SYNC_LEVEL_NONE 2000 /* default: level not defined */
+#define SYNC_FOREIGN_KEY_CHECK 1001
#define SYNC_DICT 1000
#define SYNC_DICT_AUTOINC_MUTEX 999
-#define SYNC_FOREIGN_KEY_CHECK 998
#define SYNC_PURGE_IS_RUNNING 997
#define SYNC_DICT_HEADER 995
#define SYNC_IBUF_HEADER 914
@@ -429,7 +434,7 @@ implementation of a mutual exclusion semaphore. */
struct mutex_struct {
ulint lock_word; /* This ulint is the target of the atomic
test-and-set instruction in Win32 */
-#ifndef _WIN32
+#if !defined(_WIN32) || !defined(UNIV_CAN_USE_X86_ASSEMBLER)
os_fast_mutex_t
os_fast_mutex; /* In other systems we use this OS mutex
in place of lock_word */
diff --git a/innobase/include/sync0sync.ic b/innobase/include/sync0sync.ic
index 9531377ce0b..9014eb5fb54 100644
--- a/innobase/include/sync0sync.ic
+++ b/innobase/include/sync0sync.ic
@@ -53,7 +53,7 @@ mutex_test_and_set(
1 */
mutex_t* mutex) /* in: mutex */
{
-#ifdef _WIN32
+#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
ulint res;
ulint* lw; /* assembler code is used to ensure that
lock_word is loaded from memory */
@@ -120,7 +120,7 @@ mutex_reset_lock_word(
/*==================*/
mutex_t* mutex) /* in: mutex */
{
-#ifdef _WIN32
+#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
ulint* lw; /* assembler code is used to ensure that
lock_word is loaded from memory */
ut_ad(mutex);
diff --git a/innobase/include/trx0sys.h b/innobase/include/trx0sys.h
index 98c726fb118..60d5adb72d1 100644
--- a/innobase/include/trx0sys.h
+++ b/innobase/include/trx0sys.h
@@ -259,7 +259,7 @@ therefore 256 */
/* The offset of the transaction system header on the page */
#define TRX_SYS FSEG_PAGE_DATA
-/* Transaction system header; protected by trx_sys->mutex */
+/* Transaction system header */
/*-------------------------------------------------------------*/
#define TRX_SYS_TRX_ID_STORE 0 /* the maximum trx id or trx number
modulo TRX_SYS_TRX_ID_UPDATE_MARGIN
diff --git a/innobase/include/trx0sys.ic b/innobase/include/trx0sys.ic
index 786e7905933..ada2d8cb19c 100644
--- a/innobase/include/trx0sys.ic
+++ b/innobase/include/trx0sys.ic
@@ -93,7 +93,6 @@ trx_sysf_get(
{
trx_sysf_t* header;
- ut_ad(mutex_own(&(kernel_mutex)));
ut_ad(mtr);
header = TRX_SYS + buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO,
diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h
index 26c9ace08b6..261f33d3dc3 100644
--- a/innobase/include/trx0trx.h
+++ b/innobase/include/trx0trx.h
@@ -298,6 +298,17 @@ struct trx_struct{
of view of concurrency control:
TRX_ACTIVE, TRX_COMMITTED_IN_MEMORY,
... */
+ ibool check_foreigns; /* normally TRUE, but if the user
+ wants to suppress foreign key checks,
+ (in table imports, for example) we
+ set this FALSE */
+ ibool check_unique_secondary;
+ /* normally TRUE, but if the user
+ wants to speed up inserts by
+ suppressing unique key checks
+ for secondary indexes when we decide
+ if we can use the insert buffer for
+ them, we set this FALSE */
dulint id; /* transaction id */
dulint no; /* transaction serialization number ==
max trx id when the transaction is
@@ -328,6 +339,9 @@ struct trx_struct{
/* how many tables the current SQL
statement uses, except those
in consistent read */
+ ibool has_dict_foreign_key_check_lock;
+ /* TRUE if the trx currently holds
+ an s-lock on dict_foreign_... */
ibool has_search_latch;
/* TRUE if this trx has latched the
search system latch in S-mode */
diff --git a/innobase/include/univ.i b/innobase/include/univ.i
index 8870d80f611..160a435319a 100644
--- a/innobase/include/univ.i
+++ b/innobase/include/univ.i
@@ -14,6 +14,13 @@ Created 1/20/1994 Heikki Tuuri
#include <windows.h>
+/* When compiling for Itanium IA64, undefine the flag below to prevent use
+of 32-bit assembler */
+
+#ifndef WIN64
+#define UNIV_CAN_USE_X86_ASSEMBLER
+#endif
+
/* If you want to check for errors with compiler level -W4,
comment out the above include of windows.h and let the following defines
be defined:
@@ -71,13 +78,14 @@ memory is read outside the allocated blocks. */
*/
/* Make a non-inline debug version */
+
/*
#define UNIV_DEBUG
#define UNIV_MEM_DEBUG
-#define UNIV_SEARCH_DEBUG
+#define UNIV_SYNC_DEBUG
#define UNIV_IBUF_DEBUG
-#define UNIV_SYNC_DEBUG
+#define UNIV_SEARCH_DEBUG
#define UNIV_SYNC_PERF_STAT
#define UNIV_SEARCH_PERF_STAT
*/