MySQL  8.0.17
Source Code Documentation
pfs_example_employee_salary.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
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 */
33 extern SERVICE_TYPE(pfs_plugin_table) * table_svc;
34 
35 /* Global share pointer for pfs_example_employee_salary table */
37 
38 /* A mutex instance to protect:
39  * - esalary_rows_in_table
40  * - esalary_records_vector
41  */
43 
44 /* A structure to denote a single row of the table. */
45 struct {
46  public:
49  char e_dob[20];
50  unsigned int e_dob_length;
51  char e_tob[20];
52  unsigned int e_tob_length;
53 
54  /* If there is a value in this row */
55  bool m_exist;
56 } typedef Esalary_Record;
57 
58 /**
59  * An array to keep rows of the tables.
60  * When a row is inserted in plugin table, it will be stored here.
61  * When a row is queried from plugin table, it will be fetched from here.
62  */
63 extern std::vector<Esalary_Record> esalary_records_vector;
64 
65 /* A class to define position of cursor in table. */
66 class Esalary_POS {
67  private:
68  unsigned int m_index;
69 
70  public:
72  Esalary_POS() { m_index = 0; }
73 
74  bool has_more() {
75  if (m_index < esalary_records_vector.size()) return true;
76  return false;
77  }
78  void next() { m_index++; }
79 
80  void reset() { m_index = 0; }
81 
82  unsigned int get_index() { return m_index; }
83 
84  void set_at(unsigned int index) { m_index = index; }
85 
86  void set_at(Esalary_POS *pos) { m_index = pos->m_index; }
87 
88  void set_after(Esalary_POS *pos) { m_index = pos->m_index + 1; }
89 };
90 
91 /* A structure to define a handle for table in plugin/component code. */
92 typedef struct {
93  /* Current position instance */
95  /* Next position instance */
97 
98  /* Current row for the table */
101 
105 int esalary_rnd_init(PSI_table_handle *h, bool scan);
107 int esalary_index_init(PSI_table_handle *handle, uint idx, bool sorted,
110  unsigned int idx, int find_flag);
114  uint index);
117  unsigned int index);
120  unsigned int index);
122 int esalary_delete_all_rows(void);
123 unsigned long long esalary_get_row_count(void);
125 
126 #endif /* PLUGIN_PFS_TABLE_PLUGIN_pfs_example_employee_salary_H_ */
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:443
unsigned long long esalary_get_row_count(void)
Definition: pfs_example_employee_salary.cc:288
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
Definition: pfs_example_employee_salary.h:92
~Esalary_POS()
Definition: pfs_example_employee_salary.h:71
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
Esalary_POS()
Definition: pfs_example_employee_salary.h:72
int esalary_index_next(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:122
unsigned int get_index()
Definition: pfs_example_employee_salary.h:82
t pos
Definition: dbug_analyze.cc:148
void * handle
Definition: engine_loader.c:19
PFS_engine_table_share_proxy esalary_st_share
Definition: pfs_example_employee_salary.cc:27
Esalary_POS m_next_pos
Definition: pfs_example_employee_salary.h:96
Definition: pfs_example_employee_salary.h:45
#define SERVICE_TYPE(name)
void set_after(Esalary_POS *pos)
Definition: pfs_example_employee_salary.h:88
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
int esalary_update_column_value(PSI_table_handle *handle, PSI_field *field, unsigned int index)
Definition: pfs_example_employee_salary.cc:235
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
void init_esalary_share(PFS_engine_table_share_proxy *share)
Definition: pfs_example_employee_salary.cc:290
int esalary_rnd_init(PSI_table_handle *h, bool scan)
Definition: pfs_example_employee_salary.cc:86
int esalary_rnd_pos(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:91
PSI_bigint e_salary
Definition: pfs_example_employee_salary.h:48
bool m_exist
Definition: pfs_example_employee_salary.h:55
void set_at(Esalary_POS *pos)
Definition: pfs_example_employee_salary.h:86
void esalary_reset_position(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:128
char * index(const char *, int c)
Definition: mysql.cc:2847
mysql_mutex_t LOCK_esalary_records_array
Definition: pfs_example_employee_salary.cc:28
unsigned int e_tob_length
Definition: pfs_example_employee_salary.h:52
void reset()
Definition: pfs_example_employee_salary.h:80
unsigned int uint
Definition: uca-dump.cc:29
PSI_int e_number
Definition: pfs_example_employee_salary.h:47
std::vector< Esalary_Record > esalary_records_vector
An array to keep rows of the tables.
Definition: pfs_example_employee_salary.cc:33
unsigned int e_dob_length
Definition: pfs_example_employee_salary.h:50
int esalary_read_column_value(PSI_table_handle *handle, PSI_field *field, uint index)
Definition: pfs_example_employee_salary.cc:136
int esalary_index_init(PSI_table_handle *handle, uint idx, bool sorted, PSI_index_handle **index)
Definition: pfs_example_employee_salary.cc:104
const mysql_service_pfs_plugin_table_t * table_svc
Definition: pfs_example_plugin_employee.cc:87
void next()
Definition: pfs_example_employee_salary.h:78
void set_at(unsigned int index)
Definition: pfs_example_employee_salary.h:84
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
bool has_more()
Definition: pfs_example_employee_salary.h:74
Esalary_Record current_row
Definition: pfs_example_employee_salary.h:99
int esalary_delete_all_rows(void)
Definition: pfs_example_employee_salary.cc:280
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_next(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:70
int esalary_write_row_values(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:164
struct PSI_field PSI_field
This is an opaque structure to denote filed in plugin/component code.
Definition: pfs_plugin_table_service.h:92
Esalary_POS m_pos
Definition: pfs_example_employee_salary.h:94
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
int esalary_write_column_value(PSI_table_handle *handle, PSI_field *field, unsigned int index)
Definition: pfs_example_employee_salary.cc:191
#define PSI_bigint
Definition: pfs_plugin_table_service.h:149
int esalary_update_row_values(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:221
Definition: pfs_example_employee_salary.h:66
Specifies macros to define Service Implementations.
unsigned int m_index
Definition: pfs_example_employee_salary.h:68
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_delete_row_values(PSI_table_handle *handle)
Definition: pfs_example_employee_salary.cc:265
#define PSI_int
Definition: pfs_plugin_table_service.h:147