Skip to content

MDEV-40786 make mariadb-plugin great - #5597

Draft
MooSayed1 wants to merge 1 commit into
MariaDB:mainfrom
MooSayed1:MDEV-40786
Draft

MDEV-40786 make mariadb-plugin great#5597
MooSayed1 wants to merge 1 commit into
MariaDB:mainfrom
MooSayed1:MDEV-40786

Conversation

@MooSayed1

@MooSayed1 MooSayed1 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

The Jira issue number for this PR is: MDEV-40786

Description

First step of turning the mariadb-plugin tool into a plugin package
manager, as described in the MDEV. New CLI surface:

mariadb-plugin search <plugin_name>
mariadb-plugin install <plugin_name>
mariadb-plugin uninstall <plugin_name>

The legacy <plugin> ENABLE|DISABLE syntax is kept for backward
compatibility: it is detected on the raw arguments (is_legacy_syntax()),
before any option parsing, and continues through the original code path
completely unchanged. The usage text marks it as deprecated.

Plugin names are normalized to lower case and validated against
[a-z0-9_-] (max 64 chars), since they are used to construct package
names (mariadb-plugin-<name>).

Install-method detection. The install layout (RPM, DEB, tarball) is
compiled in from INSTALL_LAYOUT, as it cannot be derived from the path:
RPM and DEB share the same directories. At runtime the tool locates
itself through argv[0] (my_path() + my_realpath(), which also
resolves the legacy mysql_plugin symlink) and verifies it belongs to
that installation: on RPM/DEB the binary must sit in the compiled-in
bindir, on a tarball the plugin directory must exist under the basedir.
A build tree is therefore not accepted.

Package-manager delegation. On RPM and DEB installations install
and uninstall delegate to the system package manager, so plugin files
stay owned by it and dependency resolution, signature checks and upgrades
keep working. apt-get is used on DEB; on RPM dnf is preferred and
zypper is used when dnf is absent. Commands run through
fork()/execvp() with an argument vector, never a shell, and inherit
the standard streams, so the package manager prompts the user itself and
its exit code is passed through unchanged. Non-root invocations are
rejected before anything is spawned.

uninstall on RPM first resolves the real package name with
rpm -q --whatprovides, because dnf 5 does not accept Provides names
for removal (dnf 4 and zypper do); this also produces a clear message
when the plugin is not installed.

Still to come on this PR: Provides: mariadb-plugin-<X> on the RPM
packages (so the uniform name resolves against mariadb.org packages),
search, and tarball support.

Release Notes

mariadb-plugin gains search, install and uninstall subcommands
(work in progress). On RPM and DEB installations install and
uninstall delegate to the system package manager. The legacy
ENABLE|DISABLE syntax still works and is now marked deprecated.

How can this PR be tested?

Manual for now (mtr and autopkgtest coverage planned in a follow-up
commit).

CLI surface, any build:

mariadb-plugin install                # error + usage, exit 1
mariadb-plugin banana foo             # unknown command error, exit 1
mariadb-plugin install 'Rock$db'      # name validation error, exit 1
mariadb-plugin install ROCKSDB        # normalized to 'rocksdb'
mariadb-plugin foo ENABLE             # legacy path: original behavior
mariadb-plugin --help                 # new usage, legacy marked deprecated

Delegation needs a binary built with the matching layout, installed in
the real bindir. Tested in containers:

  • Debian trixie, -DINSTALL_LAYOUT=DEB: mariadb-plugin install rocksdb
    and uninstall rocksdb install and remove the real
    mariadb-plugin-rocksdb package; an unknown plugin returns apt's own
    error and exit code.
  • Fedora 42 (dnf 5) and openSUSE Tumbleweed (zypper),
    -DINSTALL_LAYOUT=RPM, with a local repository providing a package
    with Provides: mariadb-plugin-test: install resolves the alias,
    uninstall resolves the real name and removes it, and uninstalling a
    plugin that is not installed reports it plainly.
  • Non-root, and running an RPM/DEB-layout binary from the wrong
    directory, both produce a single clear error.

Basing the PR against the correct MariaDB version

This is a new feature, so this PR targets main.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Aug 26, 2026
@gkodinov gkodinov self-assigned this Aug 26, 2026

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this. This is nowhere near close to being ready for review. Converting to draft until it's actually delivering towards the specification in the jira.

@gkodinov
gkodinov marked this pull request as draft August 26, 2026 08:20
@gkodinov gkodinov added MariaDB Foundation Pull requests created by MariaDB Foundation and removed External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. labels Aug 26, 2026
@gkodinov gkodinov assigned MooSayed1 and unassigned gkodinov Aug 26, 2026
@MooSayed1
MooSayed1 force-pushed the MDEV-40786 branch 3 times, most recently from 92be898 to ab1e6a9 Compare August 29, 2026 14:41
Add search, install, and uninstall subcommands to mariadb-plugin with
input validation and case normalization, while keeping legacy ENABLE and
DISABLE syntax functional for backward compatibility.

Bake the installation layout into the binary at compile time (RPM, DEB,
or tarball), as it cannot be derived from the path alone since RPM and
DEB use the same directory, and verify the executable path at runtime
via argv[0] and mysys path helpers to ensure package managers and
tarball directories target the correct installation.

Delegate install and uninstall to the system package manager on RPM and
DEB installations, so that plugin files stay owned by it. The plugin
name maps to the uniform package name mariadb-plugin-<name>. Commands
run through fork and execvp with an argument vector, never a shell, and
inherit the standard streams, so the package manager prompts the user
itself and its exit code is passed through.

RPM packages are named differently, so they get the uniform name as a
Provides, derived from the plugin component in cmake/plugin.cmake. DEB
packages already carry it.

On RPM, uninstall resolves the real package name with rpm --whatprovides,
because dnf 5 does not accept Provides names for removal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MariaDB Foundation Pull requests created by MariaDB Foundation

Development

Successfully merging this pull request may close these issues.

2 participants