1 /* 2 Copyright (c) 2015, 2021, 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 also distributed 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 included with MySQL. 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 #ifndef MYSQL_CRAWLER_INCLUDED 26 #define MYSQL_CRAWLER_INCLUDED 27 28 #include "abstract_crawler.h" 29 #include "abstract_mysql_chain_element_extension.h" 30 #include "i_connection_provider.h" 31 #include "i_callable.h" 32 #include "dump_start_dump_task.h" 33 #include "abstract_dump_task.h" 34 #include "database.h" 35 #include "table.h" 36 #include "dump_end_dump_task.h" 37 #include "mysql_chain_element_options.h" 38 #include "mysqldump_tool_chain_maker_options.h" 39 #include "database_start_dump_task.h" 40 #include "database_end_dump_task.h" 41 #include "tables_definition_ready_dump_task.h" 42 #include "simple_id_generator.h" 43 #include "base/message_data.h" 44 #include "base/abstract_program.h" 45 46 namespace Mysql{ 47 namespace Tools{ 48 namespace Dump{ 49 50 /** 51 Searches DB objects using connection to MYSQL server. 52 */ 53 class Mysql_crawler 54 : public Abstract_crawler, public Abstract_mysql_chain_element_extension 55 { 56 public: 57 Mysql_crawler( 58 I_connection_provider* connection_provider, 59 Mysql::I_callable<bool, const Mysql::Tools::Base::Message_data&>* 60 message_handler, Simple_id_generator* object_id_generator, 61 Mysql_chain_element_options* options, 62 Mysqldump_tool_chain_maker_options* m_mysqldump_tool_cmaker_options, 63 Mysql::Tools::Base::Abstract_program* program); 64 /** 65 Enumerates all objects it can access, gets chains from all registered 66 chain_maker for each object and then execute each chain. 67 */ 68 virtual void enumerate_objects(); 69 70 private: 71 void enumerate_database_objects(const Database& db); 72 73 void enumerate_tables(const Database& db); 74 75 void enumerate_table_triggers(const Table& table, 76 Abstract_dump_task* dependency); 77 78 void enumerate_views(const Database& db); 79 80 template<typename TObject>void enumerate_functions( 81 const Database& db, std::string type); 82 83 void enumerate_event_scheduler_events(const Database& db); 84 85 void enumerate_users(); 86 87 Mysqldump_tool_chain_maker_options* m_mysqldump_tool_cmaker_options; 88 89 /** 90 Rewrite statement, enclosing it with version specific comment and with 91 DEFINER clause enclosed in version-specific comment. 92 93 This function parses any CREATE statement and encloses DEFINER-clause in 94 version-specific comment: 95 input query: CREATE DEFINER=a@b FUNCTION ... 96 rewritten query: / *!50003 CREATE * / / *!50020 DEFINER=a@b * / / *!50003 97 FUNCTION ... * / 98 */ 99 std::string get_version_specific_statement(std::string create_string, 100 const std::string& keyword, std::string main_version, 101 std::string definer_version); 102 103 Dump_start_dump_task* m_dump_start_task; 104 Dump_end_dump_task* m_dump_end_task; 105 Database_start_dump_task* m_current_database_start_dump_task; 106 Database_end_dump_task* m_current_database_end_dump_task; 107 Tables_definition_ready_dump_task* m_tables_definition_ready_dump_task; 108 }; 109 110 } 111 } 112 } 113 114 #endif 115