mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Bug#18761: constant expression as UDF parameters not passed in as constant
The code that set up data to be passed to user-defined functions was very old and analyzed the "Type" of the data that was passed into the UDF, when it really should analyze the "return_type", which is hard-coded for simple Items and works correctly for complex ones like functions. --- Added test at Sergei's behest.
This commit is contained in:
@ -165,6 +165,9 @@ void avgcost_reset( UDF_INIT* initid, UDF_ARGS* args, char* is_null, char *error
|
||||
void avgcost_clear( UDF_INIT* initid, char* is_null, char *error );
|
||||
void avgcost_add( UDF_INIT* initid, UDF_ARGS* args, char* is_null, char *error );
|
||||
double avgcost( UDF_INIT* initid, UDF_ARGS* args, char* is_null, char *error );
|
||||
my_bool is_const_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
|
||||
char *is_const(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long
|
||||
*length, char *is_null, char *error);
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
@ -1075,4 +1078,31 @@ char *myfunc_argument_name(UDF_INIT *initid __attribute__((unused)),
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
my_bool is_const_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
{
|
||||
if (args->arg_count != 1)
|
||||
{
|
||||
strmov(message, "IS_CONST accepts only one argument");
|
||||
return 1;
|
||||
}
|
||||
initid->ptr= (args->args[0] != NULL) ? 1 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char * is_const(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long
|
||||
*length, char *is_null, char *error)
|
||||
{
|
||||
if (initid->ptr != 0) {
|
||||
sprintf(result, "const");
|
||||
} else {
|
||||
sprintf(result, "not const");
|
||||
}
|
||||
*is_null= 0;
|
||||
*length= strlen(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endif /* HAVE_DLOPEN */
|
||||
|
Reference in New Issue
Block a user