After sending my earlier email regarding compress_gz()/uncompress_gz() in
mysqld, I discovered user defined functions -- something I had never used
in mysqld until today.

So, I took a couple of hours and wrote a Mysql UDF to do what I requested:

# gcc -shared -DMYSQL_SERVER -DDEFAULT_MYSQL_HOME="\"/usr/local/mysql\"" 
-DDATADIR="\"/usr/local/mysql/var\"" -DSHAREDIR="\"/usr/local/mysql/share/mysql\"" 
-DHAVE_CONFIG_H -I./../include -I./../regex -I. -I../include -I.. -I. 
-I/usr/local/mysql/include -O3 -DDBUG_OFF -export-dynamic -fPIC 
-fno-implicit-templates -o mysqld_udf_zlib.so mysqld_udf_zlib.cc /usr/lib/libz.a

# cp ./mysqld_udf_zlib.so /usr/lib; ldconfig 

# mysql mysql
mysql> CREATE FUNCTION compress_gz RETURNS STRING SONAME "mysqld_udf_zlib.so"; CREATE 
FUNCTION uncompress_gz RETURNS STRING SONAME "mysqld_udf_zlib.so";
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)

mysql> select compress_gz('lester');
+-----------------------+
| compress_gz('lester') |
+-----------------------+
| xËI-.I-a             |
+-----------------------+
1 row in set (0.00 sec)

mysql> select uncompress_gz(compress_gz('lester'));
+--------------------------------------+
| uncompress_gz(compress_gz('lester')) |
+--------------------------------------+
| lester                               |
+--------------------------------------+
1 row in set (0.01 sec)

mysql> drop function compress_gz; drop function uncompress_gz;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)



It is late and I am going home for the evening.  Tomorrow I will review
the code carefully, clean it up a bit, comment it well, and will then be
happy to contribute it to MySQL AB, if you guys are interested in having
it in the contributed software page.  Is there a procedure for contribing
the code to you guys, or just email it to the mysql list, or what?

-- 
Lester H. Hightower                                       TheAIMSGroup.com
Chief Technology Officer
The Advanced Integrated Management Solutions Group


---------------------------------------------------------------------
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

Reply via email to