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