MySQL  8.0.19
Source Code Documentation
data0data.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 *****************************************************************************/
26 
27 /** @file include/data0data.h
28  SQL data field and tuple
29 
30  Created 5/30/1994 Heikki Tuuri
31  *************************************************************************/
32 
33 #ifndef data0data_h
34 #define data0data_h
35 
36 #include "univ.i"
37 
38 #include "data0type.h"
39 #include "data0types.h"
40 #include "dict0types.h"
41 #include "mem0mem.h"
42 #include "trx0types.h"
43 #include "ut0bitset.h"
44 
45 #include <ostream>
46 
47 /** Storage for overflow data in a big record, that is, a clustered
48 index record which needs external storage of data fields */
49 struct big_rec_t;
50 struct upd_t;
51 
52 #ifdef UNIV_DEBUG
53 /** Gets pointer to the type struct of SQL data field.
54  @return pointer to the type struct */
55 UNIV_INLINE
56 dtype_t *dfield_get_type(const dfield_t *field) /*!< in: SQL data field */
57  MY_ATTRIBUTE((warn_unused_result));
58 /** Gets pointer to the data in a field.
59  @return pointer to data */
60 UNIV_INLINE
61 void *dfield_get_data(const dfield_t *field) /*!< in: field */
62  MY_ATTRIBUTE((warn_unused_result));
63 #else /* UNIV_DEBUG */
64 #define dfield_get_type(field) (&(field)->type)
65 #define dfield_get_data(field) ((field)->data)
66 #endif /* UNIV_DEBUG */
67 
68 /** Sets the type struct of SQL data field.
69 @param[in] field SQL data field
70 @param[in] type pointer to data type struct */
71 UNIV_INLINE
72 void dfield_set_type(dfield_t *field, const dtype_t *type);
73 
74 /** Gets length of field data.
75  @return length of data; UNIV_SQL_NULL if SQL null data */
76 UNIV_INLINE
77 ulint dfield_get_len(const dfield_t *field) /*!< in: field */
78  MY_ATTRIBUTE((warn_unused_result));
79 
80 /** Sets length in a field.
81 @param[in] field field
82 @param[in] len length or UNIV_SQL_NULL */
83 UNIV_INLINE
84 void dfield_set_len(dfield_t *field, ulint len);
85 
86 /** Determines if a field is SQL NULL
87  @return nonzero if SQL null data */
88 UNIV_INLINE
89 ulint dfield_is_null(const dfield_t *field) /*!< in: field */
90  MY_ATTRIBUTE((warn_unused_result));
91 /** Determines if a field is externally stored
92  @return nonzero if externally stored */
93 UNIV_INLINE
94 ulint dfield_is_ext(const dfield_t *field) /*!< in: field */
95  MY_ATTRIBUTE((warn_unused_result));
96 /** Sets the "external storage" flag */
97 UNIV_INLINE
98 void dfield_set_ext(dfield_t *field); /*!< in/out: field */
99 
100 /** Gets spatial status for "external storage"
101 @param[in,out] field field */
102 UNIV_INLINE
104 
105 /** Sets spatial status for "external storage"
106 @param[in,out] field field
107 @param[in] spatial_status spatial status */
108 UNIV_INLINE
110  spatial_status_t spatial_status);
111 
112 /** Sets pointer to the data and length in a field.
113 @param[in] field field
114 @param[in] data data
115 @param[in] len length or UNIV_SQL_NULL */
116 UNIV_INLINE
117 void dfield_set_data(dfield_t *field, const void *data, ulint len);
118 
119 /** Sets pointer to the data and length in a field.
120 @param[in] field field
121 @param[in] mbr data */
122 UNIV_INLINE
123 void dfield_write_mbr(dfield_t *field, const double *mbr);
124 
125 /** Sets a data field to SQL NULL. */
126 UNIV_INLINE
127 void dfield_set_null(dfield_t *field); /*!< in/out: field */
128 
129 /** Writes an SQL null field full of zeros.
130 @param[in] data pointer to a buffer of size len
131 @param[in] len SQL null size in bytes */
132 UNIV_INLINE
133 void data_write_sql_null(byte *data, ulint len);
134 
135 /** Copies the data and len fields.
136 @param[out] field1 field to copy to
137 @param[in] field2 field to copy from */
138 UNIV_INLINE
139 void dfield_copy_data(dfield_t *field1, const dfield_t *field2);
140 
141 /** Copies a data field to another.
142 @param[out] field1 field to copy to
143 @param[in] field2 field to copy from */
144 UNIV_INLINE
145 void dfield_copy(dfield_t *field1, const dfield_t *field2);
146 
147 /** Copies the data pointed to by a data field.
148 @param[in,out] field data field
149 @param[in] heap memory heap where allocated */
150 UNIV_INLINE
151 void dfield_dup(dfield_t *field, mem_heap_t *heap);
152 
153 /** Copies the data pointed to by a data field.
154 This function works for multi-value fields only.
155 @param[in,out] field data field
156 @param[in] heap memory heap where allocated */
157 UNIV_INLINE
159 
160 /** Determine if a field is of multi-value type
161 @param[in] field data field
162 @return true if multi-value type field, otherwise false */
163 UNIV_INLINE
164 bool dfield_is_multi_value(const dfield_t *field);
165 
166 /** Tests if two data fields are equal.
167 If len==0, tests the data length and content for equality.
168 If len>0, tests the first len bytes of the content for equality.
169 @param[in] field1 first field to compare
170 @param[in] field2 second field to compare
171 @param[in] len maximum prefix to compare,
172  or 0 to compare the whole field length.
173  This works only if !multi_val
174 @return true if both fields are NULL or if they are equal */
175 inline bool dfield_datas_are_binary_equal(const dfield_t *field1,
176  const dfield_t *field2, ulint len)
177  MY_ATTRIBUTE((warn_unused_result));
178 /** Tests if dfield data length and content is equal to the given.
179  @return true if equal */
180 UNIV_INLINE
182  const dfield_t *field, /*!< in: field */
183  ulint len, /*!< in: data length or UNIV_SQL_NULL */
184  const byte *data) /*!< in: data */
185  MY_ATTRIBUTE((warn_unused_result));
186 /** Gets number of fields in a data tuple.
187  @return number of fields */
188 UNIV_INLINE
189 ulint dtuple_get_n_fields(const dtuple_t *tuple) /*!< in: tuple */
190  MY_ATTRIBUTE((warn_unused_result));
191 
192 /** Gets number of virtual fields in a data tuple.
193 @param[in] tuple dtuple to check
194 @return number of fields */
195 UNIV_INLINE
196 ulint dtuple_get_n_v_fields(const dtuple_t *tuple);
197 
198 #ifdef UNIV_DEBUG
199 /** Gets nth field of a tuple.
200 @param[in] tuple tuple
201 @param[in] n index of field
202 @return nth field */
203 UNIV_INLINE
204 dfield_t *dtuple_get_nth_field(const dtuple_t *tuple, ulint n);
205 
206 /** Gets nth virtual field of a tuple.
207 @param[in] tuple tuple
208 @param[in] n the nth field to get
209 @return nth field */
210 UNIV_INLINE
211 dfield_t *dtuple_get_nth_v_field(const dtuple_t *tuple, ulint n);
212 
213 #else /* UNIV_DEBUG */
214 #define dtuple_get_nth_field(tuple, n) ((tuple)->fields + (n))
215 #define dtuple_get_nth_v_field(tuple, n) \
216  ((tuple)->fields + (tuple)->n_fields + (n))
217 #endif /* UNIV_DEBUG */
218 /** Gets info bits in a data tuple.
219  @return info bits */
220 UNIV_INLINE
221 ulint dtuple_get_info_bits(const dtuple_t *tuple) /*!< in: tuple */
222  MY_ATTRIBUTE((warn_unused_result));
223 
224 /** Sets info bits in a data tuple.
225 @param[in] tuple tuple
226 @param[in] info_bits info bits */
227 UNIV_INLINE
228 void dtuple_set_info_bits(dtuple_t *tuple, ulint info_bits);
229 
230 /** Gets number of fields used in record comparisons.
231  @return number of fields used in comparisons in rem0cmp.* */
232 UNIV_INLINE
233 ulint dtuple_get_n_fields_cmp(const dtuple_t *tuple) /*!< in: tuple */
234  MY_ATTRIBUTE((warn_unused_result));
235 
236 /** Gets number of fields used in record comparisons.
237 @param[in] tuple tuple
238 @param[in] n_fields_cmp number of fields used in comparisons in
239  rem0cmp */
240 UNIV_INLINE
241 void dtuple_set_n_fields_cmp(dtuple_t *tuple, ulint n_fields_cmp);
242 
243 /* Estimate the number of bytes that are going to be allocated when
244 creating a new dtuple_t object */
245 #define DTUPLE_EST_ALLOC(n_fields) \
246  (sizeof(dtuple_t) + (n_fields) * sizeof(dfield_t))
247 
248 /** Creates a data tuple from an already allocated chunk of memory.
249  The size of the chunk must be at least DTUPLE_EST_ALLOC(n_fields).
250  The default value for number of fields used in record comparisons
251  for this tuple is n_fields.
252  @param[in,out] buf buffer to use
253  @param[in] buf_size buffer size
254  @param[in] n_fields number of field
255  @param[in] n_v_fields number of fields on virtual columns
256  @return created tuple (inside buf) */
257 UNIV_INLINE
258 dtuple_t *dtuple_create_from_mem(void *buf, ulint buf_size, ulint n_fields,
259  ulint n_v_fields)
260  MY_ATTRIBUTE((warn_unused_result));
261 /** Creates a data tuple to a memory heap. The default value for number
262  of fields used in record comparisons for this tuple is n_fields.
263  @return own: created tuple */
264 UNIV_INLINE
266  mem_heap_t *heap, /*!< in: memory heap where the tuple
267  is created, DTUPLE_EST_ALLOC(n_fields)
268  bytes will be allocated from this heap */
269  ulint n_fields) /*!< in: number of fields */
270  MY_ATTRIBUTE((malloc));
271 
272 /** Initialize the virtual field data in a dtuple_t
273 @param[in,out] vrow dtuple contains the virtual fields */
274 UNIV_INLINE
275 void dtuple_init_v_fld(const dtuple_t *vrow);
276 
277 /** Duplicate the virtual field data in a dtuple_t
278 @param[in,out] vrow dtuple contains the virtual fields
279 @param[in] heap heap memory to use */
280 UNIV_INLINE
281 void dtuple_dup_v_fld(const dtuple_t *vrow, mem_heap_t *heap);
282 
283 /** Creates a data tuple with possible virtual columns to a memory heap.
284 @param[in] heap memory heap where the tuple is created
285 @param[in] n_fields number of fields
286 @param[in] n_v_fields number of fields on virtual col
287 @return own: created tuple */
288 UNIV_INLINE
290  ulint n_v_fields);
291 /** Sets number of fields used in a tuple. Normally this is set in
292 dtuple_create, but if you want later to set it smaller, you can use this.
293 @param[in] tuple Tuple.
294 @param[in] n_fields Number of fields. */
295 void dtuple_set_n_fields(dtuple_t *tuple, ulint n_fields);
296 
297 /** Copies a data tuple's virtaul fields to another. This is a shallow copy;
298 @param[in,out] d_tuple destination tuple
299 @param[in] s_tuple source tuple */
300 UNIV_INLINE
301 void dtuple_copy_v_fields(dtuple_t *d_tuple, const dtuple_t *s_tuple);
302 /** Copies a data tuple to another. This is a shallow copy; if a deep copy
303  is desired, dfield_dup() will have to be invoked on each field.
304  @return own: copy of tuple */
305 UNIV_INLINE
306 dtuple_t *dtuple_copy(const dtuple_t *tuple, /*!< in: tuple to copy from */
307  mem_heap_t *heap) /*!< in: memory heap
308  where the tuple is created */
309  MY_ATTRIBUTE((malloc));
310 
311 /** The following function returns the sum of data lengths of a tuple. The space
312 occupied by the field structs or the tuple struct is not counted.
313 @param[in] tuple typed data tuple
314 @param[in] comp nonzero=ROW_FORMAT=COMPACT
315 @return sum of data lens */
316 UNIV_INLINE
317 ulint dtuple_get_data_size(const dtuple_t *tuple, ulint comp);
318 /** Computes the number of externally stored fields in a data tuple.
319  @return number of fields */
320 UNIV_INLINE
321 ulint dtuple_get_n_ext(const dtuple_t *tuple); /*!< in: tuple */
322 /** Compare two data tuples.
323 @param[in] tuple1 first data tuple
324 @param[in] tuple2 second data tuple
325 @return whether tuple1==tuple2 */
326 bool dtuple_coll_eq(const dtuple_t *tuple1, const dtuple_t *tuple2)
327  MY_ATTRIBUTE((warn_unused_result));
328 
329 /** Compute a hash value of a prefix of an index record.
330 @param[in] tuple index record
331 @param[in] n_fields number of fields to include
332 @param[in] n_bytes number of bytes to fold in the last field
333 @param[in] fold fold value of the index identifier
334 @return the folded value */
335 UNIV_INLINE
336 ulint dtuple_fold(const dtuple_t *tuple, ulint n_fields, ulint n_bytes,
337  ulint fold) MY_ATTRIBUTE((warn_unused_result));
338 
339 /** Sets types of fields binary in a tuple.
340 @param[in] tuple data tuple
341 @param[in] n number of fields to set */
342 UNIV_INLINE
343 void dtuple_set_types_binary(dtuple_t *tuple, ulint n);
344 
345 /** Checks if a dtuple contains an SQL null value.
346  @return true if some field is SQL null */
347 UNIV_INLINE
348 bool dtuple_contains_null(const dtuple_t *tuple) /*!< in: dtuple */
349  MY_ATTRIBUTE((warn_unused_result));
350 /** Checks that a data field is typed. Asserts an error if not.
351  @return true if ok */
352 bool dfield_check_typed(const dfield_t *field) /*!< in: data field */
353  MY_ATTRIBUTE((warn_unused_result));
354 /** Checks that a data tuple is typed. Asserts an error if not.
355  @return true if ok */
356 bool dtuple_check_typed(const dtuple_t *tuple) /*!< in: tuple */
357  MY_ATTRIBUTE((warn_unused_result));
358 #ifdef UNIV_DEBUG
359 /** Validates the consistency of a tuple which must be complete, i.e,
360  all fields must have been set.
361  @return true if ok */
362 bool dtuple_validate(const dtuple_t *tuple) /*!< in: tuple */
363  MY_ATTRIBUTE((warn_unused_result));
364 #endif /* UNIV_DEBUG */
365 /** Pretty prints a dfield value according to its data type. Also the hex string
366  is printed if a string contains non-printable characters. */
367 void dfield_print_also_hex(const dfield_t *dfield); /*!< in: dfield */
368 
369 /** The following function prints the contents of a tuple.
370 @param[in,out] f Output stream.
371 @param[in] tuple Tuple to print. */
372 void dtuple_print(FILE *f, const dtuple_t *tuple);
373 
374 /** Print the contents of a tuple.
375 @param[out] o output stream
376 @param[in] field array of data fields
377 @param[in] n number of data fields */
378 void dfield_print(std::ostream &o, const dfield_t *field, ulint n);
379 
380 /** Print the contents of a tuple.
381 @param[out] o output stream
382 @param[in] tuple data tuple */
383 void dtuple_print(std::ostream &o, const dtuple_t *tuple);
384 
385 /** Print the contents of a tuple.
386 @param[out] o output stream
387 @param[in] tuple data tuple */
388 inline std::ostream &operator<<(std::ostream &o, const dtuple_t &tuple) {
389  dtuple_print(o, &tuple);
390  return (o);
391 }
392 
393 /** Moves parts of long fields in entry to the big record vector so that
394 the size of tuple drops below the maximum record size allowed in the
395 database. Moves data only from those fields which are not necessary
396 to determine uniquely the insertion place of the tuple in the index.
397 @param[in,out] index Index that owns the record.
398 @param[in,out] upd Update vector.
399 @param[in,out] entry Index entry.
400 @param[in,out] n_ext Number of externally stored columns.
401 @return own: created big record vector, NULL if we are not able to
402 shorten the entry enough, i.e., if there are too many fixed-length or
403 short fields in entry or the index is clustered */
405  dtuple_t *entry, ulint *n_ext)
406  MY_ATTRIBUTE((malloc, warn_unused_result));
407 
408 /** Puts back to entry the data stored in vector. Note that to ensure the
409 fields in entry can accommodate the data, vector must have been created
410 from entry with dtuple_convert_big_rec.
411 @param[in] entry Entry whose data was put to vector.
412 @param[in] vector Big rec vector; it is freed in this function*/
414 
415 /** Frees the memory in a big rec vector. */
416 UNIV_INLINE
417 void dtuple_big_rec_free(big_rec_t *vector); /*!< in, own: big rec vector; it is
418  freed in this function */
419 
420 /*######################################################################*/
421 
422 /** Structure to hold number of multiple values */
424  public:
425  /** points to different value */
426  const void **datap;
427 
428  /** each individual value length */
429  uint32_t *data_len;
430 
431  /** convert buffer if the data is an integer */
432  uint64_t *conv_buf;
433 
434  /** number of values */
435  uint32_t num_v;
436 
437  /** number of pointers allocated */
438  uint32_t num_alc;
439 
440  /** Bitset to indicate which data should be handled for current data
441  array. This is mainly used for UPDATE case. UPDATE may not need
442  to delete all old values and insert all new values because there could
443  be some same values in both old and new data array.
444  If current data array is for INSERT and DELETE, this can(should) be
445  nullptr since all values in current array should be handled in these
446  two cases. */
448 
449  /** Allocate specified number of elements for all arrays and initialize
450  the structure accordingly
451  @param[in] num number of elements to allocate
452  @param[in] bitset true if memory for bitset should be
453  allocated too
454  @param[in,out] heap memory heap */
455  void alloc(uint32_t num, bool bitset, mem_heap_t *heap);
456 
457  /** Allocate the bitset for current data array
458  @param[in,out] heap memory heap
459  @param[in] size size of the bitset, if 0 or default,
460  the size would be num_v */
461  void alloc_bitset(mem_heap_t *heap, uint32_t size = 0);
462 
463  /** Check if two multi_value_data are equal or not, regardless of bitset
464  @param[in] multi_value Another multi-value data to be compared
465  @return true if two data structures are equal, otherwise false */
466  bool equal(const multi_value_data *multi_value) const {
467  if (num_v != multi_value->num_v) {
468  return (false);
469  }
470 
471  for (uint32_t i = 0; i < num_v; ++i) {
472  if (data_len[i] != multi_value->data_len[i] ||
473  memcmp(datap[i], multi_value->datap[i], data_len[i]) != 0) {
474  return (false);
475  }
476  }
477 
478  return (true);
479  }
480 
481  /** Copy a multi_value_data structure
482  @param[in] multi_value multi_value structure to copy from
483  @param[in,out] heap memory heap */
484  void copy(const multi_value_data *multi_value, mem_heap_t *heap) {
485  if (num_alc < multi_value->num_v) {
486  alloc(multi_value->num_v, (multi_value->bitset != nullptr), heap);
487  }
488 
489  copy_low(multi_value, heap);
490  }
491 
492  /** Compare and check if one value from dfield_t is in current data set.
493  Any caller calls this function to check if one field from clustered index
494  is equal to a record on multi-value index should understand that this
495  function can only be used for equality comparison, rather than order
496  comparison
497  @param[in] type type of the data
498  @param[in] data data value to compare
499  @param[in] len length of data
500  @return true if the value exists in current data set, otherwise false */
501  bool has(const dtype_t *type, const byte *data, uint64_t len) const;
502 
503  /** Compare and check if one value from dfield_t is in current data set.
504  Any caller calls this function to check if one field from clustered index
505  is equal to a record on multi-value index should understand that this
506  function can only be used for equality comparison, rather than order
507  comparison
508  @param[in] mtype mtype of data
509  @param[in] prtype prtype of data
510  @param[in] data data value to compare
511  @param[in] len length of data
512  @return true if the value exists in current data set, otherwise false */
513  bool has(ulint mtype, ulint prtype, const byte *data, uint64_t len) const;
514 
515 #ifdef UNIV_DEBUG
516  /* Check if there is any duplicate data in this array.
517  It is safe to assume all the data has been sorted.
518  @return true if duplicate data found, otherwise false */
519  bool duplicate() const {
520  /* Since the array is guaranteed to be sorted, so it is fine to
521  scan it sequentially and only compare current one with previous one
522  if exists. */
523  if (num_v > 1) {
524  for (uint32_t i = 1; i < num_v; ++i) {
525  if (data_len[i] == data_len[i - 1] &&
526  memcmp(datap[i], datap[i - 1], data_len[i]) == 0) {
527  return (true);
528  }
529  }
530  }
531  return (false);
532  }
533 #endif /* UNIV_DEBUG */
534 
535  private:
536  /** Copy a multi_value_data structure, current one should be bigger
537  or equal to the one to be copied
538  @param[in] multi_value multi_value structure to copy from
539  @param[in,out] heap memory heap */
540  void copy_low(const multi_value_data *multi_value, mem_heap_t *heap) {
541  ut_ad(num_alc >= multi_value->num_v);
542  for (uint32_t i = 0; i < multi_value->num_v; ++i) {
543  datap[i] =
544  mem_heap_dup(heap, multi_value->datap[i], multi_value->data_len[i]);
545  }
546  memcpy(data_len, multi_value->data_len,
547  sizeof(*data_len) * multi_value->num_v);
548  memcpy(conv_buf, multi_value->conv_buf,
549  sizeof(*conv_buf) * multi_value->num_v);
550  if (multi_value->bitset != nullptr) {
551  ut_ad(bitset != nullptr);
552  *bitset = *multi_value->bitset;
553  }
554  num_v = multi_value->num_v;
555  }
556 
557  public:
558  /** default number of multiple values */
559  static constexpr uint32_t s_default_allocate_num = 24;
560 };
561 
562 /** Class to log the multi-value data and read it from the log */
564  public:
565  /** Constructor
566  @param[in] mv_data multi-value data structure to log
567  @param[in] field_len multi-value data field length */
568  Multi_value_logger(const multi_value_data *mv_data, uint32_t field_len)
569  : m_mv_data(mv_data), m_field_len(field_len) {}
570 
571  /** Get the log length for the multi-value data
572  @param[in] precise true if precise length is needed, false if rough
573  estimation is OK
574  @return the total log length for the multi-value data */
575  uint32_t get_log_len(bool precise) const;
576 
577  /** Log the multi-value data to specified memory
578  @param[in,out] ptr the memory to write
579  @return next to the end of the multi-value data log */
580  byte *log(byte **ptr);
581 
582  /** Read the log length for the multi-value data log starting from ptr
583  @param[in] ptr log starting from here
584  @return the length of this log */
585  static uint32_t read_log_len(const byte *ptr);
586 
587  /** Read the multi-value data from the ptr
588  @param[in] ptr log starting from here
589  @param[in,out] field multi-value data field to store the array
590  @param[in,out] heap memory heap
591  @return next to the end of the multi-value data log */
592  static const byte *read(const byte *ptr, dfield_t *field, mem_heap_t *heap);
593 
594  /** Estimate how many multi-value keys at most can be accomodated into the
595  log of specified size.
596  @param[in] log_size max log size
597  @param[in] key_length max multi-value key length, charset considered
598  @param[out] num_keys max possible number of multi-value keys
599  @return the total size of the keys, let's assume all keys are concatenated
600  one by one compactly */
601  static uint32_t get_keys_capacity(uint32_t log_size, uint32_t key_length,
602  uint32_t *num_keys);
603 
604  /** Determine if the log starting from ptr is for multi-value data
605  @return true if it is for multi-value data, otherwise false */
606  static bool is_multi_value_log(const byte *ptr) {
608  }
609 
610  private:
611  /** Multi-value data */
613 
614  /** Multi-value field length */
615  uint32_t m_field_len;
616 
617  /** Length of log for NULL value or no indexed value cases */
618  static constexpr uint32_t s_log_length_for_null_or_empty = 2;
619 
620  /** Multi-value virtual column length marker. With this length marker,
621  a multi-value virtual column undo log can be identified. Meanwhile, this
622  marker should/will not conflict with any normal compressed written length
623  leading byte */
624  static constexpr uint8_t s_multi_value_virtual_col_length_marker = 0xFF;
625 
626  /** Multi-value virtual column length, which indicates that there is
627  no value on the multi-value index. It's mapped to UNIV_NO_INDEX_VALUE */
628  static constexpr uint16_t s_multi_value_no_index_value = 0x0;
629 
630  /** Multi-value virtual column length, which indicates that the field
631  is NULL. It's mapped to UNIV_SQL_NULL. Since any not NULL and not no value
632  multi-value data must be longer than 1 byte, so this is safe for this
633  special meaning */
634  static constexpr uint16_t s_multi_value_null = 0x1;
635 
636  /** The compressed length for multi-value key length logging.
637  This would not be longer than 2 bytes for now, while 2 bytes can
638  actually support key length of 16384 bytes. And the actual key
639  length would never be longer than this */
640  static constexpr uint8_t s_max_compressed_mv_key_length_size = 2;
641 };
642 
643 /** Structure for an SQL data field */
644 struct dfield_t {
645  void *data; /*!< pointer to data */
646  unsigned ext : 1; /*!< TRUE=externally stored, FALSE=local */
647  unsigned spatial_status : 2;
648  /*!< spatial status of externally stored field
649  in undo log for purge */
650  unsigned len; /*!< data length; UNIV_SQL_NULL if SQL null */
651  dtype_t type; /*!< type of data */
652 
653  bool is_virtual() const { return (type.is_virtual()); }
654 
655  void reset() {
656  data = nullptr;
657  ext = FALSE;
659  }
660 
661  /** Create a deep copy of this object
662  @param[in] heap the memory heap in which the clone will be
663  created.
664  @return the cloned object. */
665  dfield_t *clone(mem_heap_t *heap);
666 
667  byte *blobref() const;
668 
669  /** Obtain the LOB version number, if this is an externally
670  stored field. */
671  uint32_t lob_version() const;
672 
674  : data(nullptr), ext(0), spatial_status(0), len(0), type({0, 0, 0, 0}) {}
675 
676  /** Print the dfield_t object into the given output stream.
677  @param[in] out the output stream.
678  @return the ouput stream. */
679  std::ostream &print(std::ostream &out) const;
680 
681  /** Adjust and(or) set virtual column value which is read from undo
682  or online DDL log
683  @param[in] vcol virtual column definition
684  @param[in] comp true if compact format
685  @param[in] field virtual column value
686  @param[in] len value length
687  @param[in,out] heap memory heap to keep value when necessary */
688  void adjust_v_data_mysql(const dict_v_col_t *vcol, bool comp,
689  const byte *field, ulint len, mem_heap_t *heap);
690 };
691 
692 /** Compare a multi-value clustered index field with a secondary index
693 field, to see if they are equal. If the clustered index field is the
694 array, then equal means it contains the secondary index field
695 @param[in] clust_field clustered index field
696 @param[in] clust_len clustered index field length
697 @param[in] sec_field secondary index field
698 @param[in] sec_len secondary index field length
699 @param[in] col the column tied to this field
700 @return true if they are equal, otherwise false */
701 bool is_multi_value_clust_and_sec_equal(const byte *clust_field,
702  uint64_t clust_len,
703  const byte *sec_field, uint64_t sec_len,
704  const dict_col_t *col);
705 
706 /** Overloading the global output operator to easily print the given dfield_t
707 object into the given output stream.
708 @param[in] out the output stream
709 @param[in] obj the given object to print.
710 @return the output stream. */
711 inline std::ostream &operator<<(std::ostream &out, const dfield_t &obj) {
712  return (obj.print(out));
713 }
714 
715 /** Structure for an SQL data tuple of fields (logical record) */
716 struct dtuple_t {
717  /** info bits of an index record: the default is 0; this field is used if an
718  index record is built from a data tuple */
719  ulint info_bits;
720 
721  /** Number of fields in dtuple */
722  ulint n_fields;
723 
724  /** number of fields which should be used in comparison services of rem0cmp.*;
725  the index search is performed by comparing only these fields, others are
726  ignored; the default value in dtuple creation is the same value as n_fields */
728 
729  /** Fields. */
731 
732  /** Number of virtual fields. */
733  ulint n_v_fields;
734 
735  /** Fields on virtual column */
737 
738  /** Data tuples can be linked into a list using this field */
739  UT_LIST_NODE_T(dtuple_t) tuple_list;
740 #ifdef UNIV_DEBUG
741  /** memory heap where this tuple is allocated. */
743 
744  /** Magic number, used in debug assertions */
745  ulint magic_n;
746 
747 /** Value of dtuple_t::magic_n */
748 #define DATA_TUPLE_MAGIC_N 65478679
749 
750 #endif /* UNIV_DEBUG */
751 
752  /** Print the tuple to the output stream.
753  @param[in,out] out Stream to output to.
754  @return stream */
755  std::ostream &print(std::ostream &out) const {
756  dtuple_print(out, this);
757  return (out);
758  }
759 
760  /** Read the trx id from the tuple (DB_TRX_ID)
761  @return transaction id of the tuple. */
762  trx_id_t get_trx_id() const;
763 
764  /** Ignore at most n trailing default fields if this is a tuple
765  from instant index
766  @param[in] index clustered index object for this tuple */
768 
769  /** Compare a data tuple to a physical record.
770  @param[in] rec record
771  @param[in] index index
772  @param[in] offsets rec_get_offsets(rec)
773  @param[in,out] matched_fields number of completely matched fields
774  @return the comparison result of dtuple and rec
775  @retval 0 if dtuple is equal to rec
776  @retval negative if dtuple is less than rec
777  @retval positive if dtuple is greater than rec */
778  int compare(const rec_t *rec, const dict_index_t *index, const ulint *offsets,
779  ulint *matched_fields) const;
780 
781  /** Compare a data tuple to a physical record.
782  @param[in] rec record
783  @param[in] index index
784  @param[in] offsets rec_get_offsets(rec)
785  @return the comparison result of dtuple and rec
786  @retval 0 if dtuple is equal to rec
787  @retval negative if dtuple is less than rec
788  @retval positive if dtuple is greater than rec */
789  inline int compare(const rec_t *rec, const dict_index_t *index,
790  const ulint *offsets) const {
791  ulint matched_fields{};
792 
793  return (compare(rec, index, offsets, &matched_fields));
794  }
795 
796  /** Get number of externally stored fields.
797  @retval number of externally stored fields. */
798  inline ulint get_n_ext() const {
799  ulint n_ext = 0;
800  for (ulint i = 0; i < n_fields; ++i) {
801  if (dfield_is_ext(&fields[i])) {
802  n_ext++;
803  }
804  }
805  return (n_ext);
806  }
807 };
808 
809 /** A slot for a field in a big rec vector */
811  /** Constructor.
812  @param[in] field_no_ the field number
813  @param[in] len_ the data length
814  @param[in] data_ the data */
815  big_rec_field_t(ulint field_no_, ulint len_, void *data_)
816  : field_no(field_no_),
817  len(len_),
818  data(data_),
819  ext_in_old(false),
820  ext_in_new(false) {}
821 
822  byte *ptr() const { return (static_cast<byte *>(data)); }
823 
824  ulint field_no; /*!< field number in record */
825  ulint len; /*!< stored data length, in bytes */
826  void *data; /*!< stored data */
827 
828  /** If true, this field was stored externally in the old row.
829  If false, this field was stored inline in the old row.*/
831 
832  /** If true, this field is stored externally in the new row.
833  If false, this field is stored inline in the new row.*/
835 
836  /** Print the big_rec_field_t object into the given output stream.
837  @param[in] out the output stream.
838  @return the ouput stream. */
839  std::ostream &print(std::ostream &out) const;
840 };
841 
842 /** Overloading the global output operator to easily print the given
843 big_rec_field_t object into the given output stream.
844 @param[in] out the output stream
845 @param[in] obj the given object to print.
846 @return the output stream. */
847 inline std::ostream &operator<<(std::ostream &out, const big_rec_field_t &obj) {
848  return (obj.print(out));
849 }
850 
851 /** Storage format for overflow data in a big record, that is, a
852 clustered index record which needs external storage of data fields */
853 struct big_rec_t {
854  mem_heap_t *heap; /*!< memory heap from which
855  allocated */
856  const ulint capacity; /*!< fields array size */
857  ulint n_fields; /*!< number of stored fields */
858  big_rec_field_t *fields; /*!< stored fields */
859 
860  /** Constructor.
861  @param[in] max the capacity of the array of fields. */
862  explicit big_rec_t(const ulint max)
863  : heap(0), capacity(max), n_fields(0), fields(0) {}
864 
865  /** Append one big_rec_field_t object to the end of array of fields */
866  void append(const big_rec_field_t &field) {
868  fields[n_fields] = field;
869  n_fields++;
870  }
871 
872  /** Allocate a big_rec_t object in the given memory heap, and for
873  storing n_fld number of fields.
874  @param[in] heap memory heap in which this object is allocated
875  @param[in] n_fld maximum number of fields that can be stored in
876  this object
877  @return the allocated object */
878  static big_rec_t *alloc(mem_heap_t *heap, ulint n_fld);
879 
880  /** Print the current object into the given output stream.
881  @param[in] out the output stream.
882  @return the ouput stream. */
883  std::ostream &print(std::ostream &out) const;
884 };
885 
886 /** Overloading the global output operator to easily print the given
887 big_rec_t object into the given output stream.
888 @param[in] out the output stream
889 @param[in] obj the given object to print.
890 @return the output stream. */
891 inline std::ostream &operator<<(std::ostream &out, const big_rec_t &obj) {
892  return (obj.print(out));
893 }
894 
895 #include "data0data.ic"
896 
897 #endif
big_rec_field_t::ext_in_old
bool ext_in_old
If true, this field was stored externally in the old row.
Definition: data0data.h:830
dfield_t::data
void * data
pointer to data
Definition: data0data.h:645
upd_t::heap
mem_heap_t * heap
heap from which memory allocated
Definition: row0upd.h:571
dtuple_t
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:716
mem0mem.h
big_rec_t::append
void append(const big_rec_field_t &field)
Append one big_rec_field_t object to the end of array of fields.
Definition: data0data.h:866
dtuple_set_n_fields
void dtuple_set_n_fields(dtuple_t *tuple, ulint n_fields)
Sets number of fields used in a tuple.
Definition: data0data.cc:95
mem_heap_dup
void * mem_heap_dup(mem_heap_t *heap, const void *data, ulint len)
Duplicate a block of data, allocated from a memory heap.
Definition: memory.cc:56
dfield_print
void dfield_print(std::ostream &o, const dfield_t *field, ulint n)
Print the contents of a tuple.
Definition: data0data.cc:384
dict0types.h
dtuple_dup_v_fld
UNIV_INLINE void dtuple_dup_v_fld(const dtuple_t *vrow, mem_heap_t *heap)
Duplicate the virtual field data in a dtuple_t.
spatial_status_t
spatial_status_t
whether a col is used in spatial index or regular index Note: the spatial status is part of persisten...
Definition: dict0types.h:330
trx_id_t
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:148
multi_value_data::has
bool has(const dtype_t *type, const byte *data, uint64_t len) const
Compare and check if one value from dfield_t is in current data set.
Definition: data0data.cc:837
dfield_t::lob_version
uint32_t lob_version() const
Obtain the LOB version number, if this is an externally stored field.
Definition: data0data.cc:684
ut_ad
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:65
dtuple_get_n_v_fields
UNIV_INLINE ulint dtuple_get_n_v_fields(const dtuple_t *tuple)
Gets number of virtual fields in a data tuple.
dtuple_convert_back_big_rec
void dtuple_convert_back_big_rec(dtuple_t *entry, big_rec_t *vector)
Puts back to entry the data stored in vector.
Definition: data0data.cc:617
dict_index_t
Data structure for an index.
Definition: dict0mem.h:869
dtuple_t::m_heap
mem_heap_t * m_heap
memory heap where this tuple is allocated.
Definition: data0data.h:742
dtuple_convert_big_rec
big_rec_t * dtuple_convert_big_rec(dict_index_t *index, upd_t *upd, dtuple_t *entry, ulint *n_ext)
Moves parts of long fields in entry to the big record vector so that the size of tuple drops below th...
Definition: data0data.cc:421
dfield_get_data
UNIV_INLINE void * dfield_get_data(const dfield_t *field)
Gets pointer to the data in a field.
operator<<
std::ostream & operator<<(std::ostream &o, const dtuple_t &tuple)
Print the contents of a tuple.
Definition: data0data.h:388
dfield_write_mbr
UNIV_INLINE void dfield_write_mbr(dfield_t *field, const double *mbr)
Sets pointer to the data and length in a field.
dtuple_validate
bool dtuple_validate(const dtuple_t *tuple)
Validates the consistency of a tuple which must be complete, i.e, all fields must have been set.
Definition: data0data.cc:170
dfield_multi_value_dup
UNIV_INLINE void dfield_multi_value_dup(dfield_t *field, mem_heap_t *heap)
Copies the data pointed to by a data field.
big_rec_field_t::data
void * data
stored data
Definition: data0data.h:826
dfield_copy_data
UNIV_INLINE void dfield_copy_data(dfield_t *field1, const dfield_t *field2)
Copies the data and len fields.
Multi_value_logger::read_log_len
static uint32_t read_log_len(const byte *ptr)
Read the log length for the multi-value data log starting from ptr.
Definition: data0data.cc:961
FALSE
#define FALSE
Definition: types.h:47
dfield_t::dfield_t
dfield_t()
Definition: data0data.h:673
big_rec_t::print
std::ostream & print(std::ostream &out) const
Print the current object into the given output stream.
Definition: data0data.cc:767
Multi_value_logger::Multi_value_logger
Multi_value_logger(const multi_value_data *mv_data, uint32_t field_len)
Constructor.
Definition: data0data.h:568
dict_v_col_t
Data structure for a virtual column in a table.
Definition: dict0mem.h:632
dtuple_check_typed
bool dtuple_check_typed(const dtuple_t *tuple)
Checks that a data tuple is typed.
Definition: data0data.cc:157
dtype_t::is_virtual
bool is_virtual() const
Definition: data0type.h:497
Multi_value_logger::read
static const byte * read(const byte *ptr, dfield_t *field, mem_heap_t *heap)
Read the multi-value data from the ptr.
Definition: data0data.cc:974
Multi_value_logger::m_mv_data
const multi_value_data * m_mv_data
Multi-value data.
Definition: data0data.h:612
dtuple_set_info_bits
UNIV_INLINE void dtuple_set_info_bits(dtuple_t *tuple, ulint info_bits)
Sets info bits in a data tuple.
dtuple_t::magic_n
ulint magic_n
Magic number, used in debug assertions.
Definition: data0data.h:745
Multi_value_logger::log
byte * log(byte **ptr)
Log the multi-value data to specified memory.
Definition: data0data.cc:921
big_rec_t::big_rec_t
big_rec_t(const ulint max)
Constructor.
Definition: data0data.h:862
dfield_dup
UNIV_INLINE void dfield_dup(dfield_t *field, mem_heap_t *heap)
Copies the data pointed to by a data field.
dtuple_t::compare
int compare(const rec_t *rec, const dict_index_t *index, const ulint *offsets, ulint *matched_fields) const
Compare a data tuple to a physical record.
Definition: rem0cmp.cc:1128
dtuple_init_v_fld
UNIV_INLINE void dtuple_init_v_fld(const dtuple_t *vrow)
Initialize the virtual field data in a dtuple_t.
dtuple_copy_v_fields
UNIV_INLINE void dtuple_copy_v_fields(dtuple_t *d_tuple, const dtuple_t *s_tuple)
Copies a data tuple's virtaul fields to another.
is_multi_value_clust_and_sec_equal
bool is_multi_value_clust_and_sec_equal(const byte *clust_field, uint64_t clust_len, const byte *sec_field, uint64_t sec_len, const dict_col_t *col)
Compare a multi-value clustered index field with a secondary index field, to see if they are equal.
Definition: data0data.cc:819
dtuple_print
void dtuple_print(FILE *f, const dtuple_t *tuple)
The following function prints the contents of a tuple.
Definition: data0data.cc:367
multi_value_data::duplicate
bool duplicate() const
Definition: data0data.h:519
rec_t
byte rec_t
Definition: rem0types.h:39
big_rec_t
Storage format for overflow data in a big record, that is, a clustered index record which needs exter...
Definition: data0data.h:853
dfield_is_ext
UNIV_INLINE ulint dfield_is_ext(const dfield_t *field)
Determines if a field is externally stored.
Multi_value_logger::s_multi_value_virtual_col_length_marker
static constexpr uint8_t s_multi_value_virtual_col_length_marker
Multi-value virtual column length marker.
Definition: data0data.h:624
mem_block_info_t
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:337
dfield_t::ext
unsigned ext
TRUE=externally stored, FALSE=local.
Definition: data0data.h:646
Multi_value_logger::s_log_length_for_null_or_empty
static constexpr uint32_t s_log_length_for_null_or_empty
Length of log for NULL value or no indexed value cases.
Definition: data0data.h:618
dtuple_t::print
std::ostream & print(std::ostream &out) const
Print the tuple to the output stream.
Definition: data0data.h:755
SPATIAL_UNKNOWN
@ SPATIAL_UNKNOWN
Definition: dict0types.h:332
malloc
#define malloc(A)
Definition: fts0ast.h:41
dtuple_big_rec_free
UNIV_INLINE void dtuple_big_rec_free(big_rec_t *vector)
Frees the memory in a big rec vector.
big_rec_field_t::len
ulint len
stored data length, in bytes
Definition: data0data.h:825
dfield_set_data
UNIV_INLINE void dfield_set_data(dfield_t *field, const void *data, ulint len)
Sets pointer to the data and length in a field.
dfield_get_spatial_status
UNIV_INLINE spatial_status_t dfield_get_spatial_status(const dfield_t *field)
Gets spatial status for "external storage".
multi_value_data::equal
bool equal(const multi_value_data *multi_value) const
Check if two multi_value_data are equal or not, regardless of bitset.
Definition: data0data.h:466
Multi_value_logger::m_field_len
uint32_t m_field_len
Multi-value field length.
Definition: data0data.h:615
dfield_copy
UNIV_INLINE void dfield_copy(dfield_t *field1, const dfield_t *field2)
Copies a data field to another.
dtuple_coll_eq
bool dtuple_coll_eq(const dtuple_t *tuple1, const dtuple_t *tuple2)
Compare two data tuples.
Definition: data0data.cc:60
dtuple_set_n_fields_cmp
UNIV_INLINE void dtuple_set_n_fields_cmp(dtuple_t *tuple, ulint n_fields_cmp)
Gets number of fields used in record comparisons.
dfield_t::blobref
byte * blobref() const
Definition: data0data.cc:678
dtuple_t::fields
dfield_t * fields
Fields.
Definition: data0data.h:730
multi_value_data::conv_buf
uint64_t * conv_buf
convert buffer if the data is an integer
Definition: data0data.h:432
dtuple_get_nth_v_field
UNIV_INLINE dfield_t * dtuple_get_nth_v_field(const dtuple_t *tuple, ulint n)
Gets nth virtual field of a tuple.
dfield_set_len
UNIV_INLINE void dfield_set_len(dfield_t *field, ulint len)
Sets length in a field.
multi_value_data::num_alc
uint32_t num_alc
number of pointers allocated
Definition: data0data.h:438
Multi_value_logger::get_log_len
uint32_t get_log_len(bool precise) const
Get the log length for the multi-value data.
Definition: data0data.cc:885
multi_value_data
Structure to hold number of multiple values.
Definition: data0data.h:423
dtuple_t::n_fields_cmp
ulint n_fields_cmp
number of fields which should be used in comparison services of rem0cmp.
Definition: data0data.h:727
Multi_value_logger::is_multi_value_log
static bool is_multi_value_log(const byte *ptr)
Determine if the log starting from ptr is for multi-value data.
Definition: data0data.h:606
Multi_value_logger
Class to log the multi-value data and read it from the log.
Definition: data0data.h:563
Multi_value_logger::get_keys_capacity
static uint32_t get_keys_capacity(uint32_t log_size, uint32_t key_length, uint32_t *num_keys)
Estimate how many multi-value keys at most can be accomodated into the log of specified size.
Definition: data0data.cc:1020
dtuple_t::compare
int compare(const rec_t *rec, const dict_index_t *index, const ulint *offsets) const
Compare a data tuple to a physical record.
Definition: data0data.h:789
big_rec_t::fields
big_rec_field_t * fields
stored fields
Definition: data0data.h:858
dtuple_create_with_vcol
UNIV_INLINE dtuple_t * dtuple_create_with_vcol(mem_heap_t *heap, ulint n_fields, ulint n_v_fields)
Creates a data tuple with possible virtual columns to a memory heap.
big_rec_t::n_fields
ulint n_fields
number of stored fields
Definition: data0data.h:857
dfield_t::is_virtual
bool is_virtual() const
Definition: data0data.h:653
dfield_t::print
std::ostream & print(std::ostream &out) const
Print the dfield_t object into the given output stream.
Definition: data0data.cc:744
dfield_data_is_binary_equal
UNIV_INLINE bool dfield_data_is_binary_equal(const dfield_t *field, ulint len, const byte *data)
Tests if dfield data length and content is equal to the given.
big_rec_t::alloc
static big_rec_t * alloc(mem_heap_t *heap, ulint n_fld)
Allocate a big_rec_t object in the given memory heap, and for storing n_fld number of fields.
Definition: data0data.cc:644
dfield_get_len
UNIV_INLINE ulint dfield_get_len(const dfield_t *field)
Gets length of field data.
dtuple_t::v_fields
dfield_t * v_fields
Fields on virtual column.
Definition: data0data.h:736
dtuple_set_types_binary
UNIV_INLINE void dtuple_set_types_binary(dtuple_t *tuple, ulint n)
Sets types of fields binary in a tuple.
dtuple_t::get_n_ext
ulint get_n_ext() const
Get number of externally stored fields.
Definition: data0data.h:798
trx0types.h
dfield_is_null
UNIV_INLINE ulint dfield_is_null(const dfield_t *field)
Determines if a field is SQL NULL.
Bitset
A simple bitset wrapper class, whose size can be specified after the object has been defined.
Definition: ut0bitset.h:38
big_rec_field_t::print
std::ostream & print(std::ostream &out) const
Print the big_rec_field_t object into the given output stream.
Definition: data0data.cc:760
dfield_t::len
unsigned len
data length; UNIV_SQL_NULL if SQL null
Definition: data0data.h:650
multi_value_data::alloc_bitset
void alloc_bitset(mem_heap_t *heap, uint32_t size=0)
Allocate the bitset for current data array.
Definition: data0data.cc:874
big_rec_field_t
A slot for a field in a big rec vector.
Definition: data0data.h:810
consts::FILE
const std::string FILE("FILE")
big_rec_t::capacity
const ulint capacity
fields array size
Definition: data0data.h:856
dfield_check_typed
bool dfield_check_typed(const dfield_t *field)
Checks that a data field is typed.
Definition: data0data.cc:146
big_rec_t::heap
mem_heap_t * heap
memory heap from which allocated
Definition: data0data.h:854
multi_value_data::num_v
uint32_t num_v
number of values
Definition: data0data.h:435
dtype_t
Definition: data0type.h:471
dtuple_get_n_fields
UNIV_INLINE ulint dtuple_get_n_fields(const dtuple_t *tuple)
Gets number of fields in a data tuple.
ut0bitset.h
dtuple_t::ignore_trailing_default
void ignore_trailing_default(const dict_index_t *index)
Ignore at most n trailing default fields if this is a tuple from instant index.
Definition: data0data.cc:792
multi_value_data::copy
void copy(const multi_value_data *multi_value, mem_heap_t *heap)
Copy a multi_value_data structure.
Definition: data0data.h:484
dtuple_get_info_bits
UNIV_INLINE ulint dtuple_get_info_bits(const dtuple_t *tuple)
Gets info bits in a data tuple.
dtuple_get_nth_field
UNIV_INLINE dfield_t * dtuple_get_nth_field(const dtuple_t *tuple, ulint n)
Gets nth field of a tuple.
ut::vector
std::vector< T, ut_allocator< T > > vector
Specialization of vector which uses ut_allocator.
Definition: ut0new.h:1279
multi_value_data::bitset
Bitset * bitset
Bitset to indicate which data should be handled for current data array.
Definition: data0data.h:447
big_rec_field_t::field_no
ulint field_no
field number in record
Definition: data0data.h:824
_entry
Definition: completion_hash.h:34
dtuple_t::UT_LIST_NODE_T
UT_LIST_NODE_T(dtuple_t) tuple_list
Data tuples can be linked into a list using this field.
multi_value_data::copy_low
void copy_low(const multi_value_data *multi_value, mem_heap_t *heap)
Copy a multi_value_data structure, current one should be bigger or equal to the one to be copied.
Definition: data0data.h:540
dtuple_copy
UNIV_INLINE dtuple_t * dtuple_copy(const dtuple_t *tuple, mem_heap_t *heap)
Copies a data tuple to another.
dfield_t::spatial_status
unsigned spatial_status
spatial status of externally stored field in undo log for purge
Definition: data0data.h:647
Multi_value_logger::s_multi_value_null
static constexpr uint16_t s_multi_value_null
Multi-value virtual column length, which indicates that the field is NULL.
Definition: data0data.h:634
HttpMethod::type
int type
Definition: http_common.h:411
dfield_t::type
dtype_t type
type of data
Definition: data0data.h:651
dtuple_t::get_trx_id
trx_id_t get_trx_id() const
Read the trx id from the tuple (DB_TRX_ID)
Definition: data0data.cc:778
big_rec_field_t::big_rec_field_t
big_rec_field_t(ulint field_no_, ulint len_, void *data_)
Constructor.
Definition: data0data.h:815
dtuple_t::n_v_fields
ulint n_v_fields
Number of virtual fields.
Definition: data0data.h:733
dfield_set_type
UNIV_INLINE void dfield_set_type(dfield_t *field, const dtype_t *type)
Sets the type struct of SQL data field.
dfield_set_ext
UNIV_INLINE void dfield_set_ext(dfield_t *field)
Sets the "external storage" flag.
upd_t
Definition: row0upd.h:570
dict_col_t
Data structure for a column in a table.
Definition: dict0mem.h:455
multi_value_data::data_len
uint32_t * data_len
each individual value length
Definition: data0data.h:429
dfield_t::reset
void reset()
Definition: data0data.h:655
dtuple_t::info_bits
ulint info_bits
info bits of an index record: the default is 0; this field is used if an index record is built from a...
Definition: data0data.h:719
data0types.h
big_rec_field_t::ext_in_new
bool ext_in_new
If true, this field is stored externally in the new row.
Definition: data0data.h:834
dfield_set_null
UNIV_INLINE void dfield_set_null(dfield_t *field)
Sets a data field to SQL NULL.
dtuple_create_from_mem
UNIV_INLINE dtuple_t * dtuple_create_from_mem(void *buf, ulint buf_size, ulint n_fields, ulint n_v_fields)
Creates a data tuple from an already allocated chunk of memory.
dfield_get_type
UNIV_INLINE dtype_t * dfield_get_type(const dfield_t *field)
Gets pointer to the type struct of SQL data field.
dtuple_get_data_size
UNIV_INLINE ulint dtuple_get_data_size(const dtuple_t *tuple, ulint comp)
The following function returns the sum of data lengths of a tuple.
dtuple_get_n_fields_cmp
UNIV_INLINE ulint dtuple_get_n_fields_cmp(const dtuple_t *tuple)
Gets number of fields used in record comparisons.
dfield_is_multi_value
UNIV_INLINE bool dfield_is_multi_value(const dfield_t *field)
Determine if a field is of multi-value type.
multi_value_data::alloc
void alloc(uint32_t num, bool bitset, mem_heap_t *heap)
Allocate specified number of elements for all arrays and initialize the structure accordingly.
Definition: data0data.cc:857
n
int n
Definition: xcom_base.c:425
dtuple_get_n_ext
UNIV_INLINE ulint dtuple_get_n_ext(const dtuple_t *tuple)
Computes the number of externally stored fields in a data tuple.
dtuple_create
UNIV_INLINE dtuple_t * dtuple_create(mem_heap_t *heap, ulint n_fields)
Creates a data tuple to a memory heap.
dfield_t
Structure for an SQL data field.
Definition: data0data.h:644
big_rec_field_t::ptr
byte * ptr() const
Definition: data0data.h:822
data_write_sql_null
UNIV_INLINE void data_write_sql_null(byte *data, ulint len)
Writes an SQL null field full of zeros.
multi_value_data::s_default_allocate_num
static constexpr uint32_t s_default_allocate_num
default number of multiple values
Definition: data0data.h:559
dfield_print_also_hex
void dfield_print_also_hex(const dfield_t *dfield)
Pretty prints a dfield value according to its data type.
Definition: data0data.cc:203
Multi_value_logger::s_multi_value_no_index_value
static constexpr uint16_t s_multi_value_no_index_value
Multi-value virtual column length, which indicates that there is no value on the multi-value index.
Definition: data0data.h:628
dfield_t::clone
dfield_t * clone(mem_heap_t *heap)
Create a deep copy of this object.
Definition: data0data.cc:658
Multi_value_logger::s_max_compressed_mv_key_length_size
static constexpr uint8_t s_max_compressed_mv_key_length_size
The compressed length for multi-value key length logging.
Definition: data0data.h:640
dtuple_fold
UNIV_INLINE ulint dtuple_fold(const dtuple_t *tuple, ulint n_fields, ulint n_bytes, ulint fold)
Compute a hash value of a prefix of an index record.
dfield_set_spatial_status
UNIV_INLINE void dfield_set_spatial_status(dfield_t *field, spatial_status_t spatial_status)
Sets spatial status for "external storage".
dtuple_t::n_fields
ulint n_fields
Number of fields in dtuple.
Definition: data0data.h:722
index
char * index(const char *, int c)
Definition: mysql.cc:2875
upd_t::n_fields
ulint n_fields
number of update fields
Definition: row0upd.h:579
dfield_t::adjust_v_data_mysql
void adjust_v_data_mysql(const dict_v_col_t *vcol, bool comp, const byte *field, ulint len, mem_heap_t *heap)
Adjust and(or) set virtual column value which is read from undo or online DDL log.
Definition: data0data.cc:692
data0type.h
key_length
static uint key_length
Definition: mi_test1.cc:42
multi_value_data::datap
const void ** datap
points to different value
Definition: data0data.h:426
upd_t::info_bits
ulint info_bits
new value of info bits to record; default is 0
Definition: row0upd.h:572
dfield_datas_are_binary_equal
bool dfield_datas_are_binary_equal(const dfield_t *field1, const dfield_t *field2, ulint len)
Tests if two data fields are equal.
dtuple_contains_null
UNIV_INLINE bool dtuple_contains_null(const dtuple_t *tuple)
Checks if a dtuple contains an SQL null value.
false
#define false
Definition: config_static.h:43