mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 20:07:13 +02:00
Merge InnoDB 5.7 from mysql-5.7.9.
Contains also
MDEV-10547: Test multi_update_innodb fails with InnoDB 5.7
The failure happened because 5.7 has changed the signature of
the bool handler::primary_key_is_clustered() const
virtual function ("const" was added). InnoDB was using the old
signature which caused the function not to be used.
MDEV-10550: Parallel replication lock waits/deadlock handling does not work with InnoDB 5.7
Fixed mutexing problem on lock_trx_handle_wait. Note that
rpl_parallel and rpl_optimistic_parallel tests still
fail.
MDEV-10156 : Group commit tests fail on 10.2 InnoDB (branch bb-10.2-jan)
Reason: incorrect merge
MDEV-10550: Parallel replication can't sync with master in InnoDB 5.7 (branch bb-10.2-jan)
Reason: incorrect merge
This commit is contained in:
parent
848d211c5c
commit
2e814d4702
835 changed files with 173885 additions and 83591 deletions
|
|
@ -30,6 +30,7 @@ Created 10/16/1994 Heikki Tuuri
|
|||
#include "dict0dict.h"
|
||||
#include "page0cur.h"
|
||||
#include "btr0types.h"
|
||||
#include "gis0type.h"
|
||||
|
||||
/** Mode flags for btr_cur operations; these can be ORed */
|
||||
enum {
|
||||
|
|
@ -52,6 +53,13 @@ enum {
|
|||
BTR_KEEP_IBUF_BITMAP = 32
|
||||
};
|
||||
|
||||
/* btr_cur_latch_leaves() returns latched blocks and savepoints. */
|
||||
struct btr_latch_leaves_t {
|
||||
/* left block, target block and right block */
|
||||
buf_block_t* blocks[3];
|
||||
ulint savepoints[3];
|
||||
};
|
||||
|
||||
#ifndef UNIV_HOTBACKUP
|
||||
#include "que0types.h"
|
||||
#include "row0types.h"
|
||||
|
|
@ -63,7 +71,7 @@ enum {
|
|||
#ifdef UNIV_DEBUG
|
||||
/*********************************************************//**
|
||||
Returns the page cursor component of a tree cursor.
|
||||
@return pointer to page cursor component */
|
||||
@return pointer to page cursor component */
|
||||
UNIV_INLINE
|
||||
page_cur_t*
|
||||
btr_cur_get_page_cur(
|
||||
|
|
@ -71,7 +79,7 @@ btr_cur_get_page_cur(
|
|||
const btr_cur_t* cursor);/*!< in: tree cursor */
|
||||
/*********************************************************//**
|
||||
Returns the buffer block on which the tree cursor is positioned.
|
||||
@return pointer to buffer block */
|
||||
@return pointer to buffer block */
|
||||
UNIV_INLINE
|
||||
buf_block_t*
|
||||
btr_cur_get_block(
|
||||
|
|
@ -79,7 +87,7 @@ btr_cur_get_block(
|
|||
const btr_cur_t* cursor);/*!< in: tree cursor */
|
||||
/*********************************************************//**
|
||||
Returns the record pointer of a tree cursor.
|
||||
@return pointer to record */
|
||||
@return pointer to record */
|
||||
UNIV_INLINE
|
||||
rec_t*
|
||||
btr_cur_get_rec(
|
||||
|
|
@ -92,22 +100,15 @@ btr_cur_get_rec(
|
|||
#endif /* UNIV_DEBUG */
|
||||
/*********************************************************//**
|
||||
Returns the compressed page on which the tree cursor is positioned.
|
||||
@return pointer to compressed page, or NULL if the page is not compressed */
|
||||
@return pointer to compressed page, or NULL if the page is not compressed */
|
||||
UNIV_INLINE
|
||||
page_zip_des_t*
|
||||
btr_cur_get_page_zip(
|
||||
/*=================*/
|
||||
btr_cur_t* cursor);/*!< in: tree cursor */
|
||||
/*********************************************************//**
|
||||
Invalidates a tree cursor by setting record pointer to NULL. */
|
||||
UNIV_INLINE
|
||||
void
|
||||
btr_cur_invalidate(
|
||||
/*===============*/
|
||||
btr_cur_t* cursor);/*!< in: tree cursor */
|
||||
/*********************************************************//**
|
||||
Returns the page of a tree cursor.
|
||||
@return pointer to page */
|
||||
@return pointer to page */
|
||||
UNIV_INLINE
|
||||
page_t*
|
||||
btr_cur_get_page(
|
||||
|
|
@ -115,8 +116,8 @@ btr_cur_get_page(
|
|||
btr_cur_t* cursor);/*!< in: tree cursor */
|
||||
/*********************************************************//**
|
||||
Returns the index of a cursor.
|
||||
@param cursor b-tree cursor
|
||||
@return index */
|
||||
@param cursor b-tree cursor
|
||||
@return index */
|
||||
#define btr_cur_get_index(cursor) ((cursor)->index)
|
||||
/*********************************************************//**
|
||||
Positions a tree cursor at a given record. */
|
||||
|
|
@ -128,6 +129,26 @@ btr_cur_position(
|
|||
rec_t* rec, /*!< in: record in tree */
|
||||
buf_block_t* block, /*!< in: buffer block of rec */
|
||||
btr_cur_t* cursor);/*!< in: cursor */
|
||||
|
||||
/** Optimistically latches the leaf page or pages requested.
|
||||
@param[in] block guessed buffer block
|
||||
@param[in] modify_clock modify clock value
|
||||
@param[in,out] latch_mode BTR_SEARCH_LEAF, ...
|
||||
@param[in,out] cursor cursor
|
||||
@param[in] file file name
|
||||
@param[in] line line where called
|
||||
@param[in] mtr mini-transaction
|
||||
@return true if success */
|
||||
bool
|
||||
btr_cur_optimistic_latch_leaves(
|
||||
buf_block_t* block,
|
||||
ib_uint64_t modify_clock,
|
||||
ulint* latch_mode,
|
||||
btr_cur_t* cursor,
|
||||
const char* file,
|
||||
ulint line,
|
||||
mtr_t* mtr);
|
||||
|
||||
/********************************************************************//**
|
||||
Searches an index tree and positions a tree cursor on a given level.
|
||||
NOTE: n_fields_cmp in tuple must be set so that it cannot be compared
|
||||
|
|
@ -135,7 +156,6 @@ to node pointer page number fields on the upper levels of the tree!
|
|||
Note that if mode is PAGE_CUR_LE, which is used in inserts, then
|
||||
cursor->up_match and cursor->low_match both will have sensible values.
|
||||
If mode is PAGE_CUR_GE, then up_match will a have a sensible value. */
|
||||
UNIV_INTERN
|
||||
dberr_t
|
||||
btr_cur_search_to_nth_level(
|
||||
/*========================*/
|
||||
|
|
@ -144,7 +164,7 @@ btr_cur_search_to_nth_level(
|
|||
const dtuple_t* tuple, /*!< in: data tuple; NOTE: n_fields_cmp in
|
||||
tuple must be set so that it cannot get
|
||||
compared to the node ptr page number field! */
|
||||
ulint mode, /*!< in: PAGE_CUR_L, ...;
|
||||
page_cur_mode_t mode, /*!< in: PAGE_CUR_L, ...;
|
||||
NOTE that if the search is made using a unique
|
||||
prefix of a record, mode should be PAGE_CUR_LE,
|
||||
not PAGE_CUR_GE, as the latter may end up on
|
||||
|
|
@ -164,15 +184,48 @@ btr_cur_search_to_nth_level(
|
|||
to protect the record! */
|
||||
btr_cur_t* cursor, /*!< in/out: tree cursor; the cursor page is
|
||||
s- or x-latched, but see also above! */
|
||||
ulint has_search_latch,/*!< in: latch mode the caller
|
||||
currently has on btr_search_latch:
|
||||
ulint has_search_latch,
|
||||
/*!< in: latch mode the caller
|
||||
currently has on search system:
|
||||
RW_S_LATCH, or 0 */
|
||||
const char* file, /*!< in: file name */
|
||||
ulint line, /*!< in: line where called */
|
||||
mtr_t* mtr); /*!< in: mtr */
|
||||
|
||||
/** Searches an index tree and positions a tree cursor on a given level.
|
||||
This function will avoid placing latches the travesal path and so
|
||||
should be used only for cases where-in latching is not needed.
|
||||
|
||||
@param[in] index index
|
||||
@param[in] level the tree level of search
|
||||
@param[in] tuple data tuple; Note: n_fields_cmp in compared
|
||||
to the node ptr page node field
|
||||
@param[in] mode PAGE_CUR_L, ....
|
||||
Insert should always be made using PAGE_CUR_LE
|
||||
to search the position.
|
||||
@param[in,out] cursor tree cursor; points to record of interest.
|
||||
@param[in] file file name
|
||||
@param[in[ line line where called from
|
||||
@param[in,out] mtr mtr
|
||||
@param[in] mark_dirty
|
||||
if true then mark the block as dirty
|
||||
@return DB_SUCCESS or error code */
|
||||
dberr_t
|
||||
btr_cur_search_to_nth_level_with_no_latch(
|
||||
dict_index_t* index,
|
||||
ulint level,
|
||||
const dtuple_t* tuple,
|
||||
page_cur_mode_t mode,
|
||||
btr_cur_t* cursor,
|
||||
const char* file,
|
||||
ulint line,
|
||||
mtr_t* mtr,
|
||||
bool mark_dirty = true)
|
||||
__attribute__((warn_unused_result));
|
||||
|
||||
/*****************************************************************//**
|
||||
Opens a cursor at either end of an index. */
|
||||
UNIV_INTERN
|
||||
Opens a cursor at either end of an index.
|
||||
@return DB_SUCCESS or error code */
|
||||
dberr_t
|
||||
btr_cur_open_at_index_side_func(
|
||||
/*============================*/
|
||||
|
|
@ -187,12 +240,44 @@ btr_cur_open_at_index_side_func(
|
|||
ulint line, /*!< in: line where called */
|
||||
mtr_t* mtr) /*!< in/out: mini-transaction */
|
||||
MY_ATTRIBUTE((nonnull));
|
||||
|
||||
#define btr_cur_open_at_index_side(f,i,l,c,lv,m) \
|
||||
btr_cur_open_at_index_side_func(f,i,l,c,lv,__FILE__,__LINE__,m)
|
||||
|
||||
/** Opens a cursor at either end of an index.
|
||||
Avoid taking latches on buffer, just pin (by incrementing fix_count)
|
||||
to keep them in buffer pool. This mode is used by intrinsic table
|
||||
as they are not shared and so there is no need of latching.
|
||||
@param[in] from_left true if open to low end, false if open
|
||||
to high end.
|
||||
@param[in] index index
|
||||
@param[in] latch_mode latch mode
|
||||
@param[in,out] cursor cursor
|
||||
@param[in] file file name
|
||||
@param[in] line line where called
|
||||
@param[in,out] mtr mini transaction
|
||||
@return DB_SUCCESS or error code
|
||||
*/
|
||||
dberr_t
|
||||
btr_cur_open_at_index_side_with_no_latch_func(
|
||||
bool from_left,
|
||||
dict_index_t* index,
|
||||
btr_cur_t* cursor,
|
||||
ulint level,
|
||||
const char* file,
|
||||
ulint line,
|
||||
mtr_t* mtr)
|
||||
__attribute__((warn_unused_result));
|
||||
|
||||
#define btr_cur_open_at_index_side_with_no_latch(f,i,c,lv,m) \
|
||||
btr_cur_open_at_index_side_with_no_latch_func( \
|
||||
f,i,c,lv,__FILE__,__LINE__,m)
|
||||
|
||||
/**********************************************************************//**
|
||||
Positions a cursor at a randomly chosen position within a B-tree. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
Positions a cursor at a randomly chosen position within a B-tree.
|
||||
@return true if the index is available and we have put the cursor, false
|
||||
if the index is unavailable */
|
||||
bool
|
||||
btr_cur_open_at_rnd_pos_func(
|
||||
/*=========================*/
|
||||
dict_index_t* index, /*!< in: index */
|
||||
|
|
@ -209,8 +294,7 @@ It is assumed that mtr holds an x-latch on the page. The operation does
|
|||
not succeed if there is too little space on the page. If there is just
|
||||
one record on the page, the insert will always succeed; this is to
|
||||
prevent trying to split a page with just one record.
|
||||
@return DB_SUCCESS, DB_WAIT_LOCK, DB_FAIL, or error number */
|
||||
UNIV_INTERN
|
||||
@return DB_SUCCESS, DB_WAIT_LOCK, DB_FAIL, or error number */
|
||||
dberr_t
|
||||
btr_cur_optimistic_insert(
|
||||
/*======================*/
|
||||
|
|
@ -241,8 +325,7 @@ Performs an insert on a page of an index tree. It is assumed that mtr
|
|||
holds an x-latch on the tree and on the cursor page. If the insert is
|
||||
made on the leaf level, to avoid deadlocks, mtr must also own x-latches
|
||||
to brothers of page, if those brothers exist.
|
||||
@return DB_SUCCESS or error number */
|
||||
UNIV_INTERN
|
||||
@return DB_SUCCESS or error number */
|
||||
dberr_t
|
||||
btr_cur_pessimistic_insert(
|
||||
/*=======================*/
|
||||
|
|
@ -273,13 +356,12 @@ an update-in-place.
|
|||
|
||||
@retval false if out of space; IBUF_BITMAP_FREE will be reset
|
||||
outside mtr if the page was recompressed
|
||||
@retval true if enough place;
|
||||
@retval true if enough place;
|
||||
|
||||
IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if this is
|
||||
a secondary index leaf page. This has to be done either within the
|
||||
same mini-transaction, or by invoking ibuf_reset_free_bits() before
|
||||
mtr_commit(mtr). */
|
||||
UNIV_INTERN
|
||||
bool
|
||||
btr_cur_update_alloc_zip_func(
|
||||
/*==========================*/
|
||||
|
|
@ -307,7 +389,6 @@ Updates a record when the update causes no size changes in its fields.
|
|||
@retval DB_SUCCESS on success
|
||||
@retval DB_ZIP_OVERFLOW if there is not enough space left
|
||||
on the compressed page (IBUF_BITMAP_FREE was reset outside mtr) */
|
||||
UNIV_INTERN
|
||||
dberr_t
|
||||
btr_cur_update_in_place(
|
||||
/*====================*/
|
||||
|
|
@ -328,7 +409,6 @@ btr_cur_update_in_place(
|
|||
MY_ATTRIBUTE((warn_unused_result, nonnull));
|
||||
/***********************************************************//**
|
||||
Writes a redo log record of updating a record in-place. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
btr_cur_update_in_place_log(
|
||||
/*========================*/
|
||||
|
|
@ -351,7 +431,6 @@ so that tree compression is recommended.
|
|||
@retval DB_UNDERFLOW if the page would become too empty
|
||||
@retval DB_ZIP_OVERFLOW if there is not enough space left
|
||||
on the compressed page */
|
||||
UNIV_INTERN
|
||||
dberr_t
|
||||
btr_cur_optimistic_update(
|
||||
/*======================*/
|
||||
|
|
@ -377,8 +456,7 @@ Performs an update of a record on a page of a tree. It is assumed
|
|||
that mtr holds an x-latch on the tree and on the cursor page. If the
|
||||
update is made on the leaf level, to avoid deadlocks, mtr must also
|
||||
own x-latches to brothers of page, if those brothers exist.
|
||||
@return DB_SUCCESS or error code */
|
||||
UNIV_INTERN
|
||||
@return DB_SUCCESS or error code */
|
||||
dberr_t
|
||||
btr_cur_pessimistic_update(
|
||||
/*=======================*/
|
||||
|
|
@ -396,9 +474,10 @@ btr_cur_pessimistic_update(
|
|||
big_rec and the index tuple */
|
||||
big_rec_t** big_rec,/*!< out: big rec vector whose fields have to
|
||||
be stored externally by the caller, or NULL */
|
||||
const upd_t* update, /*!< in: update vector; this is allowed also
|
||||
contain trx id and roll ptr fields, but
|
||||
the values in update vector have no effect */
|
||||
upd_t* update, /*!< in/out: update vector; this is allowed to
|
||||
also contain trx id and roll ptr fields.
|
||||
Non-updated columns that are moved offpage will
|
||||
be appended to this. */
|
||||
ulint cmpl_info,/*!< in: compiler info on secondary index
|
||||
updates */
|
||||
que_thr_t* thr, /*!< in: query thread */
|
||||
|
|
@ -411,22 +490,22 @@ Marks a clustered index record deleted. Writes an undo log record to
|
|||
undo log on this delete marking. Writes in the trx id field the id
|
||||
of the deleting transaction, and in the roll ptr field pointer to the
|
||||
undo log record created.
|
||||
@return DB_SUCCESS, DB_LOCK_WAIT, or error number */
|
||||
UNIV_INTERN
|
||||
@return DB_SUCCESS, DB_LOCK_WAIT, or error number */
|
||||
dberr_t
|
||||
btr_cur_del_mark_set_clust_rec(
|
||||
/*===========================*/
|
||||
ulint flags, /*!< in: undo logging and locking flags */
|
||||
buf_block_t* block, /*!< in/out: buffer block of the record */
|
||||
rec_t* rec, /*!< in/out: record */
|
||||
dict_index_t* index, /*!< in: clustered index of the record */
|
||||
const ulint* offsets,/*!< in: rec_get_offsets(rec) */
|
||||
que_thr_t* thr, /*!< in: query thread */
|
||||
const dtuple_t* entry, /*!< in: dtuple for the deleting record */
|
||||
mtr_t* mtr) /*!< in/out: mini-transaction */
|
||||
MY_ATTRIBUTE((nonnull, warn_unused_result));
|
||||
/***********************************************************//**
|
||||
Sets a secondary index record delete mark to TRUE or FALSE.
|
||||
@return DB_SUCCESS, DB_LOCK_WAIT, or error number */
|
||||
UNIV_INTERN
|
||||
@return DB_SUCCESS, DB_LOCK_WAIT, or error number */
|
||||
dberr_t
|
||||
btr_cur_del_mark_set_sec_rec(
|
||||
/*=========================*/
|
||||
|
|
@ -442,8 +521,7 @@ that mtr holds an x-latch on the tree and on the cursor page. To avoid
|
|||
deadlocks, mtr must also own x-latches to brothers of page, if those
|
||||
brothers exist. NOTE: it is assumed that the caller has reserved enough
|
||||
free extents so that the compression will always succeed if done!
|
||||
@return TRUE if compression occurred */
|
||||
UNIV_INTERN
|
||||
@return TRUE if compression occurred */
|
||||
ibool
|
||||
btr_cur_compress_if_useful(
|
||||
/*=======================*/
|
||||
|
|
@ -458,8 +536,7 @@ btr_cur_compress_if_useful(
|
|||
Removes the record on which the tree cursor is positioned. It is assumed
|
||||
that the mtr has an x-latch on the page where the cursor is positioned,
|
||||
but no latch on the whole tree.
|
||||
@return TRUE if success, i.e., the page did not become too empty */
|
||||
UNIV_INTERN
|
||||
@return TRUE if success, i.e., the page did not become too empty */
|
||||
ibool
|
||||
btr_cur_optimistic_delete_func(
|
||||
/*===========================*/
|
||||
|
|
@ -489,8 +566,7 @@ or if it is the only page on the level. It is assumed that mtr holds
|
|||
an x-latch on the tree and on the cursor page. To avoid deadlocks,
|
||||
mtr must also own x-latches to brothers of page, if those brothers
|
||||
exist.
|
||||
@return TRUE if compression occurred */
|
||||
UNIV_INTERN
|
||||
@return TRUE if compression occurred */
|
||||
ibool
|
||||
btr_cur_pessimistic_delete(
|
||||
/*=======================*/
|
||||
|
|
@ -508,14 +584,13 @@ btr_cur_pessimistic_delete(
|
|||
stays valid: it points to successor of
|
||||
deleted record on function exit */
|
||||
ulint flags, /*!< in: BTR_CREATE_FLAG or 0 */
|
||||
enum trx_rb_ctx rb_ctx, /*!< in: rollback context */
|
||||
bool rollback,/*!< in: performing rollback? */
|
||||
mtr_t* mtr) /*!< in: mtr */
|
||||
MY_ATTRIBUTE((nonnull));
|
||||
#endif /* !UNIV_HOTBACKUP */
|
||||
/***********************************************************//**
|
||||
Parses a redo log record of updating a record in-place.
|
||||
@return end of log record or NULL */
|
||||
UNIV_INTERN
|
||||
@return end of log record or NULL */
|
||||
byte*
|
||||
btr_cur_parse_update_in_place(
|
||||
/*==========================*/
|
||||
|
|
@ -527,8 +602,7 @@ btr_cur_parse_update_in_place(
|
|||
/****************************************************************//**
|
||||
Parses the redo log record for delete marking or unmarking of a clustered
|
||||
index record.
|
||||
@return end of log record or NULL */
|
||||
UNIV_INTERN
|
||||
@return end of log record or NULL */
|
||||
byte*
|
||||
btr_cur_parse_del_mark_set_clust_rec(
|
||||
/*=================================*/
|
||||
|
|
@ -540,8 +614,7 @@ btr_cur_parse_del_mark_set_clust_rec(
|
|||
/****************************************************************//**
|
||||
Parses the redo log record for delete marking or unmarking of a secondary
|
||||
index record.
|
||||
@return end of log record or NULL */
|
||||
UNIV_INTERN
|
||||
@return end of log record or NULL */
|
||||
byte*
|
||||
btr_cur_parse_del_mark_set_sec_rec(
|
||||
/*===============================*/
|
||||
|
|
@ -550,19 +623,22 @@ btr_cur_parse_del_mark_set_sec_rec(
|
|||
page_t* page, /*!< in/out: page or NULL */
|
||||
page_zip_des_t* page_zip);/*!< in/out: compressed page, or NULL */
|
||||
#ifndef UNIV_HOTBACKUP
|
||||
/*******************************************************************//**
|
||||
Estimates the number of rows in a given index range.
|
||||
@return estimated number of rows */
|
||||
UNIV_INTERN
|
||||
ib_int64_t
|
||||
|
||||
/** Estimates the number of rows in a given index range.
|
||||
@param[in] index index
|
||||
@param[in] tuple1 range start, may also be empty tuple
|
||||
@param[in] mode1 search mode for range start
|
||||
@param[in] tuple2 range end, may also be empty tuple
|
||||
@param[in] mode2 search mode for range end
|
||||
@return estimated number of rows */
|
||||
int64_t
|
||||
btr_estimate_n_rows_in_range(
|
||||
/*=========================*/
|
||||
dict_index_t* index, /*!< in: index */
|
||||
const dtuple_t* tuple1, /*!< in: range start, may also be empty tuple */
|
||||
ulint mode1, /*!< in: search mode for range start */
|
||||
const dtuple_t* tuple2, /*!< in: range end, may also be empty tuple */
|
||||
ulint mode2, /*!< in: search mode for range end */
|
||||
trx_t* trx); /*!< in: trx */
|
||||
dict_index_t* index,
|
||||
const dtuple_t* tuple1,
|
||||
page_cur_mode_t mode1,
|
||||
const dtuple_t* tuple2,
|
||||
page_cur_mode_t mode2);
|
||||
|
||||
/*******************************************************************//**
|
||||
Estimates the number of different key values in a given index, for
|
||||
each n-column prefix of the index where 1 <= n <= dict_index_get_n_unique(index).
|
||||
|
|
@ -571,9 +647,10 @@ The estimates are stored in the array index->stat_n_diff_key_vals[] (indexed
|
|||
index->stat_n_sample_sizes[].
|
||||
If innodb_stats_method is nulls_ignored, we also record the number of
|
||||
non-null values for each prefix and stored the estimates in
|
||||
array index->stat_n_non_null_key_vals. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
array index->stat_n_non_null_key_vals.
|
||||
@return true if the index is available and we get the estimated numbers,
|
||||
false if the index is unavailable. */
|
||||
bool
|
||||
btr_estimate_number_of_different_key_vals(
|
||||
/*======================================*/
|
||||
dict_index_t* index); /*!< in: index */
|
||||
|
|
@ -582,7 +659,6 @@ btr_estimate_number_of_different_key_vals(
|
|||
@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,
|
||||
|
|
@ -593,7 +669,6 @@ 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
|
||||
index tree. In purge only the owner of externally stored field is allowed
|
||||
to free the field. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
btr_cur_disown_inherited_fields(
|
||||
/*============================*/
|
||||
|
|
@ -613,7 +688,9 @@ enum blob_op {
|
|||
/** Store off-page columns for an insert by update */
|
||||
BTR_STORE_INSERT_UPDATE,
|
||||
/** Store off-page columns for an update */
|
||||
BTR_STORE_UPDATE
|
||||
BTR_STORE_UPDATE,
|
||||
/** Store off-page columns for a freshly inserted record by bulk */
|
||||
BTR_STORE_INSERT_BULK
|
||||
};
|
||||
|
||||
/*******************************************************************//**
|
||||
|
|
@ -631,32 +708,31 @@ Stores the fields in big_rec_vec to the tablespace and puts pointers to
|
|||
them in rec. The extern flags in rec will have to be set beforehand.
|
||||
The fields are stored on pages allocated from leaf node
|
||||
file segment of the index tree.
|
||||
@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
|
||||
UNIV_INTERN
|
||||
@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
|
||||
dberr_t
|
||||
btr_store_big_rec_extern_fields(
|
||||
/*============================*/
|
||||
dict_index_t* index, /*!< in: index of rec; the index tree
|
||||
MUST be X-latched */
|
||||
buf_block_t* rec_block, /*!< in/out: block containing rec */
|
||||
rec_t* rec, /*!< in/out: record */
|
||||
const ulint* offsets, /*!< in: rec_get_offsets(rec, index);
|
||||
the "external storage" flags in offsets
|
||||
will not correspond to rec when
|
||||
this function returns */
|
||||
btr_pcur_t* pcur, /*!< in/out: a persistent cursor. if
|
||||
btr_mtr is restarted, then this can
|
||||
be repositioned. */
|
||||
const upd_t* upd, /*!< in: update vector */
|
||||
ulint* offsets, /*!< in/out: rec_get_offsets() on
|
||||
pcur. the "external storage" flags
|
||||
in offsets will correctly correspond
|
||||
to rec when this function returns */
|
||||
const big_rec_t*big_rec_vec, /*!< in: vector containing fields
|
||||
to be stored externally */
|
||||
mtr_t* btr_mtr, /*!< in: mtr containing the
|
||||
latches to the clustered index */
|
||||
mtr_t* btr_mtr, /*!< in/out: mtr containing the
|
||||
latches to the clustered index. can be
|
||||
committed and restarted. */
|
||||
enum blob_op op) /*! in: operation code */
|
||||
MY_ATTRIBUTE((nonnull, warn_unused_result));
|
||||
MY_ATTRIBUTE((warn_unused_result));
|
||||
|
||||
/*******************************************************************//**
|
||||
Frees the space in an externally stored field to the file space
|
||||
management if the field in data is owned the externally stored field,
|
||||
in a rollback we may have the additional condition that the field must
|
||||
not be inherited. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
btr_free_externally_stored_field(
|
||||
/*=============================*/
|
||||
|
|
@ -677,69 +753,68 @@ btr_free_externally_stored_field(
|
|||
to rec, or NULL if rec == NULL */
|
||||
ulint i, /*!< in: field number of field_ref;
|
||||
ignored if rec == NULL */
|
||||
enum trx_rb_ctx rb_ctx, /*!< in: rollback context */
|
||||
mtr_t* local_mtr); /*!< in: mtr containing the latch to
|
||||
data an an X-latch to the index
|
||||
tree */
|
||||
/*******************************************************************//**
|
||||
Copies the prefix of an externally stored field of a record. The
|
||||
clustered index record must be protected by a lock or a page latch.
|
||||
bool rollback, /*!< in: performing rollback? */
|
||||
mtr_t* local_mtr); /*!< in: mtr containing the latch */
|
||||
/** Copies the prefix of an externally stored field of a record.
|
||||
The clustered index record must be protected by a lock or a page latch.
|
||||
@param[out] buf the field, or a prefix of it
|
||||
@param[in] len length of buf, in bytes
|
||||
@param[in] page_size BLOB page size
|
||||
@param[in] data 'internally' stored part of the field
|
||||
containing also the reference to the external part; must be protected by
|
||||
a lock or a page latch
|
||||
@param[in] local_len length of data, in bytes
|
||||
@return the length of the copied field, or 0 if the column was being
|
||||
or has been deleted */
|
||||
UNIV_INTERN
|
||||
ulint
|
||||
btr_copy_externally_stored_field_prefix(
|
||||
/*====================================*/
|
||||
byte* buf, /*!< out: the field, or a prefix of it */
|
||||
ulint len, /*!< in: length of buf, in bytes */
|
||||
ulint zip_size,/*!< in: nonzero=compressed BLOB page size,
|
||||
zero for uncompressed BLOBs */
|
||||
const byte* data, /*!< in: 'internally' stored part of the
|
||||
field containing also the reference to
|
||||
the external part; must be protected by
|
||||
a lock or a page latch */
|
||||
ulint local_len,/*!< in: length of data, in bytes */
|
||||
trx_t* trx); /*!< in: transaction handle */
|
||||
/*******************************************************************//**
|
||||
Copies an externally stored field of a record to mem heap. The
|
||||
clustered index record must be protected by a lock or a page latch.
|
||||
byte* buf,
|
||||
ulint len,
|
||||
const page_size_t& page_size,
|
||||
const byte* data,
|
||||
ulint local_len);
|
||||
|
||||
/** Copies an externally stored field of a record to mem heap.
|
||||
The clustered index record must be protected by a lock or a page latch.
|
||||
@param[out] len length of the whole field
|
||||
@param[in] data 'internally' stored part of the field
|
||||
containing also the reference to the external part; must be protected by
|
||||
a lock or a page latch
|
||||
@param[in] page_size BLOB page size
|
||||
@param[in] local_len length of data
|
||||
@param[in,out] heap mem heap
|
||||
@return the whole field copied to heap */
|
||||
UNIV_INTERN
|
||||
byte*
|
||||
btr_copy_externally_stored_field(
|
||||
/*=============================*/
|
||||
ulint* len, /*!< out: length of the whole field */
|
||||
const byte* data, /*!< in: 'internally' stored part of the
|
||||
field containing also the reference to
|
||||
the external part; must be protected by
|
||||
a lock or a page latch */
|
||||
ulint zip_size,/*!< in: nonzero=compressed BLOB page size,
|
||||
zero for uncompressed BLOBs */
|
||||
ulint local_len,/*!< in: length of data */
|
||||
mem_heap_t* heap, /*!< in: mem heap */
|
||||
trx_t* trx); /*!< in: transaction handle */
|
||||
/*******************************************************************//**
|
||||
Copies an externally stored field of a record to mem heap.
|
||||
@return the field copied to heap, or NULL if the field is incomplete */
|
||||
UNIV_INTERN
|
||||
ulint* len,
|
||||
const byte* data,
|
||||
const page_size_t& page_size,
|
||||
ulint local_len,
|
||||
mem_heap_t* heap);
|
||||
|
||||
/** Copies an externally stored field of a record to mem heap.
|
||||
@param[in] rec record in a clustered index; must be
|
||||
protected by a lock or a page latch
|
||||
@param[in] offset array returned by rec_get_offsets()
|
||||
@param[in] page_size BLOB page size
|
||||
@param[in] no field number
|
||||
@param[out] len length of the field
|
||||
@param[in,out] heap mem heap
|
||||
@return the field copied to heap, or NULL if the field is incomplete */
|
||||
byte*
|
||||
btr_rec_copy_externally_stored_field(
|
||||
/*=================================*/
|
||||
const rec_t* rec, /*!< in: record in a clustered index;
|
||||
must be protected by a lock or a page latch */
|
||||
const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
|
||||
ulint zip_size,/*!< in: nonzero=compressed BLOB page size,
|
||||
zero for uncompressed BLOBs */
|
||||
ulint no, /*!< in: field number */
|
||||
ulint* len, /*!< out: length of the field */
|
||||
mem_heap_t* heap, /*!< in: mem heap */
|
||||
trx_t* trx); /*!< in: transaction handle */
|
||||
const rec_t* rec,
|
||||
const ulint* offsets,
|
||||
const page_size_t& page_size,
|
||||
ulint no,
|
||||
ulint* len,
|
||||
mem_heap_t* heap);
|
||||
|
||||
/*******************************************************************//**
|
||||
Flags the data tuple fields that are marked as extern storage in the
|
||||
update vector. We use this function to remember which fields we must
|
||||
mark as extern storage in a record inserted for an update.
|
||||
@return number of flagged external columns */
|
||||
UNIV_INTERN
|
||||
@return number of flagged external columns */
|
||||
ulint
|
||||
btr_push_update_extern_fields(
|
||||
/*==========================*/
|
||||
|
|
@ -750,38 +825,74 @@ btr_push_update_extern_fields(
|
|||
/***********************************************************//**
|
||||
Sets a secondary index record's delete mark to the given value. This
|
||||
function is only used by the insert buffer merge mechanism. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
btr_cur_set_deleted_flag_for_ibuf(
|
||||
/*==============================*/
|
||||
rec_t* rec, /*!< in/out: record */
|
||||
page_zip_des_t* page_zip, /*!< in/out: compressed page
|
||||
corresponding to rec, or NULL
|
||||
when the tablespace is
|
||||
uncompressed */
|
||||
when the tablespace is uncompressed */
|
||||
ibool val, /*!< in: value to set */
|
||||
mtr_t* mtr); /*!< in/out: mini-transaction */
|
||||
|
||||
/******************************************************//**
|
||||
The following function is used to set the deleted bit of a record. */
|
||||
UNIV_INLINE
|
||||
void
|
||||
btr_rec_set_deleted_flag(
|
||||
/*=====================*/
|
||||
rec_t* rec, /*!< in/out: physical record */
|
||||
page_zip_des_t* page_zip,/*!< in/out: compressed page (or NULL) */
|
||||
ulint flag); /*!< in: nonzero if delete marked */
|
||||
|
||||
/** Latches the leaf page or pages requested.
|
||||
@param[in] block leaf page where the search converged
|
||||
@param[in] page_id page id of the leaf
|
||||
@param[in] latch_mode BTR_SEARCH_LEAF, ...
|
||||
@param[in] cursor cursor
|
||||
@param[in] mtr mini-transaction
|
||||
@return blocks and savepoints which actually latched. */
|
||||
btr_latch_leaves_t
|
||||
btr_cur_latch_leaves(
|
||||
buf_block_t* block,
|
||||
const page_id_t& page_id,
|
||||
const page_size_t& page_size,
|
||||
ulint latch_mode,
|
||||
btr_cur_t* cursor,
|
||||
mtr_t* mtr);
|
||||
|
||||
/*######################################################################*/
|
||||
|
||||
/** In the pessimistic delete, if the page data size drops below this
|
||||
limit, merging it to a neighbor is tried */
|
||||
#define BTR_CUR_PAGE_COMPRESS_LIMIT (UNIV_PAGE_SIZE / 2)
|
||||
#define BTR_CUR_PAGE_COMPRESS_LIMIT(index) \
|
||||
((UNIV_PAGE_SIZE * (ulint)((index)->merge_threshold)) / 100)
|
||||
|
||||
/** A slot in the path array. We store here info on a search path down the
|
||||
tree. Each slot contains data on a single level of the tree. */
|
||||
struct btr_path_t {
|
||||
/* Assume a page like:
|
||||
records: (inf, a, b, c, d, sup)
|
||||
index of the record: 0, 1, 2, 3, 4, 5
|
||||
*/
|
||||
|
||||
struct btr_path_t{
|
||||
ulint nth_rec; /*!< index of the record
|
||||
where the page cursor stopped on
|
||||
this level (index in alphabetical
|
||||
order); value ULINT_UNDEFINED
|
||||
denotes array end */
|
||||
ulint n_recs; /*!< number of records on the page */
|
||||
ulint page_no; /*!< no of the page containing the record */
|
||||
ulint page_level; /*!< level of the page, if later we fetch
|
||||
the page under page_no and it is no different
|
||||
level then we know that the tree has been
|
||||
reorganized */
|
||||
/** Index of the record where the page cursor stopped on this level
|
||||
(index in alphabetical order). Value ULINT_UNDEFINED denotes array
|
||||
end. In the above example, if the search stopped on record 'c', then
|
||||
nth_rec will be 3. */
|
||||
ulint nth_rec;
|
||||
|
||||
/** Number of the records on the page, not counting inf and sup.
|
||||
In the above example n_recs will be 4. */
|
||||
ulint n_recs;
|
||||
|
||||
/** Number of the page containing the record. */
|
||||
ulint page_no;
|
||||
|
||||
/** Level of the page. If later we fetch the page under page_no
|
||||
and it is no different level then we know that the tree has been
|
||||
reorganized. */
|
||||
ulint page_level;
|
||||
};
|
||||
|
||||
#define BTR_PATH_ARRAY_N_SLOTS 250 /*!< size of path array (in slots) */
|
||||
|
|
@ -858,7 +969,7 @@ struct btr_cur_t {
|
|||
other search modes; see also the NOTE
|
||||
in up_match! */
|
||||
ulint low_bytes; /*!< number of matched bytes to the
|
||||
right at the time cursor positioned;
|
||||
left at the time cursor positioned;
|
||||
only used internally in searches: not
|
||||
defined after the search */
|
||||
ulint n_fields; /*!< prefix length used in a hash
|
||||
|
|
@ -872,8 +983,22 @@ struct btr_cur_t {
|
|||
rows in range, we store in this array
|
||||
information of the path through
|
||||
the tree */
|
||||
rtr_info_t* rtr_info; /*!< rtree search info */
|
||||
btr_cur_t():thr(NULL), rtr_info(NULL) {}
|
||||
/* default values */
|
||||
};
|
||||
|
||||
/******************************************************//**
|
||||
The following function is used to set the deleted bit of a record. */
|
||||
UNIV_INLINE
|
||||
void
|
||||
btr_rec_set_deleted_flag(
|
||||
/*=====================*/
|
||||
rec_t* rec, /*!< in/out: physical record */
|
||||
page_zip_des_t* page_zip,/*!< in/out: compressed page (or NULL) */
|
||||
ulint flag); /*!< in: nonzero if delete marked */
|
||||
|
||||
|
||||
/** If pessimistic delete fails because of lack of file space, there
|
||||
is still a good change of success a little later. Try this many
|
||||
times. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue