summaryrefslogtreecommitdiff
path: root/storage/innobase/include
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-11-14 14:49:20 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-11-14 14:49:20 +0200
commitae90f8431ba80383f75810248ddaaa9d2c6fd09f (patch)
tree8f4e6f29d991188b01db6695c3229f6201cc6121 /storage/innobase/include
parentc454b8964c10301dceab6d1a5489350a0f8fbf9c (diff)
parent89ae01fd0085cf0d1af272eca545e49fdadf4538 (diff)
downloadmariadb-git-ae90f8431ba80383f75810248ddaaa9d2c6fd09f.tar.gz
Merge 10.4 into 10.5
Diffstat (limited to 'storage/innobase/include')
-rw-r--r--storage/innobase/include/dict0dict.h6
-rw-r--r--storage/innobase/include/dict0mem.h66
-rw-r--r--storage/innobase/include/mtr0mtr.h89
-rw-r--r--storage/innobase/include/mtr0mtr.ic33
-rw-r--r--storage/innobase/include/page0zip.ic3
5 files changed, 122 insertions, 75 deletions
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index 5647cb488b5..a2666e7cfbc 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -976,16 +976,12 @@ added column.
@param[in,out] index index; NOTE! The index memory
object is freed in this function!
@param[in] page_no root page number of the index
-@param[in] strict true=refuse to create the index
- if records could be too big to fit in
- an B-tree page
@param[in] add_v virtual columns being added along with ADD INDEX
-@return DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION */
+@return DB_SUCCESS, or DB_CORRUPTION */
dberr_t
dict_index_add_to_cache(
dict_index_t*& index,
ulint page_no,
- bool strict = false,
const dict_add_v_col_t* add_v = NULL)
MY_ATTRIBUTE((warn_unused_result));
/********************************************************************//**
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 336834cda95..e2a42519d99 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -1214,12 +1214,6 @@ struct dict_index_t {
bool
vers_history_row(const rec_t* rec, bool &history_row);
- /** If a record of this index might not fit on a single B-tree page,
- return true.
- @param[in] strict issue error or warning
- @return true if the index record could become too big */
- bool rec_potentially_too_big(bool strict) const;
-
/** Reconstruct the clustered index fields. */
inline void reconstruct_fields();
@@ -1229,6 +1223,66 @@ struct dict_index_t {
@return whether the index contains the column or its prefix */
bool contains_col_or_prefix(ulint n, bool is_virtual) const
MY_ATTRIBUTE((warn_unused_result));
+
+ /** This ad-hoc class is used by record_size_info only. */
+ class record_size_info_t {
+ public:
+ record_size_info_t()
+ : max_leaf_size(0), shortest_size(0), too_big(false),
+ first_overrun_field_index(SIZE_T_MAX), overrun_size(0)
+ {
+ }
+
+ /** Mark row potentially too big for page and set up first
+ overflow field index. */
+ void set_too_big(size_t field_index)
+ {
+ ut_ad(field_index != SIZE_T_MAX);
+
+ too_big = true;
+ if (first_overrun_field_index > field_index) {
+ first_overrun_field_index = field_index;
+ overrun_size = shortest_size;
+ }
+ }
+
+ /** @return overrun field index or SIZE_T_MAX if nothing
+ overflowed*/
+ size_t get_first_overrun_field_index() const
+ {
+ ut_ad(row_is_too_big());
+ ut_ad(first_overrun_field_index != SIZE_T_MAX);
+ return first_overrun_field_index;
+ }
+
+ size_t get_overrun_size() const
+ {
+ ut_ad(row_is_too_big());
+ return overrun_size;
+ }
+
+ bool row_is_too_big() const { return too_big; }
+
+ size_t max_leaf_size; /** Bigger row size this index can
+ produce */
+ size_t shortest_size; /** shortest because it counts everything
+ as in overflow pages */
+
+ private:
+ bool too_big; /** This one is true when maximum row size this
+ index can produce is bigger than maximum row
+ size given page can hold. */
+ size_t first_overrun_field_index; /** After adding this field
+ index row overflowed maximum
+ allowed size. Useful for
+ reporting back to user. */
+ size_t overrun_size; /** Just overrun row size */
+ };
+
+ /** Returns max possibly record size for that index, size of a shortest
+ everything in overflow) size of the longest possible row and index
+ of a field which made index records too big to fit on a page.*/
+ inline record_size_info_t record_size_info() const;
};
/** Detach a column from an index.
diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h
index 0dbfc14c68f..f364730b21f 100644
--- a/storage/innobase/include/mtr0mtr.h
+++ b/storage/innobase/include/mtr0mtr.h
@@ -81,17 +81,12 @@ savepoint. */
/** Push an object to an mtr memo stack. */
#define mtr_memo_push(m, o, t) (m)->memo_push(o, t)
-/** Lock an rw-lock in s-mode. */
-#define mtr_s_lock(l, m) (m)->s_lock((l), __FILE__, __LINE__)
-
-/** Lock an rw-lock in x-mode. */
-#define mtr_x_lock(l, m) (m)->x_lock((l), __FILE__, __LINE__)
-
-/** Lock a tablespace in x-mode. */
+#define mtr_s_lock_space(s, m) (m)->s_lock_space((s), __FILE__, __LINE__)
#define mtr_x_lock_space(s, m) (m)->x_lock_space((s), __FILE__, __LINE__)
-/** Lock an rw-lock in sx-mode. */
-#define mtr_sx_lock(l, m) (m)->sx_lock((l), __FILE__, __LINE__)
+#define mtr_s_lock_index(i, m) (m)->s_lock(&(i)->lock, __FILE__, __LINE__)
+#define mtr_x_lock_index(i, m) (m)->x_lock(&(i)->lock, __FILE__, __LINE__)
+#define mtr_sx_lock_index(i, m) (m)->sx_lock(&(i)->lock, __FILE__, __LINE__)
#define mtr_memo_contains_flagged(m, p, l) \
(m)->memo_contains_flagged((p), (l))
@@ -240,29 +235,7 @@ struct mtr_t {
bool is_named_space(const fil_space_t* space) const;
#endif /* UNIV_DEBUG */
- /** Locks a rw-latch in S mode.
- NOTE: use mtr_s_lock().
- @param lock rw-lock
- @param file file name from where called
- @param line line number in file */
- inline void s_lock(rw_lock_t* lock, const char* file, unsigned line);
-
- /** Locks a rw-latch in X mode.
- NOTE: use mtr_x_lock().
- @param lock rw-lock
- @param file file name from where called
- @param line line number in file */
- inline void x_lock(rw_lock_t* lock, const char* file, unsigned line);
-
- /** Locks a rw-latch in X mode.
- NOTE: use mtr_sx_lock().
- @param lock rw-lock
- @param file file name from where called
- @param line line number in file */
- inline void sx_lock(rw_lock_t* lock, const char* file, unsigned line);
-
/** Acquire a tablespace X-latch.
- NOTE: use mtr_x_lock_space().
@param[in] space_id tablespace ID
@param[in] file file name from where called
@param[in] line line number in file
@@ -272,6 +245,60 @@ struct mtr_t {
const char* file,
unsigned line);
+ /** Acquire a shared rw-latch.
+ @param[in] lock rw-latch
+ @param[in] file file name from where called
+ @param[in] line line number in file */
+ void s_lock(rw_lock_t* lock, const char* file, unsigned line)
+ {
+ rw_lock_s_lock_inline(lock, 0, file, line);
+ memo_push(lock, MTR_MEMO_S_LOCK);
+ }
+
+ /** Acquire an exclusive rw-latch.
+ @param[in] lock rw-latch
+ @param[in] file file name from where called
+ @param[in] line line number in file */
+ void x_lock(rw_lock_t* lock, const char* file, unsigned line)
+ {
+ rw_lock_x_lock_inline(lock, 0, file, line);
+ memo_push(lock, MTR_MEMO_X_LOCK);
+ }
+
+ /** Acquire an shared/exclusive rw-latch.
+ @param[in] lock rw-latch
+ @param[in] file file name from where called
+ @param[in] line line number in file */
+ void sx_lock(rw_lock_t* lock, const char* file, unsigned line)
+ {
+ rw_lock_sx_lock_inline(lock, 0, file, line);
+ memo_push(lock, MTR_MEMO_SX_LOCK);
+ }
+
+ /** Acquire a tablespace S-latch.
+ @param[in] space tablespace
+ @param[in] file file name from where called
+ @param[in] line line number in file */
+ void s_lock_space(fil_space_t* space, const char* file, unsigned line)
+ {
+ ut_ad(space->purpose == FIL_TYPE_TEMPORARY
+ || space->purpose == FIL_TYPE_IMPORT
+ || space->purpose == FIL_TYPE_TABLESPACE);
+ s_lock(&space->latch, file, line);
+ }
+
+ /** Acquire a tablespace X-latch.
+ @param[in] space tablespace
+ @param[in] file file name from where called
+ @param[in] line line number in file */
+ void x_lock_space(fil_space_t* space, const char* file, unsigned line)
+ {
+ ut_ad(space->purpose == FIL_TYPE_TEMPORARY
+ || space->purpose == FIL_TYPE_IMPORT
+ || space->purpose == FIL_TYPE_TABLESPACE);
+ x_lock(&space->latch, file, line);
+ }
+
/** Release an object in the memo stack.
@param object object
@param type object type: MTR_MEMO_S_LOCK, ...
diff --git a/storage/innobase/include/mtr0mtr.ic b/storage/innobase/include/mtr0mtr.ic
index 7f991269d46..0fe56f960b7 100644
--- a/storage/innobase/include/mtr0mtr.ic
+++ b/storage/innobase/include/mtr0mtr.ic
@@ -227,36 +227,3 @@ mtr_t::set_log_mode(mtr_log_t mode)
ut_ad(0);
return(old_mode);
}
-
-/**
-Locks a lock in s-mode. */
-
-void
-mtr_t::s_lock(rw_lock_t* lock, const char* file, unsigned line)
-{
- rw_lock_s_lock_inline(lock, 0, file, line);
-
- memo_push(lock, MTR_MEMO_S_LOCK);
-}
-
-/**
-Locks a lock in x-mode. */
-
-void
-mtr_t::x_lock(rw_lock_t* lock, const char* file, unsigned line)
-{
- rw_lock_x_lock_inline(lock, 0, file, line);
-
- memo_push(lock, MTR_MEMO_X_LOCK);
-}
-
-/**
-Locks a lock in sx-mode. */
-
-void
-mtr_t::sx_lock(rw_lock_t* lock, const char* file, unsigned line)
-{
- rw_lock_sx_lock_inline(lock, 0, file, line);
-
- memo_push(lock, MTR_MEMO_SX_LOCK);
-}
diff --git a/storage/innobase/include/page0zip.ic b/storage/innobase/include/page0zip.ic
index 8df7078594e..23a14b5947c 100644
--- a/storage/innobase/include/page0zip.ic
+++ b/storage/innobase/include/page0zip.ic
@@ -154,6 +154,9 @@ tablespace is not compressed
inline bool page_zip_rec_needs_ext(ulint rec_size, ulint comp, ulint n_fields,
ulint zip_size)
{
+ /* FIXME: row size check is this function seems to be the most correct.
+ Put it in a separate function and use in more places of InnoDB */
+
ut_ad(rec_size
> ulint(comp ? REC_N_NEW_EXTRA_BYTES : REC_N_OLD_EXTRA_BYTES));
ut_ad(comp || !zip_size);