mirror of
https://github.com/MariaDB/server.git
synced 2025-09-09 18:40:27 +03:00
MDEV-30727 Check spider_hton_ptr in spider udfs
We have to #undef my_error and find it from udfs when spider is not installed.
This commit is contained in:
24
storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result
Normal file
24
storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so';
|
||||||
|
SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"');
|
||||||
|
ERROR HY000: Plugin 'SPIDER' is not loaded
|
||||||
|
CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so';
|
||||||
|
SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"');
|
||||||
|
ERROR HY000: Plugin 'SPIDER' is not loaded
|
||||||
|
CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so';
|
||||||
|
SELECT spider_copy_tables ('t', '0', '0');
|
||||||
|
ERROR HY000: Plugin 'SPIDER' is not loaded
|
||||||
|
CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so';
|
||||||
|
SELECT spider_flush_table_mon_cache ();
|
||||||
|
spider_flush_table_mon_cache ()
|
||||||
|
1
|
||||||
|
install soname 'ha_spider';
|
||||||
|
SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"');
|
||||||
|
ERROR HY000: The foreign server name you are trying to reference does not exist. Data source error: b
|
||||||
|
call mtr.add_suppression(".*\\[Error\\] (mysqld|mariadbd): Can't find record in 'spider_tables'");
|
||||||
|
SELECT spider_copy_tables ('t', '0', '0');
|
||||||
|
ERROR HY000: Can't find record in 'spider_tables'
|
||||||
|
SELECT spider_flush_table_mon_cache ();
|
||||||
|
spider_flush_table_mon_cache ()
|
||||||
|
1
|
||||||
|
Warnings:
|
||||||
|
Warning 1620 Plugin is busy and will be uninstalled on shutdown
|
30
storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test
Normal file
30
storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so';
|
||||||
|
--error ER_PLUGIN_IS_NOT_LOADED
|
||||||
|
SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"');
|
||||||
|
|
||||||
|
CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so';
|
||||||
|
--error ER_PLUGIN_IS_NOT_LOADED
|
||||||
|
SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"');
|
||||||
|
|
||||||
|
CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so';
|
||||||
|
--error ER_PLUGIN_IS_NOT_LOADED
|
||||||
|
SELECT spider_copy_tables ('t', '0', '0');
|
||||||
|
|
||||||
|
# spider_flush_table_mon_cache does not require spider init to function
|
||||||
|
CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so';
|
||||||
|
SELECT spider_flush_table_mon_cache ();
|
||||||
|
|
||||||
|
# The function functions properly after the plugin is installed
|
||||||
|
install soname 'ha_spider';
|
||||||
|
|
||||||
|
--error ER_FOREIGN_SERVER_DOESNT_EXIST
|
||||||
|
SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"');
|
||||||
|
|
||||||
|
call mtr.add_suppression(".*\\[Error\\] (mysqld|mariadbd): Can't find record in 'spider_tables'");
|
||||||
|
--error ER_KEY_NOT_FOUND
|
||||||
|
SELECT spider_copy_tables ('t', '0', '0');
|
||||||
|
|
||||||
|
SELECT spider_flush_table_mon_cache ();
|
||||||
|
|
||||||
|
--disable_query_log
|
||||||
|
--source ../../include/clean_up_spider.inc
|
@@ -1154,12 +1154,20 @@ error:
|
|||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef my_error
|
||||||
|
extern "C" void my_error(unsigned int nr, unsigned long MyFlags, ...);
|
||||||
|
|
||||||
my_bool spider_copy_tables_init_body(
|
my_bool spider_copy_tables_init_body(
|
||||||
UDF_INIT *initid,
|
UDF_INIT *initid,
|
||||||
UDF_ARGS *args,
|
UDF_ARGS *args,
|
||||||
char *message
|
char *message
|
||||||
) {
|
) {
|
||||||
DBUG_ENTER("spider_copy_tables_init_body");
|
DBUG_ENTER("spider_copy_tables_init_body");
|
||||||
|
if (!spider_hton_ptr)
|
||||||
|
{
|
||||||
|
my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "SPIDER");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
if (args->arg_count != 3 && args->arg_count != 4)
|
if (args->arg_count != 3 && args->arg_count != 4)
|
||||||
{
|
{
|
||||||
strcpy(message, "spider_copy_tables() requires 3 or 4 arguments");
|
strcpy(message, "spider_copy_tables() requires 3 or 4 arguments");
|
||||||
|
@@ -1789,6 +1789,9 @@ error:
|
|||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef my_error
|
||||||
|
extern "C" void my_error(unsigned int nr, unsigned long MyFlags, ...);
|
||||||
|
|
||||||
my_bool spider_direct_sql_init_body(
|
my_bool spider_direct_sql_init_body(
|
||||||
UDF_INIT *initid,
|
UDF_INIT *initid,
|
||||||
UDF_ARGS *args,
|
UDF_ARGS *args,
|
||||||
@@ -1797,6 +1800,11 @@ my_bool spider_direct_sql_init_body(
|
|||||||
) {
|
) {
|
||||||
SPIDER_BG_DIRECT_SQL *bg_direct_sql;
|
SPIDER_BG_DIRECT_SQL *bg_direct_sql;
|
||||||
DBUG_ENTER("spider_direct_sql_init_body");
|
DBUG_ENTER("spider_direct_sql_init_body");
|
||||||
|
if (!spider_hton_ptr)
|
||||||
|
{
|
||||||
|
my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "SPIDER");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
if (args->arg_count != 3)
|
if (args->arg_count != 3)
|
||||||
{
|
{
|
||||||
strcpy(message, "spider_(bg)_direct_sql() requires 3 arguments");
|
strcpy(message, "spider_(bg)_direct_sql() requires 3 arguments");
|
||||||
|
Reference in New Issue
Block a user