MySQL  8.0.17
Source Code Documentation
Query_result_update Class Referencefinal

#include <sql_update.h>

Inheritance diagram for Query_result_update:
Query_result_interceptor Query_result

Public Member Functions

 Query_result_update (List< Item > *field_list, List< Item > *value_list)
 
bool need_explain_interceptor () const override
 
bool prepare (THD *thd, List< Item > &list, SELECT_LEX_UNIT *u) override
 Perform preparation specific to the query expression or DML statement. More...
 
bool optimize () override
 Set up data structures for multi-table UPDATE. More...
 
bool start_execution (THD *) override
 Prepare for execution of the query expression or DML statement. More...
 
bool send_data (THD *thd, List< Item > &items) override
 
void send_error (THD *thd, uint errcode, const char *err) override
 
bool do_updates (THD *thd)
 
bool send_eof (THD *thd) override
 
void abort_result_set (THD *thd) override
 
void cleanup (THD *thd) override
 Cleanup after this execution. More...
 
- Public Member Functions inherited from Query_result_interceptor
 Query_result_interceptor ()
 
uint field_count (List< Item > &) const override
 
bool send_result_set_metadata (THD *, List< Item > &, uint) override
 
bool is_interceptor () const override final
 Checks if this Query_result intercepts and transforms the result set. More...
 
- Public Member Functions inherited from Query_result
 Query_result ()
 
virtual ~Query_result ()
 
virtual bool needs_file_privilege () const
 
virtual bool change_query_result (THD *, Query_result *)
 Change wrapped Query_result. More...
 
virtual bool check_simple_select () const
 Check if this query returns a result set and therefore is allowed in cursors and set an error message if it is not the case. More...
 
virtual bool reset ()
 Cleanup after one execution of the unit, to be ready for a next execution inside the same statement. More...
 
void begin_dataset ()
 
virtual const ha_rowsrow_count () const
 

Private Attributes

uint update_table_count
 Number of tables being updated. More...
 
TABLE_LISTupdate_tables
 Pointer to list of updated tables, linked via 'next_local'. More...
 
TABLE ** tmp_tables
 Array of references to temporary tables used to store cached updates. More...
 
Temp_table_paramtmp_table_param
 Array of parameter structs for creation of temporary tables. More...
 
TABLEmain_table
 The first table in the join operation. More...
 
TABLEtable_to_update
 In a multi-table update, this is equal to the first table in the join operation (main_table) if that table can be updated on the fly while scanning it. More...
 
ha_rows found_rows
 Number of rows found that matches join and WHERE conditions. More...
 
ha_rows updated_rows
 Number of rows actually updated, in all affected tables. More...
 
List< Item > * fields
 List of pointers to fields to update, in order from statement. More...
 
List< Item > * values
 List of pointers to values to update with, in order from statement. More...
 
List< Item > ** fields_for_table
 The fields list decomposed into separate lists per table. More...
 
List< Item > ** values_for_table
 The values list decomposed into separate lists per table. More...
 
List< TABLEunupdated_check_opt_tables
 
List of tables referenced in the CHECK OPTION condition of the updated view excluding the updated table. More...
 
Copy_fieldcopy_field
 ??? More...
 
size_t max_fields {0}
 Length of the copy_field array. More...
 
bool update_completed
 True if the full update operation is complete. More...
 
bool trans_safe
 True if all tables to be updated are transactional. More...
 
bool transactional_tables
 True if the update operation has made a change in a transactional table. More...
 
bool error_handled
 error handling (rollback and binlogging) can happen in send_eof() so that afterward send_error() needs to find out that. More...
 
COPY_INFO ** update_operations
 Array of update operations, arranged per updated table. More...
 

Additional Inherited Members

- Public Attributes inherited from Query_result
ha_rows estimated_rowcount
 Number of records estimated in this result. More...
 
double estimated_cost
 Cost to execute the subquery which produces this result. More...
 
- Protected Attributes inherited from Query_result
SELECT_LEX_UNITunit
 

Constructor & Destructor Documentation

◆ Query_result_update()

Query_result_update::Query_result_update ( List< Item > *  field_list,
List< Item > *  value_list 
)
inline

Member Function Documentation

◆ abort_result_set()

void Query_result_update::abort_result_set ( THD thd)
overridevirtual

Reimplemented from Query_result.

◆ cleanup()

void Query_result_update::cleanup ( THD )
overridevirtual

Cleanup after this execution.

Completes the execution and resets object before next execution of a prepared statement/stored procedure.

Reimplemented from Query_result.

◆ do_updates()

