85#define REC_NEW_HEAP_NO 4
86#define REC_HEAP_NO_SHIFT 3
106 "sum of old-style masks != 0xFFFFFFFFUL");
112 "sum of new-style masks != 0xFFFFFFUL");
139#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
374 if (
n > n_uniq + 1) {
383 ut_ad(rec_diff <= col_diff);
446 const ulint *offsets)
450 n_alloc = offsets[0];
466 offsets[0] = n_alloc;
479 offsets[1] = n_fields;
485 const ulint *offsets)
489 n_fields = offsets[1];
541 const ulint *offsets)
556 if (!comp && index !=
nullptr) {
566 max_n_fields = std::max(n_fields, n_unique_in_tree);
588 ut_a(!index->
n_def || i <= max_n_fields);
610 ut_ad(rec ==
nullptr ||
612 offsets[2] = (
ulint)rec;
613 offsets[3] = (
ulint)index;
628#define rec_offs_make_valid(rec, index, offsets) ((void)0)
667 for (
size_t i = 0; i < n_fields; i++) {
703 const ulint extra_bytes,
708 ptr = rec - (extra_bytes + 1);
719 ut_ad(n_fields != 0);
774 const bool is_versioned =
783 ib::error() <<
"Record has both instant and version bit set in Table '"
785 <<
"'. This indicates that the table may be corrupt. Please "
786 "run CHECK TABLE before proceeding.";
790 ib::error() <<
"Record has both instant and version bit set in Table '"
792 <<
"'. This indicates that the table may be corrupt. Please "
793 "run CHECK TABLE before proceeding.";
818 return rec_insert_state;
831 const byte **nulls,
const byte **lens, uint16_t &non_default_fields,
832 uint8_t &row_version) {
848 return rec_insert_state;
854 switch (rec_insert_state) {
865 row_version = (uint8_t)(**nulls);
879 return rec_insert_state;
894 const byte **lens, uint16_t *n_null, uint16_t &non_default_fields,
895 uint8_t &row_version) {
915 non_default_fields, row_version);
931 return rec_insert_state;
937 switch (rec_insert_state) {
941 row_version = (uint8_t)(**nulls);
981 return (rec_insert_state);
996 const byte **lens, uint16_t *n_null, uint16_t &non_default_fields,
997 uint8_t &row_version) {
1008 switch (rec_insert_state) {
1019 row_version = (uint8_t)(**nulls);
1024 if (row_version > 0) {
1042 non_default_fields =
1069 return (rec_insert_state);
1089 offsets[2] = (
ulint)rec;
1090 offsets[3] = (
ulint)index;
1093 const byte *nulls =
nullptr;
1094 const byte *lens =
nullptr;
1095 uint16_t n_null = 0;
1098 uint16_t non_default_fields = 0;
1102 rec, index, &nulls, &lens, &n_null, non_default_fields, row_version);
1105 rec, index, &nulls, &lens, &n_null, non_default_fields, row_version);
1128 ulint null_mask = 1;
1137 switch (rec_insert_state) {
1180 ut_ad(non_default_fields > 0);
1184 if (i >= non_default_fields) {
1210 if (*nulls & null_mask) {
1239 offs += len & 0x3fff;
The class error is used to emit error messages.
Definition: ut0log.h:230
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.
constexpr uint32_t DICT_INDEXES_ID
Definition: dict0boot.h:97
static 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...
static bool dict_table_is_comp(const dict_table_t *table)
Check whether the table uses the compact page format.
static ulint 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...
static ulint 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...
static bool is_valid_row_version(const uint8_t version)
Definition: dict0mem.h:427
constexpr char RECOVERY_INDEX_TABLE_NAME[]
index/table name used while applying REDO logs during recovery
Definition: dict0mem.h:89
static bool is_instant(const Alter_inplace_info *ha_alter_info)
Determine if this is an instant ALTER TABLE.
Definition: handler0alter.cc:913
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 rec_info_bits_valid(ulint bits)
Check if the info bits are valid.
Definition: rec.h:292
constexpr uint32_t REC_INFO_INSTANT_FLAG
The instant ADD COLUMN flag.
Definition: rec.h:126
static const uint8_t REC_N_FIELDS_TWO_BYTES_FLAG
Number of fields flag which means it occupies two bytes.
Definition: rec.h:210
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:261
constexpr uint32_t REC_N_OWNED_MASK
Definition: rec.h:91
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, uint8_t &row_version)
Determines the information about null bytes and variable length bytes for a new-style temporary recor...
Definition: rec.h:892
constexpr uint32_t REC_OFFS_EXTERNAL
Definition: rec.h:49
constexpr uint32_t REC_OFFS_HEADER_SIZE
Definition: rec.h:175
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, uint8_t &row_version)
Definition: rec.h:829
constexpr uint32_t REC_OFFS_DEFAULT
Definition: rec.h:51
constexpr uint32_t REC_NEW_HEAP_NO
Definition: rec.h:58
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:1082
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:658
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, uint8_t &row_version)
Determines the information about null bytes and variable length bytes for a new style record.
Definition: rec.h:994
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:642
constexpr uint32_t REC_NEXT
Definition: rec.h:66
constexpr uint32_t REC_N_OLD_EXTRA_BYTES
Definition: rec.h:130
constexpr uint32_t REC_STATUS_SUPREMUM
Definition: rec.h:156
constexpr uint32_t REC_NODE_PTR_SIZE
Definition: rec.h:162
constexpr uint32_t REC_INFO_BITS_SHIFT
Definition: rec.h:98
constexpr uint32_t REC_OFFS_DROP
Definition: rec.h:53
constexpr uint32_t REC_INFO_MIN_REC_FLAG
Definition: rec.h:118
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:302
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:95
constexpr uint32_t REC_OLD_INFO_BITS
Definition: rec.h:94
constexpr uint32_t REC_OFFS_MASK
Definition: rec.h:55
constexpr uint32_t REC_OLD_SHORT_MASK
Definition: rec.h:71
constexpr uint32_t REC_OLD_SHORT_SHIFT
Definition: rec.h:72
Rec_instant_state
Instant state of a record.
Definition: rec.h:188
constexpr uint32_t REC_INFO_BITS_MASK
Definition: rec.h:97
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:314
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:502
static const uint8_t REC_N_FIELDS_ONE_BYTE_MAX
Max number of fields which can be stored in one byte.
Definition: rec.h:213
constexpr uint32_t REC_HEAP_NO_MASK
Definition: rec.h:83
REC_INSERT_STATE
Definition: rec.h:741
@ INSERTED_AFTER_UPGRADE_BEFORE_INSTANT_ADD_NEW_IMPLEMENTATION
Definition: rec.h:750
@ INSERTED_AFTER_INSTANT_ADD_OLD_IMPLEMENTATION
Definition: rec.h:747
@ INSERTED_AFTER_INSTANT_ADD_NEW_IMPLEMENTATION
Definition: rec.h:756
@ INSERTED_BEFORE_INSTANT_ADD_NEW_IMPLEMENTATION
Definition: rec.h:753
@ INSERTED_INTO_TABLE_WITH_NO_INSTANT_NO_VERSION
Definition: rec.h:758
@ NONE
Definition: rec.h:759
@ INSERTED_BEFORE_INSTANT_ADD_OLD_IMPLEMENTATION
Definition: rec.h:744
constexpr uint32_t REC_TMP_INFO_BITS
Definition: rec.h:96
constexpr uint32_t REC_HEAP_NO_SHIFT
Definition: rec.h:61
static bool rec_offs_validate(const rec_t *rec, const dict_index_t *index, const ulint *offsets)
Validates offsets returned by rec_get_offsets().
Definition: rec.h:538
constexpr uint32_t REC_STATUS_ORDINARY
Definition: rec.h:153
static enum REC_INSERT_STATE get_rec_insert_state(const dict_index_t *index, const rec_t *rec, bool temp)
Definition: rec.h:762
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:445
constexpr uint32_t REC_STATUS_INFIMUM
Definition: rec.h:155
constexpr uint32_t REC_NEW_STATUS
Definition: rec.h:78
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:600
static bool rec_new_is_versioned(const rec_t *rec)
The following function tells if a new-style record is versioned.
Definition: rec.h:675
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:121
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:347
constexpr uint32_t REC_1BYTE_SQL_NULL_MASK
SQL null flag in a 1-byte offset of ROW_FORMAT=REDUNDANT records.
Definition: rec.h:165
constexpr uint32_t REC_OLD_N_FIELDS
Definition: rec.h:74
constexpr auto MAX_REC_PER_PAGE
Maximum number of records in a page.
Definition: rec.h:141
constexpr uint32_t REC_OFFS_COMPACT
NOTE: The functions in this file should only use functions from other files in library.
Definition: rec.h:45
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:458
static bool rec_new_temp_is_versioned(const rec_t *rec)
The following function tells if a temporary record is versioned.
Definition: rec.h:691
constexpr uint32_t REC_NEW_STATUS_MASK
Definition: rec.h:79
constexpr uint32_t REC_OFFS_SQL_NULL
Definition: rec.h:47
constexpr uint32_t REC_N_TMP_EXTRA_BYTES
Definition: rec.h:137
constexpr uint32_t REC_OLD_N_OWNED
Definition: rec.h:89
static ulint rec_offs_n_fields(const ulint *offsets)
The following function returns the number of fields in a record.
Definition: rec.h:484
static const ulint * rec_offs_base(const ulint *offsets)
Definition: rec.h:201
constexpr int32_t REC_N_NEW_EXTRA_BYTES
Definition: rec.h:133
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:324
constexpr uint32_t REC_NEXT_MASK
Definition: rec.h:67
constexpr uint32_t REC_2BYTE_SQL_NULL_MASK
SQL null flag in a 2-byte offset of ROW_FORMAT=REDUNDANT records.
Definition: rec.h:167
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:123
constexpr uint32_t REC_NEW_N_OWNED
Definition: rec.h:90
constexpr uint32_t REC_OLD_N_FIELDS_SHIFT
Definition: rec.h:76
constexpr uint32_t REC_OLD_HEAP_NO
Definition: rec.h:82
static bool rec_old_is_versioned(const rec_t *rec)
The following function tells if an old-style record is versioned.
Definition: rec.h:683
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:1266
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:416
constexpr uint32_t REC_N_OWNED_SHIFT
Definition: rec.h:92
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:702
constexpr uint32_t REC_STATUS_NODE_PTR
Definition: rec.h:154
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:433
constexpr uint32_t REC_OLD_SHORT
Definition: rec.h:70
constexpr uint32_t REC_NEXT_SHIFT
Definition: rec.h:68
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:470
constexpr uint32_t REC_OFFS_NORMAL_SIZE
Definition: rec.h:183
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:249
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:171
constexpr uint32_t REC_NEW_STATUS_SHIFT
Definition: rec.h:80
bool rec_offs_cmp(ulint *offsets1, ulint *offsets2)
Check if the given two record offsets are identical.
Definition: rec.cc:535
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:403
std::ostream & rec_offs_print(std::ostream &out, const ulint *offsets)
Print the record offsets.
Definition: rec.cc:567
static ulint rec_get_status(const rec_t *rec)
The following function retrieves the status bits of a new-style record.
Definition: rec.h:274
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:634
constexpr uint32_t REC_OLD_N_FIELDS_MASK
Definition: rec.h:75
constexpr uint32_t REC_OFFS_SMALL_SIZE
Definition: rec.h:184
byte rec_t
Definition: rem0types.h:41
constexpr uint32_t REC_MAX_N_FIELDS
Definition: rem0types.h:44
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:1763
Data structure for a column in a table.
Definition: dict0mem.h:489
bool is_added_after(uint8_t version) const
Check if column is added after the current version.
Definition: dict0mem.h:753
unsigned mtype
main data type
Definition: dict0mem.h:506
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:698
bool is_dropped_in_or_before(uint8_t version) const
Check if column is dropped before the given version.
Definition: dict0mem.h:740
unsigned prtype
precise type; MySQL data type, charset code, flags to indicate nullability, signedness,...
Definition: dict0mem.h:499
Data structure for a field in an index.
Definition: dict0mem.h:895
dict_col_t * col
pointer to the table column
Definition: dict0mem.h:898
unsigned fixed_len
0 or the fixed length of the column if smaller than DICT_ANTELOPE_MAX_INDEX_COL_LEN
Definition: dict0mem.h:908
Data structure for an index.
Definition: dict0mem.h:1046
uint32_t get_n_nullable_before(uint32_t nth) const
Returns the number of nullable fields before specified nth field.
Definition: dict0mem.h:1368
const char * table_name
table name
Definition: dict0mem.h:1057
id_name_t name
index name
Definition: dict0mem.h:1054
const byte * get_nth_default(ulint nth, ulint *length) const
Get the default value of nth field and its length if exists.
Definition: dict0mem.h:1575
bool has_instant_cols_or_row_versions() const
check if either instant or versioned.
Definition: dict0mem.h:1352
dict_field_t * get_physical_field(size_t pos) const
Gets the nth physical pos field.
Definition: dict0mem.h:1488
uint32_t get_instant_fields() const
Returns the number of fields before first instant ADD COLUMN.
Definition: dict0mem.ic:92
dict_field_t * get_field(ulint pos) const
Gets the nth field of an index.
Definition: dict0mem.h:1502
uint16_t get_nullable_before_instant_add_drop() const
Get the nullable fields before any INSTANT ADD/DROP.
Definition: dict0mem.h:1256
size_t calculate_n_instant_nullable(size_t _n_fields) const
Definition: dict0mem.h:1395
unsigned n_def
number of fields defined so far
Definition: dict0mem.h:1103
unsigned n_nullable
number of nullable fields
Definition: dict0mem.h:1112
rec_cache_t rec_cache
cache the field that needs to be re-computed on each insert.
Definition: dict0mem.h:1225
bool has_row_versions() const
Check whether index belongs to a table having row versions.
Definition: dict0mem.h:1348
bool is_clustered() const
Definition: dict0mem.h:1311
bool has_instant_cols() const
Check whether index has any instantly added columns.
Definition: dict0mem.h:1344
dict_table_t * table
back pointer to table
Definition: dict0mem.h:1060
uint32_t get_nullable_in_version(uint8_t version) const
Return nullable in a specific row version.
Definition: dict0mem.h:1436
bool has_instant_cols() const
Definition: dict0mem.h:2482
bool has_row_versions() const
Definition: dict0mem.h:2467
unsigned n_cols
Number of non-virtual columns.
Definition: dict0mem.h:2045
unsigned n_instant_cols
Number of non-virtual columns before first instant ADD COLUMN, including the system columns like n_co...
Definition: dict0mem.h:2050
table_id_t id
Id of the table.
Definition: dict0mem.h:1964
bool is_upgraded_instant() const
Checks if table is upgraded table with INSTANT ADD columns in V1.
Definition: dict0mem.h:2539
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:694
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:302
const ulint * offsets
Holds reference to cached offsets for record.
Definition: dict0mem.h:982
#define UNIV_MEM_ASSERT_W(addr, size)
Definition: univ.i:618
#define UNIV_UNLIKELY(cond)
Definition: univ.i:521
constexpr uint8_t UINT8_UNDEFINED
The 'undefined' value for a 8-bit unsigned integer.
Definition: univ.i:434
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:463
#define UNIV_MEM_ASSERT_AND_ALLOC(addr, size)
Definition: univ.i:630
constexpr ulint ULINT_MAX
Maximum value for a ulint.
Definition: univ.i:440
unsigned long int ulint
Definition: univ.i:406
constexpr size_t UNIV_PAGE_SIZE_MAX
Maximum page size InnoDB currently supports.
Definition: univ.i:323
#define ut_error
Abort execution.
Definition: ut0dbg.h:65
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:69
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:57
#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:192
int n
Definition: xcom_base.cc:509