├── .gitattributes ├── .gitignore ├── README.md ├── install.sh ├── lib_mysqludf_redis.sql ├── lib_mysqludf_redis_drop.sql ├── src ├── Makefile ├── lib_mysqludf_redis.c ├── utils.c └── utils.h ├── test ├── create_query.php ├── create_sql.php └── test_trigger.sql └── uninstall.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | 66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 67 | #packages/ 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper* 82 | 83 | # Installshield output folder 84 | [Ee]xpress 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish 98 | 99 | # Others 100 | [Bb]in 101 | [Oo]bj 102 | sql 103 | TestResults 104 | *.Cache 105 | ClientBin 106 | stylecop.* 107 | ~$* 108 | *.dbmdl 109 | Generated_Code #added for RIA/Silverlight projects 110 | 111 | # Backup & report files from converting an old project file to a newer 112 | # Visual Studio version. Backup files are not needed, because we have git ;-) 113 | _UpgradeReport_Files/ 114 | Backup*/ 115 | UpgradeLog*.XML 116 | 117 | 118 | 119 | ############ 120 | ## Windows 121 | ############ 122 | 123 | # Windows image file caches 124 | Thumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | 130 | ############# 131 | ## Python 132 | ############# 133 | 134 | *.py[co] 135 | 136 | # Packages 137 | *.egg 138 | *.egg-info 139 | dist 140 | build 141 | eggs 142 | parts 143 | bin 144 | var 145 | sdist 146 | develop-eggs 147 | .installed.cfg 148 | 149 | # Installer logs 150 | pip-log.txt 151 | 152 | # Unit test / coverage reports 153 | .coverage 154 | .tox 155 | 156 | #Translations 157 | *.mo 158 | 159 | #Mr Developer 160 | .mr.developer.cfg 161 | 162 | # Mac crap 163 | .DS_Store 164 | 165 | # Temp file 166 | *~ 167 | *.*~ 168 | insert.sql 169 | 170 | # taglist/ctags file 171 | tags 172 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [MySQL2Redis][] 2 | =============== 3 | 4 | This is a [user-defined function (UDF) ][UDF] plugin for MySQL, which can 5 | provide some [redis][Redis] command support function 6 | to push data from MySQL to Redis. 7 | 8 | This application just test on CentOS 6.2(Final),MySQL Server 5.1 and 5.5. 9 | In a Dell Server PowerEdge R601 (CPU Xeon(R) E5506 * 8, 24GB Memory), 10 | about 3000 calls in a second. 11 | 12 | If you want to a thread-able solution, you can try this project of [dawnbreaks]. 13 | 14 | [UDF]: http://dev.mysql.com/doc/refman/5.1/en/adding-functions.html 15 | [Redis]: http://redis.io/ 16 | [dawnbreaks]: https://github.com/dawnbreaks/mysql2redis 17 | 18 | Requirements 19 | ------------ 20 | 21 | 1. [MySQL2Redis][mysql2redis] is built with [HiRedis][hiredis]. 22 | So, you should install the library first. 23 | 24 | 2. MySQL2Redis is a plugin for MySQL, with the UDF support, so 25 | the MySQL server you used must support this feacture. 26 | See the [UDF] for more information. 27 | 28 | [mysql2redis]: https://github.com/jackeylu/mysql2redis 29 | [hiredis]: https://github.com/antirez/hiredis 30 | 31 | Installation 32 | ------------- 33 | 34 | Use the ./install.sh script. 35 | 36 | Test 37 | ---- 38 | 39 | See the test directory. 40 | 41 | Uninstallation 42 | -------------- 43 | 44 | Using the uninstall.sh 45 | 46 | 47 | Notice 48 | -------------- 49 | When you do a lot of redis_command() calling in a short time, 50 | you may get a lot of error like this "Connection error on (xxxx/xxx): 51 | Cannot assign requested address" in the error log of MySQL Server. 52 | And, at the same time, you can see a lot of TIME_WAIT in the netstat command 53 | output. 54 | 55 | In this case, you can set the kernel parameters or try to modify the code in 56 | hiredis on socket operation (setsockopt() with SO_REUSEADDR). 57 | 58 | >vi /etc/sysctl.conf 59 | 60 | >net.ipv4.tcp_syncookies=1 61 | 62 | >net.ipv4.tcp_tw_reuse=1 63 | 64 | >net.ipv4.tcp_tw_recycle=1 65 | 66 | 67 | and /sbin/sysctl -p to make it be usefull. 68 | 69 | 70 | Support 71 | ------- 72 | 73 | You may ask for help and discuss various other issues on 74 | the ... and report bugs on the [bug tracker][]. 75 | 76 | [bug tracker]: http://github.com/jackeylu/mysql2redis/issues 77 | 78 | 79 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # lib_mysqludf_redis - a library with redis functions 3 | # 4 | # This library is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU Lesser General Public 6 | # License as published by the Free Software Foundation; either 7 | # version 2.1 of the License, or (at your option) any later version. 8 | # 9 | # This library is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # Lesser General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Lesser General Public 15 | # License along with this library; if not, write to the Free Software 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | 18 | echo "Compiling the MySQL UDF" 19 | cd src/ 20 | make 21 | 22 | if test $? -ne 0; then 23 | echo "ERROR: You need libmysqlclient development software installed " 24 | echo "to be able to compile this UDF, on Debian/Ubuntu just run:" 25 | echo "apt-get install libmysqlclient15-dev" 26 | exit 1 27 | else 28 | echo "MySQL UDF compiled successfully" 29 | fi 30 | 31 | echo -e "\nPlease provide your MySQL root password" 32 | read pwd 33 | echo -e "\nThe password for MySQL root your inputed is $pwd\n" 34 | 35 | cd ../ 36 | mysql -u root -p$pwd mysql < lib_mysqludf_redis.sql 37 | 38 | if test $? -ne 0; then 39 | echo "ERROR: unable to install the UDF" 40 | echo "Check the enviroment path of redis, hiredis, mysql and mysql-plugin" 41 | exit 1 42 | else 43 | echo "MySQL UDF installed successfully" 44 | fi 45 | -------------------------------------------------------------------------------- /lib_mysqludf_redis.sql: -------------------------------------------------------------------------------- 1 | /* 2 | This library is free software; you can redistribute it and/or 3 | modify it under the terms of the GNU Lesser General Public 4 | License as published by the Free Software Foundation; either 5 | version 2.1 of the License, or (at your option) any later version. 6 | 7 | This library is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | Lesser General Public License for more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with this library; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | 17 | DROP FUNCTION IF EXISTS lib_mysqludf_redis_info; 18 | DROP FUNCTION IF EXISTS redis_command; 19 | 20 | CREATE FUNCTION lib_mysqludf_redis_info RETURNS string SONAME 'lib_mysqludf_redis.so'; 21 | CREATE FUNCTION redis_command RETURNS int SONAME 'lib_mysqludf_redis.so'; 22 | -------------------------------------------------------------------------------- /lib_mysqludf_redis_drop.sql: -------------------------------------------------------------------------------- 1 | /* 2 | This library is free software; you can redistribute it and/or 3 | modify it under the terms of the GNU Lesser General Public 4 | License as published by the Free Software Foundation; either 5 | version 2.1 of the License, or (at your option) any later version. 6 | 7 | This library is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | Lesser General Public License for more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with this library; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | 17 | DROP FUNCTION IF EXISTS lib_mysqludf_redis_info; 18 | DROP FUNCTION IF EXISTS redis_command; 19 | 20 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | PLUGINDIR=`/usr/bin/mysql_config --plugindir` 2 | INCLUDE=`/usr/bin/mysql_config --include` -I/usr/local/include 3 | LIBS=-lhiredis -L$(PLUGINDIR) 4 | 5 | install: 6 | gcc -Werror -O2 $(INCLUDE) -I. -fPIC -shared -rdynamic lib_mysqludf_redis.c utils.c\ 7 | $(LIBS) -o $(PLUGINDIR)/lib_mysqludf_redis.so 8 | 9 | uninstall: 10 | rm -f $(PLUGINDIR)/lib_mysqludf_redis.so 11 | 12 | clean: 13 | rm -f *~ 14 | rm -f *.so 15 | rm -f *.out 16 | -------------------------------------------------------------------------------- /src/lib_mysqludf_redis.c: -------------------------------------------------------------------------------- 1 | /* 2 | This library is free software; you can redistribute it and/or 3 | modify it under the terms of the GNU Lesser General Public 4 | License as published by the Free Software Foundation; either 5 | version 2.1 of the License, or (at your option) any later version. 6 | 7 | This library is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | Lesser General Public License for more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with this library; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) 17 | #define DLLEXP __declspec(dllexport) 18 | #else 19 | #define DLLEXP 20 | #endif 21 | 22 | #ifdef STANDARD 23 | #include 24 | #include 25 | #include 26 | #ifdef __WIN__ 27 | typedef unsigned __int64 ulonglong; 28 | typedef __int64 longlong; 29 | #else 30 | typedef unsigned long long ulonglong; 31 | typedef long long longlong; 32 | #endif /*__WIN__*/ 33 | #else 34 | #include 35 | #include 36 | #endif 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #include 43 | 44 | /** 45 | * hiredis head file 46 | */ 47 | #include 48 | 49 | /* 50 | * self-defined head file 51 | */ 52 | #include "utils.h" 53 | 54 | 55 | #ifdef HAVE_DLOPEN 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | #define LIBVERSION "lib_mysqludf_redis version 0.0.1" 61 | 62 | #ifdef __WIN__ 63 | #define SETENV(name,value) SetEnvironmentVariable(name,value); 64 | #else 65 | #define SETENV(name,value) setenv(name,value,1); 66 | #endif 67 | 68 | DLLEXP 69 | my_bool lib_mysqludf_redis_info_init( 70 | UDF_INIT *initid, 71 | UDF_ARGS *args, 72 | char *message 73 | ); 74 | 75 | DLLEXP 76 | void lib_mysqludf_redis_info_deinit( 77 | UDF_INIT *initid 78 | ); 79 | 80 | DLLEXP 81 | char* lib_mysqludf_redis_info( 82 | UDF_INIT *initid, 83 | UDF_ARGS *args, 84 | char* result, 85 | unsigned long* length, 86 | char *is_null, 87 | char *error 88 | ); 89 | 90 | /** 91 | * redis_command 92 | * 93 | * execute a redis command 94 | */ 95 | DLLEXP 96 | my_bool redis_command_init( 97 | UDF_INIT *initid, 98 | UDF_ARGS *args, 99 | char *message 100 | ); 101 | 102 | 103 | DLLEXP 104 | void redis_command_deinit( 105 | UDF_INIT *initid 106 | ); 107 | 108 | DLLEXP 109 | my_ulonglong redis_command( 110 | UDF_INIT *initid, 111 | UDF_ARGS *args, 112 | char *is_null, 113 | char *error 114 | ); 115 | 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | 121 | /** 122 | * lib_mysqludf_redis_info 123 | */ 124 | my_bool lib_mysqludf_redis_info_init( 125 | UDF_INIT *initid __attribute__((__unused__)), 126 | UDF_ARGS *args, 127 | char *message) 128 | { 129 | my_bool status; 130 | if(args->arg_count!=0){ 131 | strcpy(message, 132 | "No arguments allowed (udf: lib_mysqludf_redis_info)" 133 | ); 134 | status = 1; 135 | } else { 136 | status = 0; 137 | } 138 | return status; 139 | } 140 | 141 | void lib_mysqludf_redis_info_deinit( 142 | UDF_INIT *initid __attribute__((__unused__)) 143 | ){ 144 | /** 145 | * empty function 146 | */ 147 | } 148 | 149 | char* lib_mysqludf_redis_info( 150 | UDF_INIT *initid __attribute__((__unused__)), 151 | UDF_ARGS *args __attribute__((__unused__)), 152 | char* result, 153 | unsigned long* length, 154 | char *is_null __attribute__((__unused__)), 155 | char *error __attribute__((__unused__))) 156 | { 157 | strcpy(result,LIBVERSION); 158 | *length = strlen(LIBVERSION); 159 | return result; 160 | } 161 | 162 | 163 | /** 164 | * redis_command implementation 165 | * 166 | * redis_command(host,port,command) 167 | * 168 | */ 169 | my_bool redis_command_init( 170 | UDF_INIT *initid __attribute__((__unused__)), 171 | UDF_ARGS *args, 172 | char *message) 173 | { 174 | if( (args->arg_count == 3 && 175 | args->arg_type[0]==STRING_RESULT && 176 | args->arg_type[1]==INT_RESULT && 177 | args->arg_type[2]==STRING_RESULT)|| 178 | (args->arg_count == 5 && 179 | args->arg_type[0]==STRING_RESULT && 180 | args->arg_type[1]==INT_RESULT && 181 | args->arg_type[2]==STRING_RESULT && 182 | args->arg_type[3]==STRING_RESULT && 183 | args->arg_type[4]==STRING_RESULT) 184 | ) 185 | { 186 | 187 | args->maybe_null = 0; // each parameter could not be NULL 188 | 189 | char *host = args->args[0]; 190 | unsigned long host_len = args->lengths[0]; 191 | long long port = *((long long*)args->args[1]); 192 | char *cmd = args->args[2]; 193 | 194 | if(!check_host(host) || !check_ip(host)) 195 | { 196 | snprintf(message,MYSQL_ERRMSG_SIZE, 197 | "The first parameter is not a valid host or ip address"); 198 | return 2; 199 | } 200 | 201 | if(port <= 0) 202 | { 203 | snprintf(message,MYSQL_ERRMSG_SIZE, 204 | "The second parameter must be an integer bigger than zero"); 205 | return 2; 206 | } 207 | 208 | if(strlen(cmd) <=0 || NULL == cmd) 209 | { 210 | snprintf(message,MYSQL_ERRMSG_SIZE, 211 | "The third parameter error,[%s]\n", 212 | cmd); 213 | return 2; 214 | } 215 | if (args->arg_count == 5) 216 | { 217 | if(strlen(args->args[3]) <= 0 218 | || NULL == args->args[3] 219 | ||strlen(args->args[4]) <= 0 220 | || NULL == args->args[4] 221 | ) 222 | { 223 | snprintf(message,MYSQL_ERRMSG_SIZE, 224 | "The fourth/fifth parameter error,[%s,%s]\n", 225 | args->args[3],args->args[4]); 226 | return 2; 227 | } 228 | } 229 | // everthing looks OK. 230 | return 0; 231 | 232 | } 233 | else { 234 | snprintf(message,MYSQL_ERRMSG_SIZE, 235 | "redis_command(host,port,command) Expected exactly 3 or 5 parameteres, a string, an integer and a string" ); 236 | return 1; 237 | } 238 | 239 | } 240 | void redis_command_deinit(UDF_INIT *initid __attribute__((__unused__))){ 241 | // nonthing need to be cleanup 242 | } 243 | /** 244 | * redis_command 245 | * 246 | * the implementation 247 | * 248 | * see the MySQL error log for the fprintf output 249 | * 250 | * @return 0 everything is OK 251 | * 1 connection error, check the host/port 252 | * 2 error with an NULL reply , it is so weird 253 | * 3 command may be not a valid command, or other error 254 | */ 255 | my_ulonglong redis_command( 256 | UDF_INIT *initid __attribute__((__unused__)), 257 | UDF_ARGS *args, 258 | char *is_null __attribute__((__unused__)), 259 | char *error __attribute__((__unused__))){ 260 | char *host = args->args[0]; 261 | long long port = *((long long*)args->args[1]); 262 | char *cmd = NULL; 263 | char *format = NULL; 264 | char *value1 = NULL; 265 | char *value2 = NULL; 266 | if (args->arg_count == 5) 267 | { 268 | format = args->args[2]; 269 | value1 = args->args[3]; 270 | value2 = args->args[4]; 271 | } 272 | else 273 | { 274 | cmd = args->args[2]; 275 | } 276 | 277 | // about the redis 278 | redisContext *c = NULL; 279 | redisReply *reply = NULL; 280 | 281 | c = redisConnect(host,port); 282 | if (c->err) 283 | { 284 | fprintf(stderr, 285 | "connection error on (%s/%ld): %s\n", 286 | host,port,c->errstr); 287 | 288 | redisFree(c); 289 | c = NULL; 290 | return 1; 291 | } 292 | 293 | if (args->arg_count == 3) 294 | { 295 | reply = redisCommand(c,cmd); 296 | } 297 | else if (args->arg_count == 5) 298 | { 299 | reply = redisCommand(c, format, value1, value2); 300 | } 301 | 302 | if(NULL == reply) 303 | { 304 | fprintf(stderr,"redisCommand %s,error: %s\n", 305 | cmd,c->errstr); 306 | redisFree(c); 307 | c = NULL; 308 | return 2; 309 | } 310 | 311 | 312 | if(REDIS_REPLY_ERROR==reply->type) 313 | { 314 | fprintf(stderr,"redisCommand \"%s\" reply error:%s\n", 315 | cmd,NULL == reply->str ? "NULL" : reply->str); 316 | freeReplyObject(reply); 317 | reply = NULL; 318 | redisFree(c); 319 | c = NULL; 320 | 321 | return 3; 322 | 323 | } 324 | 325 | // do the clean work 326 | freeReplyObject(reply); 327 | reply = NULL; 328 | redisFree(c); 329 | c = NULL; 330 | 331 | return 0; 332 | } 333 | 334 | 335 | 336 | #endif /* HAVE_DLOPEN */ 337 | -------------------------------------------------------------------------------- /src/utils.c: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | /** 4 | * check the parameter *host valid or not. 5 | * 6 | * Maybe, it is no need to do so 7 | */ 8 | unsigned int check_host(const char* host) 9 | { 10 | return 1; 11 | } 12 | 13 | /** 14 | * see check_host 15 | */ 16 | unsigned int check_ip(const char* ip) 17 | { 18 | return 1; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __UNTILS__H__ 2 | #define __UNTILS__H__ 3 | 4 | /** 5 | * check given string whether a valid host address 6 | * 7 | * @return 0 not a valid host address 8 | * 1 yes 9 | */ 10 | unsigned int check_host(const char* host); 11 | 12 | /** 13 | * check the given string whether a valid ip address 14 | * 15 | * @return 0 not a valid ip address 16 | * 1 yes 17 | */ 18 | unsigned int check_ip(const char*ip); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /test/create_query.php: -------------------------------------------------------------------------------- 1 | 19 | 20 | -------------------------------------------------------------------------------- /test/create_sql.php: -------------------------------------------------------------------------------- 1 | 16 | 17 | -------------------------------------------------------------------------------- /test/test_trigger.sql: -------------------------------------------------------------------------------- 1 | use test; 2 | 3 | DROP table IF EXISTS test2; 4 | 5 | CREATE TABLE test2(a1 INT,a2 INT); 6 | 7 | DROP TRIGGER IF EXISTS test2redisref; 8 | 9 | DELIMITER | 10 | create trigger test2redisref BEFORE INSERT on test2 11 | For EACH ROW BEGIN 12 | DECLARE done INT DEFAULT 999; 13 | set done = redis_command("127.0.0.1",6379,concat("lpush testkey ",cast(NEW.a1 as CHAR))); 14 | END; 15 | | 16 | DELIMITER ; 17 | 18 | -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # lib_mysqludf_redis - a library with redis functions 3 | # 4 | # This library is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU Lesser General Public 6 | # License as published by the Free Software Foundation; either 7 | # version 2.1 of the License, or (at your option) any later version. 8 | # 9 | # This library is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # Lesser General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Lesser General Public 15 | # License along with this library; if not, write to the Free Software 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | 18 | echo "uninstall the MySQL UDF plugin lib_mysqludf_redis" 19 | cd src/ 20 | make uninstall 21 | 22 | if test $? -ne 0; then 23 | echo "uninstalled error" 24 | exit 1 25 | else 26 | echo "MySQL UDF uninstalled successfully" 27 | fi 28 | 29 | cd ../ 30 | echo -e "\nPlease provide your MySQL root password" 31 | 32 | mysql -u root -p mysql < lib_mysqludf_redis_drop.sql 33 | 34 | if test $? -ne 0; then 35 | echo "ERROR: unable to uninstall the UDF" 36 | exit 1 37 | else 38 | echo "MySQL UDF uninstalled successfully" 39 | fi 40 | --------------------------------------------------------------------------------