MySQL 8.0.39
Source Code Documentation
raw_record.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__RAW_RECORD_INCLUDED
25#define DD__RAW_RECORD_INCLUDED
26
27#include "my_config.h"
28#include "my_inttypes.h"
29#include "my_io.h" // IWYU pragma: keep
30#include "my_time_t.h" // my_time_t
31#include "sql/dd/object_id.h" // dd::Object_id
32#include "sql/dd/string_type.h" // dd::String_type
33
34class Json_wrapper;
35class Field;
36struct TABLE;
37
38namespace dd {
39
40///////////////////////////////////////////////////////////////////////////
41
42class Properties;
43
44///////////////////////////////////////////////////////////////////////////
45
47 public:
48 Raw_record(TABLE *table);
49
50 public:
51 bool update();
52 bool drop();
53
54 public:
55 bool store_pk_id(int field_no, Object_id id);
56 bool store_ref_id(int field_no, Object_id id);
57 bool store(int field_no, const String_type &s, bool is_null = false);
58 bool store(int field_no, ulonglong ull, bool is_null = false);
59 bool store(int field_no, longlong ll, bool is_null = false);
60
61 bool store(int field_no, bool b, bool is_null = false) {
62 return store(field_no, b ? 1ll : 0ll, is_null);
63 }
64
65 bool store(int field_no, uint v, bool is_null = false) {
66 return store(field_no, (ulonglong)v, is_null);
67 }
68
69 bool store(int field_no, int v, bool is_null = false) {
70 return store(field_no, (longlong)v, is_null);
71 }
72
73 bool store(int field_no, const Properties &p);
74
75 bool store_time(int field_no, my_time_t val, bool is_null = false);
76
77 /**
78 Store timeval at field specified by field_no into the record.
79
80 @param field_no Field position in the record.
81 @param tv Time value to store.
82
83 @returns
84 false on success
85 true on failure
86 */
87
88 bool store_timestamp(int field_no, const my_timeval &tv);
89
90 bool store_json(int field_no, const Json_wrapper &json);
91
92 public:
93 bool is_null(int field_no) const;
94
95 longlong read_int(int field_no) const;
96 longlong read_int(int field_no, longlong null_value) const {
97 return is_null(field_no) ? null_value : read_int(field_no);
98 }
99
100 ulonglong read_uint(int field_no) const;
101 ulonglong read_uint(int field_no, ulonglong null_value) const {
102 return is_null(field_no) ? null_value : read_uint(field_no);
103 }
104
105 String_type read_str(int field_no) const;
106 String_type read_str(int field_no, const String_type &null_value) const {
107 return is_null(field_no) ? null_value : read_str(field_no);
108 }
109
110 Object_id read_ref_id(int field_no) const;
111
112 bool read_bool(int field_no) const { return read_int(field_no) != 0; }
113
114 my_time_t read_time(int field_no) const;
115
116 /**
117 Read timeval stored at field specified by field_no from the record.
118
119 @param field_no Field position in the record.
120
121 @returns
122 timeval stored at field_no.
123 */
124
125 my_timeval read_timestamp(int field_no) const;
126
127 bool read_json(int field_no, Json_wrapper *json_wrapper) const;
128
129 protected:
130 void set_null(int field_no, bool is_null);
131
132 Field *field(
133 int field_no) const; // XXX: return non-const from const-operation
134
135 protected:
137};
138
139///////////////////////////////////////////////////////////////////////////
140
142 public:
143 Raw_new_record(TABLE *table);
144
146
147 public:
148 bool insert();
149
150 Object_id get_insert_id() const;
151
152 void finalize();
153};
154
155///////////////////////////////////////////////////////////////////////////
156
157} // namespace dd
158
159#endif // DD__RAW_RECORD_INCLUDED
Definition: field.h:575
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1161
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:74
Definition: raw_record.h:141
bool insert()
Create new record in SE.
Definition: raw_record.cc:309
~Raw_new_record()
Definition: raw_record.h:145
void finalize()
Definition: raw_record.cc:333
Raw_new_record(TABLE *table)
Definition: raw_record.cc:290
Object_id get_insert_id() const
Definition: raw_record.cc:324
Definition: raw_record.h:46
bool drop()
Drop the record from SE.
Definition: raw_record.cc:98
bool store(int field_no, bool b, bool is_null=false)
Definition: raw_record.h:61
bool store_ref_id(int field_no, Object_id id)
Definition: raw_record.cc:127
bool store_time(int field_no, my_time_t val, bool is_null=false)
Definition: raw_record.cc:197
my_timeval read_timestamp(int field_no) const
Read timeval stored at field specified by field_no from the record.
Definition: raw_record.cc:270
bool is_null(int field_no) const
Definition: raw_record.cc:224
bool store_timestamp(int field_no, const my_timeval &tv)
Store timeval at field specified by field_no into the record.
Definition: raw_record.cc:210
bool store(int field_no, uint v, bool is_null=false)
Definition: raw_record.h:65
bool read_json(int field_no, Json_wrapper *json_wrapper) const
Definition: raw_record.cc:282
String_type read_str(int field_no) const
Definition: raw_record.cc:242
longlong read_int(int field_no, longlong null_value) const
Definition: raw_record.h:96
String_type read_str(int field_no, const String_type &null_value) const
Definition: raw_record.h:106
bool store(int field_no, const String_type &s, bool is_null=false)
Definition: raw_record.cc:151
bool store(int field_no, int v, bool is_null=false)
Definition: raw_record.h:69
bool update()
Update table record into SE.
Definition: raw_record.cc:61
TABLE * m_table
Definition: raw_record.h:136
bool store_pk_id(int field_no, Object_id id)
Definition: raw_record.cc:119
my_time_t read_time(int field_no) const
Definition: raw_record.cc:260
ulonglong read_uint(int field_no) const
Definition: raw_record.cc:236
bool store_json(int field_no, const Json_wrapper &json)
Definition: raw_record.cc:217
Raw_record(TABLE *table)
Definition: raw_record.cc:48
Object_id read_ref_id(int field_no) const
Definition: raw_record.cc:253
bool read_bool(int field_no) const
Definition: raw_record.h:112
longlong read_int(int field_no) const
Definition: raw_record.cc:230
void set_null(int field_no, bool is_null)
Definition: raw_record.cc:142
Field * field(int field_no) const
Definition: raw_record.cc:113
ulonglong read_uint(int field_no, ulonglong null_value) const
Definition: raw_record.h:101
const char * p
Definition: ctype-mb.cc:1237
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
long long int longlong
Definition: my_inttypes.h:55
Common #defines and includes for file and socket I/O.
int64_t my_time_t
Portable time_t replacement.
Definition: my_time_t.h:32
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
unsigned long long Object_id
Definition: object_id.h:31
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
Definition: table.h:1399
Replacement of system's struct timeval to ensure we can carry 64 bit values even on a platform which ...
Definition: my_time_t.h:45
unsigned int uint
Definition: uca9-dump.cc:75