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