MXS-1196: Recognize builtin Oracle functions

This commit is contained in:
Johan Wikman
2017-05-18 11:49:27 +03:00
parent 1d2ca5cde7
commit a5637a311c
3 changed files with 19 additions and 3 deletions

View File

@ -368,6 +368,16 @@ static const char* BUILTIN_FUNCTIONS[] =
const size_t N_BUILTIN_FUNCTIONS = sizeof(BUILTIN_FUNCTIONS) / sizeof(BUILTIN_FUNCTIONS[0]);
static const char* ORACLE_FUNCTIONS[] =
{
"nvl",
"nvl2"
};
const size_t N_ORACLE_FUNCTIONS = sizeof(ORACLE_FUNCTIONS) / sizeof(ORACLE_FUNCTIONS[0]);
// NOTE: sort_compare and search_compare are not identical, so don't
// NOTE: optimize either of them away.
static int sort_compare(const void* key, const void* value)
@ -389,6 +399,7 @@ void init_builtin_functions()
ss_dassert(!unit.inited);
qsort(BUILTIN_FUNCTIONS, N_BUILTIN_FUNCTIONS, sizeof(char*), sort_compare);
qsort(ORACLE_FUNCTIONS, N_ORACLE_FUNCTIONS, sizeof(char*), sort_compare);
unit.inited = true;
}
@ -399,11 +410,16 @@ void finish_builtin_functions()
unit.inited = false;
}
bool is_builtin_readonly_function(const char* key)
bool is_builtin_readonly_function(const char* key, bool check_oracle)
{
ss_dassert(unit.inited);
char* value = bsearch(key, BUILTIN_FUNCTIONS, N_BUILTIN_FUNCTIONS, sizeof(char*), search_compare);
if (!value && check_oracle)
{
value = bsearch(key, ORACLE_FUNCTIONS, N_ORACLE_FUNCTIONS, sizeof(char*), search_compare);
}
return value ? true : false;
}