MySQL 8.0.30
Source Code Documentation
check_constraint_impl.h
Go to the documentation of this file.
1/* Copyright (c) 2019, 2022, 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_CONSTRAINT_IMPL_INCLUDED
24#define DD__CHECK_CONSTRAINT_IMPL_INCLUDED
25
26#include <new>
27
28#include "m_ctype.h" // my_strcasecmp
29#include "sql/dd/impl/types/entity_object_impl.h" // dd::Entity_object_impl
30#include "sql/dd/sdi_fwd.h"
31#include "sql/dd/string_type.h"
32#include "sql/dd/types/check_constraint.h" // dd::Check_constraint
33
34namespace dd {
35
36///////////////////////////////////////////////////////////////////////////
37
38class Object_table;
39class Open_dictionary_tables_ctx;
40class Raw_record;
41class Sdi_rcontext;
42class Sdi_wcontext;
43class Table;
44class Table_impl;
45
46///////////////////////////////////////////////////////////////////////////
47
49 public Check_constraint {
50 public:
52
54
56
57 public:
59
60 const Object_table &object_table() const override;
61
62 bool validate() const override;
63
64 bool store(Open_dictionary_tables_ctx *otx) override;
65
66 bool store_attributes(Raw_record *r) override;
67
68 bool restore_attributes(const Raw_record &r) override;
69
70 void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const override;
71
72 bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) override;
73
74 void debug_print(String_type &outb) const override;
75
77
78 virtual uint ordinal_position() const { return -1; }
79
80 public:
81 /////////////////////////////////////////////////////////////////////////
82 // State.
83 /////////////////////////////////////////////////////////////////////////
84
86 return m_constraint_state;
87 }
88
89 void set_constraint_state(bool is_enabled) override {
91 }
92
93 /////////////////////////////////////////////////////////////////////////
94 // Check clause/utf8.
95 /////////////////////////////////////////////////////////////////////////
96
97 const String_type &check_clause() const override { return m_check_clause; }
98
101 }
102
103 const String_type &check_clause_utf8() const override {
104 return m_check_clause_utf8;
105 }
106
109 }
110
111 /////////////////////////////////////////////////////////////////////////
112 // Alter mode ( true / false).
113 // Set during ALTER TABLE operation. In alter mode, alias_name is stored
114 // in data-dictionary to avoid name conflicts.
115 /////////////////////////////////////////////////////////////////////////
116
117 bool is_alter_mode() const override { return m_alter_mode; }
118
119 void set_alter_mode(bool alter_mode) override { m_alter_mode = alter_mode; }
120
121 /////////////////////////////////////////////////////////////////////////
122 // Alias check constriaint name.
123 /////////////////////////////////////////////////////////////////////////
124
125 const String_type &alias_name() const override { return m_alias_name; }
126
127 void set_alias_name(const String_type &alias_name) override {
129 }
130
131 /////////////////////////////////////////////////////////////////////////
132 // Table.
133 /////////////////////////////////////////////////////////////////////////
134
135 const Table &table() const override;
136
137 Table &table() override;
138
139 public:
141 return new (std::nothrow) Check_constraint_impl(table);
142 }
143
145 Table_impl *table) {
146 return new (std::nothrow) Check_constraint_impl(other, table);
147 }
148
149 // Fix "inherits ... via dominance" warnings
151 const Entity_object_impl *impl() const override {
153 }
154 Object_id id() const override { return Entity_object_impl::id(); }
155 bool is_persistent() const override {
157 }
158 const String_type &name() const override {
160 }
161 void set_name(const String_type &name) override {
163 }
164
165 private:
169 bool m_alter_mode{false};
172
173 // References to the Table object.
175};
176
177///////////////////////////////////////////////////////////////////////////
178
179/** Class used to sort check constraints by name for the same table. */
182 const dd::Check_constraint *cc2) const {
183 return (my_strcasecmp(system_charset_info, cc1->name().c_str(),
184 cc2->name().c_str()) < 0);
185 }
186};
187
188///////////////////////////////////////////////////////////////////////////
189} // namespace dd
190
191#endif // DD__CHECK_CONSTRAINT_IMPL_INCLUDED
Definition: check_constraint_impl.h:49
const String_type & check_clause_utf8() const override
Definition: check_constraint_impl.h:103
const String_type & check_clause() const override
Definition: check_constraint_impl.h:97
Object_id m_schema_id
Definition: check_constraint_impl.h:171
bool m_alter_mode
Definition: check_constraint_impl.h:169
void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const override
Converts *this into json.
Definition: check_constraint_impl.cc:142
void set_name(const String_type &name) override
Definition: check_constraint_impl.h:161
static Check_constraint_impl * restore_item(Table_impl *table)
Definition: check_constraint_impl.h:140
void set_alias_name(const String_type &alias_name) override
Definition: check_constraint_impl.h:127
virtual uint ordinal_position() const
Definition: check_constraint_impl.h:78
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: check_constraint_impl.h:155
const String_type & alias_name() const override
Definition: check_constraint_impl.h:125
const Object_table & object_table() const override
Definition: check_constraint_impl.cc:200
String_type m_alias_name
Definition: check_constraint_impl.h:170
const String_type & name() const override
Definition: check_constraint_impl.h:158
void set_ordinal_position(uint)
Definition: check_constraint_impl.h:76
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: check_constraint_impl.cc:206
bool is_alter_mode() const override
Definition: check_constraint_impl.h:117
void set_alter_mode(bool alter_mode) override
Definition: check_constraint_impl.h:119
enum_constraint_state constraint_state() const override
Definition: check_constraint_impl.h:85
Entity_object_impl * impl() override
Definition: check_constraint_impl.h:150
String_type m_check_clause
Definition: check_constraint_impl.h:167
bool restore_attributes(const Raw_record &r) override
Definition: check_constraint_impl.cc:106
bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) override
Re-establishes the state of *this by reading sdi information from the rapidjson DOM subobject provide...
Definition: check_constraint_impl.cc:155
bool store(Open_dictionary_tables_ctx *otx) override
Store the DD object into DD table.
Definition: check_constraint_impl.cc:92
const Table & table() const override
Definition: check_constraint_impl.cc:52
bool store_attributes(Raw_record *r) override
Definition: check_constraint_impl.cc:124
bool validate() const override
Definition: check_constraint_impl.cc:58
Table_impl * m_table
Definition: check_constraint_impl.h:174
Object_id id() const override
The unique dictionary object id.
Definition: check_constraint_impl.h:154
String_type m_check_clause_utf8
Definition: check_constraint_impl.h:168
void set_check_clause(const String_type &check_clause) override
Definition: check_constraint_impl.h:99
const Entity_object_impl * impl() const override
Definition: check_constraint_impl.h:151
static Check_constraint_impl * clone(const Check_constraint_impl &other, Table_impl *table)
Definition: check_constraint_impl.h:144
void set_constraint_state(bool is_enabled) override
Definition: check_constraint_impl.h:89
void debug_print(String_type &outb) const override
Definition: check_constraint_impl.cc:167
enum_constraint_state m_constraint_state
Definition: check_constraint_impl.h:166
void set_check_clause_utf8(const String_type &check_clause_utf8) override
Definition: check_constraint_impl.h:107
Definition: check_constraint.h:41
enum_constraint_state
Definition: check_constraint.h:47
@ CS_ENFORCED
Definition: check_constraint.h:47
@ CS_NOT_ENFORCED
Definition: check_constraint.h:47
Definition: entity_object_impl.h:43
void set_name(const String_type &name) override
Definition: entity_object_impl.h:61
Object_id id() const override
The unique dictionary object id.
Definition: entity_object_impl.h:48
const String_type & name() const override
Definition: entity_object_impl.h:59
Entity_object_impl * impl() override
Definition: entity_object_impl.h:67
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: entity_object_impl.h:56
virtual const String_type & name() const =0
This class represents all data dictionary table like mysql.tables, mysql.columns and more.
Definition: object_table.h:71
Auxiliary class for opening dictionary tables.
Definition: transaction_impl.h:75
Definition: raw_record.h:45
Opaque context which keeps reusable resoureces needed during deserialization.
Definition: sdi.cc:230
Opaque context which keeps reusable resources needed during serialization.
Definition: sdi.cc:128
Definition: table_impl.h:67
Definition: table.h:46
A better implementation of the UNIX ctype(3) library.
MYSQL_PLUGIN_IMPORT CHARSET_INFO * system_charset_info
Definition: mysqld.cc:1525
#define my_strcasecmp(s, a, b)
Definition: m_ctype.h:677
bool is_enabled()
Check if doublewrite is enabled.
Definition: buf0dblwr.h:387
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
RJ_Writer Sdi_writer
Alias for the rapidjson Writer type to use in serialization.
Definition: sdi_fwd.h:63
unsigned long long Object_id
Definition: object_id.h:30
rapidjson::GenericValue< RJ_Encoding, RJ_Allocator > RJ_Value
Definition: sdi_fwd.h:48
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:85
This header provides Rapidjson Type Aliases.
Class used to sort check constraints by name for the same table.
Definition: check_constraint_impl.h:180
bool operator()(const dd::Check_constraint *cc1, const dd::Check_constraint *cc2) const
Definition: check_constraint_impl.h:181
unsigned int uint
Definition: uca-dump.cc:29