1. MySQL UDFs
- Posted by Bryce Byrd <nevrgivup at sbcglob?l.?et> Oct 17, 2007
- 567 views
- Last edited Oct 18, 2007
I haven't coded in Euphoria for years now and when I did I didn't really to all that much. I know that Euphoria programs can be converted into C++ and compiled into DLL's. I don't know if any of you are familiar with MySQL UDFs but they are essentialy DLL's with C calling conventions that can be plugged into a MySQL server. To use them the signature of the DLL has to meet stringent criteria, how well can one control the signature of the created DLL? I've written and successfully used them in C++ but I'm not very familiar with it and the learning curve is abhoring. Thank you in advance for any assistance you may render to to me.
2. Re: MySQL UDFs
- Posted by Matt Lewis <matthewwalkerlewis at g?ail.c?m> Oct 18, 2007
- 530 views
Bryce Byrd wrote: > > I haven't coded in Euphoria for years now and when I did I didn't really to > all that much. > > I know that Euphoria programs can be converted into C++ and compiled > into DLL's. > > I don't know if any of you are familiar with MySQL UDFs but they are > essentialy DLL's with C calling conventions that can be plugged into > a MySQL server. The short answer is that you should be able to do this. If you want to write Euphoria routines that are the actual interface (i.e., not write some hand coded C routines that call your translated euphoria routines), you will probably need this: http://www.rapideuphoria.com/32bits.zip It will allow you to take full 32-bit ints as parameters (as in, pointers). You may also need to alter return values, if you have to return any pointers. The basic problem is that instead of a normal 32-bit integer, you may end up returning an atom that is really a double in disguise, because the value has out grown the euphoria 30-bit integer. I'm not familiar with the interface requirements for MySQL UDTs, so I can't say whether or not you'll need this. It's not difficult to do, but will require some hand editing of the translated code. This is probably the easiest way to get to where you're trying to go. Another alternative is to wrap your euphoria functions with a hand coded C interface that converts 32-bit integers that have overflowed the euphoria 30-bit integers. I do this a lot in wxEuphoria, and use this function: static object box_int( int x ) { if(x > NOVALUE && x < TOO_BIG_INT) return (object) x; else return (object)NewDouble((double)x); } You'll note that similar code is used in my 32-bit helper code. > To use them the signature of the DLL has to meet stringent criteria, > how well can one control the signature of the created DLL? You can control it completely. The exact method for doing so depends upon which compiler you're using, but generally, it may require editing some files output by the translator. Juergen has a helper app that might help you with some of this (windows only): http://www.rapideuphoria.com/ecwr.zip > I've written and successfully used them in C++ but I'm not very familiar > with it and the learning curve is abhoring. > > Thank you in advance for any assistance you may render to to me. One downside of doing this in euphoria instead of C is that you lose the structured data features of C, and have to do it all by hand. I'd recommend using a structure library. My preferred library is the one that win32lib uses (it's actually cross platform). Take a look at w32memory.ew. Matt