1 /* Copyright (c) 2014, 2017, 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__VIEW_TABLE_IMPL_INCLUDED 24 #define DD__VIEW_TABLE_IMPL_INCLUDED 25 26 #include <sys/types.h> 27 #include <new> 28 29 #include "sql/dd/impl/raw/raw_record.h" 30 #include "sql/dd/impl/types/weak_object_impl.h" // dd::Weak_object_impl 31 #include "sql/dd/string_type.h" 32 #include "sql/dd/types/view_table.h" // dd::View_table 33 34 namespace dd { 35 36 /////////////////////////////////////////////////////////////////////////// 37 38 class Object_key; 39 class Object_table; 40 class Open_dictionary_tables_ctx; 41 class View; 42 class View_impl; 43 class Weak_object; 44 45 /////////////////////////////////////////////////////////////////////////// 46 47 class View_table_impl : public Weak_object_impl, public View_table { 48 public: 49 View_table_impl(); 50 51 View_table_impl(View_impl *view); 52 53 View_table_impl(const View_table_impl &src, View_impl *parent); 54 ~View_table_impl()55 virtual ~View_table_impl() {} 56 57 public: 58 static void register_tables(Open_dictionary_tables_ctx *otx); 59 60 virtual const Object_table &object_table() const; 61 62 virtual bool validate() const; 63 64 virtual bool store_attributes(Raw_record *r); 65 66 virtual bool restore_attributes(const Raw_record &r); 67 68 virtual void debug_print(String_type &outb) const; 69 set_ordinal_position(uint)70 void set_ordinal_position(uint) {} 71 ordinal_position()72 virtual uint ordinal_position() const { return -1; } 73 74 public: 75 ///////////////////////////////////////////////////////////////////////// 76 // table_catalog. 77 ///////////////////////////////////////////////////////////////////////// 78 table_catalog()79 virtual const String_type &table_catalog() const { return m_table_catalog; } 80 set_table_catalog(const String_type & table_catalog)81 virtual void set_table_catalog(const String_type &table_catalog) { 82 m_table_catalog = table_catalog; 83 } 84 85 ///////////////////////////////////////////////////////////////////////// 86 // table_schema. 87 ///////////////////////////////////////////////////////////////////////// 88 table_schema()89 virtual const String_type &table_schema() const { return m_table_schema; } 90 set_table_schema(const String_type & table_schema)91 virtual void set_table_schema(const String_type &table_schema) { 92 m_table_schema = table_schema; 93 } 94 95 ///////////////////////////////////////////////////////////////////////// 96 // table_name. 97 ///////////////////////////////////////////////////////////////////////// 98 table_name()99 virtual const String_type &table_name() const { return m_table_name; } 100 set_table_name(const String_type & table_name)101 virtual void set_table_name(const String_type &table_name) { 102 m_table_name = table_name; 103 } 104 105 ///////////////////////////////////////////////////////////////////////// 106 // view. 107 ///////////////////////////////////////////////////////////////////////// 108 109 virtual const View &view() const; 110 111 virtual View &view(); 112 113 public: restore_item(View_impl * view)114 static View_table_impl *restore_item(View_impl *view) { 115 return new (std::nothrow) View_table_impl(view); 116 } 117 clone(const View_table_impl & other,View_impl * view)118 static View_table_impl *clone(const View_table_impl &other, View_impl *view) { 119 return new (std::nothrow) View_table_impl(other, view); 120 } 121 122 public: 123 virtual Object_key *create_primary_key() const; 124 virtual bool has_new_primary_key() const; 125 126 private: 127 String_type m_table_catalog; 128 String_type m_table_schema; 129 String_type m_table_name; 130 131 // References to other objects 132 View_impl *m_view; 133 }; 134 135 /////////////////////////////////////////////////////////////////////////// 136 137 } // namespace dd 138 139 #endif // DD__VIEW_TABLE_IMPL_INCLUDED 140