summaryrefslogtreecommitdiff
path: root/storage/innobase/include/rem0rec.h
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include/rem0rec.h')
-rw-r--r--storage/innobase/include/rem0rec.h137
1 files changed, 90 insertions, 47 deletions
diff --git a/storage/innobase/include/rem0rec.h b/storage/innobase/include/rem0rec.h
index c81f0479ce6..f38efc660c4 100644
--- a/storage/innobase/include/rem0rec.h
+++ b/storage/innobase/include/rem0rec.h
@@ -71,29 +71,72 @@ The status is stored in the low-order bits. */
/* Length of a B-tree node pointer, in bytes */
#define REC_NODE_PTR_SIZE 4
+#ifndef UNIV_INNOCHECKSUM
/** SQL null flag in a 1-byte offset of ROW_FORMAT=REDUNDANT records */
-#define REC_1BYTE_SQL_NULL_MASK 0x80UL
+static const offset_t REC_1BYTE_SQL_NULL_MASK= 0x80;
/** SQL null flag in a 2-byte offset of ROW_FORMAT=REDUNDANT records */
-#define REC_2BYTE_SQL_NULL_MASK 0x8000UL
+static const offset_t REC_2BYTE_SQL_NULL_MASK= 0x8000;
/** In a 2-byte offset of ROW_FORMAT=REDUNDANT records, the second most
significant bit denotes that the tail of a field is stored off-page. */
-#define REC_2BYTE_EXTERN_MASK 0x4000UL
+static const offset_t REC_2BYTE_EXTERN_MASK= 0x4000;
+
+static const size_t RECORD_OFFSET= 2;
+static const size_t INDEX_OFFSET=
+ RECORD_OFFSET + sizeof(rec_t *) / sizeof(offset_t);
-#ifdef UNIV_DEBUG
-/* Length of the rec_get_offsets() header */
-# define REC_OFFS_HEADER_SIZE 4
-#else /* UNIV_DEBUG */
/* Length of the rec_get_offsets() header */
-# define REC_OFFS_HEADER_SIZE 2
+static const size_t REC_OFFS_HEADER_SIZE=
+#ifdef UNIV_DEBUG
+ sizeof(rec_t *) / sizeof(offset_t) +
+ sizeof(dict_index_t *) / sizeof(offset_t) +
#endif /* UNIV_DEBUG */
+ 2;
/* Number of elements that should be initially allocated for the
offsets[] array, first passed to rec_get_offsets() */
-#define REC_OFFS_NORMAL_SIZE OFFS_IN_REC_NORMAL_SIZE
-#define REC_OFFS_SMALL_SIZE 10
+static const size_t REC_OFFS_NORMAL_SIZE= 300;
+static const size_t REC_OFFS_SMALL_SIZE= 18;
+static const size_t REC_OFFS_SEC_INDEX_SIZE=
+ /* PK max key parts */ 16 + /* sec idx max key parts */ 16 +
+ /* child page number for non-leaf pages */ 1;
+
+/* Offset consists of two parts: 2 upper bits is type and all other bits is
+value */
+
+enum field_type_t
+{
+ /** normal field */
+ STORED_IN_RECORD= 0 << 14,
+ /** this field is stored off-page */
+ STORED_OFFPAGE= 1 << 14,
+ /** just an SQL NULL */
+ SQL_NULL= 2 << 14
+};
+
+/** without 2 upper bits */
+static const offset_t DATA_MASK= 0x3fff;
+/** 2 upper bits */
+static const offset_t TYPE_MASK= ~DATA_MASK;
+inline field_type_t get_type(offset_t n)
+{
+ return static_cast<field_type_t>(n & TYPE_MASK);
+}
+inline void set_type(offset_t &n, field_type_t type)
+{
+ n= (n & DATA_MASK) | static_cast<offset_t>(type);
+}
+inline offset_t get_value(offset_t n) { return n & DATA_MASK; }
+inline offset_t combine(offset_t value, field_type_t type)
+{
+ return get_value(value) | static_cast<offset_t>(type);
+}
+
+/** Compact flag ORed to the extra size returned by rec_offs_base()[0] */
+static const offset_t REC_OFFS_COMPACT= 1 << 15;
+/** External flag in offsets returned by rec_offs_base()[0] */
+static const offset_t REC_OFFS_EXTERNAL= 1 << 14;
-#ifndef UNIV_INNOCHECKSUM
/******************************************************//**
The following function is used to get the pointer of the next chained record
on the same page.
@@ -398,7 +441,7 @@ offsets form. If the field is SQL null, the flag is ORed in the returned
value.
@return offset of the start of the field, SQL null flag ORed */
UNIV_INLINE
-ulint
+uint8_t
rec_1_get_field_end_info(
/*=====================*/
const rec_t* rec, /*!< in: record */
@@ -453,11 +496,11 @@ rec_get_n_extern_new(
(ULINT_UNDEFINED to compute all offsets)
@param[in,out] heap memory heap
@return the new offsets */
-ulint*
+offset_t*
rec_get_offsets_func(
const rec_t* rec,
const dict_index_t* index,
- ulint* offsets,
+ offset_t* offsets,
#ifdef UNIV_DEBUG
bool leaf,
#endif /* UNIV_DEBUG */
@@ -494,7 +537,7 @@ rec_get_offsets_reverse(
const dict_index_t* index, /*!< in: record descriptor */
ulint node_ptr,/*!< in: nonzero=node pointer,
0=leaf node */
- ulint* offsets)/*!< in/out: array consisting of
+ offset_t* offsets)/*!< in/out: array consisting of
offsets[0] allocated elements */
MY_ATTRIBUTE((nonnull));
#ifdef UNIV_DEBUG
@@ -507,7 +550,7 @@ rec_offs_validate(
/*==============*/
const rec_t* rec, /*!< in: record or NULL */
const dict_index_t* index, /*!< in: record descriptor or NULL */
- const ulint* offsets)/*!< in: array returned by
+ const offset_t* offsets)/*!< in: array returned by
rec_get_offsets() */
MY_ATTRIBUTE((nonnull(3), warn_unused_result));
/************************************************************//**
@@ -519,7 +562,7 @@ rec_offs_make_valid(
/*================*/
const rec_t* rec, /*!< in: record */
const dict_index_t* index, /*!< in: record descriptor */
- ulint* offsets)/*!< in: array returned by
+ offset_t* offsets)/*!< in: array returned by
rec_get_offsets() */
MY_ATTRIBUTE((nonnull));
#else
@@ -557,10 +600,10 @@ The following function is used to get an offset to the nth
data field in a record.
@return offset from the origin of rec */
UNIV_INLINE
-ulint
+offset_t
rec_get_nth_field_offs(
/*===================*/
- const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */
ulint n, /*!< in: index of the field */
ulint* len) /*!< out: length of the field; UNIV_SQL_NULL
if SQL null */
@@ -575,7 +618,7 @@ UNIV_INLINE
ulint
rec_offs_comp(
/*==========*/
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */
MY_ATTRIBUTE((warn_unused_result));
/******************************************************//**
Determine if the offsets are for a record containing
@@ -585,7 +628,7 @@ UNIV_INLINE
ulint
rec_offs_any_extern(
/*================*/
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */
MY_ATTRIBUTE((warn_unused_result));
/******************************************************//**
Determine if the offsets are for a record containing null BLOB pointers.
@@ -595,7 +638,7 @@ const byte*
rec_offs_any_null_extern(
/*=====================*/
const rec_t* rec, /*!< in: record */
- const ulint* offsets) /*!< in: rec_get_offsets(rec) */
+ const offset_t* offsets) /*!< in: rec_get_offsets(rec) */
MY_ATTRIBUTE((warn_unused_result));
/******************************************************//**
Returns nonzero if the extern bit is set in nth field of rec.
@@ -604,7 +647,7 @@ UNIV_INLINE
ulint
rec_offs_nth_extern(
/*================*/
- const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */
ulint n) /*!< in: nth field */
MY_ATTRIBUTE((warn_unused_result));
@@ -613,7 +656,7 @@ rec_offs_nth_extern(
@param[in] n nth field */
void
rec_offs_make_nth_extern(
- ulint* offsets,
+ offset_t* offsets,
const ulint n);
/******************************************************//**
Returns nonzero if the SQL NULL bit is set in nth field of rec.
@@ -622,7 +665,7 @@ UNIV_INLINE
ulint
rec_offs_nth_sql_null(
/*==================*/
- const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */
ulint n) /*!< in: nth field */
MY_ATTRIBUTE((warn_unused_result));
/******************************************************//**
@@ -632,7 +675,7 @@ UNIV_INLINE
ulint
rec_offs_nth_size(
/*==============*/
- const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */
ulint n) /*!< in: nth field */
MY_ATTRIBUTE((warn_unused_result));
@@ -643,7 +686,7 @@ UNIV_INLINE
ulint
rec_offs_n_extern(
/*==============*/
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */
MY_ATTRIBUTE((warn_unused_result));
/***********************************************************//**
This is used to modify the value of an already existing field in a record.
@@ -656,7 +699,7 @@ void
rec_set_nth_field(
/*==============*/
rec_t* rec, /*!< in: record */
- const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */
ulint n, /*!< in: index number of the field */
const void* data, /*!< in: pointer to the data if not SQL null */
ulint len) /*!< in: length of the data or UNIV_SQL_NULL.
@@ -685,7 +728,7 @@ UNIV_INLINE
ulint
rec_offs_get_n_alloc(
/*=================*/
- const ulint* offsets)/*!< in: array for rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array for rec_get_offsets() */
MY_ATTRIBUTE((warn_unused_result));
/**********************************************************//**
The following function sets the number of allocated elements
@@ -694,7 +737,7 @@ UNIV_INLINE
void
rec_offs_set_n_alloc(
/*=================*/
- ulint* offsets, /*!< out: array for rec_get_offsets(),
+ offset_t*offsets, /*!< out: array for rec_get_offsets(),
must be allocated */
ulint n_alloc) /*!< in: number of elements */
MY_ATTRIBUTE((nonnull));
@@ -707,7 +750,7 @@ UNIV_INLINE
ulint
rec_offs_n_fields(
/*==============*/
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */
MY_ATTRIBUTE((warn_unused_result));
/**********************************************************//**
The following function returns the data size of a physical
@@ -719,7 +762,7 @@ UNIV_INLINE
ulint
rec_offs_data_size(
/*===============*/
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */
MY_ATTRIBUTE((warn_unused_result));
/**********************************************************//**
Returns the total size of record minus data size of record.
@@ -730,7 +773,7 @@ UNIV_INLINE
ulint
rec_offs_extra_size(
/*================*/
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */
MY_ATTRIBUTE((warn_unused_result));
/**********************************************************//**
Returns the total size of a physical record.
@@ -739,7 +782,7 @@ UNIV_INLINE
ulint
rec_offs_size(
/*==========*/
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */
MY_ATTRIBUTE((warn_unused_result));
#ifdef UNIV_DEBUG
/**********************************************************//**
@@ -750,7 +793,7 @@ byte*
rec_get_start(
/*==========*/
const rec_t* rec, /*!< in: pointer to record */
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */
MY_ATTRIBUTE((warn_unused_result));
/**********************************************************//**
Returns a pointer to the end of the record.
@@ -760,7 +803,7 @@ byte*
rec_get_end(
/*========*/
const rec_t* rec, /*!< in: pointer to record */
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */
MY_ATTRIBUTE((warn_unused_result));
#else /* UNIV_DEBUG */
# define rec_get_start(rec, offsets) ((rec) - rec_offs_extra_size(offsets))
@@ -777,7 +820,7 @@ rec_t*
rec_copy(
void* buf,
const rec_t* rec,
- const ulint* offsets);
+ const offset_t* offsets);
/** Determine the size of a data tuple prefix in a temporary file.
@param[in] index clustered or secondary index
@@ -801,7 +844,7 @@ rec_init_offsets_temp(
/*==================*/
const rec_t* rec, /*!< in: temporary file record */
const dict_index_t* index, /*!< in: record descriptor */
- ulint* offsets)/*!< in/out: array of offsets;
+ offset_t* offsets)/*!< in/out: array of offsets;
in: n=rec_offs_n_fields(offsets) */
MY_ATTRIBUTE((nonnull));
@@ -843,7 +886,7 @@ UNIV_INLINE
ulint
rec_fold(
const rec_t* rec,
- const ulint* offsets,
+ const offset_t* offsets,
ulint n_fields,
ulint n_bytes,
index_id_t tree_id)
@@ -944,7 +987,7 @@ ibool
rec_validate(
/*=========*/
const rec_t* rec, /*!< in: physical record */
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */
MY_ATTRIBUTE((nonnull));
/***************************************************************//**
Prints an old-style physical record. */
@@ -961,7 +1004,7 @@ rec_print_mbr_rec(
/*==========*/
FILE* file, /*!< in: file where to print */
const rec_t* rec, /*!< in: physical record */
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */
MY_ATTRIBUTE((nonnull));
/***************************************************************//**
Prints a physical record. */
@@ -970,7 +1013,7 @@ rec_print_new(
/*==========*/
FILE* file, /*!< in: file where to print */
const rec_t* rec, /*!< in: physical record */
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ const offset_t* offsets)/*!< in: array returned by rec_get_offsets() */
MY_ATTRIBUTE((nonnull));
/***************************************************************//**
Prints a physical record. */
@@ -992,7 +1035,7 @@ rec_print(
std::ostream& o,
const rec_t* rec,
ulint info,
- const ulint* offsets);
+ const offset_t* offsets);
/** Wrapper for pretty-printing a record */
struct rec_index_print
@@ -1019,14 +1062,14 @@ operator<<(std::ostream& o, const rec_index_print& r);
struct rec_offsets_print
{
/** Constructor */
- rec_offsets_print(const rec_t* rec, const ulint* offsets) :
+ rec_offsets_print(const rec_t* rec, const offset_t* offsets) :
m_rec(rec), m_offsets(offsets)
{}
/** Record */
const rec_t* m_rec;
/** Offsets to each field */
- const ulint* m_offsets;
+ const offset_t* m_offsets;
};
/** Display a record.
@@ -1043,7 +1086,7 @@ public:
/** Construct a pretty-printed record.
@param rec record with header
@param offsets rec_get_offsets(rec, ...) */
- rec_printer(const rec_t* rec, const ulint* offsets)
+ rec_printer(const rec_t* rec, const offset_t* offsets)
:
std::ostringstream ()
{
@@ -1056,7 +1099,7 @@ public:
@param rec record, possibly lacking header
@param info rec_get_info_bits(rec)
@param offsets rec_get_offsets(rec, ...) */
- rec_printer(const rec_t* rec, ulint info, const ulint* offsets)
+ rec_printer(const rec_t* rec, ulint info, const offset_t* offsets)
:
std::ostringstream ()
{