mirror of https://github.com/sysown/proxysql
The four-phase plugin lifecycle (Step 2.2), pre-execution query-hook ABI
(Step 2.1), shared Prometheus registry access (Step 2.3), and generic
admin-command alias dispatch (Step 2.5) introduce new plugin ABI surface
area — a new descriptor field (register_schemas), new services-struct
entries (register_query_hook, get_prometheus_registry,
register_command_alias), new public manager methods
(invoke_register_schemas_phase, dispatch_query_hook, etc.), and a new
startup ordering in main().
These changes should not appear in the v3.x stable/innovative tiers.
Wrap every chassis-only declaration, definition, and dispatch path in
`#ifdef PROXYSQL40` so the v3.0/v3.1 builds retain the pre-chassis
behavior: a single init()-only descriptor layout, two-phase load+init
lifecycle, and the hardcoded MYSQLX alias ladder in Admin_Handler.cpp.
Changes:
* Top-level Makefile: introduce PROXYSQL40 as a distinct tier above
PROXYSQL31. Cascade rule: PROXYSQLGENAI=1 implies PROXYSQL40=1
implies PROXYSQL31=1. Bump major version number on PROXYSQL40=1
(previously tied to PROXYSQLGENAI). Export PROXYSQL40 for recursive
submakes.
* lib/Makefile, src/Makefile: add -DPROXYSQL40 via $(PSQL40) so the
compile commands match the top-level tier selection.
* include/ProxySQL_Plugin.h: gate the register_schemas descriptor
field, query-hook types/enums/typedefs, the alias-registration
callback, and the trailing services-struct fields
(register_query_hook, get_prometheus_registry,
register_command_alias). The pre-chassis descriptor remains six
fields (name, abi_version, init, start, stop, status_json) so
plugins built against v3.x headers still link and load.
* include/ProxySQL_PluginManager.h: gate the chassis-exclusive public
methods and private members (schemas_registered, aliases,
services_phase_b_, query hook pointers). Provide two declarations
of proxysql_load_configured_plugins — the four-phase variant (paired
with proxysql_init_configured_plugins) under PROXYSQL40, the legacy
single-call variant otherwise.
* lib/ProxySQL_PluginManager.cpp: gate every method that belongs to
the chassis (invoke_register_schemas_phase, register_command_alias,
resolve_alias_to_canonical, register_query_hook, has_query_hook,
dispatch_query_hook), plus the services_phase_b_ initialization
(nullptr DB handle stubs), the proxysql_dispatch_configured_plugin_
query_hook entry point, and the alternate four-phase body of
proxysql_load_configured_plugins / proxysql_init_configured_plugins.
The legacy two-phase loader is restored under !PROXYSQL40.
get_admindb_service / get_configdb_service / get_statsdb_service
stay ungated because they back the unconditional services_ member.
* lib/Admin_Handler.cpp: gate the `#include \"ProxySQL_PluginManager.h\"`
and restore under !PROXYSQL40 the 16 hardcoded MYSQLX alias vectors
plus the 16-deep if-ladder in admin_handler_command_*(). Under
PROXYSQL40 the ladder is replaced by a single call to
proxysql_resolve_configured_plugin_admin_alias(), which is
plugin-agnostic.
* src/main.cpp: gate InitConfiguredPlugins and branch the startup
sequence in ProxySQL_Main_init_phase2___not_started:
- PROXYSQL40: LoadConfiguredPlugins (Phase A+B) -> admin init (C) ->
materialize_plugin_tables -> InitConfiguredPlugins (D) ->
StartConfiguredPlugins (E).
- !PROXYSQL40: admin init -> LoadConfiguredPlugins (combined
load+init) -> materialize_plugin_tables -> StartConfiguredPlugins,
matching the pre-chassis ordering.
* plugins/mysqlx/src/mysqlx_plugin.cpp: split init under PROXYSQL40
into mysqlx_register_schemas (schema + commands) and a minimal
mysqlx_init (context only). Under !PROXYSQL40 the original single
mysqlx_init remains. Descriptor conditionally wires
register_schemas.
* plugins/mysqlx/src/mysqlx_admin_schema.cpp: under PROXYSQL40 use
the reg() helper to register canonical+aliases via the new ABI;
under !PROXYSQL40 fall back to 16 direct register_command() calls
(aliases handled by Admin_Handler's hardcoded ladder).
* test/tap/test_helpers/fake_plugin.cpp: gate fake_query_hook,
fake_register_schemas, fake_descriptor_with_phase_b, the
REGISTER_QUERY_HOOK block in fake_init, and the ENABLE_PHASE_B
descriptor selection. The pre-chassis descriptor-returning stub is
the sole return path under !PROXYSQL40.
* test/tap/tests/unit/Makefile: autodetect PROXYSQL40 via
invoke_register_schemas_phase (the chassis-exclusive symbol) in the
library archive; add -DPROXYSQL40 to fake_plugin .so compilation so
the descriptor layout matches the loader's expectations; append the
three chassis-only tests (plugin_lifecycle, plugin_prometheus,
plugin_query_hook) to UNIT_TESTS only when PROXYSQL40=1.
* test/tap/tests/unit/plugin_config_unit-t.cpp,
test/tap/tests/unit/plugin_dispatch_unit-t.cpp: compile-time-gate
the chassis-only subtests, adjust plan() counts per mode
(48/50 with PROXYSQL40, 47/32 without), and provide a
proxysql_init_configured_plugins_compat() helper that is a no-op
returning true under !PROXYSQL40 so shared test helpers work in
both modes.
Verification — all plugin unit tests pass in both modes:
PROXYSQL40=1 build (chassis enabled):
plugin_config_unit-t: 48/48
plugin_dispatch_unit-t: 50/50
plugin_lifecycle_unit-t: 14/14
plugin_query_hook_unit-t: 41/41
PROXYSQL40=0 build (v3.x behavior):
plugin_config_unit-t: 47/47
plugin_dispatch_unit-t: 32/32
(plugin_lifecycle, plugin_query_hook not built)
ProtocolX
parent
41918a42df
commit
cd48c5613e
Loading…
Reference in new issue