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