summaryrefslogtreecommitdiff
path: root/sql/udf_example.c
diff options
context:
space:
mode:
Diffstat (limited to 'sql/udf_example.c')
-rw-r--r--sql/udf_example.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/sql/udf_example.c b/sql/udf_example.c
index d37c6505ced..6c07a929b04 100644
--- a/sql/udf_example.c
+++ b/sql/udf_example.c
@@ -130,7 +130,8 @@ typedef long long longlong;
#include <m_string.h> /* To get strmov() */
#else
/* when compiled as standalone */
-#define strmov(a,b) strcpy(a,b)
+#include <string.h>
+#define strmov(a,b) stpcpy(a,b)
#define bzero(a,b) memset(a,0,b)
#define memcpy_fixed(a,b,c) memcpy(a,b,c)
#endif
@@ -1105,4 +1106,39 @@ char * is_const(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)),
}
+my_bool check_const_len_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
+{
+ if (args->arg_count != 1)
+ {
+ strmov(message, "IS_CONST accepts only one argument");
+ return 1;
+ }
+ if (args->args[0] == 0)
+ {
+ initid->ptr= (char*)"Not constant";
+ }
+ else if(strlen(args->args[0]) == args->lengths[0])
+ {
+ initid->ptr= (char*)"Correct length";
+ }
+ else
+ {
+ initid->ptr= (char*)"Wrong length";
+ }
+ initid->max_length = 100;
+ return 0;
+}
+
+char * check_const_len(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)),
+ char *result, unsigned long *length,
+ char *is_null, char *error __attribute__((unused)))
+{
+ strmov(result, initid->ptr);
+ *length= strlen(result);
+ *is_null= 0;
+ return result;
+}
+
+
+
#endif /* HAVE_DLOPEN */