MySQL 8.0.39
Source Code Documentation
mysql_crawler.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 MYSQL_CRAWLER_INCLUDED
27#define MYSQL_CRAWLER_INCLUDED
28
29#include <functional>
30
44#include "client/dump/table.h"
46#include "my_inttypes.h"
48
49namespace Mysql {
50namespace Tools {
51namespace Dump {
52
53/**
54 Searches DB objects using connection to MYSQL server.
55 */
58 public:
60 I_connection_provider *connection_provider,
61 std::function<bool(const Mysql::Tools::Base::Message_data &)>
62 *message_handler,
63 Simple_id_generator *object_id_generator,
67 /**
68 Enumerates all objects it can access, gets chains from all registered
69 chain_maker for each object and then execute each chain.
70 */
71 void enumerate_objects() 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_crawler::get_id(); }
81
82 protected:
83 // Fix "inherits ... via dominance" warnings
85 Item_processing_data *item_processed) override {
87 }
88
89 private:
91
92 void enumerate_tables(const Database &db);
93
94 void enumerate_table_triggers(const Table &table,
95 Abstract_dump_task *dependency);
96
97 void enumerate_column_statistics(const Table &table,
98 Abstract_dump_task *dependency);
99
100 void enumerate_views(const Database &db);
101
102 template <typename TObject>
103 void enumerate_functions(const Database &db, std::string type);
104
106
107 void enumerate_users();
108
110
111 /**
112 Rewrite statement, enclosing it with version specific comment and with
113 DEFINER clause enclosed in version-specific comment.
114
115 This function parses any CREATE statement and encloses DEFINER-clause in
116 version-specific comment:
117 input query: CREATE DEFINER=a@b FUNCTION ...
118 rewritten query: / *!50003 CREATE * / / *!50020 DEFINER=a@b * / / *!50003
119 FUNCTION ... * /
120 */
121 std::string get_version_specific_statement(std::string create_string,
122 const std::string &keyword,
123 std::string main_version,
124 std::string definer_version);
125
131};
132
133} // namespace Dump
134} // namespace Tools
135} // namespace Mysql
136
137#endif
Base class for all MySQL client tools.
Definition: abstract_program.h:47
Structure to represent message from server sent after executing query.
Definition: message_data.h:49
Definition: abstract_crawler.h:44
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_crawler.h:77
uint64 get_id() const override
Returns an application unique ID of this chain element object.
Definition: abstract_crawler.h:58
void register_progress_watcher(I_progress_watcher *new_progress_watcher) override
Add new Progress Watcher to report to.
Definition: abstract_crawler.h:52
Base class for most individual dump process tasks, not suitable for lightweight dump tasks (e....
Definition: abstract_dump_task.h:44
Definition: abstract_mysql_chain_element_extension.h:48
Definition: database_end_dump_task.h:36
Definition: database_start_dump_task.h:35
Definition: database.h:36
Definition: dump_end_dump_task.h:35
Definition: dump_start_dump_task.h:35
Definition: i_connection_provider.h:38
Definition: i_progress_watcher.h:37
Data structure for objects that are processed in any chain.
Definition: item_processing_data.h:43
Definition: mysql_chain_element_options.h:37
Searches DB objects using connection to MYSQL server.
Definition: mysql_crawler.h:57
Database_start_dump_task * m_current_database_start_dump_task
Definition: mysql_crawler.h:128
void enumerate_database_objects(const Database &db)
Definition: mysql_crawler.cc:175
void enumerate_tables(const Database &db)
Definition: mysql_crawler.cc:202
void enumerate_views(const Database &db)
Definition: mysql_crawler.cc:324
void enumerate_table_triggers(const Table &table, Abstract_dump_task *dependency)
Definition: mysql_crawler.cc:516
Dump_end_dump_task * m_dump_end_task
Definition: mysql_crawler.h:127
void enumerate_column_statistics(const Table &table, Abstract_dump_task *dependency)
Definition: mysql_crawler.cc:557
std::string get_version_specific_statement(std::string create_string, const std::string &keyword, std::string main_version, std::string definer_version)
Rewrite statement, enclosing it with version specific comment and with DEFINER clause enclosed in ver...
Definition: mysql_crawler.cc:608
void enumerate_functions(const Database &db, std::string type)
Definition: mysql_crawler.cc:387
void register_progress_watcher(I_progress_watcher *new_progress_watcher) override
Add new Progress Watcher to report to.
Definition: mysql_crawler.h:74
void enumerate_users()
Definition: mysql_crawler.cc:462
Tables_definition_ready_dump_task * m_tables_definition_ready_dump_task
Definition: mysql_crawler.h:130
Mysqldump_tool_chain_maker_options * m_mysqldump_tool_cmaker_options
Definition: mysql_crawler.h:109
Database_end_dump_task * m_current_database_end_dump_task
Definition: mysql_crawler.h:129
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: mysql_crawler.h:84
uint64 get_id() const override
Returns an application unique ID of this chain element object.
Definition: mysql_crawler.h:80
void enumerate_event_scheduler_events(const Database &db)
Definition: mysql_crawler.cc:421
void enumerate_objects() override
Enumerates all objects it can access, gets chains from all registered chain_maker for each object and...
Definition: mysql_crawler.cc:65
Mysql_crawler(I_connection_provider *connection_provider, std::function< bool(const Mysql::Tools::Base::Message_data &)> *message_handler, Simple_id_generator *object_id_generator, Mysql_chain_element_options *options, Mysqldump_tool_chain_maker_options *m_mysqldump_tool_cmaker_options, Mysql::Tools::Base::Abstract_program *program)
Definition: mysql_crawler.cc:52
Dump_start_dump_task * m_dump_start_task
Definition: mysql_crawler.h:126
Definition: mysqldump_tool_chain_maker_options.h:44
Definition: simple_id_generator.h:37
Definition: table.h:40
Represents task for additional work once all Table_definition_dump_task are processed.
Definition: tables_definition_ready_dump_task.h:39
Some integer typedefs for easier portability.
uint64_t uint64
Definition: my_inttypes.h:69
static char * create_string
Definition: mysqlslap.cc:199
Definition: abstract_connection_program.h:38
Definition: options.cc:49
required string type
Definition: replication_group_member_actions.proto:34