Hello.
>When attempting to load a new function with the mysql cli client the >client >complains that the server has gone away and reconnects with connection Check MySQL error log, server could die while loading the UDF. Stored procedures appeared only in 5 version. This works fine for me on 5.0.7. mysql> create function hello (s char(20)) returns char(50) RETURN CONCAT('Hello, ',s,'!');// Query OK, 0 rows affected (0.00 sec) Nic Stevens <[EMAIL PROTECTED]> wrote: >Hello, > >I'm trying to build a UDF for MySQL 4.1.12. I'm running on Linux >(FedoraFC1). My UDF function seemed to blow up the server so I went to >the >source and tried to build udf_example.cc. > >Using the precompiled binaries for Linux and using the source >distribution >for the same version (4.1.12) I was unable to build udf_example.cc as a >shared object (I followed the instructions in the source -- they didnt >work >so I used what seemed to make the most sense for building my object). >When >building the shared object the compiler spits out a warning from >asm/atomic.h (#warning Using kernel header in userland program. BAD!) > >I'm using gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1) on a >Fedore >Core 1 machine. I built the shared object with gcc -I/usr/include/mysql >-shared -o udf_example.so udf_example.cc > >When attempting to load a new function with the mysql cli client the >client >complains that the server has gone away and reconnects with connection >id of >1. Nothing is listed in mysql.funcs either. > >There needs to be better documentation of the process for building >UDF's. > >The code I need to run can be run nicely by MySQL but I can't declare a >stored function as documented. The stored function is fairly simple: > >DELIMITER // > >CREATE FUNCTION distance(z1 VARCHAR(10), z2 VARCHAR(10)) RETURNS REAL >BEGIN >DECLARE x REAL; >DECLARE y REAL; >DECALRE miles REAL; >SET x = 69.1*(lat - lat2); >SET y = 69.1*(lon1 - lon2) * COS(lon1*57.3); >SET miles = SQRT(x*x+y*y); >RETURN miles; >END >// > >The mysql client spits back : >ERROR 1064 (42000): You have an error in your SQL syntax; check the >manual >that corresponds to your MySQL server version for the right syntax to >use >near '(z1 VARCHAR(10), z2 VARCHAR(10)) RETURNS REAL > >Using the example given in the documentation I get: > >mysql> CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50) >-> RETURN CONCAT('Hello, ',s,'!'); >ERROR 1064 (42000): You have an error in your SQL syntax; check the >manual >that corresponds to your MySQL server version for the right syntax to >use >near '(s CHAR(20)) RETURNS CHAR(50) >RETURN CONCAT('Hello, ',s,'!')' at line 1 > > >DELIMITER ; >// > >Can someone elucidate the mystery of either stored functions or UDF's? -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.NET http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Gleb Paharenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.NET <___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]