summaryrefslogtreecommitdiffstats
path: root/plugin/func_test/plugin.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 18:07:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 18:07:14 +0000
commita175314c3e5827eb193872241446f2f8f5c9d33c (patch)
treecd3d60ca99ae00829c52a6ca79150a5b6e62528b /plugin/func_test/plugin.cc
parentInitial commit. (diff)
downloadmariadb-10.5-a175314c3e5827eb193872241446f2f8f5c9d33c.tar.xz
mariadb-10.5-a175314c3e5827eb193872241446f2f8f5c9d33c.zip
Adding upstream version 1:10.5.12.upstream/1%10.5.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugin/func_test/plugin.cc')
-rw-r--r--plugin/func_test/plugin.cc87
1 files changed, 87 insertions, 0 deletions
diff --git a/plugin/func_test/plugin.cc b/plugin/func_test/plugin.cc
new file mode 100644
index 00000000..81118977
--- /dev/null
+++ b/plugin/func_test/plugin.cc
@@ -0,0 +1,87 @@
+/*
+ Copyright (c) 2019, MariaDB Corporation
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#define MYSQL_SERVER
+
+#include <my_global.h>
+#include <sql_class.h>
+#include <mysql/plugin_function.h>
+
+class Item_func_sysconst_test :public Item_func_sysconst
+{
+public:
+ Item_func_sysconst_test(THD *thd): Item_func_sysconst(thd) {}
+ String *val_str(String *str)
+ {
+ null_value= str->copy(STRING_WITH_LEN("sysconst_test"), system_charset_info);
+ return null_value ? NULL : str;
+ }
+ bool fix_length_and_dec()
+ {
+ max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
+ maybe_null= true;
+ return false;
+ }
+ const char *func_name() const { return "sysconst_test"; }
+ const char *fully_qualified_func_name() const { return "sysconst_test()"; }
+ Item *get_copy(THD *thd)
+ { return get_item_copy<Item_func_sysconst_test>(thd, this); }
+};
+
+
+class Create_func_sysconst_test : public Create_func_arg0
+{
+public:
+ Item *create_builder(THD *thd) override;
+ static Create_func_sysconst_test s_singleton;
+protected:
+ Create_func_sysconst_test() {}
+};
+
+
+Create_func_sysconst_test Create_func_sysconst_test::s_singleton;
+
+Item* Create_func_sysconst_test::create_builder(THD *thd)
+{
+ return new (thd->mem_root) Item_func_sysconst_test(thd);
+}
+
+
+#define BUILDER(F) & F::s_singleton
+
+
+static Plugin_function
+ plugin_descriptor_function_sysconst_test(BUILDER(Create_func_sysconst_test));
+
+/*************************************************************************/
+
+maria_declare_plugin(type_test)
+{
+ MariaDB_FUNCTION_PLUGIN, // the plugin type (see include/mysql/plugin.h)
+ &plugin_descriptor_function_sysconst_test, // pointer to type-specific plugin descriptor
+ "sysconst_test", // plugin name
+ "MariaDB Corporation", // plugin author
+ "Function SYSCONST_TEST()", // the plugin description
+ PLUGIN_LICENSE_GPL, // the plugin license (see include/mysql/plugin.h)
+ 0, // Pointer to plugin initialization function
+ 0, // Pointer to plugin deinitialization function
+ 0x0100, // Numeric version 0xAABB means AA.BB version
+ NULL, // Status variables
+ NULL, // System variables
+ "1.0", // String version representation
+ MariaDB_PLUGIN_MATURITY_EXPERIMENTAL // Maturity(see include/mysql/plugin.h)*/
+}
+maria_declare_plugin_end;