1 /* 2 Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. 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 NDB_LOCAL_CONNECTION_H 26 #define NDB_LOCAL_CONNECTION_H 27 28 #include <memory> 29 #include <string> 30 31 #include "my_inttypes.h" 32 #include "mysql/mysql_lex_string.h" 33 34 class THD; 35 36 /* 37 Wrapper class for executing queries against the local 38 MySQL Server without affecting the current THD's 39 settings and status. 40 41 The functionality is implemented by concatenating SQL 42 queries and executing those using Ed_connection. Should 43 the SQL query fail, the exact error message and all 44 warning that occurred can be examined in order to handle 45 the error in a graceful way. 46 47 */ 48 49 class Ndb_local_connection { 50 public: 51 Ndb_local_connection(THD *thd); 52 ~Ndb_local_connection(); 53 54 bool truncate_table(const char *db, const char *table, 55 bool ignore_no_such_table); 56 57 bool delete_rows(const std::string &db, const std::string &table, 58 int ignore_no_such_table, const std::string &where); 59 60 bool create_util_table(const std::string &table_def_sql); 61 62 bool create_database(const std::string &database_name); 63 64 bool drop_database(const std::string &database_name); 65 66 bool execute_database_ddl(const std::string &ddl_query); 67 68 bool run_acl_statement(const std::string &acl_sql); 69 70 /* Don't use this function for new implementation, backward compat. only */ 71 bool raw_run_query(const char *query, size_t query_length, 72 const int *suppress_errors); 73 74 protected: 75 bool execute_query_iso(MYSQL_LEX_STRING sql_text, 76 const uint *ignore_mysql_errors, 77 const class Suppressor *suppressor = NULL); 78 79 class Ed_result_set *get_results(); 80 81 bool execute_query(MYSQL_LEX_STRING sql_text, const uint *ignore_mysql_errors, 82 const class Suppressor *suppressor = NULL); 83 84 bool m_push_warnings; 85 THD *m_thd; 86 87 private: 88 class Impl; 89 std::unique_ptr<class Impl> impl; 90 }; 91 92 class Ndb_privilege_upgrade_connection : public Ndb_local_connection { 93 public: 94 Ndb_privilege_upgrade_connection(THD *thd); 95 ~Ndb_privilege_upgrade_connection(); 96 97 bool migrate_privilege_table(const std::string &table_name); 98 99 private: 100 ulonglong m_saved_sql_mode; 101 }; 102 103 #endif 104