From ee54f3ac61946ddc9acd6a3344d664cac10388c0 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 18 May 2017 13:58:54 +0300 Subject: [PATCH] MXS-1196: Hide implicit translations The embedded library, when used in Oracle mode, reports the use of "concat" as "concat_operator_oracle" and the use of "decode" as "case. --- .../qc_mysqlembedded/qc_mysqlembedded.cc | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc index 69dc531da..0dc369c5e 100644 --- a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc +++ b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc @@ -95,6 +95,49 @@ typedef struct parsing_info_st #endif } parsing_info_t; +/** + * Defines what a particular name should be mapped to. + */ +typedef struct name_mapping +{ + const char* from; + const char* to; +} NAME_MAPPING; + +static NAME_MAPPING function_name_mappings_default[] = +{ + { NULL, NULL } +}; + +static NAME_MAPPING function_name_mappings_oracle[] = +{ + { "concat_operator_oracle", "concat" }, + { "case", "decode" }, + { NULL, NULL } +}; + +static NAME_MAPPING* function_name_mappings = function_name_mappings_default; + +static const char* map_function_name(const char* from) +{ + NAME_MAPPING* map = function_name_mappings; + const char* to = NULL; + + while (!to && map->from) + { + if (strcasecmp(from, map->from) == 0) + { + to = map->to; + } + else + { + ++map; + } + } + + return to ? to : from; +} + #define QTYPE_LESS_RESTRICTIVE_THAN_WRITE(t) (t