MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
COPY_INFO Class Reference

#include <sql_data_change.h>

Inheritance diagram for COPY_INFO:
Collaboration diagram for COPY_INFO:

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, bool ignore_errors)
 COPY_INFO (operation_type optype, List< Item > *inserted_columns, List< Item > *inserted_columns2, bool manage_defaults, enum_duplicates duplicates_handling, bool ignore_duplicates, int escape_character)
 COPY_INFO (operation_type optype, List< Item > *fields, List< Item > *values)
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 get_ignore_errors () const
virtual void set_function_defaults (TABLE *table)
bool add_function_default_columns (TABLE *table, MY_BITMAP *columns)
bool function_defaults_apply (const TABLE *table) const
bool function_defaults_apply_on_columns (MY_BITMAP *map)
bool ignore_last_columns (TABLE *table, uint count)
virtual ~COPY_INFO ()

Public Attributes

Statistics stats
int escape_char
int last_errno
List< Item > * update_values

Protected Member Functions

bool get_function_default_columns (TABLE *table)
MY_BITMAPget_cached_bitmap () const

Protected Attributes

enum enum_duplicates handle_duplicates
bool ignore

Additional Inherited Members

- Static Public Member Functions inherited from Sql_alloc
static void * operator new (size_t size) throw ()
static void * operator new[] (size_t size) throw ()
static void * operator new[] (size_t size, MEM_ROOT *mem_root) throw ()
static void * operator new (size_t size, MEM_ROOT *mem_root) throw ()
static void operator delete (void *ptr, size_t size)
static void operator delete (void *ptr, MEM_ROOT *mem_root)
static void operator delete[] (void *ptr, MEM_ROOT *mem_root)
static void operator delete[] (void *ptr, size_t size)

Detailed Description

This class encapsulates a data change operation. There are three such operations.

  1. Insert statements, i.e. INSERT INTO .. VALUES
  1. Update statements. UPDATE
    ...
  1. Delete statements. Currently this class is not used for delete statements and thus has not yet been adapted to handle it.
Todo:
Rename this class.

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.

Definition at line 57 of file sql_data_change.h.

Constructor & Destructor Documentation

COPY_INFO::COPY_INFO ( operation_type  optype,
List< Item > *  inserted_columns,
bool  manage_defaults,
enum_duplicates  duplicate_handling,
bool  ignore_errors 
)
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.
ignore_errorsWhether certain ignorable errors should be ignored. A proper documentation has never existed for this member, so the following has been compiled by examining how clients actually use the member.
  • Ignore non-fatal errors, except duplicate key error, during this insert operation (this constructor can only construct an insert operation).
  • If the insert operation spawns an update operation (as in ON DUPLICATE KEY UPDATE), tell the layer below (fill_record_n_invoke_before_triggers) to 'ignore errors'. (More detailed documentation is not available).
  • Let v be a view for which WITH CHECK OPTION applies. This can happen either if v is defined with WITH ... CHECK OPTION, or if v is being inserted into by a cascaded insert and an outer view is defined with "WITH CASCADED CHECK OPTION". If the insert operation on v spawns an update operation (as in ON DUPLICATE KEY UPDATE) for a certain row, and hence the v is being updated, ignore whether the WHERE clause was true for this row or not. I.e. if ignore is true, WITH CHECK OPTION can be ignored.
  • If the insert operation spawns an update operation (as in ON DUPLICATE KEY UPDATE) that fails, ignore this error.

Definition at line 188 of file sql_data_change.h.

COPY_INFO::COPY_INFO ( operation_type  optype,
List< Item > *  inserted_columns,
List< Item > *  inserted_columns2,
bool  manage_defaults,
enum_duplicates  duplicates_handling,
bool  ignore_duplicates,
int  escape_character 
)
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 explicitely 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 ignore_duplicates   Whether duplicate rows are ignored.
 @param duplicates_handling How to handle duplicates.
 @param escape_character    The escape character.

Definition at line 231 of file sql_data_change.h.

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

Definition at line 262 of file sql_data_change.h.

virtual COPY_INFO::~COPY_INFO ( )
inlinevirtual

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

Definition at line 358 of file sql_data_change.h.

Member Function Documentation

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.

Definition at line 316 of file sql_data_change.h.

Here is the call graph for this function:

bool COPY_INFO::function_defaults_apply ( const TABLE 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.

Definition at line 331 of file sql_data_change.h.

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.

Definition at line 341 of file sql_data_change.h.

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.

Definition at line 145 of file sql_data_change.h.

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.

Definition at line 62 of file sql_data_change.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 146 of file sql_data_change.cc.

Here is the call graph for this function:

void COPY_INFO::set_function_defaults ( TABLE table)
virtual

Assigns function default values to columns of the supplied table. This function cannot fail, but COPY_INFO::get_function_default_columns() must be called beforehand.

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

Reimplemented in Delayable_insert_operation.

Definition at line 118 of file sql_data_change.cc.

Here is the call graph for this function:

Member Data Documentation

enum enum_duplicates COPY_INFO::handle_duplicates
protected

Policy for handling insertion of duplicate values. Protected for legacy reasons.

See Also
Delayable_insert_operation::set_dup_and_ignore()

Definition at line 111 of file sql_data_change.h.

bool COPY_INFO::ignore
protected

Policy for whether certain errors should be ignored. Protected for legacy reasons.

See Also
Delayable_insert_operation::set_dup_and_ignore()

Definition at line 119 of file sql_data_change.h.

List<Item>* COPY_INFO::update_values

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

Definition at line 151 of file sql_data_change.h.


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