From 5884aa15d40b4dcc6de5cbcf276200c5fcbac938 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 6 Nov 2016 14:57:27 +0100 Subject: - Fix MDEV-11234. Escape quoting character. Should be doubled. Now it is also possible to escape it by a backslash. modified: storage/connect/tabfmt.cpp - Prepare making VEC table type support conditional. VEC tables might be unsupported in future versions modified: storage/connect/CMakeLists.txt modified: storage/connect/mycat.cc modified: storage/connect/reldef.cpp modified: storage/connect/xindex.cpp - MDEV-11067 suggested to add configuration support to the Apache wrapper. Was added but commented out until prooved it is really useful. modified: storage/connect/ApacheInterface.java modified: storage/connect/ha_connect.cc modified: storage/connect/jdbccat.h modified: storage/connect/jdbconn.cpp modified: storage/connect/jdbconn.h modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabjdbc.h - Remove useless members. modified: storage/connect/jdbconn.cpp modified: storage/connect/jdbconn.h - New UDF countin. modified: storage/connect/jsonudf.cpp modified: storage/connect/jsonudf.h --- storage/connect/jsonudf.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'storage/connect/jsonudf.cpp') diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 8bddc68e2ae..f9034f25739 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -5264,3 +5264,50 @@ char *envar(UDF_INIT *initid, UDF_ARGS *args, char *result, return str; } // end of envar +/*********************************************************************************/ +/* Returns the distinct number of B occurences in A. */ +/*********************************************************************************/ +my_bool countin_init(UDF_INIT *initid, UDF_ARGS *args, char *message) +{ + if (args->arg_count != 2) { + strcpy(message, "This function must have 2 arguments"); + return true; + } else if (args->arg_type[0] != STRING_RESULT) { + strcpy(message, "First argument must be string"); + return true; + } else if (args->arg_type[1] != STRING_RESULT) { + strcpy(message, "Second argument is not a string"); + return true; + } // endif args + + return false; +} // end of countin_init + +long long countin(UDF_INIT *initid, UDF_ARGS *args, char *result, + unsigned long *res_length, char *is_null, char *) +{ + PSZ str1, str2; + char *s; + long long n = 0; + size_t lg; + + lg = (size_t)args->lengths[0]; + s = str1 = (PSZ)malloc(lg + 1); + memcpy(str1, args->args[0], lg); + str1[lg] = 0; + + lg = (size_t)args->lengths[1]; + str2 = (PSZ)malloc(lg + 1); + memcpy(str2, args->args[1], lg); + str2[lg] = 0; + + while (s = strstr(s, str2)) { + n++; + s += lg; + } // endwhile + + free(str1); + free(str2); + return n; +} // end of countin + -- cgit v1.2.1