MySQL  8.0.20
Source Code Documentation
object_table_definition.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
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__OBJECT_TABLE_DEFINITION_INCLUDED
24 #define DD__OBJECT_TABLE_DEFINITION_INCLUDED
25 
26 #include <vector>
27 
28 #include "my_inttypes.h"
29 #include "sql/dd/string_type.h" // dd::String_type
30 
31 namespace dd {
32 
33 ///////////////////////////////////////////////////////////////////////////
34 
35 class Properties;
36 class Table;
37 
38 ///////////////////////////////////////////////////////////////////////////
39 
40 /**
41  The purpose of this interface is to enable retrieving the SQL statements
42  necessary to create and populate a DD table. An Object_table instance
43  may use one or more instances implementing this interface to keep track
44  of the table definitions corresponding to the supported DD versions.
45 */
46 
48  public:
50 
51  /**
52  Set the name of the table.
53 
54  @param name Table name.
55  */
56  virtual void set_table_name(const String_type &name) = 0;
57 
58  /**
59  Add a field to the object table definition.
60 
61  @param field_number Positional index of the field.
62  @param field_name Label which can be used to refer to the field.
63  @param field_definition Complete field definition with name, type etc.
64  */
65  virtual void add_field(int field_number, const String_type &field_name,
66  const String_type field_definition) = 0;
67 
68  /**
69  Add an index to the object table definition.
70 
71  @param index_number Positional index (sic!) of the index.
72  @param index_name Label which can be used to refer to the index.
73  @param index_definition Complete index definition.
74  */
75  virtual void add_index(int index_number, const String_type &index_name,
76  const String_type &index_definition) = 0;
77 
78  /**
79  Get the SQL DDL statement for creating the dictionary table.
80 
81  @return String containing the SQL DDL statement for the target table.
82  */
83  virtual String_type get_ddl() const = 0;
84 
85  /**
86  Get the SQL DML statements for populating the table.
87 
88  @return Vector of strings containing SQL DML statements
89  */
90  virtual const std::vector<String_type> &get_dml() const = 0;
91 
92  /**
93  Store the elements of the object table definition into a property
94  object.
95 
96  @param [out] table_def_properties Properties object containing the
97  definition.
98  */
99  virtual void store_into_properties(
100  Properties *table_def_properties) const = 0;
101 
102  /**
103  Restore the elements of the object table definition from a property
104  object.
105 
106  @param table_def_properties Properties object containing the
107  definition.
108  @return Operation outcome, false if no error.
109  */
110  virtual bool restore_from_properties(
111  const Properties &table_def_properties) = 0;
112 };
113 
114 ///////////////////////////////////////////////////////////////////////////
115 
116 } // namespace dd
117 
118 #endif // DD__OBJECT_TABLE_DEFINITION_INCLUDED
Some integer typedefs for easier portability.
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
virtual String_type get_ddl() const =0
Get the SQL DDL statement for creating the dictionary table.
virtual void add_index(int index_number, const String_type &index_name, const String_type &index_definition)=0
Add an index to the object table definition.
virtual ~Object_table_definition()
Definition: object_table_definition.h:49
virtual bool restore_from_properties(const Properties &table_def_properties)=0
Restore the elements of the object table definition from a property object.
The purpose of this interface is to enable retrieving the SQL statements necessary to create and popu...
Definition: object_table_definition.h:47
virtual void add_field(int field_number, const String_type &field_name, const String_type field_definition)=0
Add a field to the object table definition.
case opt name
Definition: sslopt-case.h:32
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:73
virtual void set_table_name(const String_type &name)=0
Set the name of the table.
virtual const std::vector< String_type > & get_dml() const =0
Get the SQL DML statements for populating the table.
virtual void store_into_properties(Properties *table_def_properties) const =0
Store the elements of the object table definition into a property object.
Definition: test_sql_stmt.cc:150
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39