summaryrefslogtreecommitdiff
path: root/storage/innobase/include
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include')
-rw-r--r--storage/innobase/include/btr0cur.h13
-rw-r--r--storage/innobase/include/dict0dict.h27
-rw-r--r--storage/innobase/include/dict0mem.h13
-rw-r--r--storage/innobase/include/lock0lock.h2
-rw-r--r--storage/innobase/include/os0once.h125
-rw-r--r--storage/innobase/include/os0sync.h14
-rw-r--r--storage/innobase/include/srv0srv.h4
-rw-r--r--storage/innobase/include/sync0rw.h12
-rw-r--r--storage/innobase/include/sync0sync.ic5
-rw-r--r--storage/innobase/include/trx0trx.h5
-rw-r--r--storage/innobase/include/univ.i10
11 files changed, 206 insertions, 24 deletions
diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h
index 833166e783c..f1e4406fcf7 100644
--- a/storage/innobase/include/btr0cur.h
+++ b/storage/innobase/include/btr0cur.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -576,6 +576,17 @@ void
btr_estimate_number_of_different_key_vals(
/*======================================*/
dict_index_t* index); /*!< in: index */
+
+/** Gets the externally stored size of a record, in units of a database page.
+@param[in] rec record
+@param[in] offsets array returned by rec_get_offsets()
+@return externally stored part, in units of a database page */
+
+ulint
+btr_rec_get_externally_stored_len(
+ const rec_t* rec,
+ const ulint* offsets);
+
/*******************************************************************//**
Marks non-updated off-page fields as disowned by this record. The ownership
must be transferred to the updated record which is inserted elsewhere in the
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index ce709a2e912..026187b2000 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
This program is free software; you can redistribute it and/or modify it under
@@ -43,6 +43,9 @@ Created 1/8/1996 Heikki Tuuri
#include "trx0types.h"
#include "row0types.h"
+extern bool innodb_table_stats_not_found;
+extern bool innodb_index_stats_not_found;
+
#ifndef UNIV_HOTBACKUP
# include "sync0sync.h"
# include "sync0rw.h"
@@ -1435,6 +1438,28 @@ UNIV_INTERN
void
dict_mutex_exit_for_mysql(void);
/*===========================*/
+
+/** Create a dict_table_t's stats latch or delay for lazy creation.
+This function is only called from either single threaded environment
+or from a thread that has not shared the table object with other threads.
+@param[in,out] table table whose stats latch to create
+@param[in] enabled if false then the latch is disabled
+and dict_table_stats_lock()/unlock() become noop on this table. */
+
+void
+dict_table_stats_latch_create(
+ dict_table_t* table,
+ bool enabled);
+
+/** Destroy a dict_table_t's stats latch.
+This function is only called from either single threaded environment
+or from a thread that has not shared the table object with other threads.
+@param[in,out] table table whose stats latch to destroy */
+
+void
+dict_table_stats_latch_destroy(
+ dict_table_t* table);
+
/**********************************************************************//**
Lock the appropriate latch to protect a given table's statistics.
table->id is used to pick the corresponding latch from a global array of
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index c5ed8d92cb0..0e3981a2946 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
This program is free software; you can redistribute it and/or modify it under
@@ -46,6 +46,7 @@ Created 1/8/1996 Heikki Tuuri
#include "hash0hash.h"
#include "trx0types.h"
#include "fts0fts.h"
+#include "os0once.h"
/* Forward declaration. */
struct ib_rbt_t;
@@ -627,6 +628,9 @@ struct dict_index_t{
ulint stat_n_leaf_pages;
/*!< approximate number of leaf pages in the
index tree */
+ bool stats_error_printed;
+ /*!< has persistent statistics error printed
+ for this index ? */
/* @} */
rw_lock_t lock; /*!< read-write lock protecting the
upper levels of the index tree */
@@ -842,6 +846,10 @@ struct dict_table_t{
initialized in dict_table_add_to_cache() */
/** Statistics for query optimization */
/* @{ */
+
+ volatile os_once::state_t stats_latch_created;
+ /*!< Creation state of 'stats_latch'. */
+
rw_lock_t* stats_latch; /*!< this latch protects:
dict_table_t::stat_initialized
dict_table_t::stat_n_rows (*)
@@ -950,6 +958,9 @@ struct dict_table_t{
/*!< see BG_STAT_* above.
Writes are covered by dict_sys->mutex.
Dirty reads are possible. */
+ bool stats_error_printed;
+ /*!< Has persistent stats error beein
+ already printed for this table ? */
/* @} */
/*----------------------*/
/**!< The following fields are used by the
diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h
index 385853bdb68..88246afebdc 100644
--- a/storage/innobase/include/lock0lock.h
+++ b/storage/innobase/include/lock0lock.h
@@ -289,7 +289,7 @@ lock_rec_insert_check_and_lock(
inserted record maybe should inherit
LOCK_GAP type locks from the successor
record */
- __attribute__((nonnull, warn_unused_result));
+ __attribute__((nonnull(2,3,4,6,7), warn_unused_result));
/*********************************************************************//**
Checks if locks of other transactions prevent an immediate modify (update,
delete mark, or delete unmark) of a clustered index record. If they do,
diff --git a/storage/innobase/include/os0once.h b/storage/innobase/include/os0once.h
new file mode 100644
index 00000000000..a8bbaf1d2d4
--- /dev/null
+++ b/storage/innobase/include/os0once.h
@@ -0,0 +1,125 @@
+/*****************************************************************************
+
+Copyright (c) 2014, Oracle and/or its affiliates. All Rights Reserved.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
+
+*****************************************************************************/
+
+/**************************************************//**
+@file include/os0once.h
+A class that aids executing a given function exactly once in a multi-threaded
+environment.
+
+Created Feb 20, 2014 Vasil Dimov
+*******************************************************/
+
+#ifndef os0once_h
+#define os0once_h
+
+#include "univ.i"
+
+#include "os0sync.h"
+#include "ut0ut.h"
+
+/** Execute a given function exactly once in a multi-threaded environment
+or wait for the function to be executed by another thread.
+
+Example usage:
+First the user must create a control variable of type os_once::state_t and
+assign it os_once::NEVER_DONE.
+Then the user must pass this variable, together with a function to be
+executed to os_once::do_or_wait_for_done().
+
+Multiple threads can call os_once::do_or_wait_for_done() simultaneously with
+the same (os_once::state_t) control variable. The provided function will be
+called exactly once and when os_once::do_or_wait_for_done() returns then this
+function has completed execution, by this or another thread. In other words
+os_once::do_or_wait_for_done() will either execute the provided function or
+will wait for its execution to complete if it is already called by another
+thread or will do nothing if the function has already completed its execution
+earlier.
+
+This mimics pthread_once(3), but unfortunatelly pthread_once(3) does not
+support passing arguments to the init_routine() function. We should use
+std::call_once() when we start compiling with C++11 enabled. */
+class os_once {
+public:
+ /** Control variables' state type */
+ typedef ib_uint32_t state_t;
+
+ /** Not yet executed. */
+ static const state_t NEVER_DONE = 0;
+
+ /** Currently being executed by this or another thread. */
+ static const state_t IN_PROGRESS = 1;
+
+ /** Finished execution. */
+ static const state_t DONE = 2;
+
+#ifdef HAVE_ATOMIC_BUILTINS
+ /** Call a given function or wait its execution to complete if it is
+ already called by another thread.
+ @param[in,out] state control variable
+ @param[in] do_func function to call
+ @param[in,out] do_func_arg an argument to pass to do_func(). */
+ static
+ void
+ do_or_wait_for_done(
+ volatile state_t* state,
+ void (*do_func)(void*),
+ void* do_func_arg)
+ {
+ /* Avoid calling os_compare_and_swap_uint32() in the most
+ common case. */
+ if (*state == DONE) {
+ return;
+ }
+
+ if (os_compare_and_swap_uint32(state,
+ NEVER_DONE, IN_PROGRESS)) {
+ /* We are the first. Call the function. */
+
+ do_func(do_func_arg);
+
+ const bool swapped = os_compare_and_swap_uint32(
+ state, IN_PROGRESS, DONE);
+
+ ut_a(swapped);
+ } else {
+ /* The state is not NEVER_DONE, so either it is
+ IN_PROGRESS (somebody is calling the function right
+ now or DONE (it has already been called and completed).
+ Wait for it to become DONE. */
+ for (;;) {
+ const state_t s = *state;
+
+ switch (s) {
+ case DONE:
+ return;
+ case IN_PROGRESS:
+ break;
+ case NEVER_DONE:
+ /* fall through */
+ default:
+ ut_error;
+ }
+
+ UT_RELAX_CPU();
+ }
+ }
+ }
+#endif /* HAVE_ATOMIC_BUILTINS */
+};
+
+#endif /* os0once_h */
diff --git a/storage/innobase/include/os0sync.h b/storage/innobase/include/os0sync.h
index 9b4ce2343c5..6d3dd850e08 100644
--- a/storage/innobase/include/os0sync.h
+++ b/storage/innobase/include/os0sync.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -434,6 +434,9 @@ Returns the old value of *ptr, atomically sets *ptr to new_val */
# define os_atomic_test_and_set_ulint(ptr, new_val) \
__sync_lock_test_and_set(ptr, new_val)
+# define os_atomic_lock_release_byte(ptr) \
+ __sync_lock_release(ptr)
+
#elif defined(HAVE_IB_SOLARIS_ATOMICS)
# define HAVE_ATOMIC_BUILTINS
@@ -515,6 +518,9 @@ Returns the old value of *ptr, atomically sets *ptr to new_val */
# define os_atomic_test_and_set_ulint(ptr, new_val) \
atomic_swap_ulong(ptr, new_val)
+# define os_atomic_lock_release_byte(ptr) \
+ (void) atomic_swap_uchar(ptr, 0)
+
#elif defined(HAVE_WINDOWS_ATOMICS)
# define HAVE_ATOMIC_BUILTINS
@@ -574,7 +580,8 @@ Returns true if swapped, ptr is pointer to target, old_val is value to
compare to, new_val is the value to swap in. */
# define os_compare_and_swap_uint32(ptr, old_val, new_val) \
- (win_cmp_and_xchg_dword(ptr, new_val, old_val) == old_val)
+ (InterlockedCompareExchange(reinterpret_cast<volatile long*>(ptr), \
+ new_val, old_val) == old_val)
# define os_compare_and_swap_ulint(ptr, old_val, new_val) \
(win_cmp_and_xchg_ulint(ptr, new_val, old_val) == old_val)
@@ -637,6 +644,9 @@ clobbered */
# define os_atomic_test_and_set_ulong(ptr, new_val) \
InterlockedExchange(ptr, new_val)
+# define os_atomic_lock_release_byte(ptr) \
+ (void) InterlockedExchange(ptr, 0)
+
#else
# define IB_ATOMICS_STARTUP_MSG \
"Mutexes and rw_locks use InnoDB's own implementation"
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index 7922b14cc86..2b58e0717fb 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -3,6 +3,7 @@
Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2008, 2009, Google Inc.
Copyright (c) 2009, Percona Inc.
+Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -453,6 +454,9 @@ extern struct export_var_t export_vars;
/** Global counters */
extern srv_stats_t srv_stats;
+/** Simulate compression failures. */
+extern uint srv_simulate_comp_failures;
+
# ifdef UNIV_PFS_THREAD
/* Keys to register InnoDB threads with performance schema */
extern mysql_pfs_key_t buf_page_cleaner_thread_key;
diff --git a/storage/innobase/include/sync0rw.h b/storage/innobase/include/sync0rw.h
index 34cd8ef4bd6..b36e04f2810 100644
--- a/storage/innobase/include/sync0rw.h
+++ b/storage/innobase/include/sync0rw.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -108,14 +108,8 @@ extern ib_mutex_t rw_lock_list_mutex;
#ifdef UNIV_SYNC_DEBUG
/* The global mutex which protects debug info lists of all rw-locks.
To modify the debug info list of an rw-lock, this mutex has to be
-
acquired in addition to the mutex protecting the lock. */
-extern ib_mutex_t rw_lock_debug_mutex;
-extern os_event_t rw_lock_debug_event; /*!< If deadlock detection does
- not get immediately the mutex it
- may wait for this event */
-extern ibool rw_lock_debug_waiters; /*!< This is set to TRUE, if
- there may be waiters for the event */
+extern os_fast_mutex_t rw_lock_debug_mutex;
#endif /* UNIV_SYNC_DEBUG */
/** Counters for RW locks. */
@@ -141,7 +135,7 @@ extern mysql_pfs_key_t trx_i_s_cache_lock_key;
extern mysql_pfs_key_t trx_purge_latch_key;
extern mysql_pfs_key_t index_tree_rw_lock_key;
extern mysql_pfs_key_t index_online_log_key;
-extern mysql_pfs_key_t dict_table_stats_latch_key;
+extern mysql_pfs_key_t dict_table_stats_key;
extern mysql_pfs_key_t trx_sys_rw_lock_key;
extern mysql_pfs_key_t hash_table_rw_lock_key;
#endif /* UNIV_PFS_RWLOCK */
diff --git a/storage/innobase/include/sync0sync.ic b/storage/innobase/include/sync0sync.ic
index f34f3f90b63..cb6f6efbed8 100644
--- a/storage/innobase/include/sync0sync.ic
+++ b/storage/innobase/include/sync0sync.ic
@@ -108,10 +108,7 @@ mutex_reset_lock_word(
ib_mutex_t* mutex) /*!< in: mutex */
{
#if defined(HAVE_ATOMIC_BUILTINS)
- /* In theory __sync_lock_release should be used to release the lock.
- Unfortunately, it does not work properly alone. The workaround is
- that more conservative __sync_lock_test_and_set is used instead. */
- os_atomic_test_and_set_byte(&mutex->lock_word, 0);
+ os_atomic_lock_release_byte(&mutex->lock_word);
#else
mutex->lock_word = 0;
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index a30bbdbebb2..7c92445b796 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -992,6 +992,11 @@ struct trx_t{
count of tables being flushed. */
/*------------------------------*/
+ THD* current_lock_mutex_owner;
+ /*!< If this is equal to current_thd,
+ then in innobase_kill_query() we know we
+ already hold the lock_sys->mutex. */
+ /*------------------------------*/
#ifdef UNIV_DEBUG
ulint start_line; /*!< Track where it was started from */
const char* start_file; /*!< Filename where it was started */
diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i
index 98c5512bd0b..bc359746a0b 100644
--- a/storage/innobase/include/univ.i
+++ b/storage/innobase/include/univ.i
@@ -44,7 +44,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 5
#define INNODB_VERSION_MINOR 6
-#define INNODB_VERSION_BUGFIX 17
+#define INNODB_VERSION_BUGFIX 19
/* The following is the InnoDB version as shown in
SELECT plugin_version FROM information_schema.plugins;
@@ -439,10 +439,10 @@ typedef unsigned __int64 ib_uint64_t;
typedef unsigned __int32 ib_uint32_t;
#else
/* Use the integer types and formatting strings defined in the C99 standard. */
-# define UINT32PF "%"PRIu32
-# define INT64PF "%"PRId64
-# define UINT64PF "%"PRIu64
-# define UINT64PFx "%016"PRIx64
+# define UINT32PF "%" PRIu32
+# define INT64PF "%" PRId64
+# define UINT64PF "%" PRIu64
+# define UINT64PFx "%016" PRIx64
# define DBUG_LSN_PF UINT64PF
typedef int64_t ib_int64_t;
typedef uint64_t ib_uint64_t;