MySQL  8.0.17
Source Code Documentation
COPY_INFO Class Reference

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, List< 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, List< Item > *inserted_columns, List< Item > *inserted_columns2, bool manage_defaults, enum_duplicates duplicates_handling, int escape_character)
 
Initializes this data change operation as an SQL LOAD DATA INFILE. More...
 
 COPY_INFO (operation_type optype, List< Item > *fields, List< Item > *values)
 Initializes this data change operation as an SQL UPDATE (multi- or not). More...
 
operation_type get_operation_type () const
 
List< Item > * get_changed_columns () const
 
const List< 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...
 
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 ()
 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
 
List< 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_BITMAPget_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...
 
List< Item > * m_changed_columns
 List of columns of the target table which the statement will explicitely fill; and thus we must not set a function default for them. More...
 
List< 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_BITMAPm_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...
 

Detailed Description

This class encapsulates a data change operation.

There are three such operations.

  1. Insert statements, i.e. INSERT INTO .. VALUES
  2. Update statements. UPDATE <table> SET ...
  3. Delete statements. Currently this class is not used for delete statements and thus has not yet been adapted to handle it.

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.

Member Enumeration Documentation

◆ operation_type

Enumerator
INSERT_OPERATION 
UPDATE_OPERATION 

Constructor & Destructor Documentation

◆ COPY_INFO() [1/4]

COPY_INFO::COPY_INFO ( const COPY_INFO other)
private

undefined

◆ COPY_INFO() [2/4]

COPY_INFO::COPY_INFO ( operation_type  optype,
List< Item > *  inserted_columns,
bool  manage_defaults,
enum_duplicates  duplicate_handling 
)
inline

Initializes this data change operation as an SQL INSERT (with all possible syntaxes and variants).

Parameters
optypeThe data change operation type.
inserted_columnsList of columns of the target table which the statement will explicitely fill; COPY_INFO must not set a function default for them. NULL means "empty list".
manage_defaultsWhether this object should manage function defaults.
duplicate_handlingThe policy for handling duplicates.

◆ COPY_INFO() [3/4]

COPY_INFO::COPY_INFO ( operation_type  optype,
List< Item > *  inserted_columns,
List< Item > *  inserted_columns2,
bool  manage_defaults,
enum_duplicates  duplicates_handling,
int  escape_character 
)
inline


Initializes this data change operation as an SQL LOAD DATA 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)
Parameters
optypeThe data change operation type.
inserted_columnsList of columns of the target table which the statement will explicitely fill; COPY_INFO must not set a function default for them. NULL means "empty list".
inserted_columns2A second list like inserted_columns
manage_defaultsWhether this object should manage function defaults.
duplicates_handlingHow to handle duplicates.
escape_characterThe escape character.

◆ COPY_INFO() [4/4]

COPY_INFO::COPY_INFO ( operation_type  optype,
List< Item > *  fields,
List< Item > *  values 
)
inline

Initializes this data change operation as an SQL UPDATE (multi- or not).

Parameters
optypeThe data change operation type.
fieldsThe column objects that are to be updated.
valuesThe values to be assigned to the fields.
Note
that UPDATE always lists columns, so non-listed columns may need a default thus m_manage_defaults is always true.

◆ ~COPY_INFO()

virtual COPY_INFO::~COPY_INFO ( )
inlinevirtual

This class allocates its memory in a MEM_ROOT, so there's nothing to delete.

Member Function Documentation

◆ add_function_default_columns()

bool COPY_INFO::add_function_default_columns ( TABLE table,
MY_BITMAP columns 
)
inline

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.

Parameters
tableThe table on which the operation is performed.
[out]columnsThe function default columns are added to this set.
Return values
falseSuccess.
trueMemory allocation error during lazy instantiation.

◆ function_defaults_apply()

bool COPY_INFO::function_defaults_apply ( const TABLE ) const
inline

True if this operation will set some fields to function default result values when invoked on the table.

Note
COPY_INFO::add_function_default_columns() must be called prior to invoking this function.

◆ function_defaults_apply_on_columns()

bool COPY_INFO::function_defaults_apply_on_columns ( MY_BITMAP map)
inline

True if any of the columns set in the bitmap have default functions that may set the column.

◆ get_cached_bitmap()

MY_BITMAP* COPY_INFO::get_cached_bitmap ( ) const
inlineprotected

The column bitmap which has been cached for this data change operation.

See also
COPY_INFO::get_function_default_columns()
Returns
The cached bitmap, or NULL if no bitmap was cached.

◆ get_changed_columns()

List<Item>* COPY_INFO::get_changed_columns ( ) const
inline

◆ get_changed_columns2()

const List<Item>* COPY_INFO::get_changed_columns2 ( ) const
inline

◆ get_duplicate_handling()

enum_duplicates COPY_INFO::get_duplicate_handling ( ) const
inline

◆ get_function_default_columns()

bool COPY_INFO::get_function_default_columns ( TABLE table)
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().

Parameters
tableThe table to be used for instantiating the column set.
Return values
falseSuccess.
trueMemory allocation error.

◆ get_manage_defaults()

bool COPY_INFO::get_manage_defaults ( ) const
inline

◆ get_operation_type()

operation_type COPY_INFO::get_operation_type ( ) const
inline

◆ ignore_last_columns()

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'.

Return values
falseif success

◆ operator=()

void COPY_INFO::operator= ( COPY_INFO )
private

undefined

◆ set_function_defaults()

bool COPY_INFO::set_function_defaults ( TABLE table)

Assigns function default values to columns of the supplied table.

Note
COPY_INFO::get_function_default_columns() and COPY_INFO::add_function_default_columns() must be called prior to invoking this function.
Parameters
tableThe table to which columns belong.
Note
It is assumed that all columns in this COPY_INFO are resolved to the table.
Return values
falseSuccess.
trueSome error happened while executing the default expression. my_error has already been called so the calling function only needs to bail out.

Member Data Documentation

◆ escape_char

int COPY_INFO::escape_char

◆ handle_duplicates

enum enum_duplicates COPY_INFO::handle_duplicates
private

Policy for handling insertion of duplicate values.

◆ last_errno

int COPY_INFO::last_errno

◆ m_changed_columns

List<Item>* COPY_INFO::m_changed_columns
private

List of columns of the target table which the statement will explicitely fill; and thus we must not set a function default for them.

NULL means "empty list".

◆ m_changed_columns2

List<Item>* COPY_INFO::m_changed_columns2
private

A second list of columns like m_changed_columns.

See the constructor specific of LOAD DATA INFILE, below.

◆ m_function_default_columns

MY_BITMAP* COPY_INFO::m_function_default_columns
private

Bitmap: bit is set if we should set column number i to its function default.

◆ m_manage_defaults

const bool COPY_INFO::m_manage_defaults
private

Whether this object must manage function defaults.

◆ m_optype

const operation_type COPY_INFO::m_optype
private

Describes the data change operation that this object represents.

◆ stats

Statistics COPY_INFO::stats

◆ update_values

List<Item>* COPY_INFO::update_values

Values for UPDATE; needed by write_record() if INSERT with DUP_UPDATE.


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