1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2017, 2020, MariaDB Corporation.
5 
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free Software
8 Foundation; version 2 of the License.
9 
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
17 
18 *****************************************************************************/
19 
20 /**************************************************//**
21 @file include/data0type.h
22 Data types
23 
24 Created 1/16/1996 Heikki Tuuri
25 *******************************************************/
26 
27 #ifndef data0type_h
28 #define data0type_h
29 
30 #include "univ.i"
31 
32 /** Special length indicating a missing instantly added column */
33 #define UNIV_SQL_DEFAULT (UNIV_SQL_NULL - 1)
34 
35 /** @return whether a length is actually stored in a field */
36 #define len_is_stored(len) (len != UNIV_SQL_NULL && len != UNIV_SQL_DEFAULT)
37 
38 extern ulint	data_mysql_default_charset_coll;
39 #define DATA_MYSQL_BINARY_CHARSET_COLL 63
40 
41 /* SQL data type struct */
42 struct dtype_t;
43 
44 /** SQL Like operator comparison types */
45 enum ib_like_t {
46 	IB_LIKE_EXACT,	/**< e.g.  STRING */
47 	IB_LIKE_PREFIX	/**< e.g., STRING% */
48 };
49 
50 /*-------------------------------------------*/
51 /* The 'MAIN TYPE' of a column */
52 #define DATA_MISSING	0	/* missing column */
53 #define	DATA_VARCHAR	1	/* character varying of the
54 				latin1_swedish_ci charset-collation; note
55 				that the MySQL format for this, DATA_BINARY,
56 				DATA_VARMYSQL, is also affected by whether the
57 				'precise type' contains
58 				DATA_MYSQL_TRUE_VARCHAR */
59 #define DATA_CHAR	2	/* fixed length character of the
60 				latin1_swedish_ci charset-collation */
61 #define DATA_FIXBINARY	3	/* binary string of fixed length */
62 #define DATA_BINARY	4	/* binary string */
63 #define DATA_BLOB	5	/* binary large object, or a TEXT type;
64 				if prtype & DATA_BINARY_TYPE == 0, then this is
65 				actually a TEXT column (or a BLOB created
66 				with < 4.0.14; since column prefix indexes
67 				came only in 4.0.14, the missing flag in BLOBs
68 				created before that does not cause any harm) */
69 #define	DATA_INT	6	/* integer: can be any size 1 - 8 bytes */
70 #define	DATA_SYS_CHILD	7	/* address of the child page in node pointer */
71 #define	DATA_SYS	8	/* system column */
72 
73 /* Data types >= DATA_FLOAT must be compared using the whole field, not as
74 binary strings */
75 
76 #define DATA_FLOAT	9
77 #define DATA_DOUBLE	10
78 #define DATA_DECIMAL	11	/* decimal number stored as an ASCII string */
79 #define	DATA_VARMYSQL	12	/* any charset varying length char */
80 #define	DATA_MYSQL	13	/* any charset fixed length char */
81 				/* NOTE that 4.1.1 used DATA_MYSQL and
82 				DATA_VARMYSQL for all character sets, and the
83 				charset-collation for tables created with it
84 				can also be latin1_swedish_ci */
85 
86 /* DATA_GEOMETRY includes all standard geometry datatypes as described in
87 OGC standard(point, line_string, polygon, multi_point, multi_polygon,
88 multi_line_string, geometry_collection, geometry).
89 Currently, geometry data is stored in the standard Well-Known Binary(WKB)
90 format (http://www.opengeospatial.org/standards/sfa).
91 We use BLOB as the underlying datatype. */
92 #define DATA_GEOMETRY	14	/* geometry datatype of variable length */
93 #define DATA_MTYPE_MAX	63	/* dtype_store_for_order_and_null_size()
94 				requires the values are <= 63 */
95 
96 #define DATA_MTYPE_CURRENT_MIN	DATA_VARCHAR	/* minimum value of mtype */
97 #define DATA_MTYPE_CURRENT_MAX	DATA_GEOMETRY	/* maximum value of mtype */
98 /*-------------------------------------------*/
99 /* The 'PRECISE TYPE' of a column */
100 /*
101 Tables created by a MySQL user have the following convention:
102 
103 - In the least significant byte in the precise type we store the MySQL type
104 code (not applicable for system columns).
105 
106 - In the second least significant byte we OR flags DATA_NOT_NULL,
107 DATA_UNSIGNED, DATA_BINARY_TYPE.
108 
109 - In the third least significant byte of the precise type of string types we
110 store the MySQL charset-collation code. In DATA_BLOB columns created with
111 < 4.0.14 we do not actually know if it is a BLOB or a TEXT column. Since there
112 are no indexes on prefixes of BLOB or TEXT columns in < 4.0.14, this is no
113 problem, though.
114 
115 Note that versions < 4.1.2 or < 5.0.1 did not store the charset code to the
116 precise type, since the charset was always the default charset of the MySQL
117 installation. If the stored charset code is 0 in the system table SYS_COLUMNS
118 of InnoDB, that means that the default charset of this MySQL installation
119 should be used.
120 
121 When loading a table definition from the system tables to the InnoDB data
122 dictionary cache in main memory, InnoDB versions >= 4.1.2 and >= 5.0.1 check
123 if the stored charset-collation is 0, and if that is the case and the type is
124 a non-binary string, replace that 0 by the default charset-collation code of
125 this MySQL installation. In short, in old tables, the charset-collation code
126 in the system tables on disk can be 0, but in in-memory data structures
127 (dtype_t), the charset-collation code is always != 0 for non-binary string
128 types.
129 
130 In new tables, in binary string types, the charset-collation code is the
131 MySQL code for the 'binary charset', that is, != 0.
132 
133 For binary string types and for DATA_CHAR, DATA_VARCHAR, and for those
134 DATA_BLOB which are binary or have the charset-collation latin1_swedish_ci,
135 InnoDB performs all comparisons internally, without resorting to the MySQL
136 comparison functions. This is to save CPU time.
137 
138 InnoDB's own internal system tables have different precise types for their
139 columns, and for them the precise type is usually not used at all.
140 */
141 
142 #define DATA_ENGLISH	4	/* English language character string: this
143 				is a relic from pre-MySQL time and only used
144 				for InnoDB's own system tables */
145 #define DATA_ERROR	111	/* another relic from pre-MySQL time */
146 
147 #define DATA_MYSQL_TYPE_MASK 255U/* AND with this mask to extract the MySQL
148 				 type from the precise type */
149 #define DATA_MYSQL_TRUE_VARCHAR 15 /* MySQL type code for the >= 5.0.3
150 				   format true VARCHAR */
151 
152 /* Precise data types for system columns and the length of those columns;
153 NOTE: the values must run from 0 up in the order given! All codes must
154 be less than 256 */
155 #define	DATA_ROW_ID	0	/* row id: a 48-bit integer */
156 #define DATA_ROW_ID_LEN	6	/* stored length for row id */
157 
158 #define DATA_TRX_ID	1	/* transaction id: 6 bytes */
159 #define DATA_TRX_ID_LEN	6
160 
161 #define	DATA_ROLL_PTR	2	/* rollback data pointer: 7 bytes */
162 #define DATA_ROLL_PTR_LEN 7
163 
164 #define	DATA_N_SYS_COLS 3	/* number of system columns defined above */
165 
166 #define DATA_FTS_DOC_ID	3	/* Used as FTS DOC ID column */
167 
168 #define DATA_SYS_PRTYPE_MASK 0xFU /* mask to extract the above from prtype */
169 
170 /* Flags ORed to the precise data type */
171 #define DATA_NOT_NULL	256U	/* this is ORed to the precise type when
172 				the column is declared as NOT NULL */
173 #define DATA_UNSIGNED	512U	/* this id ORed to the precise type when
174 				we have an unsigned integer type */
175 #define	DATA_BINARY_TYPE 1024U	/* if the data type is a binary character
176 				string, this is ORed to the precise type:
177 				this only holds for tables created with
178 				>= MySQL-4.0.14 */
179 /* #define	DATA_NONLATIN1	2048 This is a relic from < 4.1.2 and < 5.0.1.
180 				In earlier versions this was set for some
181 				BLOB columns.
182 */
183 #define DATA_GIS_MBR	2048U	/* Used as GIS MBR column */
184 /** the size of a GIS maximum bounding rectangle */
185 constexpr uint8_t DATA_MBR_LEN= uint8_t(SPDIMS * 2 * sizeof(double));
186 
187 #define	DATA_LONG_TRUE_VARCHAR 4096U	/* this is ORed to the precise data
188 				type when the column is true VARCHAR where
189 				MySQL uses 2 bytes to store the data len;
190 				for shorter VARCHARs MySQL uses only 1 byte */
191 #define	DATA_VIRTUAL	8192U	/* Virtual column */
192 
193 /** System Versioning */
194 #define DATA_VERS_START	16384U	/* start system field */
195 #define DATA_VERS_END	32768U	/* end system field */
196 /** system-versioned user data column */
197 #define DATA_VERSIONED (DATA_VERS_START|DATA_VERS_END)
198 
199 /** Check whether locking is disabled (never). */
200 #define dict_table_is_locking_disabled(table) false
201 
202 /*-------------------------------------------*/
203 
204 /* This many bytes we need to store the type information affecting the
205 alphabetical order for a single field and decide the storage size of an
206 SQL null*/
207 #define DATA_ORDER_NULL_TYPE_BUF_SIZE		4
208 /* In the >= 4.1.x storage format we add 2 bytes more so that we can also
209 store the charset-collation number; one byte is left unused, though */
210 #define DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE	6
211 
212 /* Maximum multi-byte character length in bytes, plus 1 */
213 #define DATA_MBMAX	8
214 
215 /* For checking if mtype is GEOMETRY datatype */
216 #define DATA_GEOMETRY_MTYPE(mtype)	((mtype) == DATA_GEOMETRY)
217 
218 /* For checking if mtype is BLOB or GEOMETRY, since we use BLOB as
219 the underlying datatype of GEOMETRY data. */
220 #define DATA_LARGE_MTYPE(mtype) ((mtype) == DATA_BLOB			\
221 				 || (mtype) == DATA_GEOMETRY)
222 
223 /* For checking if data type is big length data type. */
224 #define DATA_BIG_LEN_MTYPE(len, mtype) ((len) > 255 || DATA_LARGE_MTYPE(mtype))
225 
226 /* For checking if the column is a big length column. */
227 #define DATA_BIG_COL(col) DATA_BIG_LEN_MTYPE((col)->len, (col)->mtype)
228 
229 /* For checking if data type is large binary data type. */
230 #define DATA_LARGE_BINARY(mtype,prtype) ((mtype) == DATA_GEOMETRY || \
231 	((mtype) == DATA_BLOB && !((prtype) & DATA_BINARY_TYPE)))
232 
233 /* We now support 15 bits (up to 32767) collation number */
234 #define MAX_CHAR_COLL_NUM	32767
235 
236 /* Mask to get the Charset Collation number (0x7fff) */
237 #define CHAR_COLL_MASK		MAX_CHAR_COLL_NUM
238 
239 /*********************************************************************//**
240 Gets the MySQL type code from a dtype.
241 @return MySQL type code; this is NOT an InnoDB type code! */
242 UNIV_INLINE
243 ulint
244 dtype_get_mysql_type(
245 /*=================*/
246 	const dtype_t*	type);	/*!< in: type struct */
247 /*********************************************************************//**
248 Determine how many bytes the first n characters of the given string occupy.
249 If the string is shorter than n characters, returns the number of bytes
250 the characters in the string occupy.
251 @return length of the prefix, in bytes */
252 ulint
253 dtype_get_at_most_n_mbchars(
254 /*========================*/
255 	ulint		prtype,		/*!< in: precise type */
256 	ulint		mbminlen,	/*!< in: minimum length of
257 					a multi-byte character, in bytes */
258 	ulint		mbmaxlen,	/*!< in: maximum length of
259 					a multi-byte character, in bytes */
260 	ulint		prefix_len,	/*!< in: length of the requested
261 					prefix, in characters, multiplied by
262 					dtype_get_mbmaxlen(dtype) */
263 	ulint		data_len,	/*!< in: length of str (in bytes) */
264 	const char*	str);		/*!< in: the string whose prefix
265 					length is being determined */
266 /** @return whether main type is a string type */
dtype_is_string_type(ulint mtype)267 inline bool dtype_is_string_type(ulint mtype)
268 {
269 	return mtype <= DATA_BLOB
270 		|| mtype == DATA_MYSQL || mtype == DATA_VARMYSQL;
271 }
272 
273 /** @return whether a type is a binary string type */
dtype_is_binary_string_type(ulint mtype,ulint prtype)274 inline bool dtype_is_binary_string_type(ulint mtype, ulint prtype)
275 {
276 	/* Note that for tables created before MySQL 4.0.14,
277 	we do not know if a DATA_BLOB column is a BLOB or a TEXT column.
278 	For those DATA_BLOB columns we return false. */
279 
280 	return mtype == DATA_FIXBINARY || mtype == DATA_BINARY
281 		|| (mtype == DATA_BLOB && (prtype & DATA_BINARY_TYPE));
282 }
283 
284 /** @return whether a type is a non-binary string type */
dtype_is_non_binary_string_type(ulint mtype,ulint prtype)285 inline bool dtype_is_non_binary_string_type(ulint mtype, ulint prtype)
286 {
287 	return dtype_is_string_type(mtype)
288 		&& !dtype_is_binary_string_type(mtype, prtype);
289 }
290 
291 /*********************************************************************//**
292 Sets a data type structure. */
293 UNIV_INLINE
294 void
295 dtype_set(
296 /*======*/
297 	dtype_t*	type,	/*!< in: type struct to init */
298 	ulint		mtype,	/*!< in: main data type */
299 	ulint		prtype,	/*!< in: precise type */
300 	ulint		len);	/*!< in: precision of type */
301 /*********************************************************************//**
302 Copies a data type structure. */
303 UNIV_INLINE
304 void
305 dtype_copy(
306 /*=======*/
307 	dtype_t*	type1,	/*!< in: type struct to copy to */
308 	const dtype_t*	type2);	/*!< in: type struct to copy from */
309 /*********************************************************************//**
310 Gets the SQL main data type.
311 @return SQL main data type */
312 UNIV_INLINE
313 ulint
314 dtype_get_mtype(
315 /*============*/
316 	const dtype_t*	type);	/*!< in: data type */
317 /*********************************************************************//**
318 Gets the precise data type.
319 @return precise data type */
320 UNIV_INLINE
321 ulint
322 dtype_get_prtype(
323 /*=============*/
324 	const dtype_t*	type);	/*!< in: data type */
325 
326 /*********************************************************************//**
327 Compute the mbminlen and mbmaxlen members of a data type structure. */
328 UNIV_INLINE
329 void
330 dtype_get_mblen(
331 /*============*/
332 	ulint	mtype,		/*!< in: main type */
333 	ulint	prtype,		/*!< in: precise type (and collation) */
334 	unsigned* mbminlen,	/*!< out: minimum length of a
335 				multi-byte character */
336 	unsigned* mbmaxlen);	/*!< out: maximum length of a
337 				multi-byte character */
338 /**
339 Get the charset-collation code for string types.
340 @param  prtype  InnoDB precise type
341 @return charset-collation code */
dtype_get_charset_coll(ulint prtype)342 inline uint16_t dtype_get_charset_coll(ulint prtype)
343 {
344   return static_cast<uint16_t>(prtype >> 16) & CHAR_COLL_MASK;
345 }
346 
347 /** Form a precise type from the < 4.1.2 format precise type plus the
348 charset-collation code.
349 @param[in]	old_prtype	MySQL type code and the flags
350 				DATA_BINARY_TYPE etc.
351 @param[in]	charset_coll	character-set collation code
352 @return precise type, including the charset-collation code */
353 UNIV_INLINE
354 uint32_t
dtype_form_prtype(ulint old_prtype,ulint charset_coll)355 dtype_form_prtype(ulint old_prtype, ulint charset_coll)
356 {
357 	ut_ad(old_prtype < 256 * 256);
358 	ut_ad(charset_coll <= MAX_CHAR_COLL_NUM);
359 	return(uint32_t(old_prtype + (charset_coll << 16)));
360 }
361 
362 /*********************************************************************//**
363 Determines if a MySQL string type is a subset of UTF-8.  This function
364 may return false negatives, in case further character-set collation
365 codes are introduced in MySQL later.
366 @return whether a subset of UTF-8 */
367 UNIV_INLINE
368 bool
369 dtype_is_utf8(
370 /*==========*/
371 	ulint	prtype);/*!< in: precise data type */
372 /*********************************************************************//**
373 Gets the type length.
374 @return fixed length of the type, in bytes, or 0 if variable-length */
375 UNIV_INLINE
376 ulint
377 dtype_get_len(
378 /*==========*/
379 	const dtype_t*	type);	/*!< in: data type */
380 
381 /*********************************************************************//**
382 Gets the minimum length of a character, in bytes.
383 @return minimum length of a char, in bytes, or 0 if this is not a
384 character type */
385 UNIV_INLINE
386 ulint
387 dtype_get_mbminlen(
388 /*===============*/
389 	const dtype_t*	type);	/*!< in: type */
390 /*********************************************************************//**
391 Gets the maximum length of a character, in bytes.
392 @return maximum length of a char, in bytes, or 0 if this is not a
393 character type */
394 UNIV_INLINE
395 ulint
396 dtype_get_mbmaxlen(
397 /*===============*/
398 	const dtype_t*	type);	/*!< in: type */
399 /***********************************************************************//**
400 Returns the size of a fixed size data type, 0 if not a fixed size type.
401 @return fixed size, or 0 */
402 UNIV_INLINE
403 unsigned
404 dtype_get_fixed_size_low(
405 /*=====================*/
406 	ulint	mtype,		/*!< in: main type */
407 	ulint	prtype,		/*!< in: precise type */
408 	ulint	len,		/*!< in: length */
409 	ulint	mbminlen,	/*!< in: minimum length of a
410 				multibyte character, in bytes */
411 	ulint	mbmaxlen,	/*!< in: maximum length of a
412 				multibyte character, in bytes */
413 	ulint	comp);		/*!< in: nonzero=ROW_FORMAT=COMPACT  */
414 
415 /***********************************************************************//**
416 Returns the minimum size of a data type.
417 @return minimum size */
418 UNIV_INLINE
419 unsigned
420 dtype_get_min_size_low(
421 /*===================*/
422 	ulint	mtype,		/*!< in: main type */
423 	ulint	prtype,		/*!< in: precise type */
424 	ulint	len,		/*!< in: length */
425 	ulint	mbminlen,	/*!< in: minimum length of a character */
426 	ulint	mbmaxlen);	/*!< in: maximum length of a character */
427 /***********************************************************************//**
428 Returns the maximum size of a data type. Note: types in system tables may be
429 incomplete and return incorrect information.
430 @return maximum size */
431 UNIV_INLINE
432 ulint
433 dtype_get_max_size_low(
434 /*===================*/
435 	ulint	mtype,		/*!< in: main type */
436 	ulint	len);		/*!< in: length */
437 /***********************************************************************//**
438 Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a type.
439 For fixed length types it is the fixed length of the type, otherwise 0.
440 @return SQL null storage size in ROW_FORMAT=REDUNDANT */
441 UNIV_INLINE
442 ulint
443 dtype_get_sql_null_size(
444 /*====================*/
445 	const dtype_t*	type,	/*!< in: type */
446 	ulint		comp);	/*!< in: nonzero=ROW_FORMAT=COMPACT  */
447 
448 /**********************************************************************//**
449 Reads to a type the stored information which determines its alphabetical
450 ordering and the storage size of an SQL NULL value. */
451 UNIV_INLINE
452 void
453 dtype_read_for_order_and_null_size(
454 /*===============================*/
455 	dtype_t*	type,	/*!< in: type struct */
456 	const byte*	buf);	/*!< in: buffer for the stored order info */
457 /**********************************************************************//**
458 Stores for a type the information which determines its alphabetical ordering
459 and the storage size of an SQL NULL value. This is the >= 4.1.x storage
460 format. */
461 UNIV_INLINE
462 void
463 dtype_new_store_for_order_and_null_size(
464 /*====================================*/
465 	byte*		buf,	/*!< in: buffer for
466 				DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE
467 				bytes where we store the info */
468 	const dtype_t*	type,	/*!< in: type struct */
469 	ulint		prefix_len);/*!< in: prefix length to
470 				replace type->len, or 0 */
471 /**********************************************************************//**
472 Reads to a type the stored information which determines its alphabetical
473 ordering and the storage size of an SQL NULL value. This is the 4.1.x storage
474 format. */
475 UNIV_INLINE
476 void
477 dtype_new_read_for_order_and_null_size(
478 /*===================================*/
479 	dtype_t*	type,	/*!< in: type struct */
480 	const byte*	buf);	/*!< in: buffer for stored type order info */
481 
482 /*********************************************************************//**
483 Returns the type's SQL name (e.g. BIGINT UNSIGNED) from mtype,prtype,len
484 @return the SQL type name */
485 UNIV_INLINE
486 char*
487 dtype_sql_name(
488 /*===========*/
489 	unsigned	mtype,	/*!< in: mtype */
490 	unsigned	prtype,	/*!< in: prtype */
491 	unsigned	len,	/*!< in: len */
492 	char*		name,	/*!< out: SQL name */
493 	unsigned	name_sz);/*!< in: size of the name buffer */
494 
495 /*********************************************************************//**
496 Validates a data type structure.
497 @return TRUE if ok */
498 ibool
499 dtype_validate(
500 /*===========*/
501 	const dtype_t*	type);	/*!< in: type struct to validate */
502 #ifdef UNIV_DEBUG
503 /** Print a data type structure.
504 @param[in]	type	data type */
505 void
506 dtype_print(
507 	const dtype_t*	type);
508 #endif /* UNIV_DEBUG */
509 
510 /* Structure for an SQL data type.
511 If you add fields to this structure, be sure to initialize them everywhere.
512 This structure is initialized in the following functions:
513 dtype_set()
514 dtype_read_for_order_and_null_size()
515 dtype_new_read_for_order_and_null_size()
516 sym_tab_add_null_lit() */
517 
518 struct dtype_t{
519 	unsigned	prtype:32;	/*!< precise type; MySQL data
520 					type, charset code, flags to
521 					indicate nullability,
522 					signedness, whether this is a
523 					binary string, whether this is
524 					a true VARCHAR where MySQL
525 					uses 2 bytes to store the length */
526 	unsigned	mtype:8;	/*!< main data type */
527 
528 	/* the remaining fields do not affect alphabetical ordering: */
529 
530 	unsigned	len:16;		/*!< length; for MySQL data this
531 					is field->pack_length(),
532 					except that for a >= 5.0.3
533 					type true VARCHAR this is the
534 					maximum byte length of the
535 					string data (in addition to
536 					the string, MySQL uses 1 or 2
537 					bytes to store the string length) */
538 	unsigned	mbminlen:3;	/*!< minimum length of a character,
539 					in bytes */
540 	unsigned	mbmaxlen:3;	/*!< maximum length of a character,
541 					in bytes */
542 
543 	/** @return whether this is system versioned user field */
is_versioneddtype_t544 	bool is_versioned() const { return !(~prtype & DATA_VERSIONED); }
545 	/** @return whether this is the system field start */
vers_sys_startdtype_t546 	bool vers_sys_start() const
547 	{
548 		return (prtype & DATA_VERSIONED) == DATA_VERS_START;
549 	}
550 	/** @return whether this is the system field end */
vers_sys_enddtype_t551 	bool vers_sys_end() const
552 	{
553 		return (prtype & DATA_VERSIONED) == DATA_VERS_END;
554 	}
555 
556 	/** Set the type of the BLOB in the hidden metadata record. */
metadata_blob_initdtype_t557 	void metadata_blob_init()
558 	{
559 		prtype = DATA_NOT_NULL;
560 		mtype = DATA_BLOB;
561 		len = 0;
562 		mbminlen = 0;
563 		mbmaxlen = 0;
564 	}
565 };
566 
567 /** The DB_TRX_ID,DB_ROLL_PTR values for "no history is available" */
568 extern const byte reset_trx_id[DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN];
569 
570 /** Info bit denoting the predefined minimum record: this bit is set
571 if and only if the record is the first user record on a non-leaf
572 B-tree page that is the leftmost page on its level
573 (PAGE_LEVEL is nonzero and FIL_PAGE_PREV is FIL_NULL). */
574 #define REC_INFO_MIN_REC_FLAG	0x10UL
575 /** The delete-mark flag in info bits */
576 #define REC_INFO_DELETED_FLAG	0x20UL
577 
578 /** Record status values for ROW_FORMAT=COMPACT,DYNAMIC,COMPRESSED */
579 enum rec_comp_status_t {
580 	/** User record (PAGE_LEVEL=0, heap>=PAGE_HEAP_NO_USER_LOW) */
581 	REC_STATUS_ORDINARY = 0,
582 	/** Node pointer record (PAGE_LEVEL>=0, heap>=PAGE_HEAP_NO_USER_LOW) */
583 	REC_STATUS_NODE_PTR = 1,
584 	/** The page infimum pseudo-record (heap=PAGE_HEAP_NO_INFIMUM) */
585 	REC_STATUS_INFIMUM = 2,
586 	/** The page supremum pseudo-record (heap=PAGE_HEAP_NO_SUPREMUM) */
587 	REC_STATUS_SUPREMUM = 3,
588 	/** Clustered index record that has been inserted or updated
589 	after instant ADD COLUMN (more than dict_index_t::n_core_fields) */
590 	REC_STATUS_INSTANT = 4
591 };
592 
593 /** The dtuple_t::info_bits of the hidden metadata of instant ADD COLUMN.
594 @see rec_is_metadata()
595 @see rec_is_alter_metadata() */
596 static const byte REC_INFO_METADATA_ADD
597 	= REC_INFO_MIN_REC_FLAG | REC_STATUS_INSTANT;
598 
599 /** The dtuple_t::info_bits of the hidden metadata of instant ALTER TABLE.
600 @see rec_is_metadata() */
601 static const byte REC_INFO_METADATA_ALTER
602 	= REC_INFO_METADATA_ADD | REC_INFO_DELETED_FLAG;
603 
604 #include "data0type.inl"
605 
606 #endif
607