MySQL 8.0.39
Source Code Documentation
pfs_example_continent.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_continent_H_
25#define PLUGIN_PFS_TABLE_PLUGIN_pfs_example_continent_H_
26
29
31#include "thr_mutex.h"
32
33/* Global share pointer for pfs_example_continent table */
35
36/* Maximum number of rows in the table */
37#define CONTINENT_MAX_ROWS 10
38
39/* A mutex instance to protect:
40 * - continent_rows_in_table
41 * - continent_next_available_index
42 * - continent_records_array
43 */
45
46/* A structure to denote a single row of the table. */
47struct {
49 unsigned int name_length;
50
51 /* If there is a value in this row */
52 bool m_exist;
53} typedef Continent_record;
54
55/**
56 * An array to keep rows of the tables.
57 * When a row is inserted in plugin table, it will be stored here.
58 * When a row is queried from plugin table, it will be fetched from here.
59 */
61
62/* A class to define position of cursor in table. */
64 private:
65 unsigned int m_index;
66
67 public:
68 ~Continent_POS() = default;
70
71 bool has_more() {
72 if (m_index < CONTINENT_MAX_ROWS) return true;
73 return false;
74 }
75 void next() { m_index++; }
76
77 void reset() { m_index = 0; }
78
79 unsigned int get_index() { return m_index; }
80
81 void set_at(unsigned int index) { m_index = index; }
82
83 void set_at(Continent_POS *pos) { m_index = pos->m_index; }
84
85 void set_after(Continent_POS *pos) { m_index = pos->m_index + 1; }
86};
87
89 public:
91
92 virtual ~Continent_index() = default;
93
94 virtual bool match(Continent_record *record) = 0;
95
96 unsigned int m_fields;
97};
98
99/* An index on Continent Name */
101 public:
103 /* Number of characters * max multibyte length of character set */
105
106 bool match(Continent_record *record) override {
107 if (m_fields >= 1) {
108 if (!pc_string_srv->match_key_string(false, record->name,
109 record->name_length, &m_name)) {
110 return false;
111 }
112 }
113
114 return true;
115 }
116};
117
118/* A structure to define a handle for table in plugin/component code. */
120 /* Current position instance */
122 /* Next position instance */
124
125 /* Current row for the table */
127
128 /* Index on table */
130
131 /* Index indicator */
132 unsigned int index_num;
133};
134
138int continent_rnd_init(PSI_table_handle *h, bool scan);
140int continent_index_init(PSI_table_handle *handle, unsigned int idx,
141 bool sorted, PSI_index_handle **index);
143 unsigned int idx, int find_flag);
147 unsigned int index);
150 unsigned int index);
153 unsigned int index);
156unsigned long long continent_get_row_count(void);
158
160
161#endif /* PLUGIN_PFS_TABLE_PLUGIN_pfs_example_continent_H_ */
Definition: pfs_example_continent.h:63
Continent_POS()
Definition: pfs_example_continent.h:69
unsigned int m_index
Definition: pfs_example_continent.h:65
void set_after(Continent_POS *pos)
Definition: pfs_example_continent.h:85
void next()
Definition: pfs_example_continent.h:75
unsigned int get_index()
Definition: pfs_example_continent.h:79
~Continent_POS()=default
void reset()
Definition: pfs_example_continent.h:77
bool has_more()
Definition: pfs_example_continent.h:71
void set_at(unsigned int index)
Definition: pfs_example_continent.h:81
void set_at(Continent_POS *pos)
Definition: pfs_example_continent.h:83
Definition: pfs_example_continent.h:100
PSI_plugin_key_string m_name
Definition: pfs_example_continent.h:102
char m_name_buffer[CONTINENT_NAME_LEN]
Definition: pfs_example_continent.h:104
bool match(Continent_record *record) override
Definition: pfs_example_continent.h:106
Definition: pfs_example_continent.h:88
virtual bool match(Continent_record *record)=0
virtual ~Continent_index()=default
unsigned int m_fields
Definition: pfs_example_continent.h:96
Continent_index()
Definition: pfs_example_continent.h:90
static int record
Definition: mysqltest.cc:188
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 CONTINENT_NAME_LEN
Definition: pfs_example_component_population.h:46
int continent_write_row_values(PSI_table_handle *handle)
int continent_rnd_init(PSI_table_handle *h, bool scan)
Definition: pfs_example_continent.cc:98
PFS_engine_table_share_proxy continent_st_share
Definition: pfs_example_continent.cc:30
int continent_index_next(PSI_table_handle *handle)
Definition: pfs_example_continent.cc:159
int continent_rnd_next(PSI_table_handle *handle)
Definition: pfs_example_continent.cc:81
#define CONTINENT_MAX_ROWS
Definition: pfs_example_continent.h:37
Continent_record continent_records_array[CONTINENT_MAX_ROWS]
An array to keep rows of the tables.
Definition: pfs_example_continent.cc:40
int continent_write_column_value(PSI_table_handle *handle, PSI_field *field, unsigned int index)
void init_continent_share(PFS_engine_table_share_proxy *share)
Definition: pfs_example_continent.cc:253
int continent_delete_row_values(PSI_table_handle *handle)
PSI_table_handle * continent_open_table(PSI_pos **pos)
Instantiate Continent_Table_Handle at plugin code when corresponding table in performance schema is o...
Definition: pfs_example_continent.cc:56
int continent_delete_all_rows(void)
Definition: pfs_example_continent.cc:42
void continent_reset_position(PSI_table_handle *handle)
Definition: pfs_example_continent.cc:188
native_mutex_t LOCK_continent_records_array
Definition: pfs_example_continent.cc:32
unsigned long long continent_get_row_count(void)
Definition: pfs_example_continent.cc:249
int continent_read_column_value(PSI_table_handle *handle, PSI_field *field, unsigned int index)
Definition: pfs_example_continent.cc:196
int continent_update_row_values(PSI_table_handle *handle)
int continent_index_read(PSI_index_handle *index, PSI_key_reader *reader, unsigned int idx, int find_flag)
Definition: pfs_example_continent.cc:139
int write_rows_from_component(Continent_Table_Handle *h)
Definition: pfs_example_continent.cc:216
int continent_index_init(PSI_table_handle *handle, unsigned int idx, bool sorted, PSI_index_handle **index)
Definition: pfs_example_continent.cc:114
void continent_close_table(PSI_table_handle *handle)
Destroy the Continent_Table_Handle at plugin code when corresponding table in performance schema is c...
Definition: pfs_example_continent.cc:68
int continent_rnd_pos(PSI_table_handle *handle)
Definition: pfs_example_continent.cc:101
int continent_update_column_value(PSI_table_handle *handle, PSI_field *field, unsigned int index)
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
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
Specifies macros to define Service Implementations.
case opt name
Definition: sslopt-case.h:33
Definition: pfs_example_continent.h:119
Continent_index_by_name m_index
Definition: pfs_example_continent.h:129
Continent_POS m_next_pos
Definition: pfs_example_continent.h:123
Continent_POS m_pos
Definition: pfs_example_continent.h:121
unsigned int index_num
Definition: pfs_example_continent.h:132
Continent_record current_row
Definition: pfs_example_continent.h:126
Definition: pfs_example_continent.h:47
unsigned int name_length
Definition: pfs_example_continent.h:49
bool m_exist
Definition: pfs_example_continent.h:52
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
A structure to denote a key of type string in an index.
Definition: pfs_plugin_table_service.h:226
MySQL mutex implementation.
pthread_mutex_t native_mutex_t
Definition: thr_mutex_bits.h:55