113#define REC_NEW_HEAP_NO 4
114#define REC_HEAP_NO_SHIFT 3
134 "sum of old-style masks != 0xFFFFFFFFUL");
140 "sum of new-style masks != 0xFFFFFFUL");
167#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
379 if (
index->has_instant_cols_or_row_versions()) {
402 if (
n > n_uniq + 1) {
407 if (
index->has_instant_cols() && !
index->has_row_versions()) {
411 ut_ad(rec_diff <= col_diff);
415 ut_ad(
index->has_instant_cols_or_row_versions());
470 const ulint *offsets)
474 n_alloc = offsets[0];
490 offsets[0] = n_alloc;
503 offsets[1] = n_fields;
509 const ulint *offsets)
513 n_fields = offsets[1];
528 ut_ad(
index->has_instant_cols_or_row_versions());
568 const bool check_status =
true) {
580 ((
ulint)
nullptr == offsets[2] &&
581 (
index !=
nullptr && offsets ==
index->rec_cache.offsets)));
582 if (!comp &&
index !=
nullptr) {
592 max_n_fields =
std::max(n_fields, n_unique_in_tree);
594 ut_a(
index->has_instant_cols_or_row_versions());
618 ut_a(!
index->n_def || i <= max_n_fields);
637 ut_ad(rec || offsets ==
index->rec_cache.offsets);
640 ut_ad(rec ==
nullptr ||
642 offsets[2] = (
ulint)rec;
658#define rec_offs_make_valid(rec, index, offsets) ((void)0)
689 ut_ad(!
index->has_instant_cols_or_row_versions());
697 for (
size_t i = 0; i < n_fields; i++) {
698 field_end[i] = (i ? field_end[i - 1] : 0) +
index->get_field(i)->fixed_len;
726#if defined(UNIV_DEBUG) && !defined(UNIV_LIBRARY) && !defined(UNIV_HOTBACKUP)
727#define UNIV_ROW_IMPORT_DBG
733 bool force_page_boundary_check);
749#ifdef UNIV_ROW_IMPORT_DBG
768 const ulint extra_bytes,
773 ptr = rec - (extra_bytes + 1);
775 ut_d(std::optional<uint32_t> checked_result);
776 ut_d(uint16_t checked_length{});
777#ifdef UNIV_ROW_IMPORT_DBG
782 uint16_t checked_fields;
785 &checked_fields, &checked_length,
false);
787 checked_result = checked_fields;
793 ut_ad(!checked_result || (checked_result == *ptr && checked_length == 1));
801 ut_ad(n_fields != 0);
803 ut_ad(!checked_result ||
804 (checked_result == n_fields && checked_length == *
length));
850 if (!
index->has_instant_cols_or_row_versions()) {
858 const bool is_versioned =
868 ib::error() <<
"Record has both instant and version bit set in Table '"
869 <<
index->table_name <<
"', Index '" <<
index->name()
870 <<
"'. This indicates that the table may be corrupt. Please "
871 "run CHECK TABLE before proceeding.";
875 ib::error() <<
"Record has both instant and version bit set in Table '"
876 <<
index->table_name <<
"', Index '" <<
index->name()
877 <<
"'. This indicates that the table may be corrupt. Please "
878 "run CHECK TABLE before proceeding.";
896 }
else if (
index->table->has_instant_cols()) {
903 return rec_insert_state;
916 const byte **nulls,
const byte **lens, uint16_t &non_default_fields,
931 *n_null =
index->n_nullable;
933 return rec_insert_state;
939 switch (rec_insert_state) {
943 *n_null =
index->get_nullable_in_version(0);
950 row_version = (uint8_t)(**nulls);
955 *n_null =
index->get_nullable_in_version(row_version);
964 return rec_insert_state;
979 const byte **lens, uint16_t *n_null, uint16_t &non_default_fields,
1000 non_default_fields, row_version);
1014 *n_null =
index->n_nullable;
1016 return rec_insert_state;
1022 switch (rec_insert_state) {
1026 row_version = (uint8_t)(**nulls);
1032 *n_null =
index->get_nullable_in_version(row_version);
1039 non_default_fields =
1045 *n_null =
index->get_n_nullable_before(non_default_fields);
1049 *n_null =
index->get_nullable_before_instant_add_drop();
1050 non_default_fields =
index->get_instant_fields();
1055 *n_null =
index->get_nullable_before_instant_add_drop();
1066 return (rec_insert_state);
1081 const byte **lens, uint16_t *n_null, uint16_t &non_default_fields,
1093 switch (rec_insert_state) {
1098 *n_null =
index->n_nullable;
1104 row_version = (uint8_t)(**nulls);
1109 if (row_version > 0) {
1121 *n_null =
index->get_nullable_in_version(row_version);
1127 non_default_fields =
1133 *n_null =
index->calculate_n_instant_nullable(non_default_fields);
1137 *n_null =
index->get_nullable_before_instant_add_drop();
1138 non_default_fields =
index->get_instant_fields();
1143 *n_null =
index->get_nullable_before_instant_add_drop();
1154 return (rec_insert_state);
1174 offsets[2] = (
ulint)rec;
1178 const byte *nulls =
nullptr;
1179 const byte *lens =
nullptr;
1180 uint16_t n_null = 0;
1183 uint16_t non_default_fields = 0;
1187 rec,
index, &nulls, &lens, &n_null, non_default_fields, row_version);
1190 rec,
index, &nulls, &lens, &n_null, non_default_fields, row_version);
1213 ulint null_mask = 1;
1222 switch (rec_insert_state) {
1224 ut_ad(!
index->has_instant_cols_or_row_versions());
1239 (
index->table->is_upgraded_instant() && row_version == 0));
1265 ut_ad(non_default_fields > 0);
1269 if (i >= non_default_fields) {
1295 if (*nulls & null_mask) {
1324 offs += len & 0x3fff;
The class error is used to emit error messages.
Definition: ut0log.h:225
int page
Definition: ctype-mb.cc:1226
static ulint dtuple_get_n_fields(const dtuple_t *tuple)
Gets number of fields in a data tuple.
constexpr uint32_t DATA_POINT
geometry datatype of fixed length POINT
Definition: data0type.h:107
constexpr uint32_t DATA_NOT_NULL
this is ORed to the precise type when the column is declared as NOT NULL
Definition: data0type.h:207
#define DATA_BIG_COL(col)
Definition: data0type.h:286
Data dictionary creation and booting.
uint16_t dict_index_get_n_fields(const dict_index_t *index)
Gets the number of fields in the internal representation of an index, including fields added by the d...
Definition: dict0dict.ic:545
static bool dict_table_is_comp(const dict_table_t *table)
Check whether the table uses the compact page format.
uint16_t dict_index_get_n_unique_in_tree_nonleaf(const dict_index_t *index)
Gets the number of fields on nonleaf page level in the internal representation of an index which uniq...
Definition: dict0dict.ic:602
uint16_t dict_index_get_n_unique_in_tree(const dict_index_t *index)
Gets the number of fields in the internal representation of an index which uniquely determine the pos...
Definition: dict0dict.ic:580
static bool is_valid_row_version(const row_version_t version)
Definition: dict0mem.h:423
constexpr char RECOVERY_INDEX_TABLE_NAME[]
index/table name used while applying REDO logs during recovery
Definition: dict0mem.h:90
static bool is_instant(const Alter_inplace_info *ha_alter_info)
Determine if this is an instant ALTER TABLE.
Definition: handler0alter.cc:929
static uint16_t mach_read_from_2(const byte *b)
The following function is used to fetch data from 2 consecutive bytes.
static uint8_t mach_read_from_1(const byte *b)
The following function is used to fetch data from one byte.
static mi_bit_type mask[]
Definition: mi_packrec.cc:141
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:171
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:76
ValueType max(X &&first)
Definition: gtid.h:103
byte page_t
Type of the index page.
Definition: page0types.h:152
bool rec_info_bits_valid(ulint bits)
Check if the info bits are valid.
Definition: rec.h:320
constexpr uint32_t REC_INFO_INSTANT_FLAG
The instant ADD COLUMN flag.
Definition: rec.h:154
void row_import_assert_index_page_records_links_and_types_valid(const page_t *page, const dict_index_t *index)
bool row_import_rec_check_comp_metadata(const dict_index_t *index, const rec_t *rec)
Validate compact record metadata on imported page, not assuming page correctness.
Definition: row0import.cc:2699
static const uint8_t REC_N_FIELDS_TWO_BYTES_FLAG
Number of fields flag which means it occupies two bytes.
Definition: rec.h:238
static uint16_t rec_get_bit_field_2(const rec_t *rec, ulint offs, ulint mask, ulint shift)
Gets a bit field from within 2 bytes.
Definition: rec.h:289
constexpr uint32_t REC_N_OWNED_MASK
Definition: rec.h:119
constexpr uint32_t REC_OFFS_EXTERNAL
Definition: rec.h:77
constexpr uint32_t REC_OFFS_HEADER_SIZE
Definition: rec.h:203
constexpr uint32_t REC_OFFS_DEFAULT
Definition: rec.h:79
constexpr uint32_t REC_NEW_HEAP_NO
Definition: rec.h:86
void rec_init_offsets_comp_ordinary(const rec_t *rec, bool temp, const dict_index_t *index, ulint *offsets)
Determine the offset to each field in a leaf-page record in ROW_FORMAT=COMPACT.
Definition: rec.h:1167
void rec_init_fixed_offsets(const dict_index_t *index, ulint *offsets)
A simplified variant rec_init_offsets(rec, index, offsets) for the case in which the rec contains onl...
Definition: rec.h:688
static enum REC_INSERT_STATE rec_init_null_and_len_temp(const rec_t *rec, const dict_index_t *index, const byte **nulls, const byte **lens, uint16_t *n_null, uint16_t &non_default_fields, row_version_t &row_version)
Determines the information about null bytes and variable length bytes for a new-style temporary recor...
Definition: rec.h:977
static bool rec_get_instant_flag_new_temp(const rec_t *rec)
The following function tells if a new-style temp record is instant record.
Definition: rec.h:672
constexpr uint32_t REC_NEXT
Definition: rec.h:94
constexpr uint32_t REC_N_OLD_EXTRA_BYTES
Definition: rec.h:158
constexpr uint32_t REC_STATUS_SUPREMUM
Definition: rec.h:184
constexpr uint32_t REC_NODE_PTR_SIZE
Definition: rec.h:190
constexpr uint32_t REC_INFO_BITS_SHIFT
Definition: rec.h:126
constexpr uint32_t REC_OFFS_DROP
Definition: rec.h:81
static enum REC_INSERT_STATE rec_init_null_and_len_comp(const rec_t *rec, const dict_index_t *index, const byte **nulls, const byte **lens, uint16_t *n_null, uint16_t &non_default_fields, row_version_t &row_version)
Determines the information about null bytes and variable length bytes for a new style record.
Definition: rec.h:1079
constexpr uint32_t REC_INFO_MIN_REC_FLAG
Definition: rec.h:146
static ulint rec_get_info_bits(const rec_t *rec, ulint comp)
The following function is used to retrieve the info bits of a record.
Definition: rec.h:330
void rec_init_offsets(const rec_t *rec, const dict_index_t *index, ulint *offsets)
The following function determines the offsets to each field in the record.
Definition: rec.cc:348
constexpr uint32_t REC_NEW_INFO_BITS
Definition: rec.h:123
constexpr uint32_t REC_OLD_INFO_BITS
Definition: rec.h:122
constexpr uint32_t REC_OFFS_MASK
Definition: rec.h:83
constexpr uint32_t REC_OLD_SHORT_MASK
Definition: rec.h:99
constexpr uint32_t REC_OLD_SHORT_SHIFT
Definition: rec.h:100
void row_import_assert_rec_metadata_valid(const rec_t *rec, const dict_index_t *index)
Rec_instant_state
Instant state of a record.
Definition: rec.h:216
constexpr uint32_t REC_INFO_BITS_MASK
Definition: rec.h:125
bool row_import_rec_check_old_metadata(const dict_index_t *index, const rec_t *rec)
Validate REDUNDANT record metadata on imported page, not assuming page correctness.
Definition: row0import.cc:2633
static ulint rec_get_info_bits_temp(const rec_t *rec)
The following function is used to retrieve the info bits of a temporary record.
Definition: rec.h:342
static uint64_t rec_get_instant_offset(const dict_index_t *index, ulint n, uint64_t offs)
Determine the offset of a specified field in the record, when this field is a field added after an in...
Definition: rec.h:526
static const uint8_t REC_N_FIELDS_ONE_BYTE_MAX
Max number of fields which can be stored in one byte.
Definition: rec.h:241
constexpr uint32_t REC_HEAP_NO_MASK
Definition: rec.h:111
REC_INSERT_STATE
Definition: rec.h:825
@ INSERTED_AFTER_UPGRADE_BEFORE_INSTANT_ADD_NEW_IMPLEMENTATION
Definition: rec.h:834
@ INSERTED_AFTER_INSTANT_ADD_OLD_IMPLEMENTATION
Definition: rec.h:831
@ INSERTED_AFTER_INSTANT_ADD_NEW_IMPLEMENTATION
Definition: rec.h:840
@ INSERTED_BEFORE_INSTANT_ADD_NEW_IMPLEMENTATION
Definition: rec.h:837
@ INSERTED_INTO_TABLE_WITH_NO_INSTANT_NO_VERSION
Definition: rec.h:842
@ NONE
Definition: rec.h:843
@ INSERTED_BEFORE_INSTANT_ADD_OLD_IMPLEMENTATION
Definition: rec.h:828
constexpr uint32_t REC_TMP_INFO_BITS
Definition: rec.h:124
constexpr uint32_t REC_HEAP_NO_SHIFT
Definition: rec.h:89
constexpr uint32_t REC_STATUS_ORDINARY
Definition: rec.h:181
static enum REC_INSERT_STATE get_rec_insert_state(const dict_index_t *index, const rec_t *rec, bool temp)
Definition: rec.h:846
static ulint rec_offs_get_n_alloc(const ulint *offsets)
The following function returns the number of allocated elements for an array of offsets.
Definition: rec.h:469
constexpr uint32_t REC_STATUS_INFIMUM
Definition: rec.h:183
constexpr uint32_t REC_NEW_STATUS
Definition: rec.h:106
static void rec_offs_make_valid(const rec_t *rec, const dict_index_t *index, ulint *offsets)
Updates debug data in offsets, in order to avoid bogus rec_offs_validate() failures.
Definition: rec.h:630
static bool rec_new_is_versioned(const rec_t *rec)
The following function tells if a new-style record is versioned.
Definition: rec.h:705
constexpr uint32_t REC_INFO_DELETED_FLAG
The deleted flag in info bits; when bit is set to 1, it means the record has been delete marked.
Definition: rec.h:149
static uint16_t rec_get_n_fields_old(const rec_t *rec, const dict_index_t *index)
The following function is used to get the number of fields in an old-style record.
Definition: rec.h:375
constexpr uint32_t REC_1BYTE_SQL_NULL_MASK
SQL null flag in a 1-byte offset of ROW_FORMAT=REDUNDANT records.
Definition: rec.h:193
constexpr uint32_t REC_OLD_N_FIELDS
Definition: rec.h:102
constexpr auto MAX_REC_PER_PAGE
Maximum number of records in a page.
Definition: rec.h:169
constexpr uint32_t REC_OFFS_COMPACT
NOTE: The functions in this file should only use functions from other files in library.
Definition: rec.h:73
static void rec_offs_set_n_alloc(ulint *offsets, ulint n_alloc)
The following function sets the number of allocated elements for an array of offsets.
Definition: rec.h:482
static bool rec_offs_validate(const rec_t *rec, const dict_index_t *index, const ulint *offsets, const bool check_status=true)
Validates offsets returned by rec_get_offsets().
Definition: rec.h:566
static bool rec_new_temp_is_versioned(const rec_t *rec)
The following function tells if a temporary record is versioned.
Definition: rec.h:721
bool row_import_rec_get_n_fields_instant_checked(const page_t *page, const byte *ptr, uint16_t *n_fields, uint16_t *length, bool force_page_boundary_check)
Decode the number of fields for one new-style leaf-page record without asserting on malformed metadat...
Definition: row0import.cc:2543
constexpr uint32_t REC_NEW_STATUS_MASK
Definition: rec.h:107
constexpr uint32_t REC_OFFS_SQL_NULL
Definition: rec.h:75
constexpr uint32_t REC_N_TMP_EXTRA_BYTES
Definition: rec.h:165
constexpr uint32_t REC_OLD_N_OWNED
Definition: rec.h:117
static ulint rec_offs_n_fields(const ulint *offsets)
The following function returns the number of fields in a record.
Definition: rec.h:508
static const ulint * rec_offs_base(const ulint *offsets)
Definition: rec.h:229
constexpr int32_t REC_N_NEW_EXTRA_BYTES
Definition: rec.h:161
static enum REC_INSERT_STATE init_nulls_lens_for_temp_redundant(const dict_index_t *index, const rec_t *rec, uint16_t *n_null, const byte **nulls, const byte **lens, uint16_t &non_default_fields, row_version_t &row_version)
Definition: rec.h:914
static uint16_t rec_get_n_fields_old_raw(const rec_t *rec)
The following function is used to get the number of fields in an old-style record,...
Definition: rec.h:352
constexpr uint32_t REC_NEXT_MASK
Definition: rec.h:95
constexpr uint32_t REC_2BYTE_SQL_NULL_MASK
SQL null flag in a 2-byte offset of ROW_FORMAT=REDUNDANT records.
Definition: rec.h:195
ulint * rec_get_offsets(const rec_t *rec, const dict_index_t *index, ulint *offsets, ulint n_fields, ut::Location location, mem_heap_t **heap)
The following function determines the offsets to each field in the record.
Definition: rec.cc:359
constexpr uint32_t REC_INFO_VERSION_FLAG
Definition: rec.h:151
constexpr uint32_t REC_NEW_N_OWNED
Definition: rec.h:118
constexpr uint32_t REC_OLD_N_FIELDS_SHIFT
Definition: rec.h:104
constexpr uint32_t REC_OLD_HEAP_NO
Definition: rec.h:110
static bool rec_old_is_versioned(const rec_t *rec)
The following function tells if an old-style record is versioned.
Definition: rec.h:713
static bool rec_get_1byte_offs_flag(const rec_t *rec)
The following function is used to test whether the data offsets in the record are stored in one-byte ...
Definition: rec.h:1351
void rec_get_offsets_reverse(const byte *extra, const dict_index_t *index, ulint node_ptr, ulint *offsets)
The following function determines the offsets to each field in the record.
Definition: rec.cc:419
constexpr uint32_t REC_N_OWNED_SHIFT
Definition: rec.h:120
static uint32_t rec_get_n_fields_instant(const rec_t *rec, const ulint extra_bytes, uint16_t *length)
Get the number of fields for one new style leaf page record.
Definition: rec.h:767
constexpr uint32_t REC_STATUS_NODE_PTR
Definition: rec.h:182
static bool rec_n_fields_is_sane(dict_index_t *index, const rec_t *rec, const dtuple_t *entry)
Confirms the n_fields of the entry is sane with comparing the other record in the same page specified...
Definition: rec.h:461
constexpr uint32_t REC_OLD_SHORT
Definition: rec.h:98
constexpr uint32_t REC_NEXT_SHIFT
Definition: rec.h:96
static void rec_offs_set_n_fields(ulint *offsets, ulint n_fields)
The following function sets the number of fields in offsets.
Definition: rec.h:494
constexpr uint32_t REC_OFFS_NORMAL_SIZE
Definition: rec.h:211
static ulint rec_get_bit_field_1(const rec_t *rec, ulint offs, ulint mask, ulint shift)
Gets a bit field from within 1 byte.
Definition: rec.h:277
constexpr uint32_t REC_2BYTE_EXTERN_MASK
In a 2-byte offset of ROW_FORMAT=REDUNDANT records, the second most significant bit denotes that the ...
Definition: rec.h:199
constexpr uint32_t REC_NEW_STATUS_SHIFT
Definition: rec.h:108
bool rec_offs_cmp(ulint *offsets1, ulint *offsets2)
Check if the given two record offsets are identical.
Definition: rec.cc:538
static ulint rec_get_n_fields(const rec_t *rec, const dict_index_t *index)
The following function is used to get the number of fields in a record.
Definition: rec.h:431
std::ostream & rec_offs_print(std::ostream &out, const ulint *offsets)
Print the record offsets.
Definition: rec.cc:570
static ulint rec_get_status(const rec_t *rec)
The following function retrieves the status bits of a new-style record.
Definition: rec.h:302
static bool rec_get_instant_flag_new(const rec_t *rec)
The following function tells if a new-style record is instant record.
Definition: rec.h:664
constexpr uint32_t REC_OLD_N_FIELDS_MASK
Definition: rec.h:103
constexpr uint32_t REC_OFFS_SMALL_SIZE
Definition: rec.h:212
const row_version_t INVALID_ROW_VERSION
Definition: rem0types.h:56
byte rec_t
Definition: rem0types.h:41
constexpr uint32_t REC_MAX_N_FIELDS
Definition: rem0types.h:59
uint16_t row_version_t
Definition: rem0types.h:53
required uint64 version
Definition: replication_group_member_actions.proto:41
Definition: completion_hash.h:35
std::atomic< uint16_t > n_pointers
Used in debugging.
Definition: buf0buf.h:1837
Data structure for a column in a table.
Definition: dict0mem.h:485
bool is_dropped_in_or_before(row_version_t version) const
Check if column is dropped before the given version.
Definition: dict0mem.h:736
unsigned mtype
main data type
Definition: dict0mem.h:502
ulint get_fixed_size(ulint comp) const
Returns the size of a fixed size column, 0 if not a fixed size column.
Definition: dict0mem.h:694
bool is_added_after(row_version_t version) const
Check if column is added after the current version.
Definition: dict0mem.h:749
unsigned prtype
precise type; MySQL data type, charset code, flags to indicate nullability, signedness,...
Definition: dict0mem.h:495
Data structure for a field in an index.
Definition: dict0mem.h:891
dict_col_t * col
pointer to the table column
Definition: dict0mem.h:894
unsigned fixed_len
0 or the fixed length of the column if smaller than DICT_ANTELOPE_MAX_INDEX_COL_LEN
Definition: dict0mem.h:904
Data structure for an index.
Definition: dict0mem.h:1069
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:706
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:295
#define UNIV_MEM_ASSERT_W(addr, size)
Definition: univ.i:621
#define UNIV_UNLIKELY(cond)
Definition: univ.i:524
#define UNIV_PAGE_SIZE
The universal page size of the database.
Definition: univ.i:291
constexpr uint32_t UNIV_SQL_NULL
The following number as the length of a logical field means that the field has the SQL NULL as its va...
Definition: univ.i:466
#define UNIV_MEM_ASSERT_AND_ALLOC(addr, size)
Definition: univ.i:633
constexpr ulint ULINT_MAX
Maximum value for a ulint.
Definition: univ.i:437
unsigned long int ulint
Definition: univ.i:403
constexpr size_t UNIV_PAGE_SIZE_MAX
Maximum page size InnoDB currently supports.
Definition: univ.i:320
static void * ut_align_down(const void *ptr, ulint align_no)
The following function rounds down a pointer to the nearest aligned address.
#define ut_error
Abort execution.
Definition: ut0dbg.h:105
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:109
#define ut_d(EXPR)
Debug statement.
Definition: ut0dbg.h:111
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:97
#define UT_BITS_IN_BYTES(b)
Determine how many bytes (groups of 8 bits) are needed to store the given number of bits.
Definition: ut0ut.h:195
int n
Definition: xcom_base.cc:509