MySQL 8.1.0
Source Code Documentation
pfs_example_machines_by_emp_by_mtype.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 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 PLUGIN_PFS_TABLE_MACHINES_BY_EMP_BY_MTYPE_H_
24#define PLUGIN_PFS_TABLE_MACHINES_BY_EMP_BY_MTYPE_H_
25
28#include <mysql/plugin.h>
29
32
33/* Service handle */
34extern SERVICE_TYPE(pfs_plugin_column_integer_v1) * col_int_svc;
35extern SERVICE_TYPE(pfs_plugin_column_enum_v1) * col_enum_svc;
36extern SERVICE_TYPE(pfs_plugin_column_string_v2) * col_string_svc;
37
38/* Global share pointer for table */
40
41/* A structure to denote a single row of the table. */
43 public:
45 unsigned int f_name_length;
47 unsigned int l_name_length;
50
51 /* If there is a value in this row */
52 bool m_exist;
53};
54
55/* A class to define position of cursor in table. */
57 /** Outer index for employee. */
58 unsigned int m_index_1;
59 /** Current index within index_1, for machine type. */
60 unsigned int m_index_2;
61
62 /**
63 Constructor.
64 @param index_1 the first index initial value.
65 @param index_2 the second index initial value.
66 */
67 POS_m_by_emp_by_mtype(uint index_1, uint index_2)
68 : m_index_1(index_1), m_index_2(index_2) {}
69
71 /**
72 Set this index at a given position.
73 */
74 void set_at(uint index_1, uint index_2) {
75 m_index_1 = index_1;
76 m_index_2 = index_2;
77 }
78
79 /**
80 Set this index at a given position.
81 @param other a position
82 */
83 void set_at(const POS_m_by_emp_by_mtype *other) {
84 m_index_1 = other->m_index_1;
85 m_index_2 = other->m_index_2;
86 }
87
88 void reset() {
89 m_index_1 = 0;
90 m_index_2 = 0;
91 }
92
93 /**
94 Set this index after a given position.
95 @param other a position
96 */
97 void set_after(const POS_m_by_emp_by_mtype *other) {
98 m_index_1 = other->m_index_1;
99 m_index_2 = other->m_index_2 + 1;
100 }
101
103 if (m_index_1 < EMPLOYEEE_NAME_MAX_ROWS) return true;
104 return false;
105 }
106
108 if (m_index_2 < (unsigned int)TYPE_END) return true;
109 return false;
110 }
111
113
115 m_index_1++;
116 m_index_2 = 0;
117 }
118};
119
120/* A structure to define a handle for table in plugin/component code. */
121typedef struct {
122 /* Current position instance */
124 /* Next position instance */
126
127 /* Current row for the table */
130
137 bool sorted, PSI_index_handle **index);
139 PSI_key_reader *reader, unsigned int idx,
140 int find_flag);
144 PSI_field *field, uint index);
147 PSI_field *field, unsigned int index);
150 PSI_field *field, unsigned int index);
153unsigned long long m_by_emp_by_mtype_get_row_count(void);
155
156#endif /* PLUGIN_PFS_TABLE_MACHINES_BY_EMP_BY_MTYPE_H_ */
Definition: pfs_example_machines_by_emp_by_mtype.h:42
char l_name[EMPLOYEE_NAME_LEN]
Definition: pfs_example_machines_by_emp_by_mtype.h:46
unsigned int l_name_length
Definition: pfs_example_machines_by_emp_by_mtype.h:47
PSI_int count
Definition: pfs_example_machines_by_emp_by_mtype.h:49
char f_name[EMPLOYEE_NAME_LEN]
Definition: pfs_example_machines_by_emp_by_mtype.h:44
unsigned int f_name_length
Definition: pfs_example_machines_by_emp_by_mtype.h:45
bool m_exist
Definition: pfs_example_machines_by_emp_by_mtype.h:52
PSI_enum machine_type
Definition: pfs_example_machines_by_emp_by_mtype.h:48
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:63
#define EMPLOYEEE_NAME_MAX_ROWS
Definition: pfs_example_employee_name.h:41
#define EMPLOYEE_NAME_LEN
Definition: pfs_example_employee_name.h:38
@ TYPE_END
Definition: pfs_example_machine.h:45
int m_by_emp_by_mtype_index_next(PSI_table_handle *handle)
Definition: pfs_example_machines_by_emp_by_mtype.cc:154
void m_by_emp_by_mtype_reset_position(PSI_table_handle *handle)
Definition: pfs_example_machines_by_emp_by_mtype.cc:160
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:41
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:136
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:145
const mysql_service_pfs_plugin_column_enum_v1_t * col_enum_svc
Definition: pfs_example_plugin_employee.cc:99
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:25
const mysql_service_pfs_plugin_column_integer_v1_t * col_int_svc
Definition: pfs_example_plugin_employee.cc:89
const mysql_service_pfs_plugin_column_string_v2_t * col_string_svc
Definition: pfs_example_plugin_employee.cc:91
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:31
void init_m_by_emp_by_mtype_share(PFS_engine_table_share_proxy *share)
Definition: pfs_example_machines_by_emp_by_mtype.cc:197
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:168
unsigned long long m_by_emp_by_mtype_get_row_count(void)
Definition: pfs_example_machines_by_emp_by_mtype.cc:195
int m_by_emp_by_mtype_rnd_pos(PSI_table_handle *handle)
Definition: pfs_example_machines_by_emp_by_mtype.cc:123
int m_by_emp_by_mtype_rnd_init(PSI_table_handle *h, bool scan)
Definition: pfs_example_machines_by_emp_by_mtype.cc:117
int m_by_emp_by_mtype_rnd_next(PSI_table_handle *handle)
Definition: pfs_example_machines_by_emp_by_mtype.cc:74
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:96
struct PSI_pos PSI_pos
This is an opaque structure to denote cursor position in plugin/component code.
Definition: pfs_plugin_table_service.h:101
#define PSI_int
Definition: pfs_plugin_table_service.h:147
#define PSI_enum
Definition: pfs_plugin_table_service.h:152
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:105
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:109
struct PSI_field PSI_field
This is an opaque structure to denote filed in plugin/component code.
Definition: pfs_plugin_table_service.h:92
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:75
Specifies macros to define Service Implementations.
Definition: pfs_example_machines_by_emp_by_mtype.h:121
POS_m_by_emp_by_mtype m_next_pos
Definition: pfs_example_machines_by_emp_by_mtype.h:125
POS_m_by_emp_by_mtype m_pos
Definition: pfs_example_machines_by_emp_by_mtype.h:123
M_by_emp_by_mtype_record current_row
Definition: pfs_example_machines_by_emp_by_mtype.h:128
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:56
bool has_more_employee()
Definition: pfs_example_machines_by_emp_by_mtype.h:102
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:83
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:74
unsigned int m_index_1
Outer index for employee.
Definition: pfs_example_machines_by_emp_by_mtype.h:58
void next_employee()
Definition: pfs_example_machines_by_emp_by_mtype.h:114
unsigned int m_index_2
Current index within index_1, for machine type.
Definition: pfs_example_machines_by_emp_by_mtype.h:60
bool has_more_machine_type()
Definition: pfs_example_machines_by_emp_by_mtype.h:107
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:97
POS_m_by_emp_by_mtype(uint index_1, uint index_2)
Constructor.
Definition: pfs_example_machines_by_emp_by_mtype.h:67
POS_m_by_emp_by_mtype()
Definition: pfs_example_machines_by_emp_by_mtype.h:70
void next_machine_type()
Definition: pfs_example_machines_by_emp_by_mtype.h:112
void reset()
Definition: pfs_example_machines_by_emp_by_mtype.h:88