bool Query_result_update::do_updates ( THD thd)

< Flag for fatal errors

◆ need_explain_interceptor()

bool Query_result_update::need_explain_interceptor ( ) const
inlineoverridevirtual
Returns
true if an interceptor object is needed for EXPLAIN

Reimplemented from Query_result.

◆ optimize()

bool Query_result_update::optimize ( )
overridevirtual

Set up data structures for multi-table UPDATE.

IMPLEMENTATION

  • Update first table in join on the fly, if possible
  • Create temporary tables to store changed values for all other tables that are updated (and main_table if the above doesn't hold).

Reimplemented from Query_result.

◆ prepare()

bool Query_result_update::prepare ( THD ,
List< Item > &  ,
SELECT_LEX_UNIT u 
)
overridevirtual

Perform preparation specific to the query expression or DML statement.

Returns
false if success, true if error

Reimplemented from Query_result.

◆ send_data()

bool Query_result_update::send_data ( THD thd,
List< Item > &  items 
)
overridevirtual

Implements Query_result.

◆ send_eof()

bool Query_result_update::send_eof ( THD thd)
overridevirtual

Implements Query_result.

◆ send_error()

void Query_result_update::send_error ( THD thd,
uint  errcode,
const char *  err 
)
overridevirtual

Reimplemented from Query_result.

◆ start_execution()

bool Query_result_update::start_execution ( THD )
inlineoverridevirtual

Prepare for execution of the query expression or DML statement.

Generally, this will have an implementation only for outer-most SELECT_LEX objects, such as data change statements (for preparation of the target table(s)) or dump statements (for preparation of target file).

Returns
false if success, true if error

Reimplemented from Query_result.

Member Data Documentation

◆ copy_field

Copy_field* Query_result_update::copy_field
private

???

◆ error_handled

bool Query_result_update::error_handled
private

error handling (rollback and binlogging) can happen in send_eof() so that afterward send_error() needs to find out that.

◆ fields

List<Item>* Query_result_update::fields
private

List of pointers to fields to update, in order from statement.

◆ fields_for_table

List<Item>** Query_result_update::fields_for_table
private

The fields list decomposed into separate lists per table.

◆ found_rows

ha_rows Query_result_update::found_rows
private

Number of rows found that matches join and WHERE conditions.

◆ main_table

TABLE* Query_result_update::main_table
private

The first table in the join operation.

◆ max_fields

size_t Query_result_update::max_fields {0}
private

Length of the copy_field array.

◆ table_to_update

TABLE* Query_result_update::table_to_update
private

In a multi-table update, this is equal to the first table in the join operation (main_table) if that table can be updated on the fly while scanning it.

It is nullptr otherwise.

See also
safe_update_on_fly

◆ tmp_table_param

Temp_table_param* Query_result_update::tmp_table_param
private

Array of parameter structs for creation of temporary tables.

◆ tmp_tables

TABLE** Query_result_update::tmp_tables
private

Array of references to temporary tables used to store cached updates.

◆ trans_safe

bool Query_result_update::trans_safe
private

True if all tables to be updated are transactional.

◆ transactional_tables

bool Query_result_update::transactional_tables
private

True if the update operation has made a change in a transactional table.

◆ unupdated_check_opt_tables

List<TABLE> Query_result_update::unupdated_check_opt_tables
private


List of tables referenced in the CHECK OPTION condition of the updated view excluding the updated table.

◆ update_completed

bool Query_result_update::update_completed
private

True if the full update operation is complete.

◆ update_operations

COPY_INFO** Query_result_update::update_operations
private

Array of update operations, arranged per updated table.

For each updated table in the multiple table update statement, a COPY_INFO pointer is present at the table's position in this array.

The array is allocated and populated during Query_result_update::prepare(). The position that each table is assigned is also given here and is stored in the member TABLE::pos_in_table_list::shared. However, this is a publicly available field, so nothing can be trusted about its integrity.

This member is NULL when the Query_result_update is created.

See also
Query_result_update::prepare

◆ update_table_count

uint Query_result_update::update_table_count
private

Number of tables being updated.

◆ update_tables

TABLE_LIST* Query_result_update::update_tables
private

Pointer to list of updated tables, linked via 'next_local'.

◆ updated_rows

ha_rows Query_result_update::updated_rows
private

Number of rows actually updated, in all affected tables.

◆ values

List<Item>* Query_result_update::values
private

List of pointers to values to update with, in order from statement.

◆ values_for_table

List<Item>** Query_result_update::values_for_table
private

The values list decomposed into separate lists per table.


The documentation for this class was generated from the following files: