mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Bug #29804 UDF parameters don't contain correct string length
Previously, UDF *_init functions were passed constant strings with erroneous lengths. The length came from the containing variable's size, not the length of the value itself. Now the *_init functions get the constant as a null terminated string with the correct length supplied.
This commit is contained in:
@ -1106,4 +1106,39 @@ char * is_const(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)),
|
||||
}
|
||||
|
||||
|
||||
my_bool check_const_len_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
{
|
||||
if (args->arg_count != 1)
|
||||
{
|
||||
strmov(message, "IS_CONST accepts only one argument");
|
||||
return 1;
|
||||
}
|
||||
if (args->args[0] == 0)
|
||||
{
|
||||
initid->ptr= "Not constant";
|
||||
}
|
||||
else if(strlen(args->args[0]) == args->lengths[0])
|
||||
{
|
||||
initid->ptr= "Correct length";
|
||||
}
|
||||
else
|
||||
{
|
||||
initid->ptr= "Wrong length";
|
||||
}
|
||||
initid->max_length = 100;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char * check_const_len(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)),
|
||||
char *result, unsigned long *length,
|
||||
char *is_null, char *error __attribute__((unused)))
|
||||
{
|
||||
strmov(result, initid->ptr);
|
||||
*length= strlen(result);
|
||||
*is_null= 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* HAVE_DLOPEN */
|
||||
|
Reference in New Issue
Block a user