Skip to content

Commit d45c03c

Browse files
committed
MDBF-1224: fix the structure of the plugin MD file
This requires moxygen 2.1.16! Added a check Implemented a structure for the plugin API documentation. On the top there's a main page to give top level overview and concepts. It eventually references the Moxygen documentation. The moxygen documentation is a series of nested doxygen groups that define the structure for the whole Plugin API documentation. There are top levels like "server plugin API" and "client plugin API". These branch into futher subgroups as needed.
1 parent ffe7f78 commit d45c03c

60 files changed

Lines changed: 1424 additions & 671 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/mysql/Doxyfile.generated_docs_plugin_api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ RECURSIVE = YES
99
GENERATE_HTML = NO
1010
GENERATE_LATEX = NO
1111
GENERATE_XML = YES
12-
PREDEFINED = HAVE_PSI_SOCKET_INTERFACE HAVE_PSI_1 USE_PSI_1
12+
PREDEFINED = HAVE_PSI_SOCKET_INTERFACE HAVE_PSI_1 USE_PSI_1 MYSQL_DYNAMIC_PLUGIN __cplusplus

include/mysql/auth_dialog_client.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifndef MYSQL_AUTH_DIALOG_CLIENT_INCLUDED
21
/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab
32
43
This program is free software; you can redistribute it and/or modify
@@ -14,15 +13,22 @@
1413
along with this program; if not, write to the Free Software
1514
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
1615

16+
#ifndef MYSQL_AUTH_DIALOG_CLIENT_INCLUDED
17+
#define MYSQL_AUTH_DIALOG_CLIENT_INCLUDED
18+
1719
/**
1820
@file
1921
2022
Definitions needed to use Dialog client authentication plugin
2123
*/
2224

25+
/**
26+
@addtogroup plugin_client_api
27+
@{
28+
*/
29+
2330
struct st_mysql;
2431

25-
#define MYSQL_AUTH_DIALOG_CLIENT_INCLUDED
2632

2733
/**
2834
type of the mysql_authentication_dialog_ask function
@@ -53,4 +59,6 @@ typedef char *(*mysql_authentication_dialog_ask_t)(struct st_mysql *mysql,
5359
#define PASSWORD_QUESTION "\4"
5460
#define LAST_PASSWORD "\5"
5561

62+
/** @} */
63+
5664
#endif

include/mysql/client_plugin.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifndef MYSQL_CLIENT_PLUGIN_INCLUDED
21
/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab
32
Copyright (c) 2010, 2011, Oracle and/or its affiliates.
43
@@ -15,15 +14,21 @@
1514
along with this program; if not, write to the Free Software
1615
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
1716

17+
#ifndef MYSQL_CLIENT_PLUGIN_INCLUDED
18+
#define MYSQL_CLIENT_PLUGIN_INCLUDED
1819
/**
1920
@file
2021
2122
MySQL Client Plugin API
2223
2324
This file defines the API for plugins that work on the client side
2425
*/
25-
#define MYSQL_CLIENT_PLUGIN_INCLUDED
2626

27+
/**
28+
@defgroup plugin_client_api Client Plugin API
29+
API for plugins that work on the client side
30+
@{
31+
*/
2732
/*
2833
On Windows, exports from DLL need to be declared
2934
Also, plugin needs to be declared as extern "C" because MSVC
@@ -185,5 +190,7 @@ mysql_client_register_plugin(struct st_mysql *mysql,
185190
**/
186191
int mysql_plugin_options(struct st_mysql_client_plugin *plugin,
187192
const char *option, const void *value);
193+
194+
/** @} */
188195
#endif
189196

