Mysql UDF
HI! I wrote a mysql UDF that works well in older versions of mysql (3.23.*) but the same is not working for new versions like (4.0*) . The server restarts every time i invoke my function . I also compiled and linked with libmysqlclient.so.11, but still the problem persists. how to solve the problem, kindly help me. ___ WIN FREE WORLDWIDE FLIGHTS - nominate a cafe in the Yahoo! Mail Internet Cafe Awards www.yahoo.co.uk/internetcafes -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
mysql UDF in windows
i find problem while compiling the UDF in windows. the function returns an integer and so i set the type as long long but this datatype is not recognised by VC++ 6.0 and i end up with a compilation error. how can i resolve this and what the prototype for functions that returns integer values. i searched the manual but got no solution. - Download Yahoo! Messenger now for a chance to WIN Robbie Williams Live At Knebworth DVD
Re: mysql UDF in windows
At 11:45 4/12/2003 +, Prem Soman wrote: Hi, how can i resolve this and what the prototype for functions that returns integer values. i searched the manual but got no solution. In the \sql\udf_example.cpp you find: #ifdef __WIN__ typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */ typedef __int64 longlong; #else typedef unsigned long long ulonglong; typedef long long longlong; #endif /*__WIN__*/ #else -- Regards, For technical support contracts, visit https://order.mysql.com/ Are you MySQL certified?, http://www.mysql.com/certification/ Miguel Angel Solórzano [EMAIL PROTECTED] São Paulo - Brazil --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
MySql UDF under WIN32
Hi, I finally could get MySql UDF functions to work under win32 (VC++). The only thing that concerns me is that it nevers returns any error message. It works fine, but none error message is displayed. The function expects 2 strings, if one, more or none is passed, I should get the error message Wrong arguments to rateStrings, but I dont, seems like rateString_init() doesn't get called at all. Any help will be appreciated. Please see a sample code: my_bool rateStrings_init(UDF_INIT *initid, UDF_ARGS *args, char *message); void rateStrings_deinit(UDF_INIT *initid); double rateStrings(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error); my_bool rateStrings_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { if (args-arg_count != 2 || args-arg_type[0] != STRING_RESULT || args-arg_type[1] != STRING_RESULT) { strcpy(message,Wrong arguments to rateStrings; Use the source); return 1; } return 0; } void rateStrings_deinit(UDF_INIT *initid) { } double rateStrings(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error) { double r; long l1, l2; char* tmpStr1; char* tmpStr2; if (args-args[0] == NULL || args-args[1] == NULL) { *is_null = 1; *error = 1; return 0; } l1 = strlen(args-args[0]); l2 = strlen(args-args[1]); tmpStr1 = new char[l1+1]; tmpStr2 = new char[l2+1]; strcpy(tmpStr1, args-args[0]); strcpy(tmpStr2, args-args[1]); tmpStr1[l1] = '\0'; tmpStr2[l2] = '\0'; char* sourceStr1 = tmpStr1; char* sourceStr2 = tmpStr2; while(*sourceStr1) *sourceStr1++ = toupper(*sourceStr1); while(*sourceStr2) *sourceStr2++ = toupper(*sourceStr2); if (l1 == 0 || l2 == 0) return 0; if (strcmp(tmpStr1, tmpStr2) == 0) return 1; r = (double)subSim(1, l1, 1, l2, tmpStr1, tmpStr2) / (l1 + l2) * 2; //subSim is not included in this message. delete[] tmpStr1; delete[] tmpStr2; return r; } Regards, Fabian von Romberg _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: MySQL UDF questions
On Thursday, 11. April 2002 02:11, Fei Chen wrote: How do I write a UDF to handle a entire tuple, e.g. is it possible to have select my_udf(*) from myTable; ? Parmeters in the UDF could also be fields from a table. Also, is there a way for a UDF to return a data structure, say, a multi dimensional array? Or do I need to write some stringify function for the UDF to return? UDF functions can return STRING (char *), INTEGER (long) OR REAL (double). Please read the Manual: http://www.mysql.com/doc/A/d/Adding_UDF.html Regards Georg - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: MySQL UDF questions
Dear Georg, Thanks for replying. I have read the mysql manual but unfortunately have not been able to find the answer. I realize UDFs can have field names as their parameters, as in select my_udf(fld1, fld2, fld10) from myTable; but here the field names have to be specified explicitly. What I'm wondering is there a shortcut way to specify all the fields from myTable, using the * notation. Just as normally I can say select * from myTable; can I write a UDF to handle select my_udf(*) from myTable; ? There is the builtin function select count(*) from myTable; But the manual does not say how this is to be accomplished using UDFs. UDF functions can return STRING (char *), INTEGER (long) OR REAL (double). Please read the Manual: http://www.mysql.com/doc/A/d/Adding_UDF.html Indeed UDFs can return (char *), but my question is, is there a way to return an array of intergers (int *)? or some more complicated structure, say, (myStruct *)? If UDFs are limited to returning (char*), (long) or (double), does that mean the only way out is to turn (myStruct*) into some kind of string and return it as (char*)? Thanks a lot, fei - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: MySQL UDF questions
On Thursday, 11. April 2002 10:26, Fei Chen wrote: Dear Georg, * notation. Just as normally I can say select * from myTable; can I write a UDF to handle select my_udf(*) from myTable; ? There is the builtin function select count(*) from myTable; But the manual does not say how this is to be accomplished using UDFs. No, the udf is outside from mysql in a shared library. So the udf doesn't know anything about the used table(s) and his fields. When you want functionallity like count, you have to write an aggregate udf. The diffrence between a normal udf and a aggregate udf is that _reset and _add functions will be called for first row/each row. Indeed UDFs can return (char *), but my question is, is there a way to return an array of intergers (int *)? or some more complicated structure, say, (myStruct *)? If UDFs are limited to returning (char*), (long) or (double), does that mean the only way out is to turn (myStruct*) into some kind of string and return it as (char*)? An user defined function (udf) is not a api-function. It would make no sense to return other values, or a structure. What output should be displayed, when udf would return a structure? SELECT UDF(foo); Regards Georg mysql, query - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
MySQL UDF questions
Dear all, I'm new to writing UDFs in MySQL so please bear with my couple of questions. How do I write a UDF to handle a entire tuple, e.g. is it possible to have select my_udf(*) from myTable; ? Also, is there a way for a UDF to return a data structure, say, a multi dimensional array? Or do I need to write some stringify function for the UDF to return? Thanks for any tips, Cheers, fei - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php