class Sql_cmd_dml : public Sql_cmd
|
{
|
public:
|
/// @return true if data change statement, false if not (SELECT statement)
|
virtual bool is_data_change_stmt() const { return true; }
|
|
/**
|
Command-specific resolving (doesn't include LEX::prepare())
|
|
@param thd Current THD.
|
@returns false on success, true on error
|
*/
|
virtual bool prepare(THD *thd);
|
|
/**
|
Execute this query once
|
|
@param thd Thread handler
|
@returns false on success, true on error
|
*/
|
virtual bool execute(THD *thd);
|
|
virtual bool is_dml() const { return true; }
|
|
protected:
|
Sql_cmd_dml()
|
: Sql_cmd(), lex(nullptr), result(nullptr), m_empty_query(false) {}
|
|
/// @return true if query is guaranteed to return no data
|
/**
|
@todo Also check this for the following cases:
|
- Empty source for multi-table UPDATE and DELETE.
|
- Check empty query expression for INSERT
|
*/
|
bool is_empty_query() const
|
{
|
DBUG_ASSERT(is_prepared());
|
return m_empty_query;
|
}
|
|
/// Set statement as returning no data
|
void set_empty_query() { m_empty_query = true; }
|
|
/**
|
Perform a precheck of table privileges for the specific operation.
|
|
@details
|
Check that user has some relevant privileges for all tables involved in
|
the statement, e.g. SELECT privileges for tables selected from, INSERT
|
privileges for tables inserted into, etc. This function will also populate
|
TABLE_LIST::grant with all privileges the user has for each table, which
|
is later used during checking of column privileges.
|
Note that at preparation time, views are not expanded yet. Privilege
|
checking is thus rudimentary and must be complemented with later calls to
|
SELECT_LEX::check_view_privileges().
|
The reason to call this function at such an early stage is to be able to
|
quickly reject statements for which the user obviously has insufficient
|
privileges.
|
|
@param thd thread handler
|
@returns false if success, true if false
|
*/
|
virtual bool precheck(THD *thd) = 0;
|
|
/**
|
Perform the command-specific parts of DML command preparation,
|
to be called from prepare()
|
|
@param thd the current thread
|
@returns false if success, true if error
|
*/
|
virtual bool prepare_inner(THD *thd) = 0;
|
|
/**
|
The inner parts of query optimization and execution.
|
Single-table DML operations needs to reimplement this.
|
|
@param thd Thread handler
|
@returns false on success, true on error
|
*/
|
virtual bool execute_inner(THD *thd);
|
|
virtual DML_prelocking_strategy *get_dml_prelocking_strategy() = 0;
|
|
uint table_count;
|
|
protected:
|
LEX *lex; ///< Pointer to LEX for this statement
|
select_result *result; ///< Pointer to object for handling of the result
|
bool m_empty_query; ///< True if query will produce no rows
|
};
|