1 /* Copyright (c) 2014, 2018, 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__PARTITION_VALUE_INCLUDED
24 #define DD__PARTITION_VALUE_INCLUDED
25 
26 #include "my_inttypes.h"
27 #include "sql/dd/sdi_fwd.h"            // dd::Sdi_wcontext
28 #include "sql/dd/types/weak_object.h"  // dd::Weak_object
29 
30 namespace dd {
31 
32 ///////////////////////////////////////////////////////////////////////////
33 
34 class Column;
35 class Partition;
36 class Partition_value_impl;
37 
38 namespace tables {
39 class Table_partition_values;
40 }
41 
42 ///////////////////////////////////////////////////////////////////////////
43 
44 class Partition_value : virtual public Weak_object {
45  public:
46   typedef Partition_value_impl Impl;
47   typedef tables::Table_partition_values DD_table;
48 
49  public:
~Partition_value()50   virtual ~Partition_value() {}
51 
52   /////////////////////////////////////////////////////////////////////////
53   // Partition.
54   /////////////////////////////////////////////////////////////////////////
55 
56   virtual const Partition &partition() const = 0;
57 
58   virtual Partition &partition() = 0;
59 
60   /////////////////////////////////////////////////////////////////////////
61   // list_num.
62   /////////////////////////////////////////////////////////////////////////
63 
64   virtual uint list_num() const = 0;
65   virtual void set_list_num(uint list_num) = 0;
66 
67   /////////////////////////////////////////////////////////////////////////
68   // column_num.
69   /////////////////////////////////////////////////////////////////////////
70 
71   virtual uint column_num() const = 0;
72   virtual void set_column_num(uint column_num) = 0;
73 
74   /////////////////////////////////////////////////////////////////////////
75   // value.
76   /////////////////////////////////////////////////////////////////////////
77 
78   virtual const String_type &value_utf8() const = 0;
79   virtual void set_value_utf8(const String_type &value) = 0;
80 
81   /////////////////////////////////////////////////////////////////////////
82   // max_value.
83   /////////////////////////////////////////////////////////////////////////
84 
85   virtual bool max_value() const = 0;
86   virtual void set_max_value(bool max_value) = 0;
87 
88   /////////////////////////////////////////////////////////////////////////
89   // null_value.
90   /////////////////////////////////////////////////////////////////////////
91 
92   virtual bool is_value_null() const = 0;
93   virtual void set_value_null(bool is_null) = 0;
94 
95   /**
96     Converts *this into json.
97 
98     Converts all member variables that are to be included in the sdi
99     into json by transforming them appropriately and passing them to
100     the rapidjson writer provided.
101 
102     @param wctx opaque context for data needed by serialization
103     @param w rapidjson writer which will perform conversion to json
104 
105   */
106 
107   virtual void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const = 0;
108 
109   /**
110     Re-establishes the state of *this by reading sdi information from
111     the rapidjson DOM subobject provided.
112 
113     Cross-references encountered within this object are tracked in
114     sdictx, so that they can be updated when the entire object graph
115     has been established.
116 
117     @param rctx stores book-keeping information for the
118     deserialization process
119     @param val subobject of rapidjson DOM containing json
120     representation of this object
121   */
122 
123   virtual bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) = 0;
124 };
125 
126 ///////////////////////////////////////////////////////////////////////////
127 
128 }  // namespace dd
129 
130 #endif  // DD__PARTITION_VALUE_INCLUDED
131