/* Copyright ?1998 by Nem W Schlecht This file is public domain and comes with NO WARRANTY of any kind MySQL SQL code for creating/deleting this function in the 'mysql' database: CREATE FUNCTION square RETURNS INTEGER SONAME "int_example.so"; DROP FUNCTION square; Compile line: CC -DMYSQL_SERVER -DDEFAULT_MYSQL_HOME="\"/local/mysql\"" -DDATADIR="\"/local/mysql/var\"" -DSHAREDIR="\"/local/mysql/share/mysql\"" -DHAVE_CONFIG_H -DUSE_ALARM_THREAD -O3 -DDBUG_OFF -I/local/mysql/include/mysql -I/local/src/SQL/mysql-3.22.4-beta/include -I/local/src/SQL/mysql-3.22.4-beta -shared -o int_example.so int_example.cc */ #include <global.h> #include <my_sys.h> #include <mysql.h> #include <m_ctype.h> #ifdef HAVE_DLOPEN extern "C" { // The initialization function proto. my_bool square_init(UDF_INIT *initid, UDF_ARGS *args, char *message); // The de-initialzition function proto. void square_deinit(UDF_INIT *initid); // The actual function proto. longlong square(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error); } // // Initialization function - make sure correct number of arguments are passed // and that the argument is an integer value my_bool square_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { if (args->arg_count != 1 || args->arg_type[0] != INT_RESULT) { strcpy(message,"Wrong arguments to square"); return 1; } initid->maybe_null = 0; return 0; } // // De-initialization function - nothing spectial void square_deinit(UDF_INIT *initid) { } // // 'square' function. Returns the square of the integer passed to it in the // args structure long long square(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error) { int number = *((long long*) args->args[0]); return number*number; } #endif /* HAVE_DLOPEN */
소스 삽입하는 방법 정말 좋네요. 원래의 기본적인 텍스트 입력 부분과는 아예 동떨어진 부분으로 입력을 받는군요. 환상적으로 만들어 두었네 -.-;;;
영봉이 요즘 어케 살고 있는지. 또 잠수네...