MySQL 9.1.0
Source Code Documentation
pfs_example_machines_by_emp_by_mtype.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 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 PLUGIN_PFS_TABLE_MACHINES_BY_EMP_BY_MTYPE_H_
25#define PLUGIN_PFS_TABLE_MACHINES_BY_EMP_BY_MTYPE_H_
26
29#include <mysql/plugin.h>
30
33
34/* Service handle */
35extern SERVICE_TYPE(pfs_plugin_column_integer_v1) * col_int_svc;
36extern SERVICE_TYPE(pfs_plugin_column_enum_v1) * col_enum_svc;
37extern SERVICE_TYPE(pfs_plugin_column_string_v2) * col_string_svc;
38
39/* Global share pointer for table */
41
42/* A structure to denote a single row of the table. */
44 public:
46 unsigned int f_name_length;
48 unsigned int l_name_length;
51
52 /* If there is a value in this row */
53 bool m_exist;
54};
55
56/* A class to define position of cursor in table. */
58 /** Outer index for employee. */
59 unsigned int m_index_1;
60 /** Current index within index_1, for machine type. */
61 unsigned int m_index_2;
62
63 /**
64 Constructor.
65 @param index_1 the first index initial value.
66 @param index_2 the second index initial value.
67 */
68 POS_m_by_emp_by_mtype(uint index_1, uint index_2)
69 : m_index_1(index_1), m_index_2(index_2) {}
70
72 /**
73 Set this index at a given position.
74 */
75 void set_at(uint index_1, uint index_2) {
76 m_index_1 = index_1;
77 m_index_2 = index_2;
78 }
79
80 /**
81 Set this index at a given position.
82 @param other a position
83 */
84 void set_at(const POS_m_by_emp_by_mtype *other) {
85 m_index_1 = other->m_index_1;
86 m_index_2 = other->m_index_2;
87 }
88
89 void reset() {
90 m_index_1 = 0;
91 m_index_2 = 0;
92 }
93
94 /**
95 Set this index after a given position.
96 @param other a position
97 */
98 void set_after(const POS_m_by_emp_by_mtype *other) {
99 m_index_1 = other->m_index_1;
100 m_index_2 = other->m_index_2 + 1;
101 }
102
104 if (m_index_1 < EMPLOYEEE_NAME_MAX_ROWS) return true;
105 return false;
106 }
107
109 if (m_index_2 < (unsigned int)TYPE_END) return true;
110 return false;
111 }
112
114
116 m_index_1++;
117 m_index_2 = 0;
118 }
119};
120
121/* A structure to define a handle for table in plugin/component code. */
122typedef struct {
123 /* Current position instance */
125 /* Next position instance */
127
128 /* Current row for the table */
131
138 bool sorted, PSI_index_handle **index);
140 PSI_key_reader *reader, unsigned int idx,
141 int find_flag);
145 PSI_field *field, uint index);
148 PSI_field *field, unsigned int index);
151 PSI_field *field, unsigned int index);
154unsigned long long m_by_emp_by_mtype_get_row_count(void);
156
157#endif /* PLUGIN_PFS_TABLE_MACHINES_BY_EMP_BY_MTYPE_H_ */
Definition: pfs_example_machines_by_emp_by_mtype.h:43
char l_name[EMPLOYEE_NAME_LEN]
Definition: pfs_example_machines_by_emp_by_mtype.h:47
unsigned int l_name_length
Definition: pfs_example_machines_by_emp_by_mtype.h:48
PSI_int count
Definition: pfs_example_machines_by_emp_by_mtype.h:50
char f_name[EMPLOYEE_NAME_LEN]
Definition: pfs_example_machines_by_emp_by_mtype.h:45
unsigned int f_name_length
Definition: pfs_example_machines_by_emp_by_mtype.h:46
bool m_exist
Definition: pfs_example_machines_by_emp_by_mtype.h:53
PSI_enum machine_type
Definition: pfs_example_machines_by_emp_by_mtype.h:49
static int handle(int sql_errno, const char *sqlstate, const char *message, void *state)
Bridge function between the C++ API offered by this module and the C API of the parser service.
Definition: services.cc:64
#define EMPLOYEEE_NAME_MAX_ROWS
Definition: pfs_example_employee_name.h:42
#define EMPLOYEE_NAME_LEN
Definition: pfs_example_employee_name.h:39
@ TYPE_END
Definition: pfs_example_machine.h:46
int m_by_emp_by_mtype_index_next(PSI_table_handle *handle)
Definition: pfs_example_machines_by_emp_by_mtype.cc:155
void m_by_emp_by_mtype_reset_position(PSI_table_handle *handle)
Definition: pfs_example_machines_by_emp_by_mtype.cc:161
int m_by_emp_by_mtype_write_column_value(PSI_table_handle *handle, PSI_field *field, unsigned int index)
void m_by_emp_by_mtype_close_table(PSI_table_handle *handle)
Destroy the Table_Handle at plugin code when corresponding table in performance schema is closed.
Definition: pfs_example_machines_by_emp_by_mtype.cc:42
int m_by_emp_by_mtype_index_init(PSI_table_handle *handle, uint idx, bool sorted, PSI_index_handle **index)
Definition: pfs_example_machines_by_emp_by_mtype.cc:137
int m_by_emp_by_mtype_index_read(PSI_index_handle *index, PSI_key_reader *reader, unsigned int idx, int find_flag)
Definition: pfs_example_machines_by_emp_by_mtype.cc:146
const mysql_service_pfs_plugin_column_enum_v1_t * col_enum_svc
Definition: pfs_example_plugin_employee.cc:100
int m_by_emp_by_mtype_write_row_values(PSI_table_handle *handle)
int m_by_emp_by_mtype_update_column_value(PSI_table_handle *handle, PSI_field *field, unsigned int index)
PFS_engine_table_share_proxy m_by_emp_by_mtype_st_share
Definition: pfs_example_machines_by_emp_by_mtype.cc:26
const mysql_service_pfs_plugin_column_integer_v1_t * col_int_svc
Definition: pfs_example_plugin_employee.cc:90
const mysql_service_pfs_plugin_column_string_v2_t * col_string_svc
Definition: pfs_example_plugin_employee.cc:92
PSI_table_handle * m_by_emp_by_mtype_open_table(PSI_pos **pos)
Instantiate Table_Handle at plugin code when corresponding table in performance schema is opened.
Definition: pfs_example_machines_by_emp_by_mtype.cc:32
void init_m_by_emp_by_mtype_share(PFS_engine_table_share_proxy *share)
Definition: pfs_example_machines_by_emp_by_mtype.cc:198
int m_by_emp_by_mtype_delete_all_rows(void)
int m_by_emp_by_mtype_delete_row_values(PSI_table_handle *handle)
int m_by_emp_by_mtype_update_row_values(PSI_table_handle *handle)
int m_by_emp_by_mtype_read_column_value(PSI_table_handle *handle, PSI_field *field, uint index)
Definition: pfs_example_machines_by_emp_by_mtype.cc:169
unsigned long long m_by_emp_by_mtype_get_row_count(void)
Definition: pfs_example_machines_by_emp_by_mtype.cc:196
int m_by_emp_by_mtype_rnd_pos(PSI_table_handle *handle)
Definition: pfs_example_machines_by_emp_by_mtype.cc:124
int m_by_emp_by_mtype_rnd_init(PSI_table_handle *h, bool scan)
Definition: pfs_example_machines_by_emp_by_mtype.cc:118
int m_by_emp_by_mtype_rnd_next(PSI_table_handle *handle)
Definition: pfs_example_machines_by_emp_by_mtype.cc:75
struct PSI_table_handle PSI_table_handle
This is an opaque structure to denote table handle in plugin/component code.
Definition: pfs_plugin_table_service.h:97
struct PSI_pos PSI_pos
This is an opaque structure to denote cursor position in plugin/component code.
Definition: pfs_plugin_table_service.h:102
#define PSI_int
Definition: pfs_plugin_table_service.h:148
#define PSI_enum
Definition: pfs_plugin_table_service.h:153
struct PSI_key_reader PSI_key_reader
This is an opaque structure to denote Key Reader in plugin/component code.
Definition: pfs_plugin_table_service.h:106
struct PSI_index_handle PSI_index_handle
This is an opaque structure to denote Index Handle in plugin/component code.
Definition: pfs_plugin_table_service.h:110
struct PSI_field PSI_field
This is an opaque structure to denote filed in plugin/component code.
Definition: pfs_plugin_table_service.h:93
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:76
Specifies macros to define Service Implementations.
Definition: pfs_example_machines_by_emp_by_mtype.h:122
POS_m_by_emp_by_mtype m_next_pos
Definition: pfs_example_machines_by_emp_by_mtype.h:126
POS_m_by_emp_by_mtype m_pos
Definition: pfs_example_machines_by_emp_by_mtype.h:124
M_by_emp_by_mtype_record current_row
Definition: pfs_example_machines_by_emp_by_mtype.h:129
A share to be initialized by plugin/component code and to be provided to add_table() service method o...
Definition: pfs_plugin_table_service.h:462
Definition: pfs_example_machines_by_emp_by_mtype.h:57
bool has_more_employee()
Definition: pfs_example_machines_by_emp_by_mtype.h:103
void set_at(const POS_m_by_emp_by_mtype *other)
Set this index at a given position.
Definition: pfs_example_machines_by_emp_by_mtype.h:84
void set_at(uint index_1, uint index_2)
Set this index at a given position.
Definition: pfs_example_machines_by_emp_by_mtype.h:75
unsigned int m_index_1
Outer index for employee.
Definition: pfs_example_machines_by_emp_by_mtype.h:59
void next_employee()
Definition: pfs_example_machines_by_emp_by_mtype.h:115
unsigned int m_index_2
Current index within index_1, for machine type.
Definition: pfs_example_machines_by_emp_by_mtype.h:61
bool has_more_machine_type()
Definition: pfs_example_machines_by_emp_by_mtype.h:108
void set_after(const POS_m_by_emp_by_mtype *other)
Set this index after a given position.
Definition: pfs_example_machines_by_emp_by_mtype.h:98
POS_m_by_emp_by_mtype(uint index_1, uint index_2)
Constructor.
Definition: pfs_example_machines_by_emp_by_mtype.h:68
POS_m_by_emp_by_mtype()
Definition: pfs_example_machines_by_emp_by_mtype.h:71
void next_machine_type()
Definition: pfs_example_machines_by_emp_by_mtype.h:113
void reset()
Definition: pfs_example_machines_by_emp_by_mtype.h:89