MySQL 26.7.0
Source Code Documentation
bulk_data_service.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2026, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24/**
25 @file
26 Services for bulk data conversion and load to SE.
27*/
28
29#pragma once
30
31#include <assert.h>
33#include <stddef.h>
34#include <atomic>
35#include <cstdint>
36#include <cstring>
37#include <functional>
38#include <iomanip>
39#include <iostream>
40#include <limits>
41#include <memory>
42#include <mutex>
43#include <optional>
44#include <sstream>
45#include <string>
46#include <vector>
47#include "field_types.h"
49
50class THD;
51struct TABLE;
52struct CHARSET_INFO;
53using Blob_context = void *;
54
55/** The blob reference size. Refer to lob::ref_t::SIZE or FIELD_REF_SIZE. */
56constexpr size_t BLOB_REF_SIZE = 20;
57
59 std::string filename;
60 size_t row_number;
61 std::string column_name;
62 std::string column_type;
63 std::string column_input_data;
64 std::string m_error_mesg{};
65 std::string m_table_name{};
66 size_t m_bytes;
68
69 std::ostream &print(std::ostream &out) const;
70};
71
73 std::ostream &out) const {
74 out << "[Bulk_load_error_location_details: filename=" << filename
75 << ", column_name=" << column_name << "]";
76 return out;
77}
78
79/** Overloading the global output operator to print objects of type
80Bulk_load_error_location_details.
81@param[in] out output stream
82@param[in] obj object to be printed
83@return given output stream. */
84inline std::ostream &operator<<(std::ostream &out,
86 return obj.print(out);
87}
88
90 /** Column data. */
91 const char *m_data_ptr{};
92
93 /** Column data length. */
94 size_t m_data_len{};
95
96 /** Prefix length. */
97 size_t m_prefix_len{};
98
99 /** Check if it is DB_ROW_ID column based on the value it contains.
100 @return true if it is DB_ROW_ID column, false otherwise */
101 bool is_row_id() const { return m_row_id != UINT64_MAX; }
102
103 /** The generated DB_ROW_ID value */
104 uint64_t m_row_id{UINT64_MAX};
105
106 /** Mark the column to be null, by setting length to a special value. This is
107 only used for columns whose state is maintained across chunks
108 (aka fragmented columns). */
109 void set_null() {
110 assert(m_data_ptr == nullptr);
112 }
113
114 /** Check if the column is null, by checking special value for length.
115 @return true if the column is null, false otherwise. */
116 bool is_null() const {
118 m_data_ptr == nullptr);
120 }
121
122 /** Check if the column data is stored externally. If the data is stored
123 externally, then the column data contains the prefix and the blob reference
124 of the externally stored data.
125 @return true if data is stored externally, false otherwise. */
126 bool is_ext() const {
128 return m_is_ext;
129 }
130
131 /** Check if the column data is stored externally. It is called relaxed,
132 because the column length might not be equal to BLOB_REF_SIZE. Only to
133 be used while the blob is being processed by the CSV parser.
134 @return true if data is stored externally, false otherwise. */
135 bool is_ext_relaxed() const {
136 assert(!m_is_ext || m_data_len >= BLOB_REF_SIZE);
137 return m_is_ext;
138 }
139
140 /** Mark that the column data has been stored externally. */
141 void set_ext() {
143 m_is_ext = true;
144 }
145
146 /** Initialize the members */
147 void init() {
148 m_data_ptr = nullptr;
149 m_data_len = 0;
150 m_is_ext = false;
151 m_row_id = UINT64_MAX;
152 }
153
154 /** Print this object into the given output stream.
155 @param[in] out output stream into which this object will be printed.
156 @return given output stream */
157 std::ostream &print(std::ostream &out) const;
158
159 std::string to_string() const;
160
161 private:
162 /** If true, the column data is stored externally. */
163 bool m_is_ext{false};
164};
165
166inline std::string Column_text::to_string() const {
168 sout << "[Column_text: len=" << m_data_len;
169 sout << ", val=";
170
171 if (m_data_ptr == nullptr) {
172 sout << "nullptr";
173 } else {
174 for (size_t i = 0; i < m_data_len; ++i) {
175 const char c = m_data_ptr[i];
176 if (isalnum(c)) {
177 sout << c;
178 } else {
179 sout << ".";
180 }
181 }
182 sout << "[hex=";
183 for (size_t i = 0; i < m_data_len; ++i) {
184 sout << std::setfill('0') << std::setw(2) << std::hex
185 << (int)*(&m_data_ptr[i]);
186 }
187 }
188 sout << "]";
189 return sout.str();
190}
191
192inline std::ostream &Column_text::print(std::ostream &out) const {
193 out << "[Column_text: this=" << static_cast<const void *>(this)
194 << ", m_data_ptr=" << static_cast<const void *>(m_data_ptr)
195 << ", m_data_len=" << m_data_len << ", m_is_ext=" << m_is_ext << "]";
196 return out;
197}
198
199/** Overloading the global output operator to print objects of type
200Column_text.
201@param[in] out output stream
202@param[in] obj object to be printed
203@return given output stream. */
204inline std::ostream &operator<<(std::ostream &out, const Column_text &obj) {
205 return obj.print(out);
206}
207
208struct Row_meta;
209
211 /** Column Data Type */
212 int16_t m_type{};
213
214 /** Column data length. */
215 uint16_t m_data_len{};
216
217 bool m_is_prefix{false};
218
219 /** If column is NULL. */
220 bool m_is_null{false};
221
222 /** If true, the column data is stored externally in InnoDB. It also means
223 that the data contains blob reference of length BTR_EXTERN_FIELD_REF_SIZE
224 bytes at the end. */
225 bool m_is_ext{false};
226
227 /** Get the column data.
228 @return nullptr if column is null, otherwise pointer to the data. */
229 char *get_data() const { return m_is_null ? nullptr : m_data_ptr; }
230
231 /** Set the column data to the given pointer location.
232 @param[in] ptr pointer pointing to column data. */
233 void set_data(char *ptr) { m_data_ptr = ptr; }
234
235 /** Mark this column as externally stored. */
236 void set_ext() { m_is_ext = true; }
237
238 /** Check if the column is externally stored.
239 @return true if externally stored, false otherwise. */
240 bool is_ext() const { return m_is_ext; }
241
242 /** Save the beginning of the row pointer in this object. This should be
243 called only when the column is null.
244 @param[in] row_begin pointer to beginning of row.*/
245 void row(char *row_begin) {
246 assert(m_is_null);
247 m_data_len = 0;
248 m_data_ptr = row_begin;
249 }
250
251 /** Get the pointer to the beginning of row. This is valid only if the
252 column is null. This should be called on the first column of the row. There
253 is no need to call this on other columns.
254 @param[in] row_meta meta data information about the row
255 @param[in] col_index Index of the first column which is 0.
256 @return pointer to row beginning. */
257 char *get_row_begin(const Row_meta &row_meta,
258 size_t col_index [[maybe_unused]]) const;
259
260 /** Column data in integer format. Used only for specific datatype. */
261 uint64_t m_int_data;
262
263 void init() {
264 m_type = 0;
265 m_data_len = 0;
266 m_is_null = false;
267 m_data_ptr = nullptr;
268 m_int_data = 0;
269 }
270
271 std::string to_string() const;
272
273 private:
274 /** Column data or row begin. There is a need to fetch the beginning of
275 the row from the vector of Column_mysql. But in the case of secondary
276 indexes, all the keys could be null and it becomes impossible to obtain
277 the pointer to beginning of the row. To solve this problem, I am re-using
278 this pointer to hold the row begin when the column is null. So it becomes
279 important to make use of m_is_null to check if the column is null. It is NOT
280 correct to check this pointer against nullptr to confirm if column is null.*/
281 char *m_data_ptr{nullptr};
282};
283
284inline std::string Column_mysql::to_string() const {
286 sout << "[Column_mysql: type=" << m_type << ", len=" << m_data_len
287 << ", m_int_data=" << m_int_data;
288 sout << ", val=";
289
290 switch (m_type) {
291 case MYSQL_TYPE_LONG: {
292 sout << m_int_data;
293 } break;
294 default: {
295 for (size_t i = 0; i < m_data_len; ++i) {
296 const char c = m_data_ptr[i];
297 if (isalnum(c)) {
298 sout << c;
299 } else {
300 sout << ".";
301 }
302 }
303
304 } break;
305 }
306 if (m_type != MYSQL_TYPE_LONG) {
307 sout << "[hex=";
308 for (size_t i = 0; i < m_data_len; ++i) {
309 sout << std::setfill('0') << std::setw(2) << std::hex
310 << (int)*(&m_data_ptr[i]);
311 }
312 sout << "]";
313 }
314 return sout.str();
315}
316
317/** Implements the row and column memory management for parse and load
318operations. We try to pre-allocate the memory contiguously as much as we can
319to maximize the performance.
320
321@tparam Column_type Column_text when used in the CSV context, Column_sql when
322used in the InnoDB context.
323*/
324template <typename Column_type>
326 public:
327 /** Create a new row bunch.
328 @param[in] n_cols number of columns */
329 explicit Row_bunch(size_t n_cols) : m_num_columns(n_cols) {}
330
331 /** @return return number of rows in the bunch. */
332 size_t get_num_rows() const { return m_num_rows; }
333
334 /** @return return number of columns in each row. */
335 size_t get_num_cols() const { return m_num_columns; }
336
337 /** Process all columns, invoking callback for each.
338 @param[in] row_index index of the row
339 @param[in] cbk callback function
340 @return true if successful */
341 template <typename F>
342 bool process_columns(size_t row_index, F &&cbk) {
343 assert(row_index < m_num_rows);
344
345 auto row_offset = row_index * m_num_columns;
346 return process_columns_by_offset(row_offset, std::move(cbk));
347 }
348
349 template <typename F>
350 bool process_columns_by_offset(size_t row_offset, F &&cbk) {
351 assert(row_offset + m_num_columns <= m_columns.size());
352
353 for (size_t index = 0; index < m_num_columns; ++index) {
354 bool last_col = (index == m_num_columns - 1);
355 if (!cbk(m_columns[row_offset + index], last_col)) {
356 return false;
357 }
358 }
359 return true;
360 }
361
362 void reset() {
363 for (auto &col : m_columns) {
364 col.init();
365 }
366 }
367
368 /** Get current row offset to access columns.
369 @param[in] row_index row index
370 @return row offset in column vector. */
371 size_t get_row_offset(size_t row_index) const {
372 assert(row_index < m_num_rows);
373 return row_index * m_num_columns;
374 }
375
376 /** Get next row offset from current row offset.
377 @param[in,out] offset row offset
378 @return true if there is a next row. */
379 size_t get_next_row_offset(size_t &offset) const {
380 offset += m_num_columns;
381 return (offset < m_columns.size());
382 }
383
384 /** Get column using row offset and column index.
385 @param[in] row_offset row offset in column vector
386 @param[in] col_index index of the column within row
387 @return column data */
388 Column_type &get_column(size_t row_offset, size_t col_index) {
389 assert(col_index < m_num_columns);
390 assert(row_offset + col_index < m_columns.size());
391 return m_columns[row_offset + col_index];
392 }
393
394 /** Get column using row index and column index.
395 @param[in] row_index index of the row in the bunch
396 @param[in] col_index index of the column within row
397 @return column data */
398 Column_type &get_col(size_t row_index, size_t col_index) {
399 return get_column(get_row_offset(row_index), col_index);
400 }
401
402 /** Get column using the column offset.
403 @param[in] col_offset column offset
404 @return column data */
405 Column_type &get_col(size_t col_offset) { return m_columns[col_offset]; }
406
407 /** Get constant column for reading using row offset and column index.
408 @param[in] row_offset row offset in column vector
409 @param[in] col_index index of the column within row
410 @return column data */
411 const Column_type &read_column(size_t row_offset, size_t col_index) const {
412 assert(col_index < m_num_columns);
413 assert(row_offset + col_index < m_columns.size());
414 return m_columns[row_offset + col_index];
415 }
416
417 /** Set the number of rows. Adjust number of rows base on maximum column
418 storage limit.
419 @param[in,out] n_rows number of rows
420 @return true if successful, false if too many rows or columns. */
421 bool set_num_rows(size_t n_rows) {
422 /* Avoid any overflow during multiplication. */
423 if (n_rows > std::numeric_limits<uint32_t>::max() ||
425 return false;
426 }
427 auto total_cols = (uint64_t)n_rows * m_num_columns;
428
429 if (total_cols > S_MAX_TOTAL_COLS) {
430 return false;
431 }
432
433 m_num_rows = n_rows;
434
435 /* Extend columns if needed. */
436 if (m_columns.size() < total_cols) {
437 m_columns.resize(total_cols);
438 }
439 return true;
440 }
441
442 /** Limit allocation up to 600M columns. This number is rounded up from an
443 * estimate of the number of columns with the max chunk size (1024M). In the
444 * worst case we can have 2 bytes per column so a chunk can contain around
445 * 512M columns, and because of rows that spill over chunk boundaries we
446 * assume we can append a full additional row (which should have at most
447 * 4096 columns). Rounded up to 600M. */
448 const static size_t S_MAX_TOTAL_COLS = 600 * 1024 * 1024;
449
450 /** Get the total number of columns available in this row bunch.
451 @return total number of columns. */
452 size_t get_total_cols() const { return m_num_rows * m_num_columns; }
453
454 private:
455 /** All the columns. */
456 std::vector<Column_type> m_columns;
457
458 /** Number of rows. */
459 size_t m_num_rows{};
460
461 /** Number of columns in each row. */
463};
464
467
468/** Column metadata information. */
470 /** Data comparison method. */
471 enum class Compare {
472 /* Integer comparison */
474 /* Unsigned Integer comparison */
476 /* Binary comparison (memcmp) */
477 BINARY,
478 /* Need to callback to use appropriate comparison function in server. */
479 MYSQL
480 };
481
482 std::string get_compare_string() const {
483 switch (m_compare) {
485 return "INTEGER_SIGNED";
487 return "INTEGER_UNSIGNED";
488 case Compare::BINARY:
489 return "BINARY";
490 case Compare::MYSQL:
491 return "MYSQL";
492 }
493 assert(0);
494 return "INVALID";
495 }
496
497 /** @return true if integer type. */
498 bool is_integer() const {
501 }
502
503 /** Based on the column data type check if it can be stored externally.
504 @return true if the column data can be stored externally
505 @return false if the column data cannot be stored externally */
506 bool can_be_stored_externally() const;
507
508 /** true if this column is part of secondary index. */
509 bool m_is_part_of_sk{false};
510
511 /** Field type. (@ref enum_field_types) */
513
514 /** If column could be NULL. */
515 bool m_is_nullable{false};
516
517 /** true if column belongs to primary index (key or non-key) */
518 bool m_is_pk{false};
519
520 /** true if column is a key for primary or secondary index. */
521 bool m_is_key{false};
522
523 /** If the key is descending. */
524 bool m_is_desc_key{false};
525
526 /** If the prefix of this column is part of key */
527 bool m_is_prefix_key{false};
528
529 /** Prefix length */
530 size_t m_prefix_len{0};
531
532 /** If it is fixed length type. */
533 bool m_is_fixed_len{false};
534
535 /** If it is integer type. */
537
538 /** If it is unsigned integer type. */
539 bool m_is_unsigned{false};
540
541 /** Check the row header to find out if it is fixed length. For
542 character data type the row header indicates fixed length. */
544
545 /** If character column length can be kept in one byte. */
547
548 /** The length of column data if fixed. */
549 uint16_t m_fixed_len;
550
551 /** Maximum length of data in bytes. */
552 uint16_t m_max_len;
553
554 /** Index of column in row. */
555 uint16_t m_index;
556
557 /** Position of column in table. Refer to Field::field_index() */
559
560 /** Byte index in NULL bitmap. */
561 uint16_t m_null_byte;
562
563 /** BIT number in NULL bitmap. */
564 uint16_t m_null_bit;
565
566 /** Character set for char & varchar columns. */
567 const void *m_charset;
568
569 /** Field name */
570 std::string m_field_name;
571
572 /** Get a string representation of Column_meta object. Useful only for
573 debugging purposes.
574 @see Column_meta
575 @return string representation of this object. */
576 std::string to_string() const;
577
578 /** Print this object into the given output stream.
579 @param[in] out output stream into which object will be printed
580 @return given output stream. */
581 std::ostream &print(std::ostream &out) const;
582
583 /** Get the data type of the column as a string.
584 @return data type of the column as a string. */
585 std::string get_type_string() const;
586
587 /** The number of bytes used to store length information. This depends on
588 the data type.
589 @return number of bytes used to store length of column data. */
590 size_t get_length_size() const;
591};
592
593inline size_t Column_meta::get_length_size() const {
594 size_t length_size = m_is_single_byte_len ? 1 : 2;
595 switch (m_type) {
597 length_size = 1;
598 break;
599 case MYSQL_TYPE_BLOB:
600 length_size = 0;
601 break;
603 length_size = 3;
604 break;
606 [[fallthrough]];
607 case MYSQL_TYPE_JSON:
608 [[fallthrough]];
611 length_size = 4;
612 break;
613 default:
614 break;
615 }
616 return length_size;
617}
618
619inline std::string Column_meta::get_type_string() const {
620 switch (m_type) {
622 return "decimal";
623 case MYSQL_TYPE_TINY:
624 return "tiny";
625 case MYSQL_TYPE_SHORT:
626 return "short";
627 case MYSQL_TYPE_LONG:
628 return "long";
629 case MYSQL_TYPE_FLOAT:
630 return "float";
632 return "double";
633 case MYSQL_TYPE_NULL:
634 return "null";
636 return "timestamp";
638 return "longlong";
639 case MYSQL_TYPE_INT24:
640 return "int";
641 case MYSQL_TYPE_DATE:
642 return "date";
643 case MYSQL_TYPE_TIME:
644 return "time";
646 return "datetime";
647 case MYSQL_TYPE_YEAR:
648 return "year";
650 return "date";
652 return "varchar";
653 case MYSQL_TYPE_BIT:
654 return "bit";
656 return "timestamp";
658 return "datetime";
659 case MYSQL_TYPE_TIME2:
660 return "time";
662 return "typed_array";
664 return "vector";
666 return "invalid";
667 case MYSQL_TYPE_BOOL:
668 return "bool";
669 case MYSQL_TYPE_JSON:
670 return "json";
672 return "decimal";
673 case MYSQL_TYPE_ENUM:
674 return "enum";
675 case MYSQL_TYPE_SET:
676 return "set";
678 return "tiny_blob";
680 return "medium_blob";
682 return "long_blob";
683 case MYSQL_TYPE_BLOB:
684 return "blob";
686 return "var_string";
688 return "string";
690 return "geometry";
691 }
692 return "invalid";
693}
694
696 switch (m_type) {
697 case MYSQL_TYPE_JSON:
702 case MYSQL_TYPE_BLOB:
705 return true;
706 }
707 default:
708 break;
709 }
710 return false;
711}
712
713inline std::string Column_meta::to_string() const {
715 out << "[Column_meta: m_type=" << get_type_string()
716 << ", m_field_name=" << m_field_name << ", m_index=" << m_index
717 << ", m_field_index=" << m_field_index
718 << ", m_is_single_byte_len=" << m_is_single_byte_len
719 << ", m_is_fixed_len=" << m_is_fixed_len
720 << ", m_fixed_len=" << m_fixed_len << ", m_null_byte=" << m_null_byte
721 << ", m_null_bit=" << m_null_bit << ", m_compare=" << get_compare_string()
722 << ", m_is_desc_key=" << m_is_desc_key << ", m_is_key=" << m_is_key
723 << ", m_max_len=" << m_max_len << ", m_is_prefix_key=" << m_is_prefix_key
724 << ", m_prefix_len=" << m_prefix_len << "]";
725 return out.str();
726}
727
728inline std::ostream &Column_meta::print(std::ostream &out) const {
729 out << to_string();
730 return out;
731}
732
733/** Overloading the global output operator to print objects of type
734Column_meta.
735@param[in] out output stream
736@param[in] obj object to be printed
737@return given output stream. */
738inline std::ostream &operator<<(std::ostream &out, const Column_meta &obj) {
739 return obj.print(out);
740}
741
742/** Table metadata. */
744 /** Number of keys/indexes the table has. */
745 size_t m_n_keys;
746
747 /** Key number of the primary key. */
749
750 /** True if generated DB_ROW_ID is the pk. */
751 bool dbrowid_is_pk{false};
752
755
756 /** Table being bulk loaded. */
757 std::string m_table_name;
758};
759
760/** Row metadata */
761struct Row_meta {
762 /** Key type for fast comparison. */
763 enum class Key_type {
764 /* All Keys are signed integer an ascending. */
766 /* All keys are integer. */
767 INT,
768 /* Keys are of any supported type. */
769 ANY
770 };
771 /** All columns in a row are arranged with key columns first. */
772 std::vector<Column_meta> m_columns;
773
774 /** All columns in a row arranged as per col_index. */
775 std::vector<const Column_meta *> m_columns_text_order;
776
777 /** Get a string representation of this Row_meta object.
778 @see Row_meta
779 @return string representation of this object. */
780 std::string to_string() const;
781
782 /** Get the metadata of the given column.
783 @param[in] col_index position of the column in the index.
784 @return metadata of the requested column. */
785 const Column_meta &get_column_meta_index_order(size_t col_index) const {
786 assert(col_index < m_columns.size());
787 return m_columns[col_index];
788 }
789
790 /** Get the meta data of the column.
791 @param[in] col_index the index of the column as it appears in CSV file.
792 @return a reference to the column meta data.*/
793 const Column_meta &get_column_meta(size_t col_index) const {
794 assert(col_index < m_columns_text_order.size());
795 assert(col_index == m_columns_text_order[col_index]->m_index);
796 return *m_columns_text_order[col_index];
797 }
798
799 /** Total bitmap header length for the row. */
800 size_t m_bitmap_length = 0;
801
802 /** Total header length. */
803 size_t m_header_length = 0;
804
805 /** Length of the first key column. Helps to get the row pointer from first
806 key data pointer. */
807 size_t m_first_key_len = 0;
808
809 /** Key length in bytes for non-integer keys. This is required to estimate
810 the space required to save keys. */
811 size_t m_key_length = 0;
812
813 /** Number of columns used in primary key. */
814 uint32_t m_keys = 0;
815
816 /** Number of columns not used in primary Key. */
817 uint32_t m_non_keys = 0;
818
819 /** Key type for comparison. */
821
822 /** Total number of columns. A key could be on a column prefix.
823 m_columns <= m_keys + m_non_keys */
824 uint32_t m_num_columns = 0;
825
826 /** Approximate row length. */
828
829 /** Number of columns that can be stored externally. */
830 size_t m_n_blob_cols{0};
831
832 /** Name of the key */
833 std::string m_name;
834
835 /** true if primary key, false if secondary key. */
836 bool is_pk{false};
837
838 /** true if DB_ROW_ID is the pk, false otherwise. */
839 bool dbrowid_is_pk{false};
840
841 /** Key number of the index being built. */
842 size_t m_keynr;
843};
844
845inline std::ostream &operator<<(std::ostream &os,
847 switch (key_type) {
849 os << "ANY";
850 break;
852 os << "INT_SIGNED_ASC";
853 break;
855 os << "INT";
856 break;
857 }
858 return os;
859}
860
861inline std::string Row_meta::to_string() const {
863 out << "[Row_meta: m_name=" << m_name << ", m_num_columns=" << m_num_columns
864 << ", m_keys=" << m_keys << ", m_non_keys=" << m_non_keys
865 << ", m_key_length=" << m_key_length << ", m_key_type=" << m_key_type
866 << ", m_approx_row_len=" << m_approx_row_len
867 << ", m_bitmap_length=" << m_bitmap_length
868 << ", m_header_length=" << m_header_length
869 << ", m_first_key_len=" << m_first_key_len << ", m_keynr=" << m_keynr;
870 for (auto &col_meta : m_columns) {
871 out << col_meta.to_string() << ", ";
872 }
873 out << "]";
874 return out.str();
875}
876
877inline char *Column_mysql::get_row_begin(const Row_meta &row_meta,
878 size_t col_index
879 [[maybe_unused]]) const {
880 assert(m_is_null || col_index == 0);
881 return m_is_null ? m_data_ptr
882 : (m_data_ptr - row_meta.m_first_key_len -
883 row_meta.m_header_length);
884}
885
886namespace Bulk_load {
887
890 public:
891 void KeyTooBig() const override;
892 void ValueTooBig() const override;
893 void TooDeep() const override;
894 void InvalidJson() const override;
895 void InternalError(const char *message) const override;
896 bool CheckStack() const override;
897
898 const char *c_str() const { return m_error.c_str(); }
899
900 std::string get_error() const { return m_error; }
901
902 private:
903 mutable std::string m_error{};
904};
905
907 m_error = "Key is too big";
908}
909
911 m_error = "Value is too big";
912}
913
915 m_error = "JSON document has more nesting levels than supported";
916}
918 m_error = "Invalid JSON value is encountered";
919}
921 const char *message [[maybe_unused]]) const {
922 m_error = message;
923 m_error += " (Internal Error)";
924}
925
927 return false;
928}
929
930/** Callbacks for collecting time statistics */
932 /* Operation begin. */
933 std::function<void()> m_fn_begin;
934 /* Operation end. */
935 std::function<void()> m_fn_end;
936};
937
939 std::pair<std::optional<Rows_mysql>, std::optional<Rows_mysql>>;
940
942 std::string schema;
943 std::string table;
945};
946
947/** Contains the data needed for the ROW_ID generation for tables without
948explicit primary key */
950 /** Get an estimate of the number of rows to be handled by each thread.
951 This will give the number of row ids to be generated by each thread.
952 @return number of rows to be handled by each thread. */
953 size_t get_rows_per_thread() const {
954 size_t estimated_total_rows = m_total_size / m_avg_row_len.load();
955 size_t min_total_rows = 1000;
956
957 if (estimated_total_rows < min_total_rows) {
958 estimated_total_rows = min_total_rows;
959 }
960
961 return (estimated_total_rows + m_n_loaders) / m_n_loaders;
962 }
963
964 /** Get the next available range for generating DB_ROW_ID. The range includes
965 the begin value but excludes the end value.
966 @return the range for row ids for exclusive use by the calling thread. */
967 inline std::pair<uint64_t, uint64_t> get_next_rowid_range() const {
968 std::unique_lock<std::mutex> lock(m_rowid_mutex);
969
970 const uint64_t range_begin = m_next_rowid_range;
972
973 return std::make_pair(range_begin, m_next_rowid_range);
974 }
975
976 void set_begin_rowid_value(size_t row_id) { m_next_rowid_range = row_id; }
977 /* Total data size of CSV files (in bytes) */
979 /* Average row length, updated by the CSV parsing threads for each batch. */
980 std::atomic<size_t> m_avg_row_len;
981 /* Number of loaders aka concurrency in phase 1. */
983
984 private:
985 /** Protects the member m_next_rowid_range */
986 mutable std::mutex m_rowid_mutex;
987
988 /* Number of rows per subtree. */
989 mutable size_t m_next_rowid_range{0};
990};
991
992} // namespace Bulk_load
993
994/** Bulk Data conversion. */
995BEGIN_SERVICE_DEFINITION(bulk_data_convert)
996/** Convert row from text format for MySQL column format. Convert as many
997rows as possible consuming the data buffer starting form next_index. On
998output next_index is the next row index that is not yet consumed. If it
999matches the size of input text_rows, then all rows are consumed.
1000@param[in,out] thd session THD
1001@param[in] table MySQL TABLE
1002@param[in] text_rows rows with column in text
1003@param[in,out] next_index next_index in text_rows to be processed
1004@param[in,out] buffer data buffer for keeping sql row data
1005@param[in,out] buffer_length length of the data buffer
1006@param[in] charset input row data character set
1007@param[in] metadata row metadata
1008@param[out] sql_rows rows with column in MySQL column format
1009@return error code. */
1011 (THD * thd, const TABLE *table, const Rows_text &text_rows,
1012 size_t &next_index, char *buffer, size_t &buffer_length,
1013 const CHARSET_INFO *charset, const Row_meta &metadata,
1014 Rows_mysql &sql_rows,
1016
1017/** Convert row to MySQL column format from raw form
1018@param[in,out] buffer input raw data buffer
1019@param[in] buffer_length buffer length
1020@param[in] metadata row metadata
1021@param[in] start_index start row index in row bunch
1022@param[out] consumed_length length of buffer consumed
1023@param[in,out] sql_rows row bunch to fill data
1024@return error code. */
1026 (char *buffer, size_t buffer_length, const Row_meta &metadata,
1027 size_t start_index, size_t &consumed_length,
1028 Rows_mysql &sql_rows));
1029
1030/** Convert row to MySQL column format using the key
1031@param[in] metadata row metadata
1032@param[in] sql_keys Key bunch
1033@param[in] key_offset offset for the key
1034@param[in,out] sql_rows row bunch to fill data
1035@param[in] sql_index index of the row to be filled
1036@return error code. */
1038 (const Row_meta &metadata, const Rows_mysql &sql_keys,
1039 size_t key_offset, Rows_mysql &sql_rows, size_t sql_index));
1040
1041/** Check if session is interrupted.
1042@param[in,out] thd session THD
1043@return true if connection or statement is killed. */
1045
1046/** Compare two key columns
1047@param[in] key1 first key
1048@param[in] key2 second key
1049@param[in] col_meta column meta information
1050@return positive, 0, negative, if key_1 is greater, equal, less than key_2 */
1052 (const Column_mysql &key1, const Column_mysql &key2,
1053 const Column_meta &col_meta));
1054
1055/** Get row metadata information for all the indexes.
1056@param[in,out] thd session THD
1057@param[in] table MySQL TABLE
1058@param[in] have_key include Primary Key metadata
1059@param[out] metadata Metadata for each of the indexes.
1060@return true if successful. */
1062 (THD * thd, const TABLE *table, bool have_key,
1063 std::vector<Row_meta> &metadata));
1064
1065/** Get table metadata information for the table being bulk loaded.
1066@param[in,out] thd session THD
1067@param[in] table MySQL TABLE
1068@param[out] metadata Metadata of the table.
1069@return true if successful. */
1071 (THD * thd, const TABLE *table, Table_meta &metadata));
1072
1073END_SERVICE_DEFINITION(bulk_data_convert)
1074
1075/** Column metadata information. */
1076/* Bulk data load to SE. */
1078/** Begin Loading bulk data to SE.
1079@param[in,out] thd session THD
1080@param[in] table MySQL TABLE
1081@param[in] keynr key number, identifying the index being loaded.
1082@param[in] data_size total data size to load
1083@param[in] memory SE memory to be used
1084@param[in] num_threads Number of concurrent threads
1085@return SE bulk load context or nullptr in case of an error. */
1086DECLARE_METHOD(void *, begin,
1087 (THD * thd, const TABLE *table, size_t keynr, size_t data_size,
1088 size_t memory, size_t num_threads));
1089
1090/** Load a set of rows to SE table by one thread.
1091@param[in,out] thd session THD
1092@param[in,out] ctx SE load context returned by begin()
1093@param[in] table MySQL TABLE
1094@param[in] sql_rows row data to load
1095@param[in] thread current thread number
1096@param[in] wait_cbks wait stat callbacks
1097@return true if successful. */
1098DECLARE_METHOD(bool, load,
1099 (THD * thd, void *ctx, const TABLE *table,
1100 const Rows_mysql &sql_rows, size_t thread,
1101 Bulk_load::Stat_callbacks &wait_cbks));
1102
1103/** Create a blob context object to insert a blob.
1104@param[in,out] thd session THD
1105@param[in,out] load_ctx SE load context returned by begin()
1106@param[in] table MySQL TABLE
1107@param[out] blob_ctx a blob context object to insert a blob.
1108@param[out] blobref buffer to hold blob reference
1109@param[in] thread current thread number
1110@return true if successful. */
1112 (THD * thd, void *load_ctx, const TABLE *table,
1113 Blob_context &blob_ctx, unsigned char *blobref, size_t thread));
1114
1115/** Write data into a blob
1116@param[in,out] thd session THD
1117@param[in,out] load_ctx SE load context returned by begin()
1118@param[in] table MySQL TABLE
1119@param[in] blob_ctx a blob context object to insert a blob.
1120@param[out] blobref buffer to hold blob reference
1121@param[in] thread current thread number
1122@param[in] data blob data to be written
1123@param[in] data_len length of blob data to be written (in bytes);
1124@return true if successful. */
1126 (THD * thd, void *load_ctx, const TABLE *table,
1127 Blob_context blob_ctx, unsigned char *blobref, size_t thread,
1128 const unsigned char *data, size_t data_len));
1129
1130/** Close the blob
1131@param[in,out] thd session THD
1132@param[in,out] load_ctx SE load context returned by begin()
1133@param[in] table MySQL TABLE
1134@param[in] blob_ctx a blob context object to insert a blob.
1135@param[out] blobref buffer to hold blob reference
1136@param[in] thread current thread number
1137@return true if successful. */
1139 (THD * thd, void *load_ctx, const TABLE *table,
1140 Blob_context blob_ctx, unsigned char *blobref, size_t thread));
1141
1142/** End Loading bulk data to SE.
1143
1144Called at the end of bulk load execution, even if begin or load calls failed.
1145
1146@param[in,out] thd session THD
1147@param[in,out] ctx SE load context
1148@param[in] table MySQL TABLE
1149@param[in] error true, if exiting after error
1150@return true if successful. */
1151DECLARE_METHOD(bool, end,
1152 (THD * thd, void *ctx, const TABLE *table, bool error));
1153
1154/** Check if a table is supported by the bulk load implementation.
1155@param[in,out] thd session THD
1156@param[in] table MySQL TABLE
1157@return true if table is supported. */
1159
1160/** Get available buffer pool memory for bulk load operations.
1161@param[in,out] thd session THD
1162@param[in] table MySQL TABLE
1163@return buffer pool memory available for bulk load. */
1165
1166/** Copies data from existing table into the duplicated table during incremental
1167load. This is called after the bulk load component detects we reached the end of
1168the CSV input for the respective sub-loader and it signals that the loader
1169should now iterate through the remainded or the existing data in the original
1170table and migrate it.
1171@param[in,out] ctx SE load context
1172@param[in] table MySQL TABLE
1173@param[in] thread loader thread index
1174@param[in,out] wait_cbks wait stat callbacks
1175@return true if successful, false otherwise. */
1177 (void *ctx, const TABLE *table, size_t thread,
1178 Bulk_load::Stat_callbacks &wait_cbks));
1179
1180/** Sets the source table data (table name and key range boundaries) for all
1181loaders.
1182@param[in,out] ctx SE load context
1183@param[in] table MySQL TABLE
1184@param[in] source_table_data vector containing the source table data
1185@return true if successful, false otherwise. */
1188 (void *ctx, const TABLE *table,
1189 const std::vector<Bulk_load::Source_table_data> &source_table_data));
1190
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
constexpr size_t BLOB_REF_SIZE
The blob reference size.
Definition: bulk_data_service.h:56
void * Blob_context
Definition: bulk_data_service.h:53
std::ostream & operator<<(std::ostream &out, const Bulk_load_error_location_details &obj)
Overloading the global output operator to print objects of type Bulk_load_error_location_details.
Definition: bulk_data_service.h:84
Definition: bulk_data_service.h:889
const char * c_str() const
Definition: bulk_data_service.h:898
void KeyTooBig() const override
Called when a JSON object contains a member with a name that is longer than supported by the JSON bin...
Definition: bulk_data_service.h:906
std::string get_error() const
Definition: bulk_data_service.h:900
std::string m_error
Definition: bulk_data_service.h:903
void InternalError(const char *message) const override
Called when an internal error occurs.
Definition: bulk_data_service.h:920
void ValueTooBig() const override
Called when a JSON document is too big to be stored in the JSON binary format.
Definition: bulk_data_service.h:910
void TooDeep() const override
Called when a JSON document has more nesting levels than supported.
Definition: bulk_data_service.h:914
void InvalidJson() const override
Called when an invalid JSON value is encountered.
Definition: bulk_data_service.h:917
bool CheckStack() const override
Check if the stack is about to be exhausted, and report the error.
Definition: bulk_data_service.h:926
Error handler for the functions that serialize a JSON value in the JSON binary storage format.
Definition: json_error_handler.h:49
Implements the row and column memory management for parse and load operations.
Definition: bulk_data_service.h:325
bool set_num_rows(size_t n_rows)
Set the number of rows.
Definition: bulk_data_service.h:421
std::vector< Column_type > m_columns
All the columns.
Definition: bulk_data_service.h:456
size_t get_next_row_offset(size_t &offset) const
Get next row offset from current row offset.
Definition: bulk_data_service.h:379
Column_type & get_col(size_t col_offset)
Get column using the column offset.
Definition: bulk_data_service.h:405
bool process_columns(size_t row_index, F &&cbk)
Process all columns, invoking callback for each.
Definition: bulk_data_service.h:342
bool process_columns_by_offset(size_t row_offset, F &&cbk)
Definition: bulk_data_service.h:350
size_t get_num_cols() const
Definition: bulk_data_service.h:335
void reset()
Definition: bulk_data_service.h:362
size_t m_num_rows
Number of rows.
Definition: bulk_data_service.h:459
size_t get_row_offset(size_t row_index) const
Get current row offset to access columns.
Definition: bulk_data_service.h:371
size_t get_num_rows() const
Definition: bulk_data_service.h:332
const Column_type & read_column(size_t row_offset, size_t col_index) const
Get constant column for reading using row offset and column index.
Definition: bulk_data_service.h:411
Column_type & get_col(size_t row_index, size_t col_index)
Get column using row index and column index.
Definition: bulk_data_service.h:398
size_t get_total_cols() const
Get the total number of columns available in this row bunch.
Definition: bulk_data_service.h:452
Row_bunch(size_t n_cols)
Create a new row bunch.
Definition: bulk_data_service.h:329
static const size_t S_MAX_TOTAL_COLS
Limit allocation up to 600M columns.
Definition: bulk_data_service.h:448
size_t m_num_columns
Number of columns in each row.
Definition: bulk_data_service.h:462
Column_type & get_column(size_t row_offset, size_t col_index)
Get column using row offset and column index.
Definition: bulk_data_service.h:388
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
This file contains the field type.
enum_field_types
Column types for MySQL Note: Keep include/mysql/components/services/bits/stored_program_bits....
Definition: field_types.h:56
@ MYSQL_TYPE_BOOL
Currently just a placeholder.
Definition: field_types.h:80
@ MYSQL_TYPE_TIME2
Internal to MySQL.
Definition: field_types.h:76
@ MYSQL_TYPE_VARCHAR
Definition: field_types.h:72
@ MYSQL_TYPE_LONGLONG
Definition: field_types.h:65
@ MYSQL_TYPE_LONG_BLOB
Definition: field_types.h:87
@ MYSQL_TYPE_VAR_STRING
Definition: field_types.h:89
@ MYSQL_TYPE_BLOB
Definition: field_types.h:88
@ MYSQL_TYPE_TINY
Definition: field_types.h:58
@ MYSQL_TYPE_TIME
Definition: field_types.h:68
@ MYSQL_TYPE_SET
Definition: field_types.h:84
@ MYSQL_TYPE_NEWDATE
Internal to MySQL.
Definition: field_types.h:71
@ MYSQL_TYPE_VECTOR
Definition: field_types.h:78
@ MYSQL_TYPE_JSON
Definition: field_types.h:81
@ MYSQL_TYPE_STRING
Definition: field_types.h:90
@ MYSQL_TYPE_NULL
Definition: field_types.h:63
@ MYSQL_TYPE_ENUM
Definition: field_types.h:83
@ MYSQL_TYPE_TINY_BLOB
Definition: field_types.h:85
@ MYSQL_TYPE_LONG
Definition: field_types.h:60
@ MYSQL_TYPE_BIT
Definition: field_types.h:73
@ MYSQL_TYPE_INVALID
Definition: field_types.h:79
@ MYSQL_TYPE_GEOMETRY
Definition: field_types.h:91
@ MYSQL_TYPE_NEWDECIMAL
Definition: field_types.h:82
@ MYSQL_TYPE_DECIMAL
Definition: field_types.h:57
@ MYSQL_TYPE_TYPED_ARRAY
Used for replication only.
Definition: field_types.h:77
@ MYSQL_TYPE_DOUBLE
Definition: field_types.h:62
@ MYSQL_TYPE_MEDIUM_BLOB
Definition: field_types.h:86
@ MYSQL_TYPE_DATETIME2
Internal to MySQL.
Definition: field_types.h:75
@ MYSQL_TYPE_SHORT
Definition: field_types.h:59
@ MYSQL_TYPE_DATE
Definition: field_types.h:67
@ MYSQL_TYPE_FLOAT
Definition: field_types.h:61
@ MYSQL_TYPE_TIMESTAMP
Definition: field_types.h:64
@ MYSQL_TYPE_INT24
Definition: field_types.h:66
@ MYSQL_TYPE_DATETIME
Definition: field_types.h:69
@ MYSQL_TYPE_TIMESTAMP2
Definition: field_types.h:74
@ MYSQL_TYPE_YEAR
Definition: field_types.h:70
static int compare_keys(PFS_table_share *pfs, const TABLE_SHARE *share)
Definition: pfs_instr_class.cc:2435
static uint16 key1[1001]
Definition: hp_test2.cc:50
#define F
Definition: jit_executor_value.cc:374
#define UINT16_MAX
Definition: lexyy.cc:83
void error(const char *format,...)
int mysql_format_from_raw(char *buffer, size_t buffer_length, const Row_meta &metadata, size_t start_index, size_t &consumed_length, Rows_mysql &sql_rows) noexcept
Definition: bulk_data_service.cc:1892
bool get_table_metadata(THD *thd, const TABLE *table, Table_meta &table_meta) noexcept
Definition: bulk_data_service.cc:2591
int mysql_format(THD *thd, const TABLE *table, const Rows_text &text_rows, size_t &next_index, char *buffer, size_t &buffer_length, const CHARSET_INFO *charset, const Row_meta &metadata, Rows_mysql &sql_rows, Bulk_load_error_location_details &error_details) noexcept
Definition: bulk_data_service.cc:1923
bool get_row_metadata_all(THD *thd, const TABLE *table, bool have_key, std::vector< Row_meta > &row_meta_all) noexcept
Definition: bulk_data_service.cc:2612
int mysql_format_using_key(const Row_meta &metadata, const Rows_mysql &sql_keys, size_t key_offset, Rows_mysql &sql_rows, size_t sql_index) noexcept
Definition: bulk_data_service.cc:1870
bool is_killed(THD *thd) noexcept
Definition: bulk_data_service.cc:1975
bool copy_existing_data(void *ctx, const TABLE *duplicate_table, size_t thread, Bulk_load::Stat_callbacks &wait_cbks) noexcept
Definition: bulk_data_service.cc:2794
bool open_blob(THD *thd, void *load_ctx, const TABLE *table, Blob_context &blob_ctx, unsigned char *blobref, size_t thread) noexcept
Definition: bulk_data_service.cc:2680
size_t get_se_memory_size(THD *thd, const TABLE *table) noexcept
Definition: bulk_data_service.cc:2788
bool set_source_table_data(void *ctx, const TABLE *duplicate_table, const std::vector< Bulk_load::Source_table_data > &source_table_data) noexcept
Definition: bulk_data_service.cc:2803
bool write_blob(THD *thd, void *load_ctx, const TABLE *table, Blob_context blob_ctx, unsigned char *blobref, size_t thread, const unsigned char *data, size_t data_len) noexcept
Definition: bulk_data_service.cc:2690
bool close_blob(THD *thd, void *load_ctx, const TABLE *table, Blob_context blob_ctx, unsigned char *blobref, size_t thread) noexcept
Definition: bulk_data_service.cc:2698
bool is_table_supported(THD *thd, const TABLE *table) noexcept
Definition: bulk_data_service.cc:2808
Definition: bulk_data_service.h:886
std::pair< std::optional< Rows_mysql >, std::optional< Rows_mysql > > Read_range
Definition: bulk_data_service.h:939
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
const std::string charset("charset")
bool load(THD *, const dd::String_type &fname, dd::String_type *buf)
Read an sdi file from disk and store in a buffer.
Definition: sdi_file.cc:308
std::string hex(const Container &c)
Definition: hex.h:61
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:76
int key_type
Definition: method.h:38
Definition: aligned_atomic.h:44
ValueType max(X &&first)
Definition: gtid.h:103
const char * begin(const char *const c)
Definition: base64.h:44
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
Define std::hash<Gtid>.
Definition: gtid.h:355
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2720
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2724
static std::mutex lock
Definition: net_ns.cc:56
Column_type
Framework that helps consuming data in a specific format, typically provided by a service API,...
Definition: row_proxy.h:43
#define DECLARE_METHOD(retval, name, args)
Declares a method as a part of the Service definition.
Definition: service.h:103
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:91
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:86
Contains the data needed for the ROW_ID generation for tables without explicit primary key.
Definition: bulk_data_service.h:949
std::pair< uint64_t, uint64_t > get_next_rowid_range() const
Get the next available range for generating DB_ROW_ID.
Definition: bulk_data_service.h:967
size_t get_rows_per_thread() const
Get an estimate of the number of rows to be handled by each thread.
Definition: bulk_data_service.h:953
std::atomic< size_t > m_avg_row_len
Definition: bulk_data_service.h:980
std::mutex m_rowid_mutex
Protects the member m_next_rowid_range.
Definition: bulk_data_service.h:986
void set_begin_rowid_value(size_t row_id)
Definition: bulk_data_service.h:976
size_t m_n_loaders
Definition: bulk_data_service.h:982
size_t m_total_size
Definition: bulk_data_service.h:978
size_t m_next_rowid_range
Definition: bulk_data_service.h:989
Definition: bulk_data_service.h:941
Read_range range
Definition: bulk_data_service.h:944
std::string table
Definition: bulk_data_service.h:943
std::string schema
Definition: bulk_data_service.h:942
Callbacks for collecting time statistics.
Definition: bulk_data_service.h:931
std::function< void()> m_fn_begin
Definition: bulk_data_service.h:933
std::function< void()> m_fn_end
Definition: bulk_data_service.h:935
Definition: bulk_data_service.h:58
std::string filename
Definition: bulk_data_service.h:59
std::string m_table_name
Definition: bulk_data_service.h:65
size_t m_bytes
Definition: bulk_data_service.h:66
size_t row_number
Definition: bulk_data_service.h:60
std::string column_input_data
Definition: bulk_data_service.h:63
std::string column_name
Definition: bulk_data_service.h:61
size_t m_column_length
Definition: bulk_data_service.h:67
std::string m_error_mesg
Definition: bulk_data_service.h:64
std::ostream & print(std::ostream &out) const
Definition: bulk_data_service.h:72
std::string column_type
Definition: bulk_data_service.h:62
Definition: m_ctype.h:421
Column metadata information.
Definition: bulk_data_service.h:469
bool m_is_prefix_key
If the prefix of this column is part of key.
Definition: bulk_data_service.h:527
enum_field_types m_type
Field type.
Definition: bulk_data_service.h:512
std::string m_field_name
Field name.
Definition: bulk_data_service.h:570
std::string get_type_string() const
Get the data type of the column as a string.
Definition: bulk_data_service.h:619
uint16_t m_index
Index of column in row.
Definition: bulk_data_service.h:555
bool m_is_single_byte_len
If character column length can be kept in one byte.
Definition: bulk_data_service.h:546
uint16_t m_null_byte
Byte index in NULL bitmap.
Definition: bulk_data_service.h:561
bool m_is_desc_key
If the key is descending.
Definition: bulk_data_service.h:524
Compare m_compare
If it is integer type.
Definition: bulk_data_service.h:536
bool m_is_pk
true if column belongs to primary index (key or non-key)
Definition: bulk_data_service.h:518
uint16_t m_fixed_len
The length of column data if fixed.
Definition: bulk_data_service.h:549
std::string to_string() const
Get a string representation of Column_meta object.
Definition: bulk_data_service.h:713
bool is_integer() const
Definition: bulk_data_service.h:498
Compare
Data comparison method.
Definition: bulk_data_service.h:471
uint16_t m_field_index
Position of column in table.
Definition: bulk_data_service.h:558
uint16_t m_max_len
Maximum length of data in bytes.
Definition: bulk_data_service.h:552
bool m_is_fixed_len
If it is fixed length type.
Definition: bulk_data_service.h:533
bool m_is_key
true if column is a key for primary or secondary index.
Definition: bulk_data_service.h:521
uint16_t m_null_bit
BIT number in NULL bitmap.
Definition: bulk_data_service.h:564
bool can_be_stored_externally() const
Based on the column data type check if it can be stored externally.
Definition: bulk_data_service.h:695
bool m_fixed_len_if_set_in_row
Check the row header to find out if it is fixed length.
Definition: bulk_data_service.h:543
std::ostream & print(std::ostream &out) const
Print this object into the given output stream.
Definition: bulk_data_service.h:728
bool m_is_nullable
If column could be NULL.
Definition: bulk_data_service.h:515
bool m_is_part_of_sk
true if this column is part of secondary index.
Definition: bulk_data_service.h:509
bool m_is_unsigned
If it is unsigned integer type.
Definition: bulk_data_service.h:539
size_t get_length_size() const
The number of bytes used to store length information.
Definition: bulk_data_service.h:593
std::string get_compare_string() const
Definition: bulk_data_service.h:482
size_t m_prefix_len
Prefix length.
Definition: bulk_data_service.h:530
const void * m_charset
Character set for char & varchar columns.
Definition: bulk_data_service.h:567
Definition: bulk_data_service.h:210
uint64_t m_int_data
Column data in integer format.
Definition: bulk_data_service.h:261
bool is_ext() const
Check if the column is externally stored.
Definition: bulk_data_service.h:240
std::string to_string() const
Definition: bulk_data_service.h:284
bool m_is_null
If column is NULL.
Definition: bulk_data_service.h:220
void set_ext()
Mark this column as externally stored.
Definition: bulk_data_service.h:236
bool m_is_prefix
Definition: bulk_data_service.h:217
char * get_row_begin(const Row_meta &row_meta, size_t col_index) const
Get the pointer to the beginning of row.
Definition: bulk_data_service.h:877
char * m_data_ptr
Column data or row begin.
Definition: bulk_data_service.h:281
char * get_data() const
Get the column data.
Definition: bulk_data_service.h:229
int16_t m_type
Column Data Type.
Definition: bulk_data_service.h:212
uint16_t m_data_len
Column data length.
Definition: bulk_data_service.h:215
void set_data(char *ptr)
Set the column data to the given pointer location.
Definition: bulk_data_service.h:233
void init()
Definition: bulk_data_service.h:263
bool m_is_ext
If true, the column data is stored externally in InnoDB.
Definition: bulk_data_service.h:225
void row(char *row_begin)
Save the beginning of the row pointer in this object.
Definition: bulk_data_service.h:245
Definition: bulk_data_service.h:89
bool is_null() const
Check if the column is null, by checking special value for length.
Definition: bulk_data_service.h:116
bool is_ext_relaxed() const
Check if the column data is stored externally.
Definition: bulk_data_service.h:135
bool m_is_ext
If true, the column data is stored externally.
Definition: bulk_data_service.h:163
void set_null()
Mark the column to be null, by setting length to a special value.
Definition: bulk_data_service.h:109
std::ostream & print(std::ostream &out) const
Print this object into the given output stream.
Definition: bulk_data_service.h:192
const char * m_data_ptr
Column data.
Definition: bulk_data_service.h:91
bool is_row_id() const
Check if it is DB_ROW_ID column based on the value it contains.
Definition: bulk_data_service.h:101
uint64_t m_row_id
The generated DB_ROW_ID value.
Definition: bulk_data_service.h:104
size_t m_prefix_len
Prefix length.
Definition: bulk_data_service.h:97
void init()
Initialize the members.
Definition: bulk_data_service.h:147
void set_ext()
Mark that the column data has been stored externally.
Definition: bulk_data_service.h:141
bool is_ext() const
Check if the column data is stored externally.
Definition: bulk_data_service.h:126
size_t m_data_len
Column data length.
Definition: bulk_data_service.h:94
std::string to_string() const
Definition: bulk_data_service.h:166
Definition: mysql.h:303
Row metadata.
Definition: bulk_data_service.h:761
const Column_meta & get_column_meta_index_order(size_t col_index) const
Get the metadata of the given column.
Definition: bulk_data_service.h:785
const Column_meta & get_column_meta(size_t col_index) const
Get the meta data of the column.
Definition: bulk_data_service.h:793
size_t m_n_blob_cols
Number of columns that can be stored externally.
Definition: bulk_data_service.h:830
size_t m_bitmap_length
Total bitmap header length for the row.
Definition: bulk_data_service.h:800
std::string to_string() const
Get a string representation of this Row_meta object.
Definition: bulk_data_service.h:861
bool dbrowid_is_pk
true if DB_ROW_ID is the pk, false otherwise.
Definition: bulk_data_service.h:839
size_t m_first_key_len
Length of the first key column.
Definition: bulk_data_service.h:807
size_t m_header_length
Total header length.
Definition: bulk_data_service.h:803
Key_type
Key type for fast comparison.
Definition: bulk_data_service.h:763
uint32_t m_non_keys
Number of columns not used in primary Key.
Definition: bulk_data_service.h:817
uint32_t m_num_columns
Total number of columns.
Definition: bulk_data_service.h:824
size_t m_keynr
Key number of the index being built.
Definition: bulk_data_service.h:842
uint32_t m_keys
Number of columns used in primary key.
Definition: bulk_data_service.h:814
size_t m_key_length
Key length in bytes for non-integer keys.
Definition: bulk_data_service.h:811
std::string m_name
Name of the key.
Definition: bulk_data_service.h:833
std::vector< Column_meta > m_columns
All columns in a row are arranged with key columns first.
Definition: bulk_data_service.h:772
std::vector< const Column_meta * > m_columns_text_order
All columns in a row arranged as per col_index.
Definition: bulk_data_service.h:775
Key_type m_key_type
Key type for comparison.
Definition: bulk_data_service.h:820
size_t m_approx_row_len
Approximate row length.
Definition: bulk_data_service.h:827
bool is_pk
true if primary key, false if secondary key.
Definition: bulk_data_service.h:836
Definition: table.h:1456
Table metadata.
Definition: bulk_data_service.h:743
size_t m_keynr_pk
Key number of the primary key.
Definition: bulk_data_service.h:748
size_t max_row_id_value
Definition: bulk_data_service.h:754
bool dbrowid_is_pk
True if generated DB_ROW_ID is the pk.
Definition: bulk_data_service.h:751
std::string m_table_name
Table being bulk loaded.
Definition: bulk_data_service.h:757
size_t min_row_id_value
Definition: bulk_data_service.h:753
size_t m_n_keys
Number of keys/indexes the table has.
Definition: bulk_data_service.h:745