惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
U
Unit 42
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
罗磊的独立博客
月光博客
月光博客
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
B
Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
美团技术团队
Y
Y Combinator Blog
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
爱范儿
爱范儿
B
Blog RSS Feed
V
Visual Studio Blog
MyScale Blog
MyScale Blog

MariaDB.org

"Verify, Measure, and Get Your Hands Dirty": Two Decades of Database Support with Sveta Smirnova - MariaDB.org The database world grew up — notes from Percona Live Amsterdam - MariaDB.org MariaDB 13.0 Is Now Stable - MariaDB.org Trying DuckDB for Magento Analytics: An Experiment with One Million Orders - MariaDB.org MariaDB adoption is growing, and the way people get it is changing – Adoption Index 2026-09 - MariaDB.org AWS renews Diamond sponsorship of MariaDB Foundation for a fourth consecutive year - MariaDB.org Rethinking PAM - MariaDB.org From a Chocolate Wrapper to Concurrent InnoDB Page Splits - MariaDB.org Launching MariaDB's Database Survey 2026 - MariaDB.org MariaDB Plugins Beyond C++: What the Community Told Us - MariaDB.org MariaDB Connector/C Compatibility: An Update on CONC-821 - MariaDB.org MariaDB Foundation Newsletter – September 2026 - MariaDB.org MariaDB at Percona Live Amsterdam 2026: Ecosystem, Plugins, Security, and Community - MariaDB.org MariaDB Server 12.3, 11.8, 11.4 and 10.11 – Q3 2026 Maintenance Releases, and Goodbye 10.6 - MariaDB.org MariaDB Contribution Statistics, January-June 2026 - MariaDB.org Seravo becomes a Silver Sponsor of MariaDB Foundation - MariaDB.org Extending MariaDB with Native Aggregate Plugins: Laying the Groundwork for HyperLogLog - MariaDB.org MariaDB Foundation Advances TAF with HammerDB 6.0 and xt_reservoir Integration - MariaDB.org MariaDB 13.1 Feature in Focus: JSON Operators and JSON_TABLE Improvements - MariaDB.org MariaDB Foundation is pleased to welcome Auree as a Silver Sponsor. - MariaDB.org Hear Ye, Hear Ye: A Guide to MariaDB’s Governance Model - MariaDB.org Wirekite becomes Silver Sponsor of MariaDB Foundation - MariaDB.org From a Production Problem to MariaDB: Headout’s Open-Source Contribution Journey - MariaDB.org Adobe Commerce Chooses MariaDB as Its Default Database Platform - MariaDB.org ScalaHosting Becomes a Gold Sponsor of MariaDB Foundation - MariaDB.org The Queen and the "Half That Wasn't Told" - MariaDB.org IBM continues as a Platinum Sponsor of MariaDB Foundation - MariaDB.org Say the Name: MariaDB, MySQL, and the Ecosystem We Share - MariaDB.org Deploying the MariaDB Privacy-First Stack Anywhere with Terraform - MariaDB.org From PostgreSQL 12 to MariaDB 11: A Gradual Fintech Migration with 23% Lower TCO - MariaDB.org
MariaDB Server Plugins: disabled functions - MariaDB.org
Frédéric Descamps · 2026-07-06 · via MariaDB.org

During the last MariaDB Foundation Board Meeting (24 June 2026), Barry shared how it can be difficult to deploy an upgrade immediately and that they sometimes have to wait for one that fixes security bugs. Wait for the validation, wait for the fix, and the release. Even if the MariaDB engineers are doing incredible work, it might still not be fast enough for the security team.

That’s where Barry requested MariaDB implement a query-rewriter plugin, like the one in MySQL, to address the fact that, in a multi-tenant environment, certain queries that would trigger known vulnerabilities are never legitimately used by applications.

So I wrote something similar, but unfortunately, this didn’t solve the problem. Queries are way too different. For example, these two queries will provide two different digests or normalized forms:

select now() as nu;

select now() as maintenant;

So this solution was discarded, and we discussed maybe using a regular expression, but that might become too heavy; it would be better to use a proxy like MaxScale with the rewrite or regexp filter.

