MySQL 8.4.2
Source Code Documentation
|
This class encapsulates a data change operation. More...
#include <sql_data_change.h>
Classes | |
class | Statistics |
Public Types | |
enum | operation_type { INSERT_OPERATION , UPDATE_OPERATION } |
Public Member Functions | |
COPY_INFO (operation_type optype, mem_root_deque< Item * > *inserted_columns, bool manage_defaults, enum_duplicates duplicate_handling) | |
Initializes this data change operation as an SQL INSERT (with all possible syntaxes and variants). More... | |
COPY_INFO (operation_type optype, mem_root_deque< Item * > *inserted_columns, mem_root_deque< Item * > *inserted_columns2, bool manage_defaults, enum_duplicates duplicates_handling, int escape_character) | |
COPY_INFO (operation_type optype, mem_root_deque< Item * > *fields, mem_root_deque< Item * > *values) | |
Initializes this data change operation as an SQL UPDATE (multi- or not). More... | |
operation_type | get_operation_type () const |
mem_root_deque< Item * > * | get_changed_columns () const |
const mem_root_deque< Item * > * | get_changed_columns2 () const |
bool | get_manage_defaults () const |
enum_duplicates | get_duplicate_handling () const |
bool | set_function_defaults (TABLE *table) |
Assigns function default values to columns of the supplied table. More... | |
bool | add_function_default_columns (TABLE *table, MY_BITMAP *columns) |
Adds the columns that are bound to receive default values from a function (e.g. More... | |
bool | function_defaults_apply (const TABLE *) const |
True if this operation will set some fields to function default result values when invoked on the table. More... | |
bool | function_defaults_apply_on_columns (MY_BITMAP *map) |
True if any of the columns set in the bitmap have default functions that may set the column. More... | |
void | reset_counters () |
Reset counters before the next execution. More... | |
void | cleanup () |
Cleanup memory allocated by this object. More... | |
bool | ignore_last_columns (TABLE *table, uint count) |
Tells the object to not manage function defaults for the last 'count' columns of 'table'. More... | |
virtual | ~COPY_INFO ()=default |
This class allocates its memory in a MEM_ROOT, so there's nothing to delete. More... | |
Public Attributes | |
Statistics | stats |
int | escape_char |
int | last_errno |
mem_root_deque< Item * > * | update_values |
Values for UPDATE; needed by write_record() if INSERT with DUP_UPDATE. More... | |
Protected Member Functions | |
bool | get_function_default_columns (TABLE *table) |
This function will, unless done already, calculate and keep the set of function default columns. More... | |
MY_BITMAP * | get_cached_bitmap () const |
The column bitmap which has been cached for this data change operation. More... | |
Private Member Functions | |
COPY_INFO (const COPY_INFO &other) | |
undefined More... | |
void | operator= (COPY_INFO &) |
undefined More... | |
Private Attributes | |
const operation_type | m_optype |
Describes the data change operation that this object represents. More... | |
mem_root_deque< Item * > * | m_changed_columns |
List of columns of the target table which the statement will explicitly fill; and thus we must not set a function default for them. More... | |
mem_root_deque< Item * > * | m_changed_columns2 |
A second list of columns like m_changed_columns. More... | |
const bool | m_manage_defaults |
Whether this object must manage function defaults. More... | |
MY_BITMAP * | m_function_default_columns |
Bitmap: bit is set if we should set column number i to its function default. More... | |
enum enum_duplicates | handle_duplicates |
Policy for handling insertion of duplicate values. More... | |
This class encapsulates a data change operation.
There are three such operations.
The COPY_INFO structure is used by INSERT/REPLACE code. The schema of the row counting by the INSERT/INSERT ... ON DUPLICATE KEY UPDATE code: If a row is inserted then the copied variable is incremented. If a row is updated by the INSERT ... ON DUPLICATE KEY UPDATE and the new data differs from the old one then the copied and the updated variables are incremented. The touched variable is incremented if a row was touched by the update part of the INSERT ... ON DUPLICATE KEY UPDATE no matter whether the row was actually changed or not.
|
private |
undefined
|
inline |
Initializes this data change operation as an SQL INSERT
(with all possible syntaxes and variants).
optype | The data change operation type. |
inserted_columns | List of columns of the target table which the statement will explicitly fill; COPY_INFO must not set a function default for them. NULL means "empty list". |
manage_defaults | Whether this object should manage function defaults. |
duplicate_handling | The policy for handling duplicates. |
|
inline |
Initializes this data change operation as an SQL @c LOAD @c DATA @c INFILE. Note that this statement has its inserted columns spread over two lists:
LOAD DATA INFILE a_file INTO TABLE a_table (col1, col2) < first list (col1, col2) SET col3=val; < second list (col3)
@param optype The data change operation type. @param inserted_columns List of columns of the target table which the statement will explicitly fill; COPY_INFO must not set a function default for them. NULL means "empty list". @param inserted_columns2 A second list like inserted_columns @param manage_defaults Whether this object should manage function defaults. @param duplicates_handling How to handle duplicates. @param escape_character The escape character.
|
inline |
Initializes this data change operation as an SQL UPDATE
(multi- or not).
optype | The data change operation type. |
fields | The column objects that are to be updated. |
values | The values to be assigned to the fields. |
|
virtualdefault |
This class allocates its memory in a MEM_ROOT, so there's nothing to delete.
Adds the columns that are bound to receive default values from a function (e.g.
CURRENT_TIMESTAMP) to the set columns. Uses lazy instantiation of the set of function default columns.
table | The table on which the operation is performed. | |
[out] | columns | The function default columns are added to this set. |
false | Success. |
true | Memory allocation error during lazy instantiation. |
|
inline |
Cleanup memory allocated by this object.
|
inline |
True if this operation will set some fields to function default result values when invoked on the table.
|
inline |
True if any of the columns set in the bitmap have default functions that may set the column.
|
inlineprotected |
The column bitmap which has been cached for this data change operation.
|
inline |
|
inline |
|
inline |
|
protected |
This function will, unless done already, calculate and keep the set of function default columns.
Function default columns are those columns declared DEFAULT <function> and/or ON UPDATE <function>. These will store the return value of <function> when the relevant operation is applied on the table.
Calling this function, without error, is a prerequisite for calling COPY_INFO::set_function_defaults().
table | The table to be used for instantiating the column set. |
false | Success. |
true | Memory allocation error. |
|
inline |
|
inline |
bool COPY_INFO::ignore_last_columns | ( | TABLE * | table, |
uint | count | ||
) |
Tells the object to not manage function defaults for the last 'count' columns of 'table'.
false | if success |
|
private |
undefined
|
inline |
Reset counters before the next execution.
bool COPY_INFO::set_function_defaults | ( | TABLE * | table | ) |
Assigns function default values to columns of the supplied table.
table | The table to which columns belong. |
false | Success. |
true | Some error happened while executing the default expression. my_error has already been called so the calling function only needs to bail out. |
int COPY_INFO::escape_char |
|
private |
Policy for handling insertion of duplicate values.
int COPY_INFO::last_errno |
|
private |
List of columns of the target table which the statement will explicitly fill; and thus we must not set a function default for them.
NULL means "empty list".
|
private |
A second list of columns like m_changed_columns.
See the constructor specific of LOAD DATA INFILE, below.
|
private |
Bitmap: bit is set if we should set column number i to its function default.
|
private |
Whether this object must manage function defaults.
|
private |
Describes the data change operation that this object represents.
Statistics COPY_INFO::stats |
mem_root_deque<Item *>* COPY_INFO::update_values |
Values for UPDATE; needed by write_record() if INSERT with DUP_UPDATE.