1 /***********************************************************************/
2 /*  (C) Copyright to the author Olivier BERTRAND          2015         */
3 /***********************************************************************/
4 #include <my_global.h>
5 #include <mysqld.h>
6 #include <string.h>
7 
8 #if defined(__WIN__)
9 #define DllExport  __declspec( dllexport )
10 #else   // !__WIN__
11 #define DllExport
12 #endif  // !__WIN__
13 
14 extern "C" {
15 	DllExport my_bool noconst_init(UDF_INIT*, UDF_ARGS*, char*);
16 	DllExport char *noconst(UDF_INIT*, UDF_ARGS*, char*, unsigned long*, char*, char*);
17 } // extern "C"
18 
19 /***********************************************************************/
20 /*  Returns its argument saying it is not a constant.                  */
21 /***********************************************************************/
noconst_init(UDF_INIT * initid,UDF_ARGS * args,char * message)22 my_bool noconst_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
23 {
24   if (args->arg_count != 1 || args->arg_type[0] != STRING_RESULT) {
25     strcpy(message, "noconst unique argument must be a string");
26     return true;
27   } // endif arg
28 
29   initid->const_item = false;   // The trick!
30   return false;
31 } // end of noconst_init
32 
noconst(UDF_INIT * initid,UDF_ARGS * args,char * result,unsigned long * res_length,char *,char *)33 char *noconst(UDF_INIT *initid, UDF_ARGS *args, char *result,
34   unsigned long *res_length, char *, char *)
35 {
36   return args->args[0];
37 } // end of noconst
38 
39