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

Method execute

sql/sql_select.cc:34945–35025  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34943*/
34944
34945bool Sql_cmd_dml::execute(THD *thd)
34946{
34947 lex = thd->lex;
34948 ha_rows found= 0, changed= 0;
34949 bool res;
34950
34951 SELECT_LEX_UNIT *unit = &lex->unit;
34952 SELECT_LEX *select_lex= lex->first_select_lex();
34953
34954
34955 if (!is_prepared())
34956 {
34957 /*
34958 This is called when processing
34959 - a DML statement
34960 - PREPARE stmt FROM <DML "statement>"
34961 - EXECUTE stmt when stmt is prepared from a DML statement.
34962 The call will invoke open_tables_for_query()
34963 */
34964 if (prepare(thd))
34965 goto err;
34966 }
34967 else // This branch currently is never used for DML commands
34968 {
34969 if (precheck(thd))
34970 goto err;
34971
34972 MYSQL_DML_START(thd);
34973
34974 if (open_tables_for_query(thd, lex->query_tables, &table_count, 0,
34975 get_dml_prelocking_strategy()))
34976 goto err;
34977 }
34978
34979 THD_STAGE_INFO(thd, stage_init);
34980
34981 /*
34982 Locking of tables is done after preparation but before optimization.
34983 This allows to do better partition pruning and avoid locking unused
34984 partitions. As a consequence, in such a case, prepare stage can rely only
34985 on metadata about tables used and not data from them.
34986 */
34987 if (!is_empty_query())
34988 {
34989 if (lock_tables(thd, lex->query_tables, table_count, 0))
34990 goto err;
34991 }
34992
34993 unit->set_limit(select_lex);
34994
34995 /* Perform statement-specific execution */
34996 res = execute_inner(thd);
34997
34998 if (res)
34999 goto err;
35000 else
35001 MYSQL_DML_GET_STAT(thd, found, changed);
35002

Callers 2

exec_innerMethod · 0.45
do_selectFunction · 0.45

Calls 12

prepareFunction · 0.85
MYSQL_DML_STARTFunction · 0.85
open_tables_for_queryFunction · 0.85
lock_tablesFunction · 0.85
MYSQL_DML_GET_STATFunction · 0.85
MYSQL_DML_DONEFunction · 0.85
free_underlaid_joinsFunction · 0.85
first_select_lexMethod · 0.80
push_final_warningsMethod · 0.80
set_limitMethod · 0.45
cleanupMethod · 0.45
is_errorMethod · 0.45

Tested by

no test coverage detected