I have written a sample user defined function (helloworld in c++):
extern "C"
char * hello(UDF_INIT * initid, UDF_ARGS * args,
char * result, unsigned long * length,
char * is_null, char * error) {
strcpy(result, "Hello");
strcat(result, " ");
strcat(result, args -> args[0]);
* length = strlen(result);
return result;
}
extern "C"
bool hello_init(UDF_INIT * initid, UDF_ARGS * args, char * message) {
if (args -> arg_count != 1) {
strcpy(message, "hello requires exactly one string argument");
return 1;
}
if (args -> arg_type[0] != STRING_RESULT) {
strcpy(message, "hello requires exactly one string argument");
return 1;
}
initid -> max_length = args -> lengths[0] + strlen("hello ");
return 0; /* true */
}
extern "C"
void hello_deinit(UDF_INIT * initid) {
return;
}
when I create the function in sql command using :
CREATE FUNCTION remote returns string SONAME 'Hello.so';
and run the command :
mysql> select hello ('test');
+--------------------------------+
| hello ('test') |
+--------------------------------+
| 0x48656C6C6F2074657374 |
+--------------------------------+
1 row in set (0,00 sec)
the result is shown in Hex format, does any one know why and how can I show the result in varchar not hex?