MySQL 8.3.0
Source Code Documentation
bulk_load_service.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#pragma once
24
25/**
26 @file
27 This service provides interface for loading data in bulk from CSV files.
28
29*/
30
32#include <string>
33
34/* Forward declaration for opaque types. */
35class THD;
36struct TABLE;
37struct CHARSET_INFO;
38
39using Bulk_loader = void;
40
41/** Bulk loader source. */
42enum class Bulk_source {
43 /** Local file system. */
44 LOCAL,
45 /** OCI object store. */
46 OCI,
47 /** Amazon S3. */
48 S3
49};
50
51/** Bulk loader string attributes. */
52enum class Bulk_string {
53 /** Schema name */
55 /* Table name */
57 /* File prefix URL */
59 /** Column terminator */
61 /** Row terminator */
63};
64
65/** Bulk loader boolean attributes. */
66enum class Bulk_condition {
67 /** The algorithm used is different based on whether the data is in sorted
68 primary key order. This option tells whether to expect sorted input. */
70 /** If enclosing is optional. */
72};
73
74/** Bulk loader size attributes. */
75enum class Bulk_size {
76 /** Number of input files. */
78 /** Number of rows to skip. */
80 /** Number of columns in the table. */
82 /** Number of concurrent loaders to use, */
84 /** Total memory size to use for LOAD in bytes. */
85 MEMORY
86};
87
88/** Bulk loader single byte attributes. */
89enum class Bulk_char {
90 /** Escape character. */
92 /** Column enclosing character. */
94};
95
96/** Bulk load driver service. */
97BEGIN_SERVICE_DEFINITION(bulk_load_driver)
98
99/**
100 Create bulk loader.
101 @param[in] thd mysql THD
102 @param[in] table mysql TABLE object
103 @param[in] src bulk loader source
104 @param[in] charset source data character set
105 @return bulk loader object, opaque type.
106*/
107DECLARE_METHOD(Bulk_loader *, create_bulk_loader,
108 (THD * thd, const TABLE *table, Bulk_source src,
110/**
111 Set string attribute for loading data.
112 @param[in,out] loader bulk loader
113 @param[in] type attribute type
114 @param[in] value attribute value
115*/
116DECLARE_METHOD(void, set_string,
117 (Bulk_loader * loader, Bulk_string type, std::string value));
118/**
119 Set single byte character attribute for loading data.
120 @param[in,out] loader bulk loader
121 @param[in] type attribute type
122 @param[in] value attribute value
123*/
124DECLARE_METHOD(void, set_char,
125 (Bulk_loader * loader, Bulk_char type, unsigned char value));
126/**
127 Set size attribute for loading data.
128 @param[in,out] loader bulk loader
129 @param[in] type attribute type
130 @param[in] value attribute value
131*/
132DECLARE_METHOD(void, set_size,
133 (Bulk_loader * loader, Bulk_size type, size_t value));
134/**
135 Set boolean condition attribute for loading data.
136 @param[in,out] loader bulk loader
137 @param[in] type attribute type
138 @param[in] value attribute value
139*/
140DECLARE_METHOD(void, set_condition,
142/**
143 Load data from CSV files.
144 @param[in,out] loader bulk loader
145 @return true if successful.
146*/
147DECLARE_METHOD(bool, load, (Bulk_loader * loader, size_t &affected_rows));
148
149/**
150 Drop bulk loader.
151 @param[in,out] thd mysql THD
152 @param[in,out] loader loader object to drop
153*/
154DECLARE_METHOD(void, drop_bulk_loader, (THD * thd, Bulk_loader *loader));
155
156END_SERVICE_DEFINITION(bulk_load_driver)
Bulk_char
Bulk loader single byte attributes.
Definition: bulk_load_service.h:89
@ ENCLOSE_CHAR
Column enclosing character.
@ ESCAPE_CHAR
Escape character.
Bulk_condition
Bulk loader boolean attributes.
Definition: bulk_load_service.h:66
@ OPTIONAL_ENCLOSE
If enclosing is optional.
@ ORDERED_DATA
The algorithm used is different based on whether the data is in sorted primary key order.
Bulk_source
Bulk loader source.
Definition: bulk_load_service.h:42
@ LOCAL
Local file system.
@ OCI
OCI object store.
@ S3
Amazon S3.
void Bulk_loader
Definition: bulk_load_service.h:39
Bulk_string
Bulk loader string attributes.
Definition: bulk_load_service.h:52
@ COLUMN_TERM
Column terminator.
@ ROW_TERM
Row terminator.
@ SCHEMA_NAME
Schema name.
Bulk_size
Bulk loader size attributes.
Definition: bulk_load_service.h:75
@ COUNT_COLUMNS
Number of columns in the table.
@ MEMORY
Total memory size to use for LOAD in bytes.
@ CONCURRENCY
Number of concurrent loaders to use,.
@ COUNT_ROW_SKIP
Number of rows to skip.
@ COUNT_FILES
Number of input files.
static Mysys_charset_loader * loader
Definition: charset.cc:184
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
static PFS_engine_table_share_proxy table
Definition: pfs.cc:60
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:307
required string type
Definition: replication_group_member_actions.proto:33
#define DECLARE_METHOD(retval, name, args)
Declares a method as a part of the Service definition.
Definition: service.h:102
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:90
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:85
Definition: m_ctype.h:422
Definition: table.h:1403