//===----------------------------------------------------------------------===// // DuckDB // // duckdb/planner/operator/logical_insert.hpp // // //===----------------------------------------------------------------------===// #pragma once #include "duckdb/planner/logical_operator.hpp" #include "duckdb/common/index_vector.hpp" #include "duckdb/parser/statement/insert_statement.hpp" namespace duckdb { class TableCatalogEntry; class Index; //! LogicalInsert represents an insertion of data into a base table class LogicalInsert : public LogicalOperator { public: static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_INSERT; public: LogicalInsert(TableCatalogEntry &table, idx_t table_index); vector>> insert_values; //! The insertion map ([table_index -> index in result, or DConstants::INVALID_INDEX if not specified]) physical_index_vector_t column_index_map; //! The expected types for the INSERT statement (obtained from the column types) vector expected_types; //! The base table to insert into TableCatalogEntry &table; idx_t table_index; //! if returning option is used, return actual chunk to projection bool return_chunk; //! The default statements used by the table vector> bound_defaults; //! Which action to take on conflict OnConflictAction action_type; // The types that the DO UPDATE .. SET (expressions) are cast to vector expected_set_types; // The (distinct) column ids to apply the ON CONFLICT on unordered_set on_conflict_filter; // The WHERE clause of the conflict_target (ON CONFLICT .. WHERE ) unique_ptr on_conflict_condition; // The WHERE clause of the DO UPDATE clause unique_ptr do_update_condition; // The columns targeted by the DO UPDATE SET expressions vector set_columns; // The types of the columns targeted by the DO UPDATE SET expressions vector set_types; // The table_index referring to the column references qualified with 'excluded' idx_t excluded_table_index; // The columns to fetch from the 'destination' table vector columns_to_fetch; // The columns to fetch from the 'source' table vector source_columns; public: void Serialize(FieldWriter &writer) const override; static unique_ptr Deserialize(LogicalDeserializationState &state, FieldReader &reader); protected: vector GetColumnBindings() override; void ResolveTypes() override; idx_t EstimateCardinality(ClientContext &context) override; vector GetTableIndex() const override; string GetName() const override; }; } // namespace duckdb