MySQL 9.1.0
Source Code Documentation
server_telemetry_attribute_bits.h
Go to the documentation of this file.
1/* Copyright (c) 2024, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef SERVER_TELEMETRY_ATTRIBUTE_BITS_H
25#define SERVER_TELEMETRY_ATTRIBUTE_BITS_H
26
28
37};
38
39/*
40 This structure is used to pass attribute values in APIs.
41
42 For simplicity, it is a struct instead of a union.
43 The struct sizeof() is not a concern, as data is passed by address, and is
44 never used for long term storage.
45*/
48 int32_t int32_value;
49 uint32_t uint32_value;
50 int64_t int64_value;
51 uint64_t uint64_value;
53 const char *string_value; // for STRING and STRING_VIEW
54 size_t string_length; // for STRING_VIEW
55};
56
58 const char *name;
61
62 void set_bool(const char *attr_name, bool v) {
63 name = attr_name;
65 value.bool_value = v;
66 }
67
68 void set_int32(const char *attr_name, int32_t v) {
69 name = attr_name;
72 }
73
74 void set_uint32(const char *attr_name, uint32_t v) {
75 name = attr_name;
78 }
79
80 void set_int64(const char *attr_name, int64_t v) {
81 name = attr_name;
84 }
85
86 void set_uint64(const char *attr_name, uint64_t v) {
87 name = attr_name;
90 }
91
92 void set_double(const char *attr_name, double v) {
93 name = attr_name;
96 }
97
98 void set_string(const char *attr_name, const char *v) {
99 name = attr_name;
102 }
103
104 void set_string_view(const char *attr_name, const char *v, size_t len) {
105 name = attr_name;
108 value.string_length = len;
109 }
110};
111
112#endif /* SERVER_TELEMETRY_ATTRIBUTE_BITS_H */
log_attribute_type
Definition: server_telemetry_attribute_bits.h:27
@ LOG_ATTRIBUTE_UINT32
Definition: server_telemetry_attribute_bits.h:31
@ LOG_ATTRIBUTE_STRING
Definition: server_telemetry_attribute_bits.h:35
@ LOG_ATTRIBUTE_UINT64
Definition: server_telemetry_attribute_bits.h:33
@ LOG_ATTRIBUTE_BOOLEAN
Definition: server_telemetry_attribute_bits.h:29
@ LOG_ATTRIBUTE_INT32
Definition: server_telemetry_attribute_bits.h:30
@ LOG_ATTRIBUTE_INT64
Definition: server_telemetry_attribute_bits.h:32
@ LOG_ATTRIBUTE_STRING_VIEW
Definition: server_telemetry_attribute_bits.h:36
@ LOG_ATTRIBUTE_DOUBLE
Definition: server_telemetry_attribute_bits.h:34
Definition: server_telemetry_attribute_bits.h:57
void set_double(const char *attr_name, double v)
Definition: server_telemetry_attribute_bits.h:92
void set_string(const char *attr_name, const char *v)
Definition: server_telemetry_attribute_bits.h:98
enum log_attribute_type type
Definition: server_telemetry_attribute_bits.h:59
void set_int64(const char *attr_name, int64_t v)
Definition: server_telemetry_attribute_bits.h:80
void set_uint32(const char *attr_name, uint32_t v)
Definition: server_telemetry_attribute_bits.h:74
void set_string_view(const char *attr_name, const char *v, size_t len)
Definition: server_telemetry_attribute_bits.h:104
void set_bool(const char *attr_name, bool v)
Definition: server_telemetry_attribute_bits.h:62
void set_uint64(const char *attr_name, uint64_t v)
Definition: server_telemetry_attribute_bits.h:86
const char * name
Definition: server_telemetry_attribute_bits.h:58
void set_int32(const char *attr_name, int32_t v)
Definition: server_telemetry_attribute_bits.h:68
log_attribute_value value
Definition: server_telemetry_attribute_bits.h:60
Definition: server_telemetry_attribute_bits.h:46
uint64_t uint64_value
Definition: server_telemetry_attribute_bits.h:51
bool bool_value
Definition: server_telemetry_attribute_bits.h:47
double double_value
Definition: server_telemetry_attribute_bits.h:52
int32_t int32_value
Definition: server_telemetry_attribute_bits.h:48
uint32_t uint32_value
Definition: server_telemetry_attribute_bits.h:49
const char * string_value
Definition: server_telemetry_attribute_bits.h:53
int64_t int64_value
Definition: server_telemetry_attribute_bits.h:50
size_t string_length
Definition: server_telemetry_attribute_bits.h:54