MySQL 9.1.0
Source Code Documentation
ha_blackhole.h
Go to the documentation of this file.
1/* Copyright (c) 2005, 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#include <sys/types.h>
25
26#include "my_base.h"
27#include "my_inttypes.h"
28#include "sql/handler.h" /* handler */
29#include "sql/key.h"
30#include "sql/table.h" /* TABLE_SHARE */
31#include "thr_lock.h" /* THR_LOCK */
32
33class String;
34class THD;
35struct FT_INFO;
36namespace dd {
37class Table;
38}
39
40/*
41 Shared structure for correct LOCK operation
42*/
47 char table_name[1];
48};
49
50/*
51 Class definition for the blackhole storage engine
52 "Dumbest named feature ever"
53*/
54class ha_blackhole : public handler {
55 THR_LOCK_DATA lock; /* MySQL lock */
57
58 public:
59 ha_blackhole(handlerton *hton, TABLE_SHARE *table_arg);
60 ~ha_blackhole() override = default;
61 /* The name that will be used for display purposes */
62 const char *table_type() const override { return "BLACKHOLE"; }
64 return HA_KEY_ALG_BTREE;
65 }
66 bool is_index_algorithm_supported(enum ha_key_alg key_alg) const override {
67 return key_alg == HA_KEY_ALG_BTREE || key_alg == HA_KEY_ALG_RTREE;
68 }
69 ulonglong table_flags() const override {
74 }
75 ulong index_flags(uint inx, uint, bool) const override {
76 return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT)
77 ? 0
80 }
81 /* The following defines can be increased if necessary */
82#define BLACKHOLE_MAX_KEY 64 /* Max allowed keys */
83#define BLACKHOLE_MAX_KEY_SEG 16 /* Max segments for key */
84#define BLACKHOLE_MAX_KEY_LENGTH 3072 /* Keep compatible with innoDB */
85 uint max_supported_keys() const override { return BLACKHOLE_MAX_KEY; }
86 uint max_supported_key_length() const override {
88 }
90 [[maybe_unused]]) const override {
92 }
93 int open(const char *name, int mode, uint test_if_locked,
94 const dd::Table *table_def) override;
95 int close(void) override;
96 int rnd_init(bool scan) override;
97 int rnd_next(uchar *buf) override;
98 int rnd_pos(uchar *buf, uchar *pos) override;
99 int index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map,
100 enum ha_rkey_function find_flag) override;
101 int index_read_idx_map(uchar *buf, uint idx, const uchar *key,
102 key_part_map keypart_map,
103 enum ha_rkey_function find_flag) override;
105 key_part_map keypart_map) override;
106 int index_next(uchar *buf) override;
107 int index_prev(uchar *buf) override;
108 int index_first(uchar *buf) override;
109 int index_last(uchar *buf) override;
110 void position(const uchar *record) override;
111 int info(uint flag) override;
112 int external_lock(THD *thd, int lock_type) override;
113 int create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info,
114 dd::Table *table_def) override;
116 enum thr_lock_type lock_type) override;
117 FT_INFO *ft_init_ext(uint flags, uint inx, String *key) override;
118 int ft_init() override;
119
120 protected:
121 int ft_read(uchar *buf) override;
122
123 private:
124 int write_row(uchar *buf) override;
125 int update_row(const uchar *old_data, uchar *new_data) override;
126 int delete_row(const uchar *buf) override;
127};
app_data_ptr new_data(u_int n, char *val, cons_type consensus)
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: table.h:47
Definition: ha_blackhole.h:54
bool is_index_algorithm_supported(enum ha_key_alg key_alg) const override
Check if SE supports specific key algorithm.
Definition: ha_blackhole.h:66
int index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) override
Positions an index cursor to the index specified in the handle ('active_index').
Definition: ha_blackhole.cc:195
int index_prev(uchar *buf) override
Definition: ha_blackhole.cc:237
int external_lock(THD *thd, int lock_type) override
Is not invoked for non-transactional temporary tables.
Definition: ha_blackhole.cc:158
int rnd_next(uchar *buf) override
Definition: ha_blackhole.cc:128
int open(const char *name, int mode, uint test_if_locked, const dd::Table *table_def) override
Definition: ha_blackhole.cc:84
ulong index_flags(uint inx, uint, bool) const override
Definition: ha_blackhole.h:75
int ft_read(uchar *buf) override
Definition: ha_blackhole.cc:276
~ha_blackhole() override=default
int index_read_idx_map(uchar *buf, uint idx, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) override
Positions an index cursor to the index specified in argument.
Definition: ha_blackhole.cc:207
int info(uint flag) override
General method to gather info from handler.
Definition: ha_blackhole.cc:150
st_blackhole_share * share
Definition: ha_blackhole.h:56
int write_row(uchar *buf) override
Write a row.
Definition: ha_blackhole.cc:104
void position(const uchar *record) override
Definition: ha_blackhole.cc:145
ulonglong table_flags() const override
Definition: ha_blackhole.h:69
int index_next(uchar *buf) override
Definition: ha_blackhole.cc:230
FT_INFO * ft_init_ext(uint flags, uint inx, String *key) override
Definition: ha_blackhole.cc:258
int close(void) override
Definition: ha_blackhole.cc:93
uint max_supported_key_length() const override
Definition: ha_blackhole.h:86
int delete_row(const uchar *buf) override
Definition: ha_blackhole.cc:116
THR_LOCK_DATA ** store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) override
Is not invoked for non-transactional temporary tables.
Definition: ha_blackhole.cc:163
const char * table_type() const override
The following can be called without an open handler.
Definition: ha_blackhole.h:62
int ft_init() override
Definition: ha_blackhole.cc:274
int index_first(uchar *buf) override
Definition: ha_blackhole.cc:244
THR_LOCK_DATA lock
Definition: ha_blackhole.h:55
uint max_supported_keys() const override
Definition: ha_blackhole.h:85
ha_blackhole(handlerton *hton, TABLE_SHARE *table_arg)
Definition: ha_blackhole.cc:81
int rnd_init(bool scan) override
rnd_init() can be called two times without rnd_end() in between (it only makes sense if scan=1).
Definition: ha_blackhole.cc:123
int index_last(uchar *buf) override
Definition: ha_blackhole.cc:251
int create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info, dd::Table *table_def) override
Create table (implementation).
Definition: ha_blackhole.cc:99
uint max_supported_key_part_length(HA_CREATE_INFO *create_info) const override
Definition: ha_blackhole.h:89
int rnd_pos(uchar *buf, uchar *pos) override
Definition: ha_blackhole.cc:139
int index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map) override
The following functions works like index_read, but it find the last row with the current key value or...
Definition: ha_blackhole.cc:219
enum ha_key_alg get_default_index_algorithm() const override
Get default key algorithm for SE.
Definition: ha_blackhole.h:63
int update_row(const uchar *old_data, uchar *new_data) override
Update a single row.
Definition: ha_blackhole.cc:109
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4583
TABLE_SHARE * table_share
Definition: handler.h:4591
A table definition from the master.
Definition: rpl_utility.h:249
#define BLACKHOLE_MAX_KEY
Definition: ha_blackhole.h:82
#define BLACKHOLE_MAX_KEY_LENGTH
Definition: ha_blackhole.h:84
static int flags[50]
Definition: hp_test1.cc:40
static int flag
Definition: hp_test1.cc:40
This file includes constants used by all storage engines.
ha_key_alg
Definition: my_base.h:98
@ HA_KEY_ALG_RTREE
Definition: my_base.h:109
@ HA_KEY_ALG_BTREE
Definition: my_base.h:108
@ HA_KEY_ALG_FULLTEXT
Definition: my_base.h:111
ha_rkey_function
Definition: my_base.h:78
ulong key_part_map
Definition: my_base.h:1008
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
unsigned char uchar
Definition: my_inttypes.h:52
static int record
Definition: mysqltest.cc:193
Definition: buf0block_hint.cc:30
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
mode
Definition: file_handle.h:61
required string key
Definition: replication_asynchronous_connection_failover.proto:60
#define HA_BINLOG_ROW_CAPABLE
Definition: handler.h:347
#define HA_FILE_BASED
Definition: handler.h:332
#define HA_CAN_INDEX_BLOBS
Definition: handler.h:265
#define HA_READ_NEXT
Definition: handler.h:534
#define HA_KEYREAD_ONLY
Definition: handler.h:579
#define HA_READ_OUT_OF_SYNC
Definition: handler.h:432
#define HA_CAN_GEOMETRY
Definition: handler.h:236
#define HA_CAN_FULLTEXT
Definition: handler.h:313
#define HA_BINLOG_STMT_CAPABLE
Definition: handler.h:348
#define HA_CAN_SQL_HANDLER
Definition: handler.h:318
#define HA_READ_ORDER
Definition: handler.h:550
#define HA_READ_RANGE
Definition: handler.h:557
#define HA_AUTO_PART_KEY
Definition: handler.h:270
#define HA_NULL_IN_KEY
Definition: handler.h:253
#define HA_READ_PREV
Definition: handler.h:538
case opt name
Definition: sslopt-case.h:29
Definition: ft_global.h:72
Struct to hold information about the table that should be created.
Definition: handler.h:3210
This structure is shared between different table objects.
Definition: table.h:704
KEY * key_info
Definition: table.h:754
Definition: table.h:1421
Definition: thr_lock.h:124
Definition: thr_lock.h:139
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2740
Definition: ha_blackhole.h:43
uint table_name_length
Definition: ha_blackhole.h:46
char table_name[1]
Definition: ha_blackhole.h:47
uint use_count
Definition: ha_blackhole.h:45
THR_LOCK lock
Definition: ha_blackhole.h:44
thr_lock_type
Definition: thr_lock.h:51