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
44#include "my_inttypes.h"
45
46namespace Mysql {
47namespace Tools {
48namespace Dump {
49
50/**
51 Prints object data in SQL format.
52 */
55 public virtual I_data_formatter {
56 public:
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,
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
75 I_progress_watcher *new_progress_watcher) override {
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
85 Item_processing_data *item_processed) override {
87 }
88
89 private:
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
98 Database_start_dump_task *database_definition_dump_task);
99
101 Table_definition_dump_task *table_definition_dump_task);
102
104 Table_deferred_indexes_dump_task *table_indexes_dump_task);
105
106 void format_row_group(Row_group_dump_task *row_group);
107
109 std::string);
110
111 bool innodb_stats_tables(std::string db, std::string table);
112
116};
117
118} // namespace Dump
119} // namespace Tools
120} // namespace Mysql
121
122#endif
Structure to represent message from server sent after executing query.
Definition: message_data.h:49
Helper class to run SQL query on existing MySQL database server connection, receive all data and all ...
Definition: mysql_query_runner.h:49
void register_progress_watcher(I_progress_watcher *new_progress_watcher) override
Add new Progress Watcher to report to.
Definition: abstract_chain_element.h:58
uint64 get_id() const override
Returns an application unique ID of this chain element object.
Definition: abstract_chain_element.cc:36
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
Definition: abstract_mysql_chain_element_extension.h:48
Implementation of common logic for classes that directs execution of dump tasks to Data Formatters.
Definition: abstract_output_writer_wrapper.h:44
Abstract task for dumping object carrying its definition in SQL formatted string only.
Definition: abstract_plain_sql_object_dump_task.h:42
Definition: database_start_dump_task.h:35
Definition: dump_end_dump_task.h:35
Definition: dump_start_dump_task.h:35
Definition: i_connection_provider.h:38
Definition: i_data_formatter.h:36
Definition: i_progress_watcher.h:37
Data structure for objects that are processed in any chain.
Definition: item_processing_data.h:43
Definition: mysqldump_tool_chain_maker_options.h:44
Represents single data row.
Definition: row_group_dump_task.h:43
Definition: simple_id_generator.h:37
Definition: sql_formatter_options.h:47
Prints object data in SQL format.
Definition: sql_formatter.h:55
void format_row_group(Row_group_dump_task *row_group)
Definition: sql_formatter.cc:46
Mysql::Tools::Base::Mysql_query_runner * m_escaping_runner
Definition: sql_formatter.h:113
~Sql_formatter() override
Definition: sql_formatter.cc:490
const Mysqldump_tool_chain_maker_options * m_mysqldump_tool_options
Definition: sql_formatter.h:114
void format_table_definition(Table_definition_dump_task *table_definition_dump_task)
Definition: sql_formatter.cc:219
void format_dump_start(Dump_start_dump_task *dump_start_dump_task)
Definition: sql_formatter.cc:279
void format_sql_objects_definer(Abstract_plain_sql_object_dump_task *, std::string)
Definition: sql_formatter.cc:408
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
void format_database_start(Database_start_dump_task *database_definition_dump_task)
Definition: sql_formatter.cc:245
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
void register_progress_watcher(I_progress_watcher *new_progress_watcher) override
Add new Progress Watcher to report to.
Definition: sql_formatter.h:74
void format_table_indexes(Table_deferred_indexes_dump_task *table_indexes_dump_task)
Definition: sql_formatter.cc:192
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
uint64 get_id() const override
Returns an application unique ID of this chain element object.
Definition: sql_formatter.h:80
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
void format_plain_sql_object(Abstract_plain_sql_object_dump_task *plain_sql_dump_task)
Definition: sql_formatter.cc:357
void format_dump_end(Dump_end_dump_task *dump_start_dump_task)
Definition: sql_formatter.cc:255
const Sql_formatter_options * m_options
Definition: sql_formatter.h:115
Represents task for deferred creation secondary indexes for single DB table.
Definition: table_deferred_indexes_dump_task.h:38
Represents single DB table DDL creation task.
Definition: table_definition_dump_task.h:38
Some integer typedefs for easier portability.
uint64_t uint64
Definition: my_inttypes.h:69
Definition: abstract_connection_program.h:38
Definition: options.cc:49