And then the real problem arose: most of their issues stemmed from built-in functions they never use in their application, but that could become dangerous. So they asked if it was possible to “just” disable some built-in functions

The Solution

Of course, there is nothing currently implemented in MariaDB Server that allows the DBA to disable built-in functions.

But our Chief Architect, Sergei Golubchik, had an idea: a dynamic plugin loaded at startup could disable a function and return an error. We could monkey-patch a C++ virtual method at runtime by directly modifying a class’s vtable.

Monkey-patching means changing the behavior of existing code at runtime, rather than by editing and recompiling the original source. It’s primarily used in dynamic languages like Python and JavaScript to add, replace, or suppress functionality in memory.

That rang a bell and opened a new perspective to reach the desired objective.

The key idea

MariaDB has internal registries of built-in SQL functions, represented as arrays:

extern Native_func_registry_array native_func_registry_array;
extern Native_func_registry_array native_func_registry_array_geom;
extern Native_func_registry_array oracle_func_registry_array;

Each entry looks like this:

struct Native_func_registry
{
  LEX_CSTRING name;
  Create_func *builder;
};

Meaning that each function has a name and a builder (an object used to create the function expression).

Finally, MariaDB also has hash tables used to look up functions quickly:

extern Native_functions_hash native_functions_hash;
extern Native_functions_hash native_functions_hash_oracle;

So when a SQL statement contains something like:

SELECT SLEEP(10);

MariaDB parses SLEEP, searches the function registry/hash, finds its Create_func *builder, and uses that to construct the function call.

This plugin simply removes selected entries from those hashes.

After removal, the function still exists in the compiled MariaDB code, but the SQL layer can no longer resolve its name via the normal native-function lookup path.

Creating a plugin for MariaDB Server isn’t complicated (see this page), so I tried to write a plugin that, when loaded at startup, would disable functions referenced by a global read-only variable using the key idea above.

The plugin is available on my GitHub repository.

When compiled and installed, you can load the module directly from the my.cnf:

[mariadb]
plugin_load_add=disabled_functions
disabled_functions=SLEEP,COLUMN_LIST

This will load the plugin and disable the commands SLEEP() and COLUMN_LIST():

MariaDB [test]> SELECT * FROM information_schema.PLUGINS  
                WHERE plugin_name = 'disabled_functions'\G
*************************** 1. row ***************************
           PLUGIN_NAME: disabled_functions
        PLUGIN_VERSION: 1.0
         PLUGIN_STATUS: ACTIVE
           PLUGIN_TYPE: DAEMON
   PLUGIN_TYPE_VERSION: 130100.0
        PLUGIN_LIBRARY: disabled_functions.so
PLUGIN_LIBRARY_VERSION: 1.15
         PLUGIN_AUTHOR: lefred
    PLUGIN_DESCRIPTION: Disables selected native built-in SQL functions
        PLUGIN_LICENSE: GPL
           LOAD_OPTION: ON
       PLUGIN_MATURITY: Experimental
   PLUGIN_AUTH_VERSION: 1.0
1 row in set (0.002 sec)

MariaDB [test]> SHOW GLOBAL VARIABLES LIKE 'disabled_functions_list';
+-------------------------+-------------------+
| Variable_name           | Value             |
+-------------------------+-------------------+
| disabled_functions_list | SLEEP,COLUMN_LIST |
+-------------------------+-------------------+
1 row in set (0.000 sec)

Now let’s try to use one of these functions:

MariaDB [test]> select sleep();
ERROR 1305 (42000): FUNCTION test.sleep does not exist
MariaDB [test]> select sleep(10);
ERROR 1305 (42000): FUNCTION test.sleep does not exist
MariaDB [test]> select sleep('fred');
ERROR 1305 (42000): FUNCTION test.sleep does not exist
MariaDB [test]> 

The plugin works exactly as expected.

Conclusion

This is not a wow-feature plugin, but it illustrates how flexible MariaDB is and how quickly it’s possible to extend it with a feature that could be used in production.

Please give it a try, and if you code some plugins, please share them with me. I will be happy to test them.

As usual, enjoy MariaDB Server and enjoy hacking!