MySQL  8.0.21
Source Code Documentation
schema.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2019, 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__SCHEMA_INCLUDED
24 #define DD__SCHEMA_INCLUDED
25 
26 #include "my_inttypes.h"
27 #include "sql/dd/impl/raw/object_keys.h" // IWYU pragma: keep
28 #include "sql/dd/sdi_fwd.h" // RJ_Document
29 #include "sql/dd/types/entity_object.h" // dd::Entity_object
30 
31 class THD;
32 
33 namespace dd {
34 
35 ///////////////////////////////////////////////////////////////////////////
36 
37 class Item_name_key;
38 class Primary_id_key;
39 class Schema_impl;
40 class Table;
41 class View;
42 class Event;
43 class Function;
44 class Procedure;
45 class Void_key;
46 class Time_zone;
47 class Properties;
48 
49 namespace tables {
50 class Schemata;
51 }
52 
53 /////////////////////////////////////////////////////////////////////////
54 // enum_encryption_type.
55 /////////////////////////////////////////////////////////////////////////
56 
57 enum class enum_encryption_type { ET_NO = 1, ET_YES };
58 
59 ///////////////////////////////////////////////////////////////////////////
60 
61 class Schema : virtual public Entity_object {
62  public:
63  typedef Schema_impl Impl;
68  typedef Void_key Aux_key;
69 
70  // We need a set of functions to update a preallocated key.
71  virtual bool update_id_key(Id_key *key) const {
72  return update_id_key(key, id());
73  }
74 
75  static bool update_id_key(Id_key *key, Object_id id);
76 
77  virtual bool update_name_key(Name_key *key) const {
78  return update_name_key(key, name());
79  }
80 
81  static bool update_name_key(Name_key *key, const String_type &name);
82 
83  virtual bool update_aux_key(Aux_key *) const { return true; }
84 
85  public:
86  /////////////////////////////////////////////////////////////////////////
87  // Default collation.
88  /////////////////////////////////////////////////////////////////////////
89 
90  virtual Object_id default_collation_id() const = 0;
91  virtual void set_default_collation_id(Object_id default_collation_id) = 0;
92 
93  /////////////////////////////////////////////////////////////////////////
94  // Default encryption.
95  /////////////////////////////////////////////////////////////////////////
96 
97  virtual bool default_encryption() const = 0;
98  virtual void set_default_encryption(bool default_encryption) = 0;
99 
100  /////////////////////////////////////////////////////////////////////////
101  // created
102  /////////////////////////////////////////////////////////////////////////
103 
104  virtual ulonglong created(bool convert_time) const = 0;
105  virtual void set_created(ulonglong created) = 0;
106 
107  /////////////////////////////////////////////////////////////////////////
108  // last_altered
109  /////////////////////////////////////////////////////////////////////////
110 
111  virtual ulonglong last_altered(bool convert_time) const = 0;
112  virtual void set_last_altered(ulonglong last_altered) = 0;
113 
114  /////////////////////////////////////////////////////////////////////////
115  // se_private_data.
116  /////////////////////////////////////////////////////////////////////////
117 
118  virtual const Properties &se_private_data() const = 0;
119 
120  virtual Properties &se_private_data() = 0;
121  virtual bool set_se_private_data(const String_type &se_private_data_raw) = 0;
122  virtual bool set_se_private_data(const Properties &se_private_data) = 0;
123 
124  public:
125  virtual Event *create_event(THD *thd) const = 0;
126 
127  virtual Function *create_function(THD *thd) const = 0;
128 
129  virtual Procedure *create_procedure(THD *thd) const = 0;
130 
131  virtual Table *create_table(THD *thd) const = 0;
132 
133  virtual View *create_view(THD *thd) const = 0;
134 
135  virtual View *create_system_view(THD *thd) const = 0;
136 
137  /**
138  Allocate a new object and invoke the copy contructor.
139 
140  @return pointer to dynamically allocated copy
141  */
142  virtual Schema *clone() const = 0;
143 };
144 
145 ///////////////////////////////////////////////////////////////////////////
146 
147 } // namespace dd
148 
149 #endif // DD__SCHEMA_INCLUDE
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Definition: schema_impl.h:62
Item_name_key Name_key
Definition: schema.h:67
Definition: object_keys.h:165
Some integer typedefs for easier portability.
Definition: view.h:38
Primary_id_key Id_key
Definition: schema.h:66
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
Base class for dictionary objects which has single column integer primary key.
Definition: entity_object.h:47
Definition: event.h:47
This header provides Rapidjson Type Aliases.
Definition: procedure.h:36
Definition: schemata.h:43
This class represents abstract time zone and provides basic interface for MYSQL_TIME <-> my_time_t co...
Definition: tztime.h:51
Void_key Aux_key
Definition: schema.h:68
static ORDER * clone(THD *thd, ORDER *order)
Shallow clone the list of ORDER objects using mem_root and return the cloned list.
Definition: window.cc:76
virtual bool update_name_key(Name_key *key) const
Definition: schema.h:77
bool create_view(THD *thd, const dd::Schema &schema, TABLE_LIST *view)
Store view metadata in the data-dictionary.
Definition: dd_view.cc:601
Definition: function.h:38
Definition: object_keys.h:76
bool create_event(THD *thd, const Schema &schema, const String_type &event_name, const String_type &event_body, const String_type &event_body_utf8, const LEX_USER *definer, Event_parse_data *event_data)
Create an event object and commit it to DD Table Events.
Definition: dd_event.cc:350
tables::Schemata DD_table
Definition: schema.h:65
case opt name
Definition: sslopt-case.h:32
unsigned long long Object_id
Definition: object_id.h:30
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:73
static const char * key
Definition: suite_stubs.c:14
std::function< void(const Type)> Function
Definition: ut0counter.h:240
Definition: object_keys.h:53
std::unique_ptr< dd::Table > create_table(THD *thd, const dd::Schema &sch_obj, const dd::String_type &table_name, HA_CREATE_INFO *create_info, const List< Create_field > &create_fields, const KEY *keyinfo, uint keys, Alter_info::enum_enable_or_disable keys_onoff, const FOREIGN_KEY *fk_keyinfo, uint fk_keys, const Sql_check_constraint_spec_list *check_cons_spec, handler *file)
Prepares a dd::Table object from mysql_prepare_create_table() output and return it to the caller...
Definition: dd_table.cc:2354
Schema_impl Impl
Definition: schema.h:63
Definition: schema.h:61
virtual bool update_aux_key(Aux_key *) const
Definition: schema.h:83
Definition: test_sql_stmt.cc:150
virtual bool update_id_key(Id_key *key) const
Definition: schema.h:71
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39
Definition: table.h:46
enum_encryption_type
Definition: schema.h:57
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:799
Schema Cache_partition
Definition: schema.h:64