MySQL 8.4.0
Source Code Documentation
Query_result_insert Class Reference

#include <sql_insert.h>

Inheritance diagram for Query_result_insert:
[legend]

Public Member Functions

 Query_result_insert (Table_ref *table_list_par, mem_root_deque< Item * > *target_columns, mem_root_deque< Item * > *target_or_source_columns, mem_root_deque< Item * > *update_fields, mem_root_deque< Item * > *update_values, enum_duplicates duplic)
 
bool need_explain_interceptor () const override
 
bool prepare (THD *thd, const mem_root_deque< Item * > &list, Query_expression *u) override
 Perform preparation specific to the query expression or DML statement. More...
 
bool start_execution (THD *thd) override
 Set up the target table for execution. More...
 
bool send_data (THD *thd, const mem_root_deque< Item * > &items) override
 
virtual void store_values (THD *thd, const mem_root_deque< Item * > &values)
 
bool send_eof (THD *thd) override
 
void abort_result_set (THD *thd) override
 
void cleanup () override
 Cleanup after this execution. More...
 
- Public Member Functions inherited from Query_result_interceptor
 Query_result_interceptor ()
 
uint field_count (const mem_root_deque< Item * > &) const override
 
bool send_result_set_metadata (THD *, const mem_root_deque< Item * > &, uint) override
 
- Public Member Functions inherited from Query_result
 Query_result ()
 
virtual ~Query_result ()=default
 
virtual bool needs_file_privilege () const
 
virtual bool change_query_result (THD *, Query_result *)
 Change wrapped Query_result. More...
 
virtual bool create_table_for_query_block (THD *)
 Create table, only needed to support CREATE TABLE ... SELECT. More...
 
virtual bool check_supports_cursor () const
 Check if this query result set supports cursors. More...
 
virtual bool reset ()
 Cleanup after one execution of the unit, to be ready for a next execution inside the same statement. More...
 
virtual bool use_protocol_adapter () const
 
virtual bool use_protocol_wrapper () const
 
virtual void set_limit (ha_rows)
 Only overridden (and non-empty) for Query_result_union, q.v. More...
 
virtual Server_side_cursorcursor () const
 

Public Attributes

Table_reftable_list
 The table used for insertion of rows. More...
 
TABLEtable {nullptr}
 
ulonglong autoinc_value_of_last_inserted_row {0}
 
COPY_INFO info
 
COPY_INFO update
 the UPDATE part of "info" More...
 
bool insert_into_view
 
- 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

bool bulk_insert_started {false}
 ha_start_bulk_insert has been called. Never cleared. More...
 
- Protected Attributes inherited from Query_result
Query_expressionunit
 

Private Member Functions

virtual bool stmt_binlog_is_trans () const
 Indicates whether this statement should be written to binary log's transactional cache in statement mode. More...
 

Private Attributes

mem_root_deque< Item * > * fields
 The columns of the table to be inserted into, or the columns of the table from which values are selected. More...
 

Constructor & Destructor Documentation

◆ Query_result_insert()

Query_result_insert::Query_result_insert ( Table_ref table_list_par,
mem_root_deque< Item * > *  target_columns,
mem_root_deque< Item * > *  target_or_source_columns,
mem_root_deque< Item * > *  update_fields,
mem_root_deque< Item * > *  update_values,
enum_duplicates  duplic 
)
inline
 Creates a Query_result_insert for routing a result set to an existing
 table.

 @param table_list_par   The table reference for the destination table.
 @param target_columns   See details.
 @param target_or_source_columns See details.
 @param update_fields    The columns to be updated in case of duplicate
                         keys. May be NULL.
 @param update_values    The values to be assigned in case of duplicate
                         keys. May be NULL.
 @param duplic           The policy for handling duplicates.

 @todo This constructor takes 8 arguments, 6 of which are used to
 immediately construct a COPY_INFO object. Obviously the constructor
 should take the COPY_INFO object as argument instead. Also, some
 Query_result_insert members initialized here are totally redundant, as they

are found inside the COPY_INFO.

 The target_columns and target_or_source_columns arguments are set by
 callers as follows:
 @li if CREATE SELECT:
  - target_columns == NULL,
  - target_or_source_columns == expressions listed after SELECT, as in
      CREATE ... SELECT expressions
 @li if INSERT SELECT:
  target_columns
  == target_or_source_columns
  == columns listed between INSERT and SELECT, as in
      INSERT INTO t (columns) SELECT ...

 We set the manage_defaults argument of info's constructor as follows
 ([...] denotes something optional):
 @li If target_columns==NULL, the statement is
     CREATE TABLE a_table [(columns1)] SELECT expressions2

so 'info' must manage defaults of columns1.

  • Otherwise it is:
         INSERT INTO a_table [(columns1)] SELECT ...
    
    target_columns is columns1, if not empty then 'info' must manage defaults of other columns than columns1.

Member Function Documentation

◆ abort_result_set()

void Query_result_insert::abort_result_set ( THD thd)
overridevirtual

Reimplemented from Query_result.

Reimplemented in Query_result_create.

◆ cleanup()

void Query_result_insert::cleanup ( void  )
overridevirtual

Cleanup after this execution.

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

Reimplemented from Query_result.

◆ need_explain_interceptor()

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

Reimplemented from Query_result.

◆ prepare()

bool Query_result_insert::prepare ( THD ,
const mem_root_deque< Item * > &  ,
Query_expression u 
)
overridevirtual

Perform preparation specific to the query expression or DML statement.

Returns
false if success, true if error

Reimplemented from Query_result.

Reimplemented in Query_result_create.

◆ send_data()

bool Query_result_insert::send_data ( THD thd,
const mem_root_deque< Item * > &  items 
)
overridevirtual

Implements Query_result.

◆ send_eof()

bool Query_result_insert::send_eof ( THD thd)
overridevirtual

Implements Query_result.

Reimplemented in Query_result_create.

◆ start_execution()

bool Query_result_insert::start_execution ( THD thd)
overridevirtual

Set up the target table for execution.

If the target table is the same as one of the source tables (INSERT SELECT), the target table is not finally set up in the join optimization phase. Do the final setup now.

Returns
false always

Reimplemented from Query_result.

Reimplemented in Query_result_create.

◆ stmt_binlog_is_trans()

bool Query_result_insert::stmt_binlog_is_trans ( ) const
privatevirtual

Indicates whether this statement should be written to binary log's transactional cache in statement mode.

Reimplemented in Query_result_create.

◆ store_values()

void Query_result_insert::store_values ( THD thd,
const mem_root_deque< Item * > &  values 
)
virtual

Reimplemented in Query_result_create.

Member Data Documentation

◆ autoinc_value_of_last_inserted_row

ulonglong Query_result_insert::autoinc_value_of_last_inserted_row {0}

◆ bulk_insert_started

bool Query_result_insert::bulk_insert_started {false}
protected

ha_start_bulk_insert has been called. Never cleared.

◆ fields

mem_root_deque<Item *>* Query_result_insert::fields
private

The columns of the table to be inserted into, or the columns of the table from which values are selected.

For legacy reasons both are allowed.

◆ info

COPY_INFO Query_result_insert::info

◆ insert_into_view

bool Query_result_insert::insert_into_view

◆ table

TABLE* Query_result_insert::table {nullptr}

◆ table_list

Table_ref* Query_result_insert::table_list

The table used for insertion of rows.

◆ update

COPY_INFO Query_result_insert::update

the UPDATE part of "info"


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