summaryrefslogtreecommitdiffstats
path: root/plugin/func_test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 18:00:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 18:00:34 +0000
commit3f619478f796eddbba6e39502fe941b285dd97b1 (patch)
treee2c7b5777f728320e5b5542b6213fd3591ba51e2 /plugin/func_test
parentInitial commit. (diff)
downloadmariadb-3f619478f796eddbba6e39502fe941b285dd97b1.tar.xz
mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.zip
Adding upstream version 1:10.11.6.upstream/1%10.11.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugin/func_test')
-rw-r--r--plugin/func_test/CMakeLists.txt17
-rw-r--r--plugin/func_test/mysql-test/func_test/func_test.result28
-rw-r--r--plugin/func_test/mysql-test/func_test/func_test.test23
-rw-r--r--plugin/func_test/mysql-test/func_test/suite.opt1
-rw-r--r--plugin/func_test/mysql-test/func_test/suite.pm9
-rw-r--r--plugin/func_test/plugin.cc92
6 files changed, 170 insertions, 0 deletions
diff --git a/plugin/func_test/CMakeLists.txt b/plugin/func_test/CMakeLists.txt
new file mode 100644
index 00000000..38ce82d3
--- /dev/null
+++ b/plugin/func_test/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Copyright (c) 2019, MariaDB corporation. All rights reserved.
+#
+# 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 Street, Fifth Floor, Boston, MA 02110-1335 USA
+
+MYSQL_ADD_PLUGIN(func_test plugin.cc RECOMPILE_FOR_EMBEDDED
+ MODULE_ONLY COMPONENT Test)
diff --git a/plugin/func_test/mysql-test/func_test/func_test.result b/plugin/func_test/mysql-test/func_test/func_test.result
new file mode 100644
index 00000000..92d03fbd
--- /dev/null
+++ b/plugin/func_test/mysql-test/func_test/func_test.result
@@ -0,0 +1,28 @@
+SELECT
+PLUGIN_NAME,
+PLUGIN_VERSION,
+PLUGIN_STATUS,
+PLUGIN_TYPE,
+PLUGIN_AUTHOR,
+PLUGIN_DESCRIPTION,
+PLUGIN_LICENSE,
+PLUGIN_MATURITY,
+PLUGIN_AUTH_VERSION
+FROM INFORMATION_SCHEMA.PLUGINS
+WHERE PLUGIN_TYPE='FUNCTION'
+ AND PLUGIN_NAME='sysconst_test';
+PLUGIN_NAME sysconst_test
+PLUGIN_VERSION 1.0
+PLUGIN_STATUS ACTIVE
+PLUGIN_TYPE FUNCTION
+PLUGIN_AUTHOR MariaDB Corporation
+PLUGIN_DESCRIPTION Function SYSCONST_TEST()
+PLUGIN_LICENSE GPL
+PLUGIN_MATURITY Experimental
+PLUGIN_AUTH_VERSION 1.0
+SELECT sysconst_test();
+sysconst_test()
+sysconst_test
+SELECT sysconst_test();
+sysconst_test()
+sysconst_test
diff --git a/plugin/func_test/mysql-test/func_test/func_test.test b/plugin/func_test/mysql-test/func_test/func_test.test
new file mode 100644
index 00000000..d5e6a604
--- /dev/null
+++ b/plugin/func_test/mysql-test/func_test/func_test.test
@@ -0,0 +1,23 @@
+#--echo #
+#--echo #
+#--echo #
+
+--vertical_results
+SELECT
+ PLUGIN_NAME,
+ PLUGIN_VERSION,
+ PLUGIN_STATUS,
+ PLUGIN_TYPE,
+ PLUGIN_AUTHOR,
+ PLUGIN_DESCRIPTION,
+ PLUGIN_LICENSE,
+ PLUGIN_MATURITY,
+ PLUGIN_AUTH_VERSION
+FROM INFORMATION_SCHEMA.PLUGINS
+WHERE PLUGIN_TYPE='FUNCTION'
+ AND PLUGIN_NAME='sysconst_test';
+--horizontal_results
+
+
+SELECT sysconst_test();
+SELECT sysconst_test();
diff --git a/plugin/func_test/mysql-test/func_test/suite.opt b/plugin/func_test/mysql-test/func_test/suite.opt
new file mode 100644
index 00000000..8c8bfe0f
--- /dev/null
+++ b/plugin/func_test/mysql-test/func_test/suite.opt
@@ -0,0 +1 @@
+--plugin-load-add=$FUNC_TEST_SO
diff --git a/plugin/func_test/mysql-test/func_test/suite.pm b/plugin/func_test/mysql-test/func_test/suite.pm
new file mode 100644
index 00000000..ddaa6b55
--- /dev/null
+++ b/plugin/func_test/mysql-test/func_test/suite.pm
@@ -0,0 +1,9 @@
+package My::Suite::Func_test;
+
+@ISA = qw(My::Suite);
+
+return "No FUNC_TEST plugin" unless $ENV{FUNC_TEST_SO};
+
+sub is_default { 1 }
+
+bless { };
diff --git a/plugin/func_test/plugin.cc b/plugin/func_test/plugin.cc
new file mode 100644
index 00000000..5cbf05f4
--- /dev/null
+++ b/plugin/func_test/plugin.cc
@@ -0,0 +1,92 @@
+/*
+ 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) override
+ {
+ null_value= str->copy(STRING_WITH_LEN("sysconst_test"), system_charset_info);
+ return null_value ? NULL : str;
+ }
+ bool fix_length_and_dec(THD *thd) override
+ {
+ max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
+ set_maybe_null();
+ return false;
+ }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("sysconst_test") };
+ return name;
+ }
+ const char *fully_qualified_func_name() const override
+ { return "sysconst_test()"; }
+ Item *get_copy(THD *thd) override
+ { 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;