Jeremy Zawodny wrote:

On Tue, Aug 12, 2003 at 02:32:00PM +0800, Ariz Jacinto wrote:


i've created a simple UDF (for testing) that returns a string.
my problem is that the string that it returns, contain some
of the characters of  the  longest string in the column.

example:

Table
+-----------------+
|        name       |
+-----------------+
| hello world   |
| goodbye        |
+-----------------+


mysql> select echo(name) from table;


   hello world
   goodbyerld        <---- ???

*How do i fix this???



Maybe you can post the code and we'll help you fix it.




as you can see from my code, i'm trying to study on how to make my own
UDF coz i'm going to migrate our postgresql UDFs to MySQL...

any tips/link to tutorials will be highly appreciated....




--- code ------------------------------------------------------------------------------------------------------



#include <my_global.h> #include <my_sys.h> #include <mysql.h> #include <m_ctype.h>

my_bool echo_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
void echo_deinit(UDF_INIT *initid);
extern "C" __declspec(dllexport) char *echo(UDF_INIT *initid, UDF_ARGS *args, char 
*is_null, char *error);



my_bool echo_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
if (args->arg_count != 1 || args->arg_type[0] != STRING_RESULT) {
strcpy(message,"Wrong argument type");
return 1;
}


initid->maybe_null = 0;

 return 0;
}


void echo_deinit(UDF_INIT *initid) { }


extern "C" __declspec(dllexport) char *echo(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error) { return args->args[0]; }


--- code ------------------------------------------------------------------------------------------------------






--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to