MySQL 8.4.2
Source Code Documentation
charset_impl.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 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__CHARSET_IMPL_INCLUDED
25#define DD__CHARSET_IMPL_INCLUDED
26
27#include <stdio.h>
28#include <sys/types.h>
29#include <new>
30
31#include "sql/dd/impl/types/entity_object_impl.h" // dd::Entity_object_imp
33#include "sql/dd/object_id.h"
34#include "sql/dd/string_type.h"
35#include "sql/dd/types/charset.h" // dd::Charset
36
37namespace dd {
38
39///////////////////////////////////////////////////////////////////////////
40
41class Object_table;
42class Open_dictionary_tables_ctx;
43class Raw_record;
44class Weak_object;
45class Object_table;
46
47///////////////////////////////////////////////////////////////////////////
48
49class Charset_impl : public Entity_object_impl, public Charset {
50 public:
53
54 public:
55 const Object_table &object_table() const override;
56
58
59 bool validate() const override;
60
61 bool restore_attributes(const Raw_record &r) override;
62
63 bool store_attributes(Raw_record *r) override;
64
65 public:
66 /////////////////////////////////////////////////////////////////////////
67 // Default collation.
68 /////////////////////////////////////////////////////////////////////////
69
72 }
73
74 void set_default_collation_id(Object_id collation_id) override {
75 m_default_collation_id = collation_id;
76 }
77
78 /////////////////////////////////////////////////////////////////////////
79 // mb_max_length
80 /////////////////////////////////////////////////////////////////////////
81
82 uint mb_max_length() const override { return m_mb_max_length; }
83
84 virtual void set_mb_max_length(uint mb_max_length) {
86 }
87
88 /////////////////////////////////////////////////////////////////////////
89 // comment
90 /////////////////////////////////////////////////////////////////////////
91
92 const String_type &comment() const override { return m_comment; }
93
94 virtual void set_comment(const String_type &comment) { m_comment = comment; }
95
96 // Fix "inherits ... via dominance" warnings
98 const Entity_object_impl *impl() const override {
100 }
101 Object_id id() const override { return Entity_object_impl::id(); }
102 bool is_persistent() const override {
104 }
105 const String_type &name() const override {
107 }
108 void set_name(const String_type &name) override {
110 }
111
112 public:
113 void debug_print(String_type &outb) const override {
114 char outbuf[1024];
115 sprintf(outbuf,
116 "CHARSET OBJECT: {OID: %lld}, name= %s, "
117 "collation_id= {OID: %lld}, mb_max_length= %u, "
118 "comment= %s",
120 m_comment.c_str());
121 outb = String_type(outbuf);
122 }
123
124 private:
127
129
130 Charset *clone() const override { return new Charset_impl(*this); }
131
133 /*
134 Even though we don't drop charsets en masse we still create slimmed
135 down version for consistency sake.
136 */
137 Charset_impl *placeholder = new Charset_impl();
138 placeholder->set_id(id());
139 placeholder->set_name(name());
140 return placeholder;
141 }
142};
143
144///////////////////////////////////////////////////////////////////////////
145
146} // namespace dd
147
148#endif // DD__CHARSET_IMPL_INCLUDED
Definition: charset_impl.h:49
Charset_impl()
Definition: charset_impl.h:51
uint m_mb_max_length
Definition: charset_impl.h:125
bool store_attributes(Raw_record *r) override
Definition: charset_impl.cc:69
bool restore_attributes(const Raw_record &r) override
Definition: charset_impl.cc:54
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: charset_impl.cc:99
const String_type & comment() const override
Definition: charset_impl.h:92
void set_name(const String_type &name) override
Definition: charset_impl.h:108
const Entity_object_impl * impl() const override
Definition: charset_impl.h:98
Charset * clone_dropped_object_placeholder() const override
Allocate a new object which can serve as a placeholder for the original object in the Dictionary_clie...
Definition: charset_impl.h:132
String_type m_comment
Definition: charset_impl.h:126
const String_type & name() const override
Definition: charset_impl.h:105
const Object_table & object_table() const override
Definition: charset_impl.cc:93
Object_id id() const override
The unique dictionary object id.
Definition: charset_impl.h:101
Charset * clone() const override
Allocate a new object and invoke the copy constructor.
Definition: charset_impl.h:130
uint mb_max_length() const override
Definition: charset_impl.h:82
void debug_print(String_type &outb) const override
Definition: charset_impl.h:113
void set_default_collation_id(Object_id collation_id) override
Definition: charset_impl.h:74
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: charset_impl.h:102
Object_id default_collation_id() const override
Definition: charset_impl.h:70
virtual void set_mb_max_length(uint mb_max_length)
Definition: charset_impl.h:84
bool validate() const override
Definition: charset_impl.cc:42
virtual void set_comment(const String_type &comment)
Definition: charset_impl.h:94
Entity_object_impl * impl() override
Definition: charset_impl.h:97
Object_id m_default_collation_id
Definition: charset_impl.h:128
Definition: charset.h:46
Definition: entity_object_impl.h:44
void set_name(const String_type &name) override
Definition: entity_object_impl.h:62
void set_id(Object_id id)
Definition: entity_object_impl.h:51
Object_id id() const override
The unique dictionary object id.
Definition: entity_object_impl.h:49
const String_type & name() const override
Definition: entity_object_impl.h:60
Entity_object_impl * impl() override
Definition: entity_object_impl.h:68
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: entity_object_impl.h:57
This class represents all data dictionary table like mysql.tables, mysql.columns and more.
Definition: object_table.h:72
Auxiliary class for opening dictionary tables.
Definition: transaction_impl.h:76
Definition: raw_record.h:46
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
unsigned long long Object_id
Definition: object_id.h:31
const Object_id INVALID_OBJECT_ID
The default object ID which represents that the DD object is new and not persistent in dictionary tab...
Definition: object_id.h:37
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86