MySQL  8.0.22
Source Code Documentation
check_constraint.h
Go to the documentation of this file.
1 /* Copyright (c) 2019, 2020, Oracle and/or its affiliates.
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__CHECK_CONSTRAINTS_INCLUDED
24 #define DD__CHECK_CONSTRAINTS_INCLUDED
25 
26 #include "sql/dd/types/entity_object.h" // dd::Entity_object
27 
28 namespace dd {
29 
30 ///////////////////////////////////////////////////////////////////////////
31 
32 class Table;
33 class Check_constraint_impl;
34 
35 namespace tables {
36 class Check_constraints;
37 }
38 
39 ///////////////////////////////////////////////////////////////////////////
40 
41 class Check_constraint : virtual public Entity_object {
42  public:
45 
46  public:
47  enum enum_constraint_state { CS_NOT_ENFORCED = 1, CS_ENFORCED };
48 
49  public:
50  ~Check_constraint() override {}
51 
52  /////////////////////////////////////////////////////////////////////////
53  // State. (enforced / not enforced)
54  /////////////////////////////////////////////////////////////////////////
55 
56  virtual enum_constraint_state constraint_state() const = 0;
57  virtual void set_constraint_state(bool is_enforced) = 0;
58 
59  /////////////////////////////////////////////////////////////////////////
60  // Check clause/utf8.
61  /////////////////////////////////////////////////////////////////////////
62 
63  virtual const String_type &check_clause() const = 0;
64  virtual void set_check_clause(const String_type &check_clause) = 0;
65 
66  virtual const String_type &check_clause_utf8() const = 0;
67  virtual void set_check_clause_utf8(const String_type &check_clause_utf8) = 0;
68 
69  /////////////////////////////////////////////////////////////////////////
70  // Alter mode ( true / false).
71  // Set during ALTER TABLE operation. In alter mode, alias name is stored
72  // in data-dictionary to avoid name conflicts.
73  /////////////////////////////////////////////////////////////////////////
74 
75  virtual bool is_alter_mode() const = 0;
76  virtual void set_alter_mode(bool alter_mode) = 0;
77 
78  /////////////////////////////////////////////////////////////////////////
79  // Alias check constriaint name.
80  /////////////////////////////////////////////////////////////////////////
81 
82  virtual const String_type &alias_name() const = 0;
83  virtual void set_alias_name(const String_type &alias_name) = 0;
84 
85  /////////////////////////////////////////////////////////////////////////
86  // Parent table.
87  /////////////////////////////////////////////////////////////////////////
88 
89  virtual const Table &table() const = 0;
90 
91  virtual Table &table() = 0;
92 
93  /**
94  Converts *this into json.
95 
96  Converts all member variables that are to be included in the sdi
97  into json by transforming them appropriately and passing them to
98  the rapidjson writer provided.
99 
100  @param wctx opaque context for data needed by serialization
101  @param w rapidjson writer which will perform conversion to json
102 
103  */
104 
105  virtual void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const = 0;
106 
107  /**
108  Re-establishes the state of *this by reading sdi information from
109  the rapidjson DOM subobject provided.
110 
111  Cross-references encountered within this object are tracked in
112  sdictx, so that they can be updated when the entire object graph
113  has been established.
114 
115  @param rctx stores book-keeping information for the
116  deserialization process
117  @param val subobject of rapidjson DOM containing json
118  representation of this object
119  @retval false success
120  @retval true failure
121  */
122 
123  virtual bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) = 0;
124 };
125 
126 ///////////////////////////////////////////////////////////////////////////
127 
128 } // namespace dd
129 
130 #endif // DD__CHECK_CONSTRAINTS_INCLUDED
bool deserialize(THD *thd, const Sdi_type &sdi, Table *dst_table, SdiCompatibilityChecker comp_checker, String_type *deser_schema_name)
Deserialize a dd::Table object.
Definition: sdi.cc:474
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
Opaque context which keeps reusable resources needed during serialization.
Definition: sdi.cc:127
Definition: check_constraint.h:41
rapidjson::GenericValue< RJ_Encoding, RJ_Allocator > RJ_Value
Definition: sdi_fwd.h:48
tables::Check_constraints DD_table
Definition: check_constraint.h:44
enum_constraint_state
Definition: check_constraint.h:47
Opaque context which keeps reusable resoureces needed during deserialization.
Definition: sdi.cc:230
~Check_constraint() override
Definition: check_constraint.h:50
Definition: check_constraints.h:37
Check_constraint_impl Impl
Definition: check_constraint.h:43
RJ_Writer Sdi_writer
Alias for the rapidjson Writer type to use in serialization.
Definition: sdi_fwd.h:63
Definition: test_sql_stmt.cc:150
Definition: check_constraint_impl.h:48
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:40
Definition: table.h:46
Sdi_type serialize(THD *thd, const Table &table, const String_type &schema_name)
Serialize a Table object.
Definition: sdi.cc:363