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