Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
e666b865
Commit
e666b865
authored
Aug 14, 2023
by
Federico Razzoli
Committed by
Daniel Black
Aug 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EXAMPLE storage engine: update comments
parent
0254eb93
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
25 deletions
+21
-25
storage/example/ha_example.cc
storage/example/ha_example.cc
+6
-10
storage/example/ha_example.h
storage/example/ha_example.h
+15
-15
No files found.
storage/example/ha_example.cc
View file @
e666b865
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
build by doing the following during your build process:<br> ./configure
build by doing the following during your build process:<br> ./configure
--with-example-storage-engine
--with-example-storage-engine
Once this is done, M
ySQL
will let you create tables with:<br>
Once this is done, M
ariaDB
will let you create tables with:<br>
CREATE TABLE <table name> (...) ENGINE=EXAMPLE;
CREATE TABLE <table name> (...) ENGINE=EXAMPLE;
The example storage engine is set up to use table locks. It
The example storage engine is set up to use table locks. It
...
@@ -51,9 +51,9 @@
...
@@ -51,9 +51,9 @@
of this file.
of this file.
@note
@note
When you create an EXAMPLE table, the M
ySQL
Server creates a table .frm
When you create an EXAMPLE table, the M
ariaDB
Server creates a table .frm
(format) file in the database directory, using the table name as the file
(format) file in the database directory, using the table name as the file
name as is customary with M
ySQL
. No other files are created. To get an idea
name as is customary with M
ariaDB
. No other files are created. To get an idea
of what occurs, here is an example select that would do a scan of an entire
of what occurs, here is an example select that would do a scan of an entire
table:
table:
...
@@ -86,10 +86,6 @@
...
@@ -86,10 +86,6 @@
ha_example::open() would also have been necessary. Calls to
ha_example::open() would also have been necessary. Calls to
ha_example::extra() are hints as to what will be occuring to the request.
ha_example::extra() are hints as to what will be occuring to the request.
A Longer Example can be found called the "Skeleton Engine" which can be
found on TangentOrg. It has both an engine and a full build environment
for building a pluggable storage engine.
Happy coding!<br>
Happy coding!<br>
-Brian
-Brian
*/
*/
...
@@ -771,7 +767,7 @@ int ha_example::external_lock(THD *thd, int lock_type)
...
@@ -771,7 +767,7 @@ int ha_example::external_lock(THD *thd, int lock_type)
Before adding the lock into the table lock handler (see thr_lock.c),
Before adding the lock into the table lock handler (see thr_lock.c),
mysqld calls store lock with the requested locks. Store lock can now
mysqld calls store lock with the requested locks. Store lock can now
modify a write lock to a read lock (or some other lock), ignore the
modify a write lock to a read lock (or some other lock), ignore the
lock (if we don't want to use M
ySQL
table locks at all), or add locks
lock (if we don't want to use M
ariaDB
table locks at all), or add locks
for many tables (like we do when we are using a MERGE handler).
for many tables (like we do when we are using a MERGE handler).
Berkeley DB, for example, changes all WRITE locks to TL_WRITE_ALLOW_WRITE
Berkeley DB, for example, changes all WRITE locks to TL_WRITE_ALLOW_WRITE
...
@@ -781,7 +777,7 @@ int ha_example::external_lock(THD *thd, int lock_type)
...
@@ -781,7 +777,7 @@ int ha_example::external_lock(THD *thd, int lock_type)
When releasing locks, store_lock() is also called. In this case one
When releasing locks, store_lock() is also called. In this case one
usually doesn't have to do anything.
usually doesn't have to do anything.
In some exceptional cases M
ySQL
may send a request for a TL_IGNORE;
In some exceptional cases M
ariaDB
may send a request for a TL_IGNORE;
This means that we are requesting the same lock as last time and this
This means that we are requesting the same lock as last time and this
should also be ignored. (This may happen when someone does a flush
should also be ignored. (This may happen when someone does a flush
table when we have opened a part of the tables, in which case mysqld
table when we have opened a part of the tables, in which case mysqld
...
@@ -1084,7 +1080,7 @@ static int show_func_example(MYSQL_THD thd, struct st_mysql_show_var *var,
...
@@ -1084,7 +1080,7 @@ static int show_func_example(MYSQL_THD thd, struct st_mysql_show_var *var,
var
->
value
=
buf
;
// it's of SHOW_VAR_FUNC_BUFF_SIZE bytes
var
->
value
=
buf
;
// it's of SHOW_VAR_FUNC_BUFF_SIZE bytes
my_snprintf
(
buf
,
SHOW_VAR_FUNC_BUFF_SIZE
,
my_snprintf
(
buf
,
SHOW_VAR_FUNC_BUFF_SIZE
,
"enum_var is %lu, ulong_var is %lu, int_var is %d, "
"enum_var is %lu, ulong_var is %lu, int_var is %d, "
"double_var is %f, %.6b"
,
// %b is a MySQL extension
"double_var is %f, %.6b"
,
// %b is a M
ariaDB/M
ySQL extension
srv_enum_var
,
srv_ulong_var
,
THDVAR
(
thd
,
int_var
),
srv_enum_var
,
srv_ulong_var
,
THDVAR
(
thd
,
int_var
),
srv_double_var
,
"really"
);
srv_double_var
,
"really"
);
return
0
;
return
0
;
...
...
storage/example/ha_example.h
View file @
e666b865
...
@@ -62,7 +62,7 @@ class Example_share : public Handler_share {
...
@@ -62,7 +62,7 @@ class Example_share : public Handler_share {
*/
*/
class
ha_example
:
public
handler
class
ha_example
:
public
handler
{
{
THR_LOCK_DATA
lock
;
///< M
ySQL
lock
THR_LOCK_DATA
lock
;
///< M
ariaDB
lock
Example_share
*
share
;
///< Shared lock info
Example_share
*
share
;
///< Shared lock info
Example_share
*
get_share
();
///< Get the share
Example_share
*
get_share
();
///< Get the share
...
@@ -97,7 +97,7 @@ class ha_example: public handler
...
@@ -97,7 +97,7 @@ class ha_example: public handler
@details
@details
part is the key part to check. First key part is 0.
part is the key part to check. First key part is 0.
If all_parts is set, M
ySQL
wants to know the flags for the combined
If all_parts is set, M
ariaDB
wants to know the flags for the combined
index, up to and including 'part'.
index, up to and including 'part'.
*/
*/
ulong
index_flags
(
uint
inx
,
uint
part
,
bool
all_parts
)
const
ulong
index_flags
(
uint
inx
,
uint
part
,
bool
all_parts
)
const
...
@@ -109,7 +109,7 @@ class ha_example: public handler
...
@@ -109,7 +109,7 @@ class ha_example: public handler
unireg.cc will call max_supported_record_length(), max_supported_keys(),
unireg.cc will call max_supported_record_length(), max_supported_keys(),
max_supported_key_parts(), uint max_supported_key_length()
max_supported_key_parts(), uint max_supported_key_length()
to make sure that the storage engine can handle the data it is about to
to make sure that the storage engine can handle the data it is about to
send. Return *real* limits of your storage engine here; M
ySQL
will do
send. Return *real* limits of your storage engine here; M
ariaDB
will do
min(your_limits, MySQL_limits) automatically.
min(your_limits, MySQL_limits) automatically.
*/
*/
uint
max_supported_record_length
()
const
{
return
HA_MAX_REC_LENGTH
;
}
uint
max_supported_record_length
()
const
{
return
HA_MAX_REC_LENGTH
;
}
...
@@ -117,7 +117,7 @@ class ha_example: public handler
...
@@ -117,7 +117,7 @@ class ha_example: public handler
/** @brief
/** @brief
unireg.cc will call this to make sure that the storage engine can handle
unireg.cc will call this to make sure that the storage engine can handle
the data it is about to send. Return *real* limits of your storage engine
the data it is about to send. Return *real* limits of your storage engine
here; M
ySQL
will do min(your_limits, MySQL_limits) automatically.
here; M
ariaDB
will do min(your_limits, MySQL_limits) automatically.
@details
@details
There is no need to implement ..._key_... methods if your engine doesn't
There is no need to implement ..._key_... methods if your engine doesn't
...
@@ -128,7 +128,7 @@ class ha_example: public handler
...
@@ -128,7 +128,7 @@ class ha_example: public handler
/** @brief
/** @brief
unireg.cc will call this to make sure that the storage engine can handle
unireg.cc will call this to make sure that the storage engine can handle
the data it is about to send. Return *real* limits of your storage engine
the data it is about to send. Return *real* limits of your storage engine
here; M
ySQL
will do min(your_limits, MySQL_limits) automatically.
here; M
ariaDB
will do min(your_limits, MySQL_limits) automatically.
@details
@details
There is no need to implement ..._key_... methods if your engine doesn't
There is no need to implement ..._key_... methods if your engine doesn't
...
@@ -139,7 +139,7 @@ class ha_example: public handler
...
@@ -139,7 +139,7 @@ class ha_example: public handler
/** @brief
/** @brief
unireg.cc will call this to make sure that the storage engine can handle
unireg.cc will call this to make sure that the storage engine can handle
the data it is about to send. Return *real* limits of your storage engine
the data it is about to send. Return *real* limits of your storage engine
here; M
ySQL
will do min(your_limits, MySQL_limits) automatically.
here; M
ariaDB
will do min(your_limits, MySQL_limits) automatically.
@details
@details
There is no need to implement ..._key_... methods if your engine doesn't
There is no need to implement ..._key_... methods if your engine doesn't
...
@@ -187,7 +187,7 @@ class ha_example: public handler
...
@@ -187,7 +187,7 @@ class ha_example: public handler
Everything below are methods that we implement in ha_example.cc.
Everything below are methods that we implement in ha_example.cc.
Most of these methods are not obligatory, skip them and
Most of these methods are not obligatory, skip them and
M
ySQL
will treat them as not implemented
M
ariaDB
will treat them as not implemented
*/
*/
/** @brief
/** @brief
We implement this in ha_example.cc; it's a required method.
We implement this in ha_example.cc; it's a required method.
...
@@ -201,50 +201,50 @@ class ha_example: public handler
...
@@ -201,50 +201,50 @@ class ha_example: public handler
/** @brief
/** @brief
We implement this in ha_example.cc. It's not an obligatory method;
We implement this in ha_example.cc. It's not an obligatory method;
skip it and and M
ySQL
will treat it as not implemented.
skip it and and M
ariaDB
will treat it as not implemented.
*/
*/
int
write_row
(
const
uchar
*
buf
);
int
write_row
(
const
uchar
*
buf
);
/** @brief
/** @brief
We implement this in ha_example.cc. It's not an obligatory method;
We implement this in ha_example.cc. It's not an obligatory method;
skip it and and M
ySQL
will treat it as not implemented.
skip it and and M
ariaDB
will treat it as not implemented.
*/
*/
int
update_row
(
const
uchar
*
old_data
,
const
uchar
*
new_data
);
int
update_row
(
const
uchar
*
old_data
,
const
uchar
*
new_data
);
/** @brief
/** @brief
We implement this in ha_example.cc. It's not an obligatory method;
We implement this in ha_example.cc. It's not an obligatory method;
skip it and and M
ySQL
will treat it as not implemented.
skip it and and M
ariaDB
will treat it as not implemented.
*/
*/
int
delete_row
(
const
uchar
*
buf
);
int
delete_row
(
const
uchar
*
buf
);
/** @brief
/** @brief
We implement this in ha_example.cc. It's not an obligatory method;
We implement this in ha_example.cc. It's not an obligatory method;
skip it and and M
ySQL
will treat it as not implemented.
skip it and and M
ariaDB
will treat it as not implemented.
*/
*/
int
index_read_map
(
uchar
*
buf
,
const
uchar
*
key
,
int
index_read_map
(
uchar
*
buf
,
const
uchar
*
key
,
key_part_map
keypart_map
,
enum
ha_rkey_function
find_flag
);
key_part_map
keypart_map
,
enum
ha_rkey_function
find_flag
);
/** @brief
/** @brief
We implement this in ha_example.cc. It's not an obligatory method;
We implement this in ha_example.cc. It's not an obligatory method;
skip it and and M
ySQL
will treat it as not implemented.
skip it and and M
ariaDB
will treat it as not implemented.
*/
*/
int
index_next
(
uchar
*
buf
);
int
index_next
(
uchar
*
buf
);
/** @brief
/** @brief
We implement this in ha_example.cc. It's not an obligatory method;
We implement this in ha_example.cc. It's not an obligatory method;
skip it and and M
ySQL
will treat it as not implemented.
skip it and and M
ariaDB
will treat it as not implemented.
*/
*/
int
index_prev
(
uchar
*
buf
);
int
index_prev
(
uchar
*
buf
);
/** @brief
/** @brief
We implement this in ha_example.cc. It's not an obligatory method;
We implement this in ha_example.cc. It's not an obligatory method;
skip it and and M
ySQL
will treat it as not implemented.
skip it and and M
ariaDB
will treat it as not implemented.
*/
*/
int
index_first
(
uchar
*
buf
);
int
index_first
(
uchar
*
buf
);
/** @brief
/** @brief
We implement this in ha_example.cc. It's not an obligatory method;
We implement this in ha_example.cc. It's not an obligatory method;
skip it and and M
ySQL
will treat it as not implemented.
skip it and and M
ariaDB
will treat it as not implemented.
*/
*/
int
index_last
(
uchar
*
buf
);
int
index_last
(
uchar
*
buf
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment