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