MySQL 8.1.0
Source Code Documentation
rem0wrec.h
Go to the documentation of this file.
1/*****************************************************************************
2Copyright (c) 2021, 2023, Oracle and/or its affiliates.
3
4This program is free software; you can redistribute it and/or modify it under
5the terms of the GNU General Public License, version 2.0, as published by the
6Free Software Foundation.
7
8This program is also distributed with certain software (including but not
9limited to OpenSSL) that is licensed under separate terms, as designated in a
10particular file or component or in included license documentation. The authors
11of MySQL hereby grant you an additional permission to link the program and
12your derivative works with the separately licensed software that they have
13included with MySQL.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
18for more details.
19
20You should have received a copy of the GNU General Public License along with
21this program; if not, write to the Free Software Foundation, Inc.,
2251 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
24*****************************************************************************/
25
26/** @file include/rem0wrec.h
27 Record manager wrapper declaration.
28
29 After INSTANT ADD/DROP feature, fields index on logical record might not be
30 same as field index on physical record. So this wrapper is implemented which
31 translates logical index to physical index. And then functions of low level
32 record manager (rem0lrec.h) are called with physical index of the field.
33
34 Created 13/08/2021 Mayank Prasad
35******************************************************************************/
36
37#ifndef rem0wrec_h
38#define rem0wrec_h
39
40#include "rem/rec.h"
41
42/** Gets the value of the specified field in the record.
43@param[in] index record descriptor
44@param[in] rec physical record
45@param[in] offsets array returned by rec_get_offsets()
46@param[in] n index of the field
47@param[out] len length of the field, UNIV_SQL_NULL if SQL null
48@return value of the field */
49byte *rec_get_nth_field(const dict_index_t *index, const rec_t *rec,
50 const ulint *offsets, ulint n, ulint *len);
51
52const byte *rec_get_nth_field_old(const dict_index_t *index, const rec_t *rec,
53 ulint n, ulint *len);
54
55/** Gets the physical size of an old-style field.
56Also an SQL null may have a field of size > 0, if the data type is of a fixed
57size.
58@param[in] index record descriptor
59@param[in] rec record
60@param[in] n index of the field
61@return field size in bytes */
62[[nodiscard]] ulint rec_get_nth_field_size(const dict_index_t *index,
63 const rec_t *rec, ulint n);
64
65/** The following function is used to get an offset to the nth data field in a
66record.
67@param[in] index record descriptor
68@param[in] offsets array returned by rec_get_offsets()
69@param[in] n index of the field
70@param[out] len length of the field; UNIV_SQL_NULL if SQL null;
71 UNIV_SQL_ADD_COL_DEFAULT if it's default value and no
72 value inlined
73@return offset from the origin of rec */
74ulint rec_get_nth_field_offs(const dict_index_t *index, const ulint *offsets,
75 ulint n, ulint *len);
76
77/** The following function is used to get the offset to the nth
78data field in an old-style record.
79@param[in] index record descriptor
80@param[in] rec record
81@param[in] n index of the field
82@param[in] len length of the field;UNIV_SQL_NULL if SQL null
83@return offset to the field */
84ulint rec_get_nth_field_offs_old(const dict_index_t *index, const rec_t *rec,
85 ulint n, ulint *len);
86
87/** Returns nonzero if the extern bit is set in nth field of rec.
88@param[in] index record descriptor
89@param[in] offsets array returned by rec_get_offsets()
90@param[in] n nth field
91@return nonzero if externally stored */
92[[nodiscard]] ulint rec_offs_nth_extern(const dict_index_t *index,
93 const ulint *offsets, ulint n);
94
95/** Mark the nth field as externally stored.
96@param[in] index record descriptor
97@param[in] offsets array returned by rec_get_offsets()
98@param[in] n nth field */
99void rec_offs_make_nth_extern(dict_index_t *index, ulint *offsets, ulint n);
100
101/** Returns nonzero if the SQL NULL bit is set in nth field of rec.
102@param[in] index record descriptor
103@param[in] offsets array returned by rec_get_offsets()
104@param[in] n nth field
105@return nonzero if SQL NULL */
106[[nodiscard]] ulint rec_offs_nth_sql_null(const dict_index_t *index,
107 const ulint *offsets, ulint n);
108
109/** Returns nonzero if the default bit is set in nth field of rec.
110@param[in] index record descriptor
111@param[in] offsets array returned by rec_get_offsets()
112@param[in] n nth field
113@return nonzero if default bit is set */
114ulint rec_offs_nth_default(const dict_index_t *index, const ulint *offsets,
115 ulint n);
116
117/** Gets the physical size of a field.
118@param[in] index record descriptor
119@param[in] offsets array returned by rec_get_offsets()
120@param[in] n nth field
121@return length of field */
122[[nodiscard]] ulint rec_offs_nth_size(const dict_index_t *index,
123 const ulint *offsets, ulint n);
124
125/** This is used to modify the value of an already existing field in a record.
126The previous value must have exactly the same size as the new value. If len is
127UNIV_SQL_NULL then the field is treated as an SQL null.
128For records in ROW_FORMAT=COMPACT (new-style records), len must not be
129UNIV_SQL_NULL unless the field already is SQL null.
130@param[in] index record descriptor
131@param[in] rec record
132@param[in] offsets array returned by rec_get_offsets()
133@param[in] n index number of the field
134@param[in] len length of the data or UNIV_SQL_NULL.
135 If not SQL null, must have the same length as the
136 previous value.
137 If SQL null, previous value must be SQL null.
138@param[in] data pointer to the data if not SQL null */
139void rec_set_nth_field(const dict_index_t *index, rec_t *rec,
140 const ulint *offsets, ulint n, const void *data,
141 ulint len);
142
143/** Returns nonzero if the field is stored off-page.
144@param[in] index index
145@param[in] rec record
146@param[in] n field index
147@retval 0 if the field is stored in-page
148@retval REC_2BYTE_EXTERN_MASK if the field is stored externally */
149[[nodiscard]] ulint rec_2_is_field_extern(const dict_index_t *index,
150 const rec_t *rec, ulint n);
151
152/** The following function returns the data size of an old-style physical
153record, that is the sum of field lengths. SQL null fields are counted as length
1540 fields. The value returned by the function is the distance from record origin
155to record end in bytes.
156@return size */
158#endif
Record manager.
byte rec_t
Definition: rem0types.h:40
void rec_offs_make_nth_extern(dict_index_t *index, ulint *offsets, ulint n)
Mark the nth field as externally stored.
Definition: rem0wrec.cc:146
ulint rec_get_nth_field_size(const dict_index_t *index, const rec_t *rec, ulint n)
Gets the physical size of an old-style field.
Definition: rem0wrec.cc:93
ulint rec_offs_nth_default(const dict_index_t *index, const ulint *offsets, ulint n)
Returns nonzero if the default bit is set in nth field of rec.
Definition: rem0wrec.cc:164
void rec_set_nth_field(const dict_index_t *index, rec_t *rec, const ulint *offsets, ulint n, const void *data, ulint len)
This is used to modify the value of an already existing field in a record.
Definition: rem0wrec.cc:184
ulint rec_get_nth_field_offs_old(const dict_index_t *index, const rec_t *rec, ulint n, ulint *len)
The following function is used to get the offset to the nth data field in an old-style record.
Definition: rem0wrec.cc:119
byte * rec_get_nth_field(const dict_index_t *index, const rec_t *rec, const ulint *offsets, ulint n, ulint *len)
Gets the value of the specified field in the record.
Definition: rem0wrec.cc:80
const byte * rec_get_nth_field_old(const dict_index_t *index, const rec_t *rec, ulint n, ulint *len)
Definition: rem0wrec.cc:87
ulint rec_offs_nth_size(const dict_index_t *index, const ulint *offsets, ulint n)
Gets the physical size of a field.
Definition: rem0wrec.cc:174
ulint rec_get_nth_field_offs(const dict_index_t *index, const ulint *offsets, ulint n, ulint *len)
The following function is used to get an offset to the nth data field in a record.
Definition: rem0wrec.cc:110
ulint rec_2_is_field_extern(const dict_index_t *index, const rec_t *rec, ulint n)
Returns nonzero if the field is stored off-page.
Definition: rem0wrec.cc:194
ulint rec_offs_nth_extern(const dict_index_t *index, const ulint *offsets, ulint n)
Returns nonzero if the extern bit is set in nth field of rec.
Definition: rem0wrec.cc:136
ulint rec_offs_nth_sql_null(const dict_index_t *index, const ulint *offsets, ulint n)
Returns nonzero if the SQL NULL bit is set in nth field of rec.
Definition: rem0wrec.cc:154
ulint rec_get_data_size_old(const rec_t *rec)
The following function returns the data size of an old-style physical record, that is the sum of fiel...
Definition: rem0wrec.cc:211
Data structure for an index.
Definition: dict0mem.h:1045
unsigned long int ulint
Definition: univ.i:405
int n
Definition: xcom_base.cc:508