#ifdef STANDARD # include # include # ifdef __WIN__ typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */ typedef __int64 longlong; # else typedef unsigned long long ulonglong; typedef long long longlong; # endif /*__WIN__*/ #else # include # include #endif #include #include #include // To get strmov() /* These must be right or mysqld will not find the symbol! */ extern "C" { my_bool bug_init (UDF_INIT* initid, UDF_ARGS* args, char* message); void bug_deinit (UDF_INIT* initid); char* bug_clear (UDF_INIT* initid, char* is_null, char* error); void bug_add (UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error); char* bug (UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length, char* is_null, char* error); } my_bool bug_init( UDF_INIT* initid, UDF_ARGS* args, char* message ) { if (args->arg_count != 1) { strcpy( message, "wrong number of arguments: BUG() requires one argument" ); return 1; } if (args->arg_type[0] != INT_RESULT) { strcpy( message, "wrong argument type: BUG() requires an INT argument" ); return 1; } initid->max_length = 255; return 0; } void bug_deinit( UDF_INIT* initid ) { } char* bug_clear(UDF_INIT* initid, char* is_null, char* message) { *is_null = 0; return NULL; } void bug_add(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* message ) { *is_null = 0; } char* bug(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length, char* is_null, char* error) { *length = 2; *is_null = 0; *error = 0; sprintf(result, "42"); result[2] = '\0'; return result; }