MCPcopy Create free account
hub / github.com/MariaDB/server / parse_optimizer_hints

Method parse_optimizer_hints

sql/sql_lex.cc:13982–14016  ·  view source on GitHub ↗

Parse optimizer hints and return as Hint_list allocated on thd->mem_root. The caller should check both parts of the return value to know what happened, as follows: Retval.first Retval.second Meaning ------------ --------------- ------- false != nullptr the hints were parsed without errors true != nullptr impossible combination false =

Source from the content-addressed store, hash-verified

13980 true == nullptr fatal error, such as EOM
13981*/
13982std::pair<bool, Optimizer_hint_parser_output *>
13983LEX::parse_optimizer_hints(const Lex_comment_st &hints_str)
13984{
13985 DBUG_ASSERT(!hints_str.str || hints_str.length >= 5);
13986 if (!hints_str.str)
13987 return {false, nullptr}; // There were no a hint comment
13988
13989 // Instantiate the query hint parser.
13990 // Remove the leading '/*+' and trailing '*/'
13991 // when passing hints to the parser.
13992 Optimizer_hint_parser p(thd, thd->charset(),
13993 Lex_cstring(hints_str.str + 3, hints_str.length - 5));
13994 // Parse hints
13995 Optimizer_hint_parser_output hints(&p);
13996 DBUG_ASSERT(!p.is_error() || !hints);
13997
13998 if (p.is_fatal_error())
13999 {
14000 /*
14001 Fatal error (e.g. EOM), have the caller fail.
14002 The SQL error should be in DA already.
14003 */
14004 DBUG_ASSERT(thd->is_error());
14005 return {true, nullptr}; // Set the flag of fatal error
14006 }
14007
14008 if (!hints) // Hint parsing failed with a syntax error
14009 {
14010 p.push_warning_syntax_error(thd, hints_str.lineno);
14011 return {false, nullptr}; // Continue and ignore hints.
14012 }
14013
14014 // Hints were not empty and were parsed without errors
14015 return {false, new (thd->mem_root) Optimizer_hint_parser_output(std::move(hints))};
14016}
14017
14018
14019/*

Callers

nothing calls this directly

Calls 5

Lex_cstringClass · 0.85
charsetMethod · 0.45
is_errorMethod · 0.45
is_fatal_errorMethod · 0.45

Tested by

no test coverage detected