MySQL 8.0.39
Source Code Documentation
pfs_example_employee_salary.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_PLUGIN_pfs_example_employee_salary_H_
25#define PLUGIN_PFS_TABLE_PLUGIN_pfs_example_employee_salary_H_
26
29#include <mysql/plugin.h>
30#include <algorithm>
31#include <vector>
32
33/* Service handle */
34extern SERVICE_TYPE(pfs_plugin_column_integer_v1) * col_int_svc;
35extern SERVICE_TYPE(pfs_plugin_column_bigint_v1) * col_bigint_svc;
36extern SERVICE_TYPE(pfs_plugin_column_date_v1) * col_date_svc;
37extern SERVICE_TYPE(pfs_plugin_column_time_v1) * col_time_svc;
38
39/* Global share pointer for pfs_example_employee_salary table */
41
42/* A mutex instance to protect:
43 * - esalary_rows_in_table
44 * - esalary_records_vector
45 */
47
48/* A structure to denote a single row of the table. */
50 public:
53 char e_dob[20];
54 unsigned int e_dob_length;
55 char e_tob[20];
56 unsigned int e_tob_length;
57
58 /* If there is a value in this row */
59 bool m_exist;
60};
61
62/**
63 * An array to keep rows of the tables.
64 * When a row is inserted in plugin table, it will be stored here.
65 * When a row is queried from plugin table, it will be fetched from here.
66 */
67extern std::vector<Esalary_Record> esalary_records_vector;
68
69/* A class to define position of cursor in table. */
71 private:
72 unsigned int m_index;
73
74 public:
75 ~Esalary_POS() = default;
77
78 bool has_more() {
79 if (m_index < esalary_records_vector.size()) return true;
80 return false;
81 }
82 void next() { m_index++; }
83
84 void reset() { m_index = 0; }
85
86 unsigned int get_index() { return m_index; }
87
88 void set_at(unsigned int index) { m_index = index; }
89
90 void set_at(Esalary_POS *pos) { m_index = pos->m_index; }
91
92 void set_after(Esalary_POS *pos) { m_index = pos->m_index + 1; }
93};
94
95/* A structure to define a handle for table in plugin/component code. */
97 /* Current position instance */
99 /* Next position instance */
101
102 /* Current row for the table */
104};
105
109int esalary_rnd_init(PSI_table_handle *h, bool scan);
111int esalary_index_init(PSI_table_handle *handle, uint idx, bool sorted,
112 PSI_index_handle **index);
114 unsigned int idx, int find_flag);
118 uint index);
121 unsigned int index);
124 unsigned int index);
127unsigned long long esalary_get_row_count(void);
129
130#endif /* PLUGIN_PFS_TABLE_PLUGIN_pfs_example_employee_salary_H_ */
Definition: pfs_example_employee_salary.h:70
void set_at(Esalary_POS *pos)
Definition: pfs_example_employee_salary.h:90
void reset()
Definition: pfs_example_employee_salary.h:84
Esalary_POS()
Definition: pfs_example_employee_salary.h:76
~Esalary_POS()=default
void set_after(Esalary_POS *pos)
Definition: pfs_example_employee_salary.h:92
unsigned int get_index()
Definition: pfs_example_employee_salary.h:86
bool has_more()
Definition: pfs_example_employee_salary.h:78
void set_at(unsigned int index)
Definition: pfs_example_employee_salary.h:88
void next()
Definition: pfs_example_employee_salary.h:82
unsigned int m_index
Definition: pfs_example_employee_salary.h:72
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
const mysql_service_pfs_plugin_column_time_v1_t * col_time_svc
Definition: pfs_example_plugin_employee.cc:98
int esalary_update_column_value(PSI_table_handle *handle, PSI_field *field, unsigned int index)
Definition: pfs_example_employee_salary.cc:235
mysql_mutex_t LOCK_esalary_records_array
Definition: pfs_example_employee_salary.cc:29
int esalary_delete_row_values(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:265
void init_esalary_share(PFS_engine_table_share_proxy *share)
Definition: pfs_example_employee_salary.cc:290
int esalary_read_column_value(PSI_table_handle *handle, PSI_field *field, uint index)
Definition: pfs_example_employee_salary.cc:136
const mysql_service_pfs_plugin_column_bigint_v1_t * col_bigint_svc
Definition: pfs_example_plugin_employee.cc:94
const mysql_service_pfs_plugin_column_integer_v1_t * col_int_svc
Definition: pfs_example_plugin_employee.cc:90
PSI_table_handle * esalary_open_table(PSI_pos **pos)
Instantiate Esalary_Table_Handle at plugin code when corresponding table in performance schema is ope...
Definition: pfs_example_employee_salary.cc:40
int esalary_index_next(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:122
int esalary_index_init(PSI_table_handle *handle, uint idx, bool sorted, PSI_index_handle **index)
Definition: pfs_example_employee_salary.cc:105
int esalary_write_column_value(PSI_table_handle *handle, PSI_field *field, unsigned int index)
Definition: pfs_example_employee_salary.cc:191
int esalary_write_row_values(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:164
const mysql_service_pfs_plugin_column_date_v1_t * col_date_svc
Definition: pfs_example_plugin_employee.cc:96
PFS_engine_table_share_proxy esalary_st_share
Definition: pfs_example_employee_salary.cc:28
int esalary_index_read(PSI_index_handle *index, PSI_key_reader *reader, unsigned int idx, int find_flag)
Definition: pfs_example_employee_salary.cc:113
int esalary_rnd_pos(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:92
void esalary_close_table(PSI_table_handle *handle)
Destroy the Esalary_Table_Handle at plugin code when corresponding table in performance schema is clo...
Definition: pfs_example_employee_salary.cc:55
int esalary_rnd_init(PSI_table_handle *h, bool scan)
Definition: pfs_example_employee_salary.cc:87
void esalary_reset_position(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:128
int esalary_delete_all_rows(void)
Definition: pfs_example_employee_salary.cc:280
unsigned long long esalary_get_row_count(void)
Definition: pfs_example_employee_salary.cc:288
std::vector< Esalary_Record > esalary_records_vector
An array to keep rows of the tables.
Definition: pfs_example_employee_salary.cc:34
int esalary_update_row_values(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:221
int esalary_rnd_next(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:71
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_bigint
Definition: pfs_plugin_table_service.h:150
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_employee_salary.h:49
PSI_int e_number
Definition: pfs_example_employee_salary.h:51
char e_dob[20]
Definition: pfs_example_employee_salary.h:53
unsigned int e_tob_length
Definition: pfs_example_employee_salary.h:56
unsigned int e_dob_length
Definition: pfs_example_employee_salary.h:54
char e_tob[20]
Definition: pfs_example_employee_salary.h:55
bool m_exist
Definition: pfs_example_employee_salary.h:59
PSI_bigint e_salary
Definition: pfs_example_employee_salary.h:52
Definition: pfs_example_employee_salary.h:96
Esalary_Record current_row
Definition: pfs_example_employee_salary.h:103
Esalary_POS m_next_pos
Definition: pfs_example_employee_salary.h:100
Esalary_POS m_pos
Definition: pfs_example_employee_salary.h:98
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:463
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
unsigned int uint
Definition: uca9-dump.cc:75