MySQL 9.7.4
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 /** Check if it is DB_ROW_ID column based on the value it contains.
97 @return true if it is DB_ROW_ID column, false otherwise */
98 bool is_row_id() const { return m_row_id != UINT64_MAX; }
99
100 /** The generated DB_ROW_ID value */
101 uint64_t m_row_id{UINT64_MAX};
102
103 /** Mark the column to be null, by setting length to a special value. This is
104 only used for columns whose state is maintained across chunks
105 (aka fragmented columns). */
106 void set_null() {
107 assert(m_data_ptr == nullptr);
109 }
110
111 /** Check if the column is null, by checking special value for length.
112 @return true if the column is null, false otherwise. */
113 bool is_null() const {
115 m_data_ptr == nullptr);
117 }
118
119 /** Check if the column data is stored externally. If the data is stored
120 externally, then the data length (m_data_len) would be equal to the
121 BLOB_REF_SIZE and the column data (m_data_ptr) will contain the lob
122 reference.
123 @return true if data is stored externally, false otherwise. */
124 bool is_ext() const {
125 assert(!m_is_ext || m_data_len == BLOB_REF_SIZE);
126 return m_is_ext;
127 }
128
129 /** Check if the column data is stored externally. It is called relaxed,
130 because the column length might not be equal to BLOB_REF_SIZE. Only to
131 be used while the blob is being processed by the CSV parser.
132 @return true if data is stored externally, false otherwise. */
133 bool is_ext_relaxed() const {
134 assert(!m_is_ext || m_data_len >= BLOB_REF_SIZE);
135 return m_is_ext;
136 }
137
138 /** Mark that the column data has been stored externally. */
139 void set_ext() {
140 assert(m_data_len == BLOB_REF_SIZE);
141 m_is_ext = true;
142 }
143
144 /** Initialize the members */
145 void init() {
146 m_data_ptr = nullptr;
147 m_data_len = 0;
148 m_is_ext = false;
149 m_row_id = UINT64_MAX;
150 }
151
152 /** Print this object into the given output stream.
153 @param[in] out output stream into which this object will be printed.
154 @return given output stream */
155 std::ostream &print(std::ostream &out) const;
156
157 std::string to_string() const;
158
159 private:
160 /** If true, the column data is stored externally. */
161 bool m_is_ext{false};
162};
163
164inline std::string Column_text::to_string() const {
166 sout << "[Column_text: len=" << m_data_len;
167 sout << ", val=";
168
169 if (m_data_ptr == nullptr) {
170 sout << "nullptr";
171 } else {
172 for (size_t i = 0; i < m_data_len; ++i) {
173 const char c = m_data_ptr[i];
174 if (isalnum(c)) {
175 sout << c;
176 } else {
177 sout << ".";
178 }
179 }
180 sout << "[hex=";
181 for (size_t i = 0; i < m_data_len; ++i) {
182 sout << std::setfill('0') << std::setw(2) << std::hex
183 << (int)*(&m_data_ptr[i]);
184 }
185 }
186 sout << "]";
187 return sout.str();
188}
189
190inline std::ostream &Column_text::print(std::ostream &out) const {
191 out << "[Column_text: this=" << static_cast<const void *>(this)
192 << ", m_data_ptr=" << static_cast<const void *>(m_data_ptr)
193 << ", m_data_len=" << m_data_len << ", m_is_ext=" << m_is_ext << "]";
194 return out;
195}
196
197/** Overloading the global output operator to print objects of type
198Column_text.
199@param[in] out output stream
200@param[in] obj object to be printed
201@return given output stream. */
202inline std::ostream &operator<<(std::ostream &out, const Column_text &obj) {
203 return obj.print(out);
204}
205
206struct Row_meta;
207
209 /** Column Data Type */
210 int16_t m_type{};
211
212 /** Column data length. */
213 uint16_t m_data_len{};
214
215 /** If column is NULL. */
216 bool m_is_null{false};
217
218 /** If column data is stored externally in InnoDB. */
219 bool m_is_ext{false};
220
221 char *get_data() const { return m_is_null ? nullptr : m_data_ptr; }
222
223 void set_data(char *ptr) { m_data_ptr = ptr; }
224
225 /** Mark this column as externally stored. */
226 void set_ext() { m_is_ext = true; }
227
228 /** @return true if column data is stored externally in InnoDB. */
229 bool is_ext() const { return m_is_ext; }
230
231 /** Save the beginning of the row pointer in this object. This should be
232 called only when the column is null.
233 @param[in] row_begin pointer to beginning of row.*/
234 void row(char *row_begin) {
235 assert(m_is_null);
236 m_data_len = 0;
237 m_data_ptr = row_begin;
238 }
239
240 /** Get the pointer to the beginning of row. This is valid only if the
241 column is null. This should be called on the first column of the row. There
242 is no need to call this on other columns.
243 @param[in] row_meta meta data information about the row
244 @param[in] col_index Index of the first column which is 0.
245 @return pointer to row beginning. */
246 char *get_row_begin(const Row_meta &row_meta,
247 size_t col_index [[maybe_unused]]) const;
248
249 /** Column data in integer format. Used only for specific datatype. */
250 uint64_t m_int_data;
251
252 void init() {
253 m_type = 0;
254 m_data_len = 0;
255 m_is_null = false;
256 m_is_ext = false;
257 m_data_ptr = nullptr;
258 m_int_data = 0;
259 }
260
261 std::string to_string() const;
262
263 private:
264 /** Column data or row begin. There is a need to fetch the beginning of
265 the row from the vector of Column_mysql. But in the case of secondary
266 indexes, all the keys could be null and it becomes impossible to obtain
267 the pointer to beginning of the row. To solve this problem, I am re-using
268 this pointer to hold the row begin when the column is null. So it becomes
269 important to make use of m_is_null to check if the column is null. It is NOT
270 correct to check this pointer against nullptr to confirm if column is null.*/
271 char *m_data_ptr{nullptr};
272};
273
274inline std::string Column_mysql::to_string() const {
276 sout << "[Column_mysql: type=" << m_type << ", len=" << m_data_len
277 << ", m_int_data=" << m_int_data;
278 sout << ", val=";
279
280 switch (m_type) {
281 case MYSQL_TYPE_LONG: {
282 sout << m_int_data;
283 } break;
284 default: {
285 for (size_t i = 0; i < m_data_len; ++i) {
286 const char c = m_data_ptr[i];
287 if (isalnum(c)) {
288 sout << c;
289 } else {
290 sout << ".";
291 }
292 }
293
294 } break;
295 }
296 if (m_type != MYSQL_TYPE_LONG) {
297 sout << "[hex=";
298 for (size_t i = 0; i < m_data_len; ++i) {
299 sout << std::setfill('0') << std::setw(2) << std::hex
300 << (int)*(&m_data_ptr[i]);
301 }
302 sout << "]";
303 }
304 return sout.str();
305}
306
307/** Implements the row and column memory management for parse and load
308operations. We try to pre-allocate the memory contiguously as much as we can
309to maximize the performance.
310
311@tparam Column_type Column_text when used in the CSV context, Column_sql when
312used in the InnoDB context.
313*/
314template <typename Column_type>
316 public:
317 /** Create a new row bunch.
318 @param[in] n_cols number of columns */
319 explicit Row_bunch(size_t n_cols) : m_num_columns(n_cols) {}
320
321 /** @return return number of rows in the bunch. */
322 size_t get_num_rows() const { return m_num_rows; }
323
324 /** @return return number of columns in each row. */
325 size_t get_num_cols() const { return m_num_columns; }
326
327 /** Process all columns, invoking callback for each.
328 @param[in] row_index index of the row
329 @param[in] cbk callback function
330 @return true if successful */
331 template <typename F>
332 bool process_columns(size_t row_index, F &&cbk) {
333 assert(row_index < m_num_rows);
334
335 auto row_offset = row_index * m_num_columns;
336 return process_columns_by_offset(row_offset, std::move(cbk));
337 }
338
339 template <typename F>
340 bool process_columns_by_offset(size_t row_offset, F &&cbk) {
341 assert(row_offset + m_num_columns <= m_columns.size());
342
343 for (size_t index = 0; index < m_num_columns; ++index) {
344 bool last_col = (index == m_num_columns - 1);
345 if (!cbk(m_columns[row_offset + index], last_col)) {
346 return false;
347 }
348 }
349 return true;
350 }
351
352 void reset() {
353 for (auto &col : m_columns) {
354 col.init();
355 }
356 }
357
358 /** Get current row offset to access columns.
359 @param[in] row_index row index
360 @return row offset in column vector. */
361 size_t get_row_offset(size_t row_index) const {
362 assert(row_index < m_num_rows);
363 return row_index * m_num_columns;
364 }
365
366 /** Get next row offset from current row offset.
367 @param[in,out] offset row offset
368 @return true if there is a next row. */
369 size_t get_next_row_offset(size_t &offset) const {
370 offset += m_num_columns;
371 return (offset < m_columns.size());
372 }
373
374 /** Get column using row offset and column index.
375 @param[in] row_offset row offset in column vector
376 @param[in] col_index index of the column within row
377 @return column data */
378 Column_type &get_column(size_t row_offset, size_t col_index) {
379 assert(col_index < m_num_columns);
380 assert(row_offset + col_index < m_columns.size());
381 return m_columns[row_offset + col_index];
382 }
383
384 /** Get column using row index and column index.
385 @param[in] row_index index of the row in the bunch
386 @param[in] col_index index of the column within row
387 @return column data */
388 Column_type &get_col(size_t row_index, size_t col_index) {
389 return get_column(get_row_offset(row_index), col_index);
390 }
391
392 /** Get column using the column offset.
393 @param[in] col_offset column offset
394 @return column data */
395 Column_type &get_col(size_t col_offset) { return m_columns[col_offset]; }
396
397 /** Get constant column for reading using row offset and column index.
398 @param[in] row_offset row offset in column vector
399 @param[in] col_index index of the column within row
400 @return column data */
401 const Column_type &read_column(size_t row_offset, size_t col_index) const {
402 assert(col_index < m_num_columns);
403 assert(row_offset + col_index < m_columns.size());
404 return m_columns[row_offset + col_index];
405 }
406
407 /** Set the number of rows. Adjust number of rows base on maximum column
408 storage limit.
409 @param[in,out] n_rows number of rows
410 @return true if successful, false if too many rows or columns. */
411 bool set_num_rows(size_t n_rows) {
412 /* Avoid any overflow during multiplication. */
413 if (n_rows > std::numeric_limits<uint32_t>::max() ||
415 return false;
416 }
417 auto total_cols = (uint64_t)n_rows * m_num_columns;
418
419 if (total_cols > S_MAX_TOTAL_COLS) {
420 return false;
421 }
422
423 m_num_rows = n_rows;
424
425 /* Extend columns if needed. */
426 if (m_columns.size() < total_cols) {
427 m_columns.resize(total_cols);
428 }
429 return true;
430 }
431
432 /** Limit allocation up to 600M columns. This number is rounded up from an
433 * estimate of the number of columns with the max chunk size (1024M). In the
434 * worst case we can have 2 bytes per column so a chunk can contain around
435 * 512M columns, and because of rows that spill over chunk boundaries we
436 * assume we can append a full additional row (which should have at most
437 * 4096 columns). Rounded up to 600M. */
438 const static size_t S_MAX_TOTAL_COLS = 600 * 1024 * 1024;
439
440 private:
441 /** All the columns. */
442 std::vector<Column_type> m_columns;
443
444 /** Number of rows. */
445 size_t m_num_rows{};
446
447 /** Number of columns in each row. */
449};
450
453
454/** Column metadata information. */
456 /** Data comparison method. */
457 enum class Compare {
458 /* Integer comparison */
460 /* Unsigned Integer comparison */
462 /* Binary comparison (memcmp) */
463 BINARY,
464 /* Need to callback to use appropriate comparison function in server. */
465 MYSQL
466 };
467
468 std::string get_compare_string() const {
469 switch (m_compare) {
471 return "INTEGER_SIGNED";
473 return "INTEGER_UNSIGNED";
474 case Compare::BINARY:
475 return "BINARY";
476 case Compare::MYSQL:
477 return "MYSQL";
478 }
479 assert(0);
480 return "INVALID";
481 }
482
483 /** @return true if integer type. */
484 bool is_integer() const {
487 }
488
489 /** Based on the column data type check if it can be stored externally.
490 @return true if the column data can be stored externally
491 @return false if the column data cannot be stored externally */
492 bool can_be_stored_externally() const;
493
494 /** true if this column is part of secondary index. */
495 bool m_is_part_of_sk{false};
496
497 /** Field type. (@ref enum_field_types) */
499
500 /** If column could be NULL. */
501 bool m_is_nullable{false};
502
503 /** true if column belongs to primary index (key or non-key) */
504 bool m_is_pk{false};
505
506 /** true if column is a key for primary or secondary index. */
507 bool m_is_key{false};
508
509 /** If the key is descending. */
510 bool m_is_desc_key{false};
511
512 /** If the key is prefix of the column. */
513 bool m_is_prefix_key{false};
514
515 /** If it is fixed length type. */
516 bool m_is_fixed_len{false};
517
518 /** If it is integer type. */
520
521 /** If it is unsigned integer type. */
522 bool m_is_unsigned{false};
523
524 /** Check the row header to find out if it is fixed length. For
525 character data type the row header indicates fixed length. */
527
528 /** If character column length can be kept in one byte. */
530
531 /** The length of column data if fixed. */
532 uint16_t m_fixed_len;
533
534 /** Maximum length of data in bytes. */
535 uint16_t m_max_len;
536
537 /** Index of column in row. */
538 uint16_t m_index;
539
540 /** Position of column in table. Refer to Field::field_index() */
542
543 /** Byte index in NULL bitmap. */
544 uint16_t m_null_byte;
545
546 /** BIT number in NULL bitmap. */
547 uint16_t m_null_bit;
548
549 /** Character set for char & varchar columns. */
550 const void *m_charset;
551
552 /** Field name */
553 std::string m_field_name;
554
555 /** Get a string representation of Column_meta object. Useful only for
556 debugging purposes.
557 @see Column_meta
558 @return string representation of this object. */
559 std::string to_string() const;
560
561 /** Print this object into the given output stream.
562 @param[in] out output stream into which object will be printed
563 @return given output stream. */
564 std::ostream &print(std::ostream &out) const;
565
566 /** Get the data type of the column as a string.
567 @return data type of the column as a string. */
568 std::string get_type_string() const;
569};
570
571inline std::string Column_meta::get_type_string() const {
572 switch (m_type) {
574 return "decimal";
575 case MYSQL_TYPE_TINY:
576 return "tiny";
577 case MYSQL_TYPE_SHORT:
578 return "short";
579 case MYSQL_TYPE_LONG:
580 return "long";
581 case MYSQL_TYPE_FLOAT:
582 return "float";
584 return "double";
585 case MYSQL_TYPE_NULL:
586 return "null";
588 return "timestamp";
590 return "longlong";
591 case MYSQL_TYPE_INT24:
592 return "int";
593 case MYSQL_TYPE_DATE:
594 return "date";
595 case MYSQL_TYPE_TIME:
596 return "time";
598 return "datetime";
599 case MYSQL_TYPE_YEAR:
600 return "year";
602 return "date";
604 return "varchar";
605 case MYSQL_TYPE_BIT:
606 return "bit";
608 return "timestamp";
610 return "datetime";
611 case MYSQL_TYPE_TIME2:
612 return "time";
614 return "typed_array";
616 return "vector";
618 return "invalid";
619 case MYSQL_TYPE_BOOL:
620 return "bool";
621 case MYSQL_TYPE_JSON:
622 return "json";
624 return "decimal";
625 case MYSQL_TYPE_ENUM:
626 return "enum";
627 case MYSQL_TYPE_SET:
628 return "set";
630 return "tiny_blob";
632 return "medium_blob";
634 return "long_blob";
635 case MYSQL_TYPE_BLOB:
636 return "blob";
638 return "var_string";
640 return "string";
642 return "geometry";
643 }
644 return "invalid";
645}
646
648 switch (m_type) {
649 case MYSQL_TYPE_JSON:
654 case MYSQL_TYPE_BLOB:
657 return true;
658 }
659 default:
660 break;
661 }
662 return false;
663}
664
665inline std::string Column_meta::to_string() const {
667 out << "[Column_meta: m_type=" << get_type_string()
668 << ", m_field_name=" << m_field_name << ", m_index=" << m_index
669 << ", m_field_index=" << m_field_index
670 << ", m_is_single_byte_len=" << m_is_single_byte_len
671 << ", m_is_fixed_len=" << m_is_fixed_len
672 << ", m_fixed_len=" << m_fixed_len << ", m_null_byte=" << m_null_byte
673 << ", m_null_bit=" << m_null_bit << ", m_compare=" << get_compare_string()
674 << ", m_is_desc_key=" << m_is_desc_key << ", m_is_key=" << m_is_key
675 << ", m_max_len=" << m_max_len << ", m_is_prefix_key=" << m_is_prefix_key
676 << "]";
677 return out.str();
678}
679
680inline std::ostream &Column_meta::print(std::ostream &out) const {
681 out << to_string();
682 return out;
683}
684
685/** Overloading the global output operator to print objects of type
686Column_meta.
687@param[in] out output stream
688@param[in] obj object to be printed
689@return given output stream. */
690inline std::ostream &operator<<(std::ostream &out, const Column_meta &obj) {
691 return obj.print(out);
692}
693
694/** Table metadata. */
696 /** Number of keys/indexes the table has. */
697 size_t m_n_keys;
698
699 /** Key number of the primary key. */
701
702 /** True if generated DB_ROW_ID is the pk. */
703 bool dbrowid_is_pk{false};
704
707
708 /** Table being bulk loaded. */
709 std::string m_table_name;
710};
711
712/** Row metadata */
713struct Row_meta {
714 /** Key type for fast comparison. */
715 enum class Key_type {
716 /* All Keys are signed integer an ascending. */
718 /* All keys are integer. */
719 INT,
720 /* Keys are of any supported type. */
721 ANY
722 };
723 /** All columns in a row are arranged with key columns first. */
724 std::vector<Column_meta> m_columns;
725
726 /** All columns in a row arranged as per col_index. */
727 std::vector<const Column_meta *> m_columns_text_order;
728
729 /** Get a string representation of this Row_meta object.
730 @see Row_meta
731 @return string representation of this object. */
732 std::string to_string() const;
733
734 /** Get the metadata of the given column.
735 @param[in] col_index position of the column in the index.
736 @return metadata of the requested column. */
737 const Column_meta &get_column_meta_index_order(size_t col_index) const {
738 assert(col_index < m_columns.size());
739 return m_columns[col_index];
740 }
741
742 /** Get the meta data of the column.
743 @param[in] col_index the index of the column as it appears in CSV file.
744 @return a reference to the column meta data.*/
745 const Column_meta &get_column_meta(size_t col_index) const {
746 assert(col_index < m_columns_text_order.size());
747 assert(col_index == m_columns_text_order[col_index]->m_index);
748 return *m_columns_text_order[col_index];
749 }
750
751 /** Total bitmap header length for the row. */
752 size_t m_bitmap_length = 0;
753
754 /** Total header length. */
755 size_t m_header_length = 0;
756
757 /** Length of the first key column. Helps to get the row pointer from first
758 key data pointer. */
759 size_t m_first_key_len = 0;
760
761 /** Key length in bytes for non-integer keys. This is required to estimate
762 the space required to save keys. */
763 size_t m_key_length = 0;
764
765 /** Number of columns used in primary key. */
766 uint32_t m_keys = 0;
767
768 /** Number of columns not used in primary Key. */
769 uint32_t m_non_keys = 0;
770
771 /** Key type for comparison. */
773
774 /** Total number of columns. A key could be on a column prefix.
775 m_columns <= m_keys + m_non_keys */
776 uint32_t m_num_columns = 0;
777
778 /** Approximate row length. */
780
781 /** Number of columns that can be stored externally. */
782 size_t m_n_blob_cols{0};
783
784 /** Name of the key */
785 std::string m_name;
786
787 /** true if primary key, false if secondary key. */
788 bool is_pk{false};
789
790 /** true if DB_ROW_ID is the pk, false otherwise. */
791 bool dbrowid_is_pk{false};
792};
793
794inline std::ostream &operator<<(std::ostream &os,
796 switch (key_type) {
798 os << "ANY";
799 break;
801 os << "INT_SIGNED_ASC";
802 break;
804 os << "INT";
805 break;
806 }
807 return os;
808}
809
810inline std::string Row_meta::to_string() const {
812 out << "[Row_meta: m_name=" << m_name << ", m_num_columns=" << m_num_columns
813 << ", m_keys=" << m_keys << ", m_non_keys=" << m_non_keys
814 << ", m_key_length=" << m_key_length << ", m_key_type=" << m_key_type
815 << ", m_approx_row_len=" << m_approx_row_len;
816 for (auto &col_meta : m_columns) {
817 out << col_meta.to_string() << ", ";
818 }
819 out << "]";
820 return out.str();
821}
822
823inline char *Column_mysql::get_row_begin(const Row_meta &row_meta,
824 size_t col_index
825 [[maybe_unused]]) const {
826 assert(m_is_null || col_index == 0);
827 return m_is_null ? m_data_ptr
828 : (m_data_ptr - row_meta.m_first_key_len -
829 row_meta.m_header_length);
830}
831
832namespace Bulk_load {
833
836 public:
837 void KeyTooBig() const override;
838 void ValueTooBig() const override;
839 void TooDeep() const override;
840 void InvalidJson() const override;
841 void InternalError(const char *message) const override;
842 bool CheckStack() const override;
843
844 const char *c_str() const { return m_error.c_str(); }
845
846 std::string get_error() const { return m_error; }
847
848 private:
849 mutable std::string m_error{};
850};
851
853 m_error = "Key is too big";
854}
855
857 m_error = "Value is too big";
858}
859
861 m_error = "JSON document has more nesting levels than supported";
862}
864 m_error = "Invalid JSON value is encountered";
865}
867 const char *message [[maybe_unused]]) const {
868 m_error = message;
869 m_error += " (Internal Error)";
870}
871
873 return false;
874}
875
876/** Callbacks for collecting time statistics */
878 /* Operation begin. */
879 std::function<void()> m_fn_begin;
880 /* Operation end. */
881 std::function<void()> m_fn_end;
882};
883
885 std::pair<std::optional<Rows_mysql>, std::optional<Rows_mysql>>;
886
888 std::string schema;
889 std::string table;
891};
892
893/** Contains the data needed for the ROW_ID generation for tables without
894explicit primary key */
896 /** Get an estimate of the number of rows to be handled by each thread.
897 This will give the number of row ids to be generated by each thread.
898 @return number of rows to be handled by each thread. */
899 size_t get_rows_per_thread() const {
900 size_t estimated_total_rows = m_total_size / m_avg_row_len.load();
901 size_t min_total_rows = 1000;
902
903 if (estimated_total_rows < min_total_rows) {
904 estimated_total_rows = min_total_rows;
905 }
906
907 return (estimated_total_rows + m_n_loaders) / m_n_loaders;
908 }
909
910 /** Get the next available range for generating DB_ROW_ID. The range includes
911 the begin value but excludes the end value.
912 @return the range for row ids for exclusive use by the calling thread. */
913 inline std::pair<uint64_t, uint64_t> get_next_rowid_range() const {
914 std::unique_lock<std::mutex> lock(m_rowid_mutex);
915
916 const uint64_t range_begin = m_next_rowid_range;
918
919 return std::make_pair(range_begin, m_next_rowid_range);
920 }
921
922 void set_begin_rowid_value(size_t row_id) { m_next_rowid_range = row_id; }
923 /* Total data size of CSV files (in bytes) */
925 /* Average row length, updated by the CSV parsing threads for each batch. */
926 std::atomic<size_t> m_avg_row_len;
927 /* Number of loaders aka concurrency in phase 1. */
929
930 private:
931 /** Protects the member m_next_rowid_range */
932 mutable std::mutex m_rowid_mutex;
933
934 /* Number of rows per subtree. */
935 mutable size_t m_next_rowid_range{0};
936};
937
938} // namespace Bulk_load
939
940/** Bulk Data conversion. */
941BEGIN_SERVICE_DEFINITION(bulk_data_convert)
942/** Convert row from text format for MySQL column format. Convert as many
943rows as possible consuming the data buffer starting form next_index. On
944output next_index is the next row index that is not yet consumed. If it
945matches the size of input text_rows, then all rows are consumed.
946@param[in,out] thd session THD
947@param[in] table MySQL TABLE
948@param[in] text_rows rows with column in text
949@param[in,out] next_index next_index in text_rows to be processed
950@param[in,out] buffer data buffer for keeping sql row data
951@param[in,out] buffer_length length of the data buffer
952@param[in] charset input row data character set
953@param[in] metadata row metadata
954@param[out] sql_rows rows with column in MySQL column format
955@return error code. */
957 (THD * thd, const TABLE *table, const Rows_text &text_rows,
958 size_t &next_index, char *buffer, size_t &buffer_length,
959 const CHARSET_INFO *charset, const Row_meta &metadata,
960 Rows_mysql &sql_rows,
962
963/** Convert row to MySQL column format from raw form
964@param[in,out] buffer input raw data buffer
965@param[in] buffer_length buffer length
966@param[in] metadata row metadata
967@param[in] start_index start row index in row bunch
968@param[out] consumed_length length of buffer consumed
969@param[in,out] sql_rows row bunch to fill data
970@return error code. */
972 (char *buffer, size_t buffer_length, const Row_meta &metadata,
973 size_t start_index, size_t &consumed_length,
974 Rows_mysql &sql_rows));
975
976/** Convert row to MySQL column format using the key
977@param[in] metadata row metadata
978@param[in] sql_keys Key bunch
979@param[in] key_offset offset for the key
980@param[in,out] sql_rows row bunch to fill data
981@param[in] sql_index index of the row to be filled
982@return error code. */
984 (const Row_meta &metadata, const Rows_mysql &sql_keys,
985 size_t key_offset, Rows_mysql &sql_rows, size_t sql_index));
986
987/** Check if session is interrupted.
988@param[in,out] thd session THD
989@return true if connection or statement is killed. */
991
992/** Compare two key columns
993@param[in] key1 first key
994@param[in] key2 second key
995@param[in] col_meta column meta information
996@return positive, 0, negative, if key_1 is greater, equal, less than key_2 */
998 (const Column_mysql &key1, const Column_mysql &key2,
999 const Column_meta &col_meta));
1000
1001/** Get row metadata information for all the indexes.
1002@param[in,out] thd session THD
1003@param[in] table MySQL TABLE
1004@param[in] have_key include Primary Key metadata
1005@param[out] metadata Metadata for each of the indexes.
1006@return true if successful. */
1008 (THD * thd, const TABLE *table, bool have_key,
1009 std::vector<Row_meta> &metadata));
1010
1011/** Get table metadata information for the table being bulk loaded.
1012@param[in,out] thd session THD
1013@param[in] table MySQL TABLE
1014@param[out] metadata Metadata of the table.
1015@return true if successful. */
1017 (THD * thd, const TABLE *table, Table_meta &metadata));
1018
1019END_SERVICE_DEFINITION(bulk_data_convert)
1020
1021/** Column metadata information. */
1022/* Bulk data load to SE. */
1024/** Begin Loading bulk data to SE.
1025@param[in,out] thd session THD
1026@param[in] table MySQL TABLE
1027@param[in] keynr key number, identifying the index being loaded.
1028@param[in] data_size total data size to load
1029@param[in] memory SE memory to be used
1030@param[in] num_threads Number of concurrent threads
1031@return SE bulk load context or nullptr in case of an error. */
1032DECLARE_METHOD(void *, begin,
1033 (THD * thd, const TABLE *table, size_t keynr, size_t data_size,
1034 size_t memory, size_t num_threads));
1035
1036/** Load a set of rows to SE table by one thread.
1037@param[in,out] thd session THD
1038@param[in,out] ctx SE load context returned by begin()
1039@param[in] table MySQL TABLE
1040@param[in] sql_rows row data to load
1041@param[in] thread current thread number
1042@param[in] wait_cbks wait stat callbacks
1043@return true if successful. */
1044DECLARE_METHOD(bool, load,
1045 (THD * thd, void *ctx, const TABLE *table,
1046 const Rows_mysql &sql_rows, size_t thread,
1047 Bulk_load::Stat_callbacks &wait_cbks));
1048
1049/** Create a blob context object to insert a blob.
1050@param[in,out] thd session THD
1051@param[in,out] load_ctx SE load context returned by begin()
1052@param[in] table MySQL TABLE
1053@param[out] blob_ctx a blob context object to insert a blob.
1054@param[out] blobref buffer to hold blob reference
1055@param[in] thread current thread number
1056@return true if successful. */
1058 (THD * thd, void *load_ctx, const TABLE *table,
1059 Blob_context &blob_ctx, unsigned char *blobref, size_t thread));
1060
1061/** Write data into a blob
1062@param[in,out] thd session THD
1063@param[in,out] load_ctx SE load context returned by begin()
1064@param[in] table MySQL TABLE
1065@param[in] blob_ctx a blob context object to insert a blob.
1066@param[out] blobref buffer to hold blob reference
1067@param[in] thread current thread number
1068@param[in] data blob data to be written
1069@param[in] data_len length of blob data to be written (in bytes);
1070@return true if successful. */
1072 (THD * thd, void *load_ctx, const TABLE *table,
1073 Blob_context blob_ctx, unsigned char *blobref, size_t thread,
1074 const unsigned char *data, size_t data_len));
1075
1076/** Close the blob
1077@param[in,out] thd session THD
1078@param[in,out] load_ctx SE load context returned by begin()
1079@param[in] table MySQL TABLE
1080@param[in] blob_ctx a blob context object to insert a blob.
1081@param[out] blobref buffer to hold blob reference
1082@param[in] thread current thread number
1083@return true if successful. */
1085 (THD * thd, void *load_ctx, const TABLE *table,
1086 Blob_context blob_ctx, unsigned char *blobref, size_t thread));
1087
1088/** End Loading bulk data to SE.
1089
1090Called at the end of bulk load execution, even if begin or load calls failed.
1091
1092@param[in,out] thd session THD
1093@param[in,out] ctx SE load context
1094@param[in] table MySQL TABLE
1095@param[in] error true, if exiting after error
1096@return true if successful. */
1097DECLARE_METHOD(bool, end,
1098 (THD * thd, void *ctx, const TABLE *table, bool error));
1099
1100/** Check if a table is supported by the bulk load implementation.
1101@param[in,out] thd session THD
1102@param[in] table MySQL TABLE
1103@return true if table is supported. */
1105
1106/** Get available buffer pool memory for bulk load operations.
1107@param[in,out] thd session THD
1108@param[in] table MySQL TABLE
1109@return buffer pool memory available for bulk load. */
1111
1112/** Copies data from existing table into the duplicated table during incremental
1113load. This is called after the bulk load component detects we reached the end of
1114the CSV input for the respective sub-loader and it signals that the loader
1115should now iterate through the remainded or the existing data in the original
1116table and migrate it.
1117@param[in,out] ctx SE load context
1118@param[in] table MySQL TABLE
1119@param[in] thread loader thread index
1120@param[in,out] wait_cbks wait stat callbacks
1121@return true if successful, false otherwise. */
1123 (void *ctx, const TABLE *table, size_t thread,
1124 Bulk_load::Stat_callbacks &wait_cbks));
1125
1126/** Sets the source table data (table name and key range boundaries) for all
1127loaders.
1128@param[in,out] ctx SE load context
1129@param[in] table MySQL TABLE
1130@param[in] source_table_data vector containing the source table data
1131@return true if successful, false otherwise. */
1134 (void *ctx, const TABLE *table,
1135 const std::vector<Bulk_load::Source_table_data> &source_table_data));
1136
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:835
const char * c_str() const
Definition: bulk_data_service.h:844
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:852
std::string get_error() const
Definition: bulk_data_service.h:846
std::string m_error
Definition: bulk_data_service.h:849
void InternalError(const char *message) const override
Called when an internal error occurs.
Definition: bulk_data_service.h:866
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:856
void TooDeep() const override
Called when a JSON document has more nesting levels than supported.
Definition: bulk_data_service.h:860
void InvalidJson() const override
Called when an invalid JSON value is encountered.
Definition: bulk_data_service.h:863
bool CheckStack() const override
Check if the stack is about to be exhausted, and report the error.
Definition: bulk_data_service.h:872
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:315
bool set_num_rows(size_t n_rows)
Set the number of rows.
Definition: bulk_data_service.h:411
std::vector< Column_type > m_columns
All the columns.
Definition: bulk_data_service.h:442
size_t get_next_row_offset(size_t &offset) const
Get next row offset from current row offset.
Definition: bulk_data_service.h:369
Column_type & get_col(size_t col_offset)
Get column using the column offset.
Definition: bulk_data_service.h:395
bool process_columns(size_t row_index, F &&cbk)
Process all columns, invoking callback for each.
Definition: bulk_data_service.h:332
bool process_columns_by_offset(size_t row_offset, F &&cbk)
Definition: bulk_data_service.h:340
size_t get_num_cols() const
Definition: bulk_data_service.h:325
void reset()
Definition: bulk_data_service.h:352
size_t m_num_rows
Number of rows.
Definition: bulk_data_service.h:445
size_t get_row_offset(size_t row_index) const
Get current row offset to access columns.
Definition: bulk_data_service.h:361
size_t get_num_rows() const
Definition: bulk_data_service.h:322
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:401
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:388
Row_bunch(size_t n_cols)
Create a new row bunch.
Definition: bulk_data_service.h:319
static const size_t S_MAX_TOTAL_COLS
Limit allocation up to 600M columns.
Definition: bulk_data_service.h:438
size_t m_num_columns
Number of columns in each row.
Definition: bulk_data_service.h:448
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:378
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:55
@ MYSQL_TYPE_BOOL
Currently just a placeholder.
Definition: field_types.h:79
@ MYSQL_TYPE_TIME2
Internal to MySQL.
Definition: field_types.h:75
@ MYSQL_TYPE_VARCHAR
Definition: field_types.h:71
@ MYSQL_TYPE_LONGLONG
Definition: field_types.h:64
@ MYSQL_TYPE_LONG_BLOB
Definition: field_types.h:86
@ MYSQL_TYPE_VAR_STRING
Definition: field_types.h:88
@ MYSQL_TYPE_BLOB
Definition: field_types.h:87
@ MYSQL_TYPE_TINY
Definition: field_types.h:57
@ MYSQL_TYPE_TIME
Definition: field_types.h:67
@ MYSQL_TYPE_SET
Definition: field_types.h:83
@ MYSQL_TYPE_NEWDATE
Internal to MySQL.
Definition: field_types.h:70
@ MYSQL_TYPE_VECTOR
Definition: field_types.h:77
@ MYSQL_TYPE_JSON
Definition: field_types.h:80
@ MYSQL_TYPE_STRING
Definition: field_types.h:89
@ MYSQL_TYPE_NULL
Definition: field_types.h:62
@ MYSQL_TYPE_ENUM
Definition: field_types.h:82
@ MYSQL_TYPE_TINY_BLOB
Definition: field_types.h:84
@ MYSQL_TYPE_LONG
Definition: field_types.h:59
@ MYSQL_TYPE_BIT
Definition: field_types.h:72
@ MYSQL_TYPE_INVALID
Definition: field_types.h:78
@ MYSQL_TYPE_GEOMETRY
Definition: field_types.h:90
@ MYSQL_TYPE_NEWDECIMAL
Definition: field_types.h:81
@ MYSQL_TYPE_DECIMAL
Definition: field_types.h:56
@ MYSQL_TYPE_TYPED_ARRAY
Used for replication only.
Definition: field_types.h:76
@ MYSQL_TYPE_DOUBLE
Definition: field_types.h:61
@ MYSQL_TYPE_MEDIUM_BLOB
Definition: field_types.h:85
@ MYSQL_TYPE_DATETIME2
Internal to MySQL.
Definition: field_types.h:74
@ MYSQL_TYPE_SHORT
Definition: field_types.h:58
@ MYSQL_TYPE_DATE
Definition: field_types.h:66
@ MYSQL_TYPE_FLOAT
Definition: field_types.h:60
@ MYSQL_TYPE_TIMESTAMP
Definition: field_types.h:63
@ MYSQL_TYPE_INT24
Definition: field_types.h:65
@ MYSQL_TYPE_DATETIME
Definition: field_types.h:68
@ MYSQL_TYPE_TIMESTAMP2
Definition: field_types.h:73
@ MYSQL_TYPE_YEAR
Definition: field_types.h:69
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:1904
bool get_table_metadata(THD *thd, const TABLE *table, Table_meta &table_meta) noexcept
Definition: bulk_data_service.cc:2576
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:1935
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:2597
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:1845
bool is_killed(THD *thd) noexcept
Definition: bulk_data_service.cc:1987
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:2777
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:2663
size_t get_se_memory_size(THD *thd, const TABLE *table) noexcept
Definition: bulk_data_service.cc:2771
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:2786
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:2673
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:2681
bool is_table_supported(THD *thd, const TABLE *table) noexcept
Definition: bulk_data_service.cc:2791
Definition: bulk_data_service.h:832
std::pair< std::optional< Rows_mysql >, std::optional< Rows_mysql > > Read_range
Definition: bulk_data_service.h:885
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:2876
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2880
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:895
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:913
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:899
std::atomic< size_t > m_avg_row_len
Definition: bulk_data_service.h:926
std::mutex m_rowid_mutex
Protects the member m_next_rowid_range.
Definition: bulk_data_service.h:932
void set_begin_rowid_value(size_t row_id)
Definition: bulk_data_service.h:922
size_t m_n_loaders
Definition: bulk_data_service.h:928
size_t m_total_size
Definition: bulk_data_service.h:924
size_t m_next_rowid_range
Definition: bulk_data_service.h:935
Definition: bulk_data_service.h:887
Read_range range
Definition: bulk_data_service.h:890
std::string table
Definition: bulk_data_service.h:889
std::string schema
Definition: bulk_data_service.h:888
Callbacks for collecting time statistics.
Definition: bulk_data_service.h:877
std::function< void()> m_fn_begin
Definition: bulk_data_service.h:879
std::function< void()> m_fn_end
Definition: bulk_data_service.h:881
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:455
bool m_is_prefix_key
If the key is prefix of the column.
Definition: bulk_data_service.h:513
enum_field_types m_type
Field type.
Definition: bulk_data_service.h:498
std::string m_field_name
Field name.
Definition: bulk_data_service.h:553
std::string get_type_string() const
Get the data type of the column as a string.
Definition: bulk_data_service.h:571
uint16_t m_index
Index of column in row.
Definition: bulk_data_service.h:538
bool m_is_single_byte_len
If character column length can be kept in one byte.
Definition: bulk_data_service.h:529
uint16_t m_null_byte
Byte index in NULL bitmap.
Definition: bulk_data_service.h:544
bool m_is_desc_key
If the key is descending.
Definition: bulk_data_service.h:510
Compare m_compare
If it is integer type.
Definition: bulk_data_service.h:519
bool m_is_pk
true if column belongs to primary index (key or non-key)
Definition: bulk_data_service.h:504
uint16_t m_fixed_len
The length of column data if fixed.
Definition: bulk_data_service.h:532
std::string to_string() const
Get a string representation of Column_meta object.
Definition: bulk_data_service.h:665
bool is_integer() const
Definition: bulk_data_service.h:484
Compare
Data comparison method.
Definition: bulk_data_service.h:457
uint16_t m_field_index
Position of column in table.
Definition: bulk_data_service.h:541
uint16_t m_max_len
Maximum length of data in bytes.
Definition: bulk_data_service.h:535
bool m_is_fixed_len
If it is fixed length type.
Definition: bulk_data_service.h:516
bool m_is_key
true if column is a key for primary or secondary index.
Definition: bulk_data_service.h:507
uint16_t m_null_bit
BIT number in NULL bitmap.
Definition: bulk_data_service.h:547
bool can_be_stored_externally() const
Based on the column data type check if it can be stored externally.
Definition: bulk_data_service.h:647
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:526
std::ostream & print(std::ostream &out) const
Print this object into the given output stream.
Definition: bulk_data_service.h:680
bool m_is_nullable
If column could be NULL.
Definition: bulk_data_service.h:501
bool m_is_part_of_sk
true if this column is part of secondary index.
Definition: bulk_data_service.h:495
bool m_is_unsigned
If it is unsigned integer type.
Definition: bulk_data_service.h:522
std::string get_compare_string() const
Definition: bulk_data_service.h:468
const void * m_charset
Character set for char & varchar columns.
Definition: bulk_data_service.h:550
Definition: bulk_data_service.h:208
uint64_t m_int_data
Column data in integer format.
Definition: bulk_data_service.h:250
bool is_ext() const
Definition: bulk_data_service.h:229
std::string to_string() const
Definition: bulk_data_service.h:274
bool m_is_null
If column is NULL.
Definition: bulk_data_service.h:216
void set_ext()
Mark this column as externally stored.
Definition: bulk_data_service.h:226
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:823
char * m_data_ptr
Column data or row begin.
Definition: bulk_data_service.h:271
char * get_data() const
Definition: bulk_data_service.h:221
int16_t m_type
Column Data Type.
Definition: bulk_data_service.h:210
uint16_t m_data_len
Column data length.
Definition: bulk_data_service.h:213
void set_data(char *ptr)
Definition: bulk_data_service.h:223
void init()
Definition: bulk_data_service.h:252
bool m_is_ext
If column data is stored externally in InnoDB.
Definition: bulk_data_service.h:219
void row(char *row_begin)
Save the beginning of the row pointer in this object.
Definition: bulk_data_service.h:234
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:113
bool is_ext_relaxed() const
Check if the column data is stored externally.
Definition: bulk_data_service.h:133
bool m_is_ext
If true, the column data is stored externally.
Definition: bulk_data_service.h:161
void set_null()
Mark the column to be null, by setting length to a special value.
Definition: bulk_data_service.h:106
std::ostream & print(std::ostream &out) const
Print this object into the given output stream.
Definition: bulk_data_service.h:190
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:98
uint64_t m_row_id
The generated DB_ROW_ID value.
Definition: bulk_data_service.h:101
void init()
Initialize the members.
Definition: bulk_data_service.h:145
void set_ext()
Mark that the column data has been stored externally.
Definition: bulk_data_service.h:139
bool is_ext() const
Check if the column data is stored externally.
Definition: bulk_data_service.h:124
size_t m_data_len
Column data length.
Definition: bulk_data_service.h:94
std::string to_string() const
Definition: bulk_data_service.h:164
Definition: mysql.h:300
Row metadata.
Definition: bulk_data_service.h:713
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:737
const Column_meta & get_column_meta(size_t col_index) const
Get the meta data of the column.
Definition: bulk_data_service.h:745
size_t m_n_blob_cols
Number of columns that can be stored externally.
Definition: bulk_data_service.h:782
size_t m_bitmap_length
Total bitmap header length for the row.
Definition: bulk_data_service.h:752
std::string to_string() const
Get a string representation of this Row_meta object.
Definition: bulk_data_service.h:810
bool dbrowid_is_pk
true if DB_ROW_ID is the pk, false otherwise.
Definition: bulk_data_service.h:791
size_t m_first_key_len
Length of the first key column.
Definition: bulk_data_service.h:759
size_t m_header_length
Total header length.
Definition: bulk_data_service.h:755
Key_type
Key type for fast comparison.
Definition: bulk_data_service.h:715
uint32_t m_non_keys
Number of columns not used in primary Key.
Definition: bulk_data_service.h:769
uint32_t m_num_columns
Total number of columns.
Definition: bulk_data_service.h:776
uint32_t m_keys
Number of columns used in primary key.
Definition: bulk_data_service.h:766
size_t m_key_length
Key length in bytes for non-integer keys.
Definition: bulk_data_service.h:763
std::string m_name
Name of the key.
Definition: bulk_data_service.h:785
std::vector< Column_meta > m_columns
All columns in a row are arranged with key columns first.
Definition: bulk_data_service.h:724
std::vector< const Column_meta * > m_columns_text_order
All columns in a row arranged as per col_index.
Definition: bulk_data_service.h:727
Key_type m_key_type
Key type for comparison.
Definition: bulk_data_service.h:772
size_t m_approx_row_len
Approximate row length.
Definition: bulk_data_service.h:779
bool is_pk
true if primary key, false if secondary key.
Definition: bulk_data_service.h:788
Definition: table.h:1456
Table metadata.
Definition: bulk_data_service.h:695
size_t m_keynr_pk
Key number of the primary key.
Definition: bulk_data_service.h:700
size_t max_row_id_value
Definition: bulk_data_service.h:706
bool dbrowid_is_pk
True if generated DB_ROW_ID is the pk.
Definition: bulk_data_service.h:703
std::string m_table_name
Table being bulk loaded.
Definition: bulk_data_service.h:709
size_t min_row_id_value
Definition: bulk_data_service.h:705
size_t m_n_keys
Number of keys/indexes the table has.
Definition: bulk_data_service.h:697