Skip to content

Commit 03295f0

Browse files
committed
MDEV-30727 Check spider_hton_ptr in spider udfs
UDF isn't supposed to use my_error(), it should return the error message in the provided error message buffer Fixes valgrind: ==93993== Conditional jump or move depends on uninitialised value(s) ==93993== at 0x484ECCD: strnlen (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==93993== by 0x1AD2B2C: process_str_arg (my_vsnprintf.c:259) ==93993== by 0x1AD47E0: my_vsnprintf_ex (my_vsnprintf.c:696) ==93993== by 0x1A3B91E: my_error (my_error.c:120) ==93993== by 0xF87BE8: udf_handler::fix_fields(THD*, Item_func_or_sum*, unsigned int, Item**) (item_func.cc:3638) followup for 267dd5a
1 parent 7a789e2 commit 03295f0

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so';
22
SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"');
3-
ERROR HY000: Plugin 'SPIDER' is not loaded
3+
ERROR HY000: Can't initialize function 'spider_direct_sql'; Plugin 'SPIDER' is not loaded
44
CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so';
55
SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"');
6-
ERROR HY000: Plugin 'SPIDER' is not loaded
6+
ERROR HY000: Can't initialize function 'spider_bg_direct_sql'; Plugin 'SPIDER' is not loaded
77
CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so';
88
SELECT spider_copy_tables ('t', '0', '0');
9-
ERROR HY000: Plugin 'SPIDER' is not loaded
9+
ERROR HY000: Can't initialize function 'spider_copy_tables'; Plugin 'SPIDER' is not loaded
1010
CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so';
1111
SELECT spider_flush_table_mon_cache ();
1212
spider_flush_table_mon_cache ()

storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so';
2-
--error ER_PLUGIN_IS_NOT_LOADED
2+
--error ER_CANT_INITIALIZE_UDF
33
SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"');
44

55
CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so';
6-
--error ER_PLUGIN_IS_NOT_LOADED
6+
--error ER_CANT_INITIALIZE_UDF
77
SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"');
88

99
CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so';
10-
--error ER_PLUGIN_IS_NOT_LOADED
10+
--error ER_CANT_INITIALIZE_UDF
1111
SELECT spider_copy_tables ('t', '0', '0');
1212

1313
# spider_flush_table_mon_cache does not require spider init to function

storage/spider/spd_copy_tables.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,9 +1154,6 @@ long long spider_copy_tables_body(
11541154
DBUG_RETURN(0);
11551155
}
11561156

1157-
#undef my_error
1158-
extern "C" void my_error(unsigned int nr, unsigned long MyFlags, ...);
1159-
11601157
my_bool spider_copy_tables_init_body(
11611158
UDF_INIT *initid,
11621159
UDF_ARGS *args,
@@ -1165,7 +1162,7 @@ my_bool spider_copy_tables_init_body(
11651162
DBUG_ENTER("spider_copy_tables_init_body");
11661163
if (!spider_hton_ptr)
11671164
{
1168-
my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "SPIDER");
1165+
strcpy(message, "Plugin 'SPIDER' is not loaded");
11691166
goto error;
11701167
}
11711168
if (args->arg_count != 3 && args->arg_count != 4)

storage/spider/spd_direct_sql.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,9 +1789,6 @@ long long spider_direct_sql_body(
17891789
DBUG_RETURN(0);
17901790
}
17911791

1792-
#undef my_error
1793-
extern "C" void my_error(unsigned int nr, unsigned long MyFlags, ...);
1794-
17951792
my_bool spider_direct_sql_init_body(
17961793
UDF_INIT *initid,
17971794
UDF_ARGS *args,
@@ -1802,7 +1799,7 @@ my_bool spider_direct_sql_init_body(
18021799
DBUG_ENTER("spider_direct_sql_init_body");
18031800
if (!spider_hton_ptr)
18041801
{
1805-
my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "SPIDER");
1802+
strcpy(message, "Plugin 'SPIDER' is not loaded");
18061803
goto error;
18071804
}
18081805
if (args->arg_count != 3)

0 commit comments

Comments
 (0)