1 /* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. 2 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License, version 2.0, 5 as published by the Free Software Foundation. 6 7 This program is also distributed with certain software (including 8 but not limited to OpenSSL) that is licensed under separate terms, 9 as designated in a particular file or component or in included license 10 documentation. The authors of MySQL hereby grant you an additional 11 permission to link the program and your derivative works with the 12 separately licensed software that they have included with MySQL. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License, version 2.0, for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 23 #ifndef DD__OBJECT_TABLE_IMPL_INCLUDED 24 #define DD__OBJECT_TABLE_IMPL_INCLUDED 25 26 #include "sql/dd/impl/types/object_table_definition_impl.h" // Object_table_def 27 #include "sql/dd/types/object_table.h" // Object_table 28 29 class THD; 30 31 namespace dd { 32 33 /////////////////////////////////////////////////////////////////////////// 34 35 class Object_table_impl : virtual public Object_table { 36 protected: 37 mutable uint m_last_dd_version; 38 Object_table_definition_impl m_target_def; 39 mutable bool m_actual_present; 40 mutable Object_table_definition_impl m_actual_def; 41 bool m_hidden; 42 43 public: 44 // Enumeration of options that are used by all DD table subclasses. 45 enum class Common_option { 46 ENGINE, 47 CHARSET, 48 COLLATION, 49 ROW_FORMAT, 50 STATS_PERSISTENT, 51 TABLESPACE 52 }; 53 54 /* 55 Enumeration of indexes that are used by several DD table subclasses. 56 Some object keys will implicitly expect these indexes to have a 57 certain predefined ordinal position. Note that the enumeration is 58 the positional index of each index (starting at 0), not the ordinal 59 position of the index (starting at 1). 60 */ 61 enum class Common_index { PK_ID, UK_NAME }; 62 63 /* 64 Enumeration of fields that are expected by some object keys to have 65 the same ordinal position for most DD tables. The enumeration is the 66 positional index of the field (starting at 0). 67 */ 68 enum class Common_field { ID }; 69 70 /* 71 Constructor used for tables required by plugins. Common options are 72 not used for those. 73 */ Object_table_impl(const String_type & schema_name,const String_type & table_name,const String_type & ddl_statement)74 Object_table_impl(const String_type &schema_name, 75 const String_type &table_name, 76 const String_type &ddl_statement) 77 : m_last_dd_version(0), 78 m_target_def(schema_name, table_name, ddl_statement), 79 m_actual_present(false), 80 m_actual_def(), 81 m_hidden(false) {} 82 83 /* 84 Constructor used by DD table subclasses. These will all use the 85 common options. 86 */ 87 Object_table_impl(); 88 name()89 virtual const String_type &name() const { 90 return m_target_def.get_table_name(); 91 } 92 target_table_definition()93 virtual Object_table_definition_impl *target_table_definition() { 94 return (m_last_dd_version != 0 ? nullptr : &m_target_def); 95 } 96 target_table_definition()97 virtual const Object_table_definition_impl *target_table_definition() const { 98 return (m_last_dd_version != 0 ? nullptr : &m_target_def); 99 } 100 set_abandoned(uint last_dd_version)101 virtual void set_abandoned(uint last_dd_version) const { 102 m_last_dd_version = last_dd_version; 103 } 104 is_abandoned()105 virtual bool is_abandoned() const { return (m_last_dd_version != 0); } 106 actual_table_definition()107 virtual const Object_table_definition_impl *actual_table_definition() const { 108 return (m_actual_present ? &m_actual_def : nullptr); 109 } 110 111 virtual bool set_actual_table_definition( 112 const Properties &table_def_properties) const; 113 114 virtual int field_number(int target_field_number, 115 const String_type &field_label) const; 116 117 virtual int field_number(const String_type &field_label) const; 118 populate(THD *)119 virtual bool populate(THD *) const { return false; } 120 is_hidden()121 virtual bool is_hidden() const { return m_hidden; } 122 set_hidden(bool hidden)123 virtual void set_hidden(bool hidden) { m_hidden = hidden; } 124 ~Object_table_impl()125 virtual ~Object_table_impl() {} 126 }; 127 128 /////////////////////////////////////////////////////////////////////////// 129 130 } // namespace dd 131 132 #endif // DD__OBJECT_TABLE_IMPL_INCLUDED 133