MySQL 8.3.0
Source Code Documentation
catalogs.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2023, 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_TABLES__CATALOGS_INCLUDED
24#define DD_TABLES__CATALOGS_INCLUDED
25
26#include "sql/dd/impl/tables/dd_properties.h" // TARGET_DD_VERSION
28
29struct CHARSET_INFO;
30
31namespace dd {
32
33namespace tables {
34
35///////////////////////////////////////////////////////////////////////////
36
38 public:
39 static const Catalogs &instance() {
40 static Catalogs *s_instance = new Catalogs();
41 return *s_instance;
42 }
43
44 static const CHARSET_INFO *name_collation() {
46 }
47
49 FIELD_ID = static_cast<uint>(Common_field::ID),
54 NUMBER_OF_FIELDS // Always keep this entry at the end of the enum
55 };
56
58 INDEX_PK_ID = static_cast<uint>(Common_index::PK_ID),
59 INDEX_UK_NAME = static_cast<uint>(Common_index::UK_NAME)
60 };
61
63 m_target_def.set_table_name("catalogs");
64
66 "id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT");
67 m_target_def.add_field(FIELD_NAME, "FIELD_NAME",
68 "name VARCHAR(64) NOT NULL COLLATE " +
69 String_type(name_collation()->m_coll_name));
70 m_target_def.add_field(FIELD_CREATED, "FIELD_CREATED",
71 "created TIMESTAMP NOT NULL");
72 m_target_def.add_field(FIELD_LAST_ALTERED, "FIELD_LAST_ALTERED",
73 "last_altered TIMESTAMP NOT NULL");
74 m_target_def.add_field(FIELD_OPTIONS, "FIELD_OPTIONS",
75 "options MEDIUMTEXT");
76
77 m_target_def.add_index(INDEX_PK_ID, "INDEX_PK_ID", "PRIMARY KEY (id)");
78 m_target_def.add_index(INDEX_UK_NAME, "INDEX_UK_NAME", "UNIQUE KEY (name)");
79
81 "INSERT INTO catalogs(id, name, options, created, last_altered) "
82 "VALUES (1, 'def', NULL, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
83 }
84};
85
86///////////////////////////////////////////////////////////////////////////
87
88} // namespace tables
89} // namespace dd
90
91#endif // DD_TABLES__CATALOGS_INCLUDED
void add_field(int field_number, const String_type &field_name, const String_type field_definition) override
Add a field to the object table definition.
Definition: object_table_definition_impl.h:217
void set_table_name(const String_type &name) override
Set the name of the table.
Definition: object_table_definition_impl.h:213
virtual void add_populate_statement(const String_type &statement)
Definition: object_table_definition_impl.h:244
static const CHARSET_INFO * fs_name_collation()
Get the collation which is used for names related to the file system (e.g.
Definition: object_table_definition_impl.h:162
void add_index(int index_number, const String_type &index_name, const String_type &index_definition) override
Add an index to the object table definition.
Definition: object_table_definition_impl.h:225
Definition: object_table_impl.h:35
Object_table_definition_impl m_target_def
Definition: object_table_impl.h:38
Definition: catalogs.h:37
static const Catalogs & instance()
Definition: catalogs.h:39
Catalogs()
Definition: catalogs.h:62
static const CHARSET_INFO * name_collation()
Definition: catalogs.h:44
enum_fields
Definition: catalogs.h:48
@ FIELD_LAST_ALTERED
Definition: catalogs.h:52
@ FIELD_ID
Definition: catalogs.h:49
@ NUMBER_OF_FIELDS
Definition: catalogs.h:54
@ FIELD_NAME
Definition: catalogs.h:50
@ FIELD_OPTIONS
Definition: catalogs.h:53
@ FIELD_CREATED
Definition: catalogs.h:51
enum_indexes
Definition: catalogs.h:57
@ INDEX_PK_ID
Definition: catalogs.h:58
@ INDEX_UK_NAME
Definition: catalogs.h:59
const dd::system_views::Columns_extensions * s_instance
Definition: columns_extensions.cc:41
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
Definition: m_ctype.h:422