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

Function parse_sql

sql/sql_parse.cc:10328–10427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10326*/
10327
10328bool parse_sql(THD *thd, Parser_state *parser_state,
10329 Object_creation_ctx *creation_ctx, bool do_pfs_digest)
10330{
10331 bool ret_value;
10332 DBUG_ENTER("parse_sql");
10333 DBUG_ASSERT(thd->m_parser_state == NULL);
10334 DBUG_ASSERT(thd->lex->m_sql_cmd == NULL);
10335
10336 MYSQL_QUERY_PARSE_START(thd->query());
10337 /* Backup creation context. */
10338
10339 Object_creation_ctx *backup_ctx= NULL;
10340
10341 if (creation_ctx)
10342 backup_ctx= creation_ctx->set_n_backup(thd);
10343
10344 /* Set parser state. */
10345
10346 thd->m_parser_state= parser_state;
10347
10348 parser_state->m_digest_psi= NULL;
10349 parser_state->m_lip.m_digest= NULL;
10350
10351 if (do_pfs_digest)
10352 {
10353 /* Start Digest */
10354 parser_state->m_digest_psi= MYSQL_DIGEST_START(thd->m_statement_psi);
10355
10356 if (parser_state->m_digest_psi != NULL)
10357 {
10358 /*
10359 If either:
10360 - the caller wants to compute a digest
10361 - the performance schema wants to compute a digest
10362 set the digest listener in the lexer.
10363 */
10364 parser_state->m_lip.m_digest= thd->m_digest;
10365 parser_state->m_lip.m_digest->m_digest_storage.m_charset_number= thd->charset()->number;
10366 }
10367 }
10368
10369 /* Parse the query. */
10370
10371 bool mysql_parse_status= thd->variables.sql_mode & MODE_ORACLE
10372 ? ORAparse(thd) : MYSQLparse(thd);
10373
10374 if (mysql_parse_status)
10375 /*
10376 Restore the original LEX if it was replaced when parsing
10377 a stored procedure. We must ensure that a parsing error
10378 does not leave any side effects in the THD.
10379 */
10380 LEX::cleanup_lex_after_parse_error(thd);
10381
10382 DBUG_ASSERT(opt_bootstrap || mysql_parse_status ||
10383 thd->lex->select_stack_top == 0);
10384 thd->lex->current_select= thd->lex->first_select_lex();
10385

Callers 12

mysql_unpack_partitionFunction · 0.85
check_n_loadMethod · 0.85
executeMethod · 0.85
mysql_parseFunction · 0.85
parse_exprMethod · 0.85
sp_compileFunction · 0.85
execute_server_codeFunction · 0.85
prepareMethod · 0.85
mysql_make_viewFunction · 0.85

Calls 7

set_n_backupMethod · 0.80
first_select_lexMethod · 0.80
get_internal_handlerMethod · 0.80
restore_envMethod · 0.80
queryMethod · 0.45
charsetMethod · 0.45
is_errorMethod · 0.45

Tested by

no test coverage detected