Bug #38570 calling UDF causes a server crash
Description:
I worked on bug #38257
SELECT udf_real_max_length();
080805 13:22:20 - mysqld got signal 10 ;
....
ERROR 2013 (HY000): Lost connection to MySQL server during query
How to repeat:
FIle: udf_return_values.c
-------------------------
#include <string.h>
#include <my_global.h>
#include <mysql.h>
#if defined(_WIN32) || defined(_WIN64)
#define DLLEXP __declspec(dllexport)
#else
#define DLLEXP /* no dll */
#endif
#ifdef __cplusplus
extern "C" {
#endif
DLLEXP my_bool udf_int_max_length_init(UDF_INIT *initid){
return 0;
}
DLLEXP longlong udf_int_max_length(
UDF_INIT *initid, UDF_ARGS *args,
my_bool *is_null, my_bool *error
){
return initid->max_length;
}
DLLEXP my_bool udf_real_max_length_init(UDF_INIT *initid){
initid->decimals = 0;
return 0;
}
DLLEXP double udf_real_max_length(
UDF_INIT *initid, UDF_ARGS *args,
my_bool *is_null, my_bool *error
){
initid->decimals = 0;
return (double)initid->max_length;
}
DLLEXP my_bool udf_str_max_length_init(UDF_INIT *initid){
initid->decimals = 0;
return 0;
}
DLLEXP char* udf_str_max_length(
UDF_INIT *initid, UDF_ARGS *args,
char* buffer, unsigned long* length,
my_bool *is_null, my_bool *error
){
initid->decimals = 0;
sprintf(buffer, "%u\0", initid->max_length);
*length = strlen(buffer);
return buffer;
}
#ifdef __cplusplus
}
#endif
Compile:
--------
gcc -Wall -I/opt/mysql/mysql/include -shared -o udf_return_values.so udf_return_values.c
Move udf_return_values.so to plugin dir
---------------------------------------
CREATE FUNCTION udf_real_max_length RETURNS REAL soname 'udf_return_values.so';
Query OK, 0 rows affected (0.00 sec)
SELECT udf_real_max_length();
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.