MySQL 9.0.0
Source Code Documentation
sql_update.h File Reference
#include <sys/types.h>
#include "mem_root_deque.h"
#include "my_alloc.h"
#include "my_sqlcommand.h"
#include "my_table_map.h"
#include "sql/query_result.h"
#include "sql/sql_cmd_dml.h"
#include "sql/sql_list.h"
#include "sql/thr_malloc.h"

Go to the source code of this file.

Classes

class  Query_result_update
 
class  Sql_cmd_update
 

Functions

bool records_are_comparable (const TABLE *table)
 True if the table's input and output record buffers are comparable using compare_records(TABLE*). More...
 
bool compare_records (const TABLE *table)
 Compares the input and output record buffers of the table to see if a row has changed. More...
 
bool should_switch_to_multi_table_if_subqueries (const THD *thd, const Query_block *select, const Table_ref *table_list)
 Decides if a single-table UPDATE/DELETE statement should switch to the multi-table code path, if there are subqueries which might benefit from semijoin or subquery materialization, and if no feature specific to the single-table path are used. More...
 
table_map GetImmediateUpdateTable (const JOIN *join, bool single_target)
 Find out which of the target tables can be updated immediately while scanning. More...
 
bool FinalizeOptimizationForUpdate (JOIN *join)
 Makes the TABLE and handler objects ready for being used in an UPDATE statement. More...
 
unique_ptr_destroy_only< RowIteratorCreateUpdateRowsIterator (THD *thd, MEM_ROOT *mem_root, JOIN *join, unique_ptr_destroy_only< RowIterator > source)
 Creates an UpdateRowsIterator which updates the rows returned by the given "source" iterator. More...
 

Function Documentation

◆ compare_records()

bool compare_records ( const TABLE table)

Compares the input and output record buffers of the table to see if a row has changed.

The algorithm iterates over updated columns and if they are nullable compares NULL bits in the buffer before comparing actual data. Special care must be taken to compare only the relevant NULL bits and mask out all others as they may be undefined. The storage engine will not and should not touch them.

Parameters
tableThe table to evaluate.
Returns
true if row has changed.
false otherwise.

◆ CreateUpdateRowsIterator()

unique_ptr_destroy_only< RowIterator > CreateUpdateRowsIterator ( THD thd,
MEM_ROOT mem_root,
JOIN join,
unique_ptr_destroy_only< RowIterator source 
)

Creates an UpdateRowsIterator which updates the rows returned by the given "source" iterator.

◆ FinalizeOptimizationForUpdate()

bool FinalizeOptimizationForUpdate ( JOIN join)

Makes the TABLE and handler objects ready for being used in an UPDATE statement.

Called at the beginning of each execution.

Parameters
joinThe top-level JOIN object of the UPDATE operation.
Returns
true on error.

◆ GetImmediateUpdateTable()

table_map GetImmediateUpdateTable ( const JOIN join,
bool  single_target 
)

Find out which of the target tables can be updated immediately while scanning.

This is used by the old optimizer after the plan has been created. The hypergraph optimizer does not use this function, as it makes the decision about immediate update during planning, not after planning.

Parameters
joinThe top-level JOIN object of the UPDATE statement.
single_targetTrue if the UPDATE statement has exactly one target table.
Returns
Map of tables to update while scanning.

◆ records_are_comparable()

bool records_are_comparable ( const TABLE table)

True if the table's input and output record buffers are comparable using compare_records(TABLE*).

◆ should_switch_to_multi_table_if_subqueries()

bool should_switch_to_multi_table_if_subqueries ( const THD thd,
const Query_block qb,
const Table_ref table_list 
)

Decides if a single-table UPDATE/DELETE statement should switch to the multi-table code path, if there are subqueries which might benefit from semijoin or subquery materialization, and if no feature specific to the single-table path are used.

Parameters
thdThread handler
qbQuery block
table_listTable to modify
Returns
true if we should switch