include/mysql/generate_plugin_api_docs.sh

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,33 @@
1010
# md/<group>.md - documentation for group <group>
1111
# md/<page>.md - documentation for each <page>
1212
# Note: target_dir is created if not present.
13-
# Note: requires at least moxygen 2.1.11
13+
14+
# compare version numbers
15+
# usage: vercmp <versionnr1> <versionnr2>
16+
# with format for versions xxx.xxx.xxx
17+
# returns: 0 if versionnr1 equal or greater
18+
# 1 if versionnr1 lower
19+
20+
vercmp()
21+
{
22+
local a1 b1 c1 a2 b2 c2
23+
v1=$1
24+
v2=$2
25+
set -- $( echo "$v1" | sed 's/\./ /g' )
26+
a1=$1 b1=$2 c1=$3
27+
set -- $( echo "$v2" | sed 's/\./ /g' )
28+
a2=$1 b2=$2 c2=$3
29+
ret=$(( (a1-a2)*1000000+(b1-b2)*1000+c1-c2 ))
30+
if [ $ret -lt 0 ] ; then
31+
v=-1
32+
elif [ $ret -eq 0 ] ; then
33+
v=0
34+
else
35+
v=1
36+
fi
37+
printf "%d" $v
38+
return
39+
}
1440

1541
# If no target_dir is specified, the current directory is used.
1642
if [ -n "$1" ]; then
@@ -22,6 +48,15 @@ fi
2248
# Exit on error, undefined variable, or pipe failure
2349
set -euo pipefail
2450

51+
#check if moxygen version is good enough
52+
moxygen_version=$(moxygen --version)
53+
require_moxygen_version="2.1.16"
54+
if [ $(vercmp "$moxygen_version" "$require_moxygen_version") -lt 0 ]; then
55+
echo "moxygen version $require_moxygen_version or higher is required," \
56+
"but $moxygen_version is installed."
57+
exit 1
58+
fi
59+
2560
# Clean up the output directory, if it exists
2661
rm -rf "$TARGET_DIR/md"
2762
rm -rf "$TARGET_DIR/xml"

include/mysql/index.dox

Lines changed: 142 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,150 @@
11
/**
22
@mainpage Plugin API Documentation
33

4-
The MariaDB plugin API allows development of plugins that can extend the basic server functionality.
4+
MariaDB Server Plugin API is a C-based extensibility framework
5+
(largely compatible with MySQL’s but extended) that allows dynamic or
6+
static loading of modules to add or modify server behavior without
7+
recompiling the core server.
58

6-
- Concepts
9+
- @subpage concepts
710
- Get started: Building a plugin
811
- Plugin types
912
- Plugin services
1013
- [API reference](api.md#)
11-
*/
14+
*/
15+
16+
/**
17+
@page concepts Plugin API Concepts
18+
19+
@section concept_big_picture The Big Bicture: The server, Plugins and Interfaces
20+
21+
The server does, at certain stages of its execution, call plugin APIs when it
22+
needs certain operation performed: e.g. authenticate a user, log a message,
23+
read and write from/to a database table etc.
24+
25+
These API are like written functionality contracts.
26+
They allow separating the server functionality from the actual API
27+
implementations themselves. And, since the API implementions are a dynamic set,
28+
adding new implementations extends the server functionality
29+
(e.g. adds new ways a user can be authenticated or message be logged)
30+
without having to re-compile and even re-start the server itself.
31+
32+
The MariaDB plugin infrastructure uses the following logical terms:
33+
34+
@subsection concept_plugin_api Plugin API
35+
36+
A well defined, versioned and stable interface specification.
37+
It's also abstract, as it's not tied to any one specific implementation.
38+
39+
@subsection concept_plugin Plugin
40+
41+
A named and versioned implementation of a specific @ref concept_plugin_api.
42+
43+
@subsection concept_plugin_library Plugin Library
44+
45+
(habitually abbreviated as a plugin)
46+
An executable binary that contains one or more @ref concept_plugin that can
47+
be accessed by the server when it needs to call plugin API implementations.
48+
49+
50+
@sa @ref implementation on how the above concepts are implemented.
51+
*/
52+
53+
/**
54+
@page implementation Plugin API Implementation
55+
56+
This is how the individual abstract concepts are implemented and
57+
interact with each other.
58+
59+
@section impl_server The Server Plugin API implementation
60+
61+
The server is the bedrock of the plugin infrastructure and contains the
62+
base implementation to make use of it.
63+
Plugins can theoretically be loaded into other binaries, but chances are
64+
that they won't operate all that well (if at all) in this case since they
65+
heavily depend on server's infrastructure.
66+
67+
Here's what the server implements to support plugins:
68+
69+
@subsection impl_server_global_plugin_list The global plugin list
70+
71+
The server maintains a global in-memory list of all available plugins (plugin_array), mirrored into a set of hash tables (plugin_hash) and guarded by LOCK_plugin.
72+
73+
The plugin libraries containing the available plugins can be:
74+
- statically linked into the server binary
75+
- dynamically loaded at startup via the --plugin-load... command line arguments
76+
- dynamically loaded just prior to the server's commencement of normal operations from the mysql.plugins table.
77+
- dynamically loaded at runtime via the INSTALL PLUGIN SQL command.
78+
- unloaded at runtime via the UNINSTALL PLUGIN SQL command
79+
- unloaded at server shutdown
80+
81+
The server implements all of the above possibilities in its code.
82+
83+
It also implements and provides a list of interfaces the plugins can use to call back and interact with the server.
84+
These are called @ref impl_server_plugin_services.
85+
86+
@subsection impl_server_plugin_services Plugin Services Implementation
87+
88+
The server maintains a global named list of plugin service API implementations.
89+
Every time a @ref concept_plugin_library is initialized, the server gets its global
90+
service API implementation list and sets pointers to each individual API slot into
91+
the empty pointer block provided by the @ref concept_plugin_library.
92+
The library code compiled to call these API pointers can now access
93+
the actual server implementations of these services API.
94+
95+
@sa @ref plugin_api_services for a list of the services provided by the server.
96+
97+
@subsection impl_server_plugin_api_call How the server calls a plugin API.
98+
99+
At certain opportune stages of server's normal operation the server might decide
100+
to "reach out" to a plugin by calling a plugin API. Since the plugins are named it
101+
can call any individual plugin by name. E.g. when executing `CREATE TABLE engine=foo`,
102+
the server will:
103+
104+
- look "foo" into the cache of plugin "references" (plugin_ref) for that plugin type, if available.
105+
- If no cached reference is found:
106+
- Take LOCK_plugin
107+
- Look "foo" up into the global plugin_array for implementations of the specific plugin API (storage engine in this case)
108+
- If found, create a reference (plugin_ref) to the plugin.
109+
- call API "method" (function pointers) through the plugin_ref, if found.
110+
- when done, either store the plugin_ref into a cache for reuse or release it.
111+
112+
@section impl_plugin_library The Plugin library Implementation
113+
114+
A @ref concept_plugin_library is executable code, either a part of
115+
the server itself or bundled as a shared library.
116+
117+
@subsection impl_plugin_library_static Statically linked plugin libraries.
118+
119+
Plugins linked statically to the server are collected into a global
120+
server "plugin library" and "installed" (and initialized) at server startup.
121+
122+
@subsection impl_plugin_library_dynamic Dynamic plugin libraries
123+
124+
A @ref concept_plugin_library is usually compiled as OS dynamic library:
125+
DLLs on MS Windows, .so on Unixes.
126+
What differentiates a @ref concept_plugin_library from a regular OS
127+
shared library is that it exposes a specific public symbol
128+
_maria_plugin_declarations_ that the server recognizes.
129+
In fact it also exposes _maria_plugin_interface_version_ and
130+
_maria_sizeof_struct_st_plugin_, but these are auxilary.
131+
132+
_maria_plugin_declarations_ is an array of @ref st_maria_plugin structures,
133+
each describing a @ref concept_plugin this @ref concept_plugin_library provides.
134+
135+
When the @ref concept_plugin_library is loaded into the server:
136+
* the library is version and maturity checked
137+
* for each @ref concept_plugin contained
138+
* plugin API version check is performed
139+
* the plugin is initialized
140+
* the plugin system and status variables are added to the variable global lists
141+
* the plugin is added into the global plugin_array.
142+
143+
At unload time the effect of plugin library load above is reversed.
144+
145+
@section impl_plugin Plugin implementation
146+
147+
A MariaDB plugin is a logical, versioned implementation of exactly two interfaces:
148+
- The base @ref st_maria_plugin plugin management interface
149+
- A specific plugin interface, one of @ref plugin_types.
150+
*/

0 commit comments

Comments
 (0)