MySQL  8.0.17
Source Code Documentation
Query_result_insert Class Reference

#include <sql_insert.h>

Inheritance diagram for Query_result_insert:
Query_result_interceptor Query_result Query_result_create

Public Member Functions

 Query_result_insert (TABLE_LIST *table_list_par, TABLE *table_par, List< Item > *target_columns, List< Item > *target_or_source_columns, List< Item > *update_fields, List< Item > *update_values, enum_duplicates duplic)
 
Creates a Query_result_insert for routing a result set to an existing table. More...
 
bool need_explain_interceptor () const override
 
bool prepare (THD *thd, List< Item > &list, SELECT_LEX_UNIT *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, List< Item > &items) override
 
virtual void store_values (THD *thd, List< Item > &values)
 
void send_error (THD *thd, uint errcode, const char *err) override
 
bool send_eof (THD *thd) override
 
void abort_result_set (THD *thd) override
 
void cleanup (THD *thd) override
 Cleanup after this execution. More...
 
- Public Member Functions inherited from Query_result_interceptor
 Query_result_interceptor ()
 
uint field_count (List< Item > &) const override
 
bool send_result_set_metadata (THD *, List< Item > &, uint) override
 
bool is_interceptor () const override final
 Checks if this Query_result intercepts and transforms the result set. More...
 
- Public Member Functions inherited from Query_result
 Query_result ()
 
virtual ~Query_result ()
 
virtual bool needs_file_privilege () const
 
virtual bool change_query_result (THD *, Query_result *)
 Change wrapped Query_result. More...
 
virtual bool optimize ()
 Optimize the result processing of a query expression, applicable to data change operation (not simple select queries). More...
 
virtual bool check_simple_select () const
 Check if this query returns a result set and therefore is allowed in cursors and set an error message if it is not the case. More...
 
virtual bool reset ()
 Cleanup after one execution of the unit, to be ready for a next execution inside the same statement. More...
 
void begin_dataset ()
 
virtual const ha_rowsrow_count () const
 

Public Attributes

TABLE_LISTtable_list
 The table used for insertion of rows. More...
 
TABLEtable
 
ulonglong autoinc_value_of_last_inserted_row
 
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
 ha_start_bulk_insert has been called. Never cleared. More...
 
- Protected Attributes inherited from Query_result
SELECT_LEX_UNITunit
 

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

List< 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_LIST table_list_par,
TABLE table_par,
List< Item > *  target_columns,
List< Item > *  target_or_source_columns,
List< Item > *  update_fields,
List< Item > *  update_values,
enum_duplicates  duplic 
)
inline


Creates a Query_result_insert for routing a result set to an existing table.

Parameters
table_list_parThe table reference for the destination table.
table_parThe destination table. May be NULL.
target_columnsSee details.
target_or_source_columnsSee details.
update_fieldsThe columns to be updated in case of duplicate keys. May be NULL.
update_valuesThe values to be assigned in case of duplicate keys. May be NULL.
duplicThe policy for handling duplicates.
 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 ( THD )
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 ,
List< Item > &  ,
SELECT_LEX_UNIT 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,
List< 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.

◆ send_error()

void Query_result_insert::send_error ( THD thd,
uint  errcode,
const char *  err 
)
overridevirtual

Reimplemented from 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 prepared in the join optimization phase. Do the final preparation 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,
List< 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

◆ bulk_insert_started

bool Query_result_insert::bulk_insert_started
protected

ha_start_bulk_insert has been called. Never cleared.

◆ fields

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

◆ table_list

TABLE_LIST* 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: