Median-udf in mysql : Step By Step Installation And Problem Fixes For Installing My Sql Udf - Presentation Transcript
My step by step installation and problem fixes of MySQL
Statistical UDF – Median.
Hi, Following is a kind of snap shot / steps I executed on my linux-
ubuntu box to get the Median UDF working on MySQL 5.0.
I faced approx 3 minor errors which I got resolved, they ‘re also
included in steps.
root@krex:~/mysqludf# wget
http://www.mooreds.com/files/mysql-udf-patched.tar.gz
root@krex:~/mysqludf# ls
mysql-udf-patched.tar.gz
root@krex:~/mysqludf# tar -xzf mysql-udf-patched.tar.gz
root@krex:~/mysqludf# cd mysql-udf/
root@krex:~/mysqludf/mysql-udf# ls
udf_colwidth.cc udf_correlation.cc udf_intercept.cc
udf_median.cc udf_slope.cc udf_weightedavg.cc
udf_confidence_higher.cc udf_faculty.cc udf_kurtosis.cc
udf_noverm.cc udf_stdnorm_density.cc
udf_confidence_lower.cc udf_geomean.cc udf_longest.cc
udf_skewness.cc udf_stdnorm_dist.cc
root@krex:~/mysqludf/mysql-udf# gcc -shared -lstdc++ -I
/usr/include -I /usr/local/include -I /usr/local/mysql/include/ -o
udf_median.so udf_median.cc
udf_median.cc:31:23: error: my_global.h: No such file or directory
udf_median.cc:32:20: error: my_sys.h: No such file or directory
udf_median.cc:34:19: error: mysql.h: No such file or directory
udf_median.cc:35:21: error: m_ctype.h: No such file or directory
udf_median.cc:36:24: error: m_string.h: No such file or directory
root@krex:~/mysqludf/mysql-udf# locate my_global.h
/opt/lampp/include/mysql/my_global.h
root@krex:~/mysqludf/mysql-udf# gcc -shared -lstdc++ -I
/usr/include -I /usr/local/include -I /opt/lampp/include/ -I
/opt/lampp/include/mysql/ -o udf_median.so udf_median.cc
In file included from udf_median.cc:31:
/opt/lampp/include/mysql/my_global.h:353:24: error: asm/atomic.h:
No such file or directory
root@krex:~/mysqludf/mysql-udf# locate atomic.h
/opt/lampp/include/atomic.h
root@krex:~/mysqludf/mysql-udf# mkdir
/opt/lampp/include/asm
root@krex:~/mysqludf/mysql-udf# cp
/opt/lampp/include/atomic.h /opt/lampp/include/asm/
root@krex:~/mysqludf/mysql-udf# gcc -shared -lstdc++ -I
/usr/include -I /usr/local/include -I /opt/lampp/include/ -I
/opt/lampp/include/mysql/ -o udf_median.so udf_median.cc
/usr/bin/ld: /tmp/ccimPFiX.o: relocation R_X86_64_32 against
`compare_doubles(void const*, void const*)' can not be used when
making a shared object; recompile with -fPIC
/tmp/ccimPFiX.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
root@krex:~/mysqludf/mysql-udf# uname -a
Linux xeon-01 2.6.20-15-generic #2 SMP Sun Apr 15 06:17:24 UTC
2007 x86_64 GNU/Linux
root@krex:~/mysqludf/mysql-udf# gcc -shared -fPIC -lstdc++ -I
/usr/include -I /usr/local/include -I /opt/lampp/include/ -I
/opt/lampp/include/mysql/ -o udf_median.so udf_median.cc
root@krex:~/mysqludf/mysql-udf# ls
udf_colwidth.cc udf_correlation.cc udf_intercept.cc
udf_median.cc udf_skewness.cc udf_stdnorm_dist.cc
udf_confidence_higher.cc udf_faculty.cc udf_kurtosis.cc
udf_median.so udf_slope.cc udf_weightedavg.cc
udf_confidence_lower.cc udf_geomean.cc udf_longest.cc
udf_noverm.cc udf_stdnorm_density.cc
root@krex:~/mysqludf/mysql-udf# cp udf_median.so /usr/lib/
root@krex:~/mysqludf/mysql-udf# mysql -uiconmans -picopals
test
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection id is 84928
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.
mysql> create aggregate function median returns real soname
'udf_median.so';
Query OK, 0 rows affected (0.04 sec)
mysql> select median(SalePrice) from DB.Table_Name;
+-------------------+
| median(SalePrice) |
+-------------------+
| 262000.00 |
+-------------------+
1 row in set (2.49 sec)
Voila…. Installation finished !!! Now its easy enough to obtain median!
http://kedar.nitty-witty.com
0 comments
Post a comment