24#ifndef TABLE_WITH_CURSOR_H
25#define TABLE_WITH_CURSOR_H
133 std::is_default_constructible_v<Type> &&
135 {
object.advance() };
137 {
object.set_cursor(
object.get_cursor()) };
138 {
object.is_at_end() } -> std::convertible_to<bool>;
139 {
object.copy_field(
index, field) };
140 { Type::get_approximate_row_count() } -> std::convertible_to<int>;
141 { Type::get_table_name() } -> std::same_as<const char *>;
142 { Type::get_table_definition() } -> std::same_as<const char *>;
149template <Is_table_with_cursor Table_with_cursor_tp>
154 using Cursor_t =
decltype(std::declval<Table_with_cursor_t>().get_cursor());
156 "The return type for Table_with_cursor_t::get_cursor() must be "
157 "*trivially comparable*, i.e., both satisfy "
158 "std::is_trivially_copyable and "
159 "be equality-comparable using memcmp (i.e., must have no "
182 table_share.
m_table_name = Table_with_cursor_t::get_table_name();
185 Table_with_cursor_t::get_table_definition();
187 sizeof(
decltype(std::declval<Table_with_cursor_t>().get_cursor()));
257 if constexpr (
requires {
258 Table_with_cursor_t::get_approximate_row_count();
260 return Table_with_cursor_t::get_approximate_row_count();
276 auto *handle_ptr =
new Self_t;
277 *opaque_pos =
reinterpret_cast<PSI_pos *
>(&handle_ptr->m_current_cursor);
340 return *(
Self_t *)opaque_handle;
370template <Is_table_with_cursor Table_with_cursor>
Adaptor class that takes a table with cursor and provides an implementation of MySQL's handler interf...
Definition: table_with_cursor.h:150
static void close_table(PSI_table_handle *opaque_handle)
Implementation of PFS_engine_table_proxy::close_table, matching close_table_t.
Definition: table_with_cursor.h:286
int do_rnd_pos()
Member function implementing rnd_pos.
Definition: table_with_cursor.h:317
static PFS_engine_table_share_proxy & init_table_share()
Definition: table_with_cursor.h:178
int status() const
Definition: table_with_cursor.h:331
static PSI_table_handle * open_table(PSI_pos **opaque_pos)
Implementation of PFS_engine_table_proxy::open_table, matching open_table_t.
Definition: table_with_cursor.h:273
static int rnd_next(PSI_table_handle *opaque_handle)
Implementation of PFS_engine_table_proxy::rnd_next, matching rnd_next_t.
Definition: table_with_cursor.h:224
static int rnd_init(PSI_table_handle *opaque_handle, bool)
Implementation of PFS_engine_table_proxy::rnd_init, matching rnd_init_t.
Definition: table_with_cursor.h:214
static PFS_engine_table_share_proxy & get_table_share()
Definition: table_with_cursor.h:171
static Self_t & get_handle_adaptor(PSI_table_handle *opaque_handle)
Cast point to PSI_table_handle to reference to Table_handle_adaptor.
Definition: table_with_cursor.h:339
int do_rnd_next()
Member function implementing rnd_next.
Definition: table_with_cursor.h:304
static int read_column_value(PSI_table_handle *opaque_handle, PSI_field *field, unsigned int index)
Implementation of PFS_engine_table_proxy::read_column_value, matching read_column_value_t.
Definition: table_with_cursor.h:245
bool m_before_first_row
True if the current position is "one-before-the-first-row".
Definition: table_with_cursor.h:349
decltype(std::declval< Table_with_cursor_t >().get_cursor()) Cursor_t
Definition: table_with_cursor.h:154
Table_handle_adaptor()
Definition: table_with_cursor.h:163
int do_rnd_init()
Member function implementing rnd_init.
Definition: table_with_cursor.h:294
Table_with_cursor_tp Table_with_cursor_t
Definition: table_with_cursor.h:152
Cursor_t m_current_cursor
Current cursor.
Definition: table_with_cursor.h:363
static int rnd_pos(PSI_table_handle *opaque_handle)
Implementation of PFS_engine_table_proxy::rnd_pos, matching rnd_pos_t.
Definition: table_with_cursor.h:234
Table_handle_adaptor< Table_with_cursor_t > Self_t
Definition: table_with_cursor.h:153
Cursor_t m_begin_cursor
Cursor to the first row.
Definition: table_with_cursor.h:357
void do_read_column_value(PSI_field *field, unsigned int index)
Member function implementing read_column_value.
Definition: table_with_cursor.h:325
static unsigned long long get_row_count()
Implementation of PFS_engine_table_share_proxy::get_row_count, matching get_row_count_t.
Definition: table_with_cursor.h:256
Table_with_cursor_t m_table_with_cursor
Table_with_cursor object representing the table and the current cursor position.
Definition: table_with_cursor.h:353
Concept that identifies that a class is a "table with cursor".
Definition: table_with_cursor.h:132
Concept requiring that objects are copyable using memcpy, and equality-testable using memcmp.
Definition: table_with_cursor.h:59
Definition: packet_based_table_with_cursor.h:36
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:76
MediaType
Definition: media_type.h:33
@ READONLY
Definition: pfs_plugin_table_service.h:437
#define PFS_HA_ERR_END_OF_FILE
Definition: pfs_plugin_table_service.h:78
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_field PSI_field
This is an opaque structure to denote field in plugin/component code.
Definition: pfs_plugin_table_service.h:93
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:462
delete_all_rows_t delete_all_rows
Definition: pfs_plugin_table_service.h:479
const char * m_table_name
Definition: pfs_plugin_table_service.h:468
const char * m_table_definition
Definition: pfs_plugin_table_service.h:473
PFS_engine_table_proxy m_proxy_engine_table
Definition: pfs_plugin_table_service.h:465
unsigned int m_table_name_length
Definition: pfs_plugin_table_service.h:470
enum Access_control m_acl
Definition: pfs_plugin_table_service.h:477
get_row_count_t get_row_count
Definition: pfs_plugin_table_service.h:480
unsigned int m_ref_length
Definition: pfs_plugin_table_service.h:474
PFS_engine_table_share_proxy * get_table_share_from_table_with_cursor()
Takes a table with cursor and returns a new PFS_engine_table_share_proxy for the class.
Definition: table_with_cursor.h:371