MySQL
8.0.40
Source Code Documentation
sql_formatter.h
Go to the documentation of this file.
1
/*
2
Copyright (c) 2015, 2024, Oracle and/or its affiliates.
3
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License, version 2.0,
6
as published by the Free Software Foundation.
7
8
This program is designed to work with certain software (including
9
but not limited to OpenSSL) that is licensed under separate terms,
10
as designated in a particular file or component or in included license
11
documentation. The authors of MySQL hereby grant you an additional
12
permission to link the program and your derivative works with the
13
separately licensed software that they have either included with
14
the program or referenced in the documentation.
15
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU General Public License, version 2.0, for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with this program; if not, write to the Free Software
23
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
*/
25
26
#ifndef SQL_FORMATTER_INCLUDED
27
#define SQL_FORMATTER_INCLUDED
28
29
#include <functional>
30
31
#include "
client/dump/abstract_mysql_chain_element_extension.h
"
32
#include "
client/dump/abstract_output_writer_wrapper.h
"
33
#include "
client/dump/abstract_plain_sql_object_dump_task.h
"
34
#include "
client/dump/database_end_dump_task.h
"
35
#include "
client/dump/database_start_dump_task.h
"
36
#include "
client/dump/dump_end_dump_task.h
"
37
#include "
client/dump/dump_start_dump_task.h
"
38
#include "
client/dump/i_data_formatter.h
"
39
#include "
client/dump/mysqldump_tool_chain_maker_options.h
"
40
#include "
client/dump/row_group_dump_task.h
"
41
#include "
client/dump/sql_formatter_options.h
"
42
#include "
client/dump/table_deferred_indexes_dump_task.h
"
43
#include "
client/dump/table_definition_dump_task.h
"
44
#include "
my_inttypes.h
"
45
46
namespace
Mysql
{
47
namespace
Tools {
48
namespace
Dump {
49
50
/**
51
Prints object data in SQL format.
52
*/
53
class
Sql_formatter
:
public
Abstract_output_writer_wrapper
,
54
public
Abstract_mysql_chain_element_extension
,
55
public
virtual
I_data_formatter
{
56
public
:
57
Sql_formatter
(
58
I_connection_provider
*connection_provider,
59
std::function<
bool
(
const
Mysql::Tools::Base::Message_data
&)>
60
*message_handler,
61
Simple_id_generator
*object_id_generator,
62
const
Mysqldump_tool_chain_maker_options
*mysqldump_tool_options,
63
const
Sql_formatter_options
*
options
);
64
65
~Sql_formatter
()
override
;
66
67
/**
68
Creates string representation for output of DB object related to specified
69
dump task object.
70
*/
71
void
format_object
(
Item_processing_data
*item_to_process)
override
;
72
73
// Fix "inherits ... via dominance" warnings
74
void
register_progress_watcher
(
75
I_progress_watcher
*new_progress_watcher)
override
{
76
Abstract_chain_element::register_progress_watcher
(new_progress_watcher);
77
}
78
79
// Fix "inherits ... via dominance" warnings
80
uint64
get_id
()
const override
{
return
Abstract_chain_element::get_id
(); }
81
82
protected
:
83
// Fix "inherits ... via dominance" warnings
84
void
item_completion_in_child_callback
(
85
Item_processing_data
*item_processed)
override
{
86
Abstract_chain_element::item_completion_in_child_callback
(item_processed);
87
}
88
89
private
:
90
void
format_plain_sql_object
(
91
Abstract_plain_sql_object_dump_task
*plain_sql_dump_task);
92
93
void
format_dump_start
(
Dump_start_dump_task
*dump_start_dump_task);
94
95
void
format_dump_end
(
Dump_end_dump_task
*dump_start_dump_task);
96
97
void
format_database_start
(
98
Database_start_dump_task
*database_definition_dump_task);
99
100
void
format_table_definition
(
101
Table_definition_dump_task
*table_definition_dump_task);
102
103
void
format_table_indexes
(
104
Table_deferred_indexes_dump_task
*table_indexes_dump_task);
105
106
void
format_row_group
(
Row_group_dump_task
*row_group);
107
108
void
format_sql_objects_definer
(
Abstract_plain_sql_object_dump_task
*,
109
std::string);
110
111
bool
innodb_stats_tables
(std::string db, std::string table);
112
113
Mysql::Tools::Base::Mysql_query_runner
*
m_escaping_runner
;
114
const
Mysqldump_tool_chain_maker_options
*
m_mysqldump_tool_options
;
115
const
Sql_formatter_options
*
m_options
;
116
};
117
118
}
// namespace Dump
119
}
// namespace Tools
120
}
// namespace Mysql
121
122
#endif
abstract_mysql_chain_element_extension.h
abstract_output_writer_wrapper.h
abstract_plain_sql_object_dump_task.h
Mysql::Tools::Base::Message_data
Structure to represent message from server sent after executing query.
Definition:
message_data.h:49
Mysql::Tools::Base::Mysql_query_runner
Helper class to run SQL query on existing MySQL database server connection, receive all data and all ...
Definition:
mysql_query_runner.h:49
Mysql::Tools::Dump::Abstract_chain_element::register_progress_watcher
void register_progress_watcher(I_progress_watcher *new_progress_watcher) override
Add new Progress Watcher to report to.
Definition:
abstract_chain_element.h:58
Mysql::Tools::Dump::Abstract_chain_element::get_id
uint64 get_id() const override
Returns an application unique ID of this chain element object.
Definition:
abstract_chain_element.cc:36
Mysql::Tools::Dump::Abstract_chain_element::item_completion_in_child_callback
void item_completion_in_child_callback(Item_processing_data *item_processed) override
This callback can be requested to be called by child for any object processing.
Definition:
abstract_chain_element.cc:150
Mysql::Tools::Dump::Abstract_mysql_chain_element_extension
Definition:
abstract_mysql_chain_element_extension.h:48
Mysql::Tools::Dump::Abstract_output_writer_wrapper
Implementation of common logic for classes that directs execution of dump tasks to Data Formatters.
Definition:
abstract_output_writer_wrapper.h:44
Mysql::Tools::Dump::Abstract_plain_sql_object_dump_task
Abstract task for dumping object carrying its definition in SQL formatted string only.
Definition:
abstract_plain_sql_object_dump_task.h:42
Mysql::Tools::Dump::Database_start_dump_task
Definition:
database_start_dump_task.h:35
Mysql::Tools::Dump::Dump_end_dump_task
Definition:
dump_end_dump_task.h:35
Mysql::Tools::Dump::Dump_start_dump_task
Definition:
dump_start_dump_task.h:35
Mysql::Tools::Dump::I_connection_provider
Definition:
i_connection_provider.h:38
Mysql::Tools::Dump::I_data_formatter
Definition:
i_data_formatter.h:36
Mysql::Tools::Dump::I_progress_watcher
Definition:
i_progress_watcher.h:37
Mysql::Tools::Dump::Item_processing_data
Data structure for objects that are processed in any chain.
Definition:
item_processing_data.h:43
Mysql::Tools::Dump::Mysqldump_tool_chain_maker_options
Definition:
mysqldump_tool_chain_maker_options.h:44
Mysql::Tools::Dump::Row_group_dump_task
Represents single data row.
Definition:
row_group_dump_task.h:43
Mysql::Tools::Dump::Simple_id_generator
Definition:
simple_id_generator.h:37
Mysql::Tools::Dump::Sql_formatter_options
Definition:
sql_formatter_options.h:47
Mysql::Tools::Dump::Sql_formatter
Prints object data in SQL format.
Definition:
sql_formatter.h:55
Mysql::Tools::Dump::Sql_formatter::format_row_group
void format_row_group(Row_group_dump_task *row_group)
Definition:
sql_formatter.cc:46
Mysql::Tools::Dump::Sql_formatter::m_escaping_runner
Mysql::Tools::Base::Mysql_query_runner * m_escaping_runner
Definition:
sql_formatter.h:113
Mysql::Tools::Dump::Sql_formatter::~Sql_formatter
~Sql_formatter() override
Definition:
sql_formatter.cc:490
Mysql::Tools::Dump::Sql_formatter::m_mysqldump_tool_options
const Mysqldump_tool_chain_maker_options * m_mysqldump_tool_options
Definition:
sql_formatter.h:114
Mysql::Tools::Dump::Sql_formatter::format_table_definition
void format_table_definition(Table_definition_dump_task *table_definition_dump_task)
Definition:
sql_formatter.cc:219
Mysql::Tools::Dump::Sql_formatter::format_dump_start
void format_dump_start(Dump_start_dump_task *dump_start_dump_task)
Definition:
sql_formatter.cc:279
Mysql::Tools::Dump::Sql_formatter::format_sql_objects_definer
void format_sql_objects_definer(Abstract_plain_sql_object_dump_task *, std::string)
Definition:
sql_formatter.cc:408
Mysql::Tools::Dump::Sql_formatter::format_object
void format_object(Item_processing_data *item_to_process) override
Creates string representation for output of DB object related to specified dump task object.
Definition:
sql_formatter.cc:444
Mysql::Tools::Dump::Sql_formatter::format_database_start
void format_database_start(Database_start_dump_task *database_definition_dump_task)
Definition:
sql_formatter.cc:245
Mysql::Tools::Dump::Sql_formatter::innodb_stats_tables
bool innodb_stats_tables(std::string db, std::string table)
Check if the table is innodb stats table in mysql database.
Definition:
sql_formatter.cc:439
Mysql::Tools::Dump::Sql_formatter::register_progress_watcher
void register_progress_watcher(I_progress_watcher *new_progress_watcher) override
Add new Progress Watcher to report to.
Definition:
sql_formatter.h:74
Mysql::Tools::Dump::Sql_formatter::format_table_indexes
void format_table_indexes(Table_deferred_indexes_dump_task *table_indexes_dump_task)
Definition:
sql_formatter.cc:192
Mysql::Tools::Dump::Sql_formatter::item_completion_in_child_callback
void item_completion_in_child_callback(Item_processing_data *item_processed) override
This callback can be requested to be called by child for any object processing.
Definition:
sql_formatter.h:84
Mysql::Tools::Dump::Sql_formatter::get_id
uint64 get_id() const override
Returns an application unique ID of this chain element object.
Definition:
sql_formatter.h:80
Mysql::Tools::Dump::Sql_formatter::Sql_formatter
Sql_formatter(I_connection_provider *connection_provider, std::function< bool(const Mysql::Tools::Base::Message_data &)> *message_handler, Simple_id_generator *object_id_generator, const Mysqldump_tool_chain_maker_options *mysqldump_tool_options, const Sql_formatter_options *options)
Definition:
sql_formatter.cc:474
Mysql::Tools::Dump::Sql_formatter::format_plain_sql_object
void format_plain_sql_object(Abstract_plain_sql_object_dump_task *plain_sql_dump_task)
Definition:
sql_formatter.cc:357
Mysql::Tools::Dump::Sql_formatter::format_dump_end
void format_dump_end(Dump_end_dump_task *dump_start_dump_task)
Definition:
sql_formatter.cc:255
Mysql::Tools::Dump::Sql_formatter::m_options
const Sql_formatter_options * m_options
Definition:
sql_formatter.h:115
Mysql::Tools::Dump::Table_deferred_indexes_dump_task
Represents task for deferred creation secondary indexes for single DB table.
Definition:
table_deferred_indexes_dump_task.h:38
Mysql::Tools::Dump::Table_definition_dump_task
Represents single DB table DDL creation task.
Definition:
table_definition_dump_task.h:38
database_end_dump_task.h
database_start_dump_task.h
dump_end_dump_task.h
dump_start_dump_task.h
i_data_formatter.h
my_inttypes.h
Some integer typedefs for easier portability.
uint64
uint64_t uint64
Definition:
my_inttypes.h:69
mysqldump_tool_chain_maker_options.h
Mysql
Definition:
abstract_connection_program.h:38
options
Definition:
options.cc:49
row_group_dump_task.h
sql_formatter_options.h
table_deferred_indexes_dump_task.h
table_definition_dump_task.h
client
dump
sql_formatter.h
Generated by
1.9.2