OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::InsertStmt Class Referenceabstract

#include <ParserNode.h>

+ Inheritance diagram for Parser::InsertStmt:
+ Collaboration diagram for Parser::InsertStmt:

Public Member Functions

 InsertStmt (std::string *t, std::list< std::string * > *c)
 
const std::string * get_table () const
 
const std::list
< std::unique_ptr< std::string > > & 
get_column_list () const
 
void analyze (const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override=0
 
- Public Member Functions inherited from Parser::Node
virtual ~Node ()
 

Protected Attributes

std::unique_ptr< std::string > table_
 
std::list< std::unique_ptr
< std::string > > 
column_list_
 

Detailed Description

Definition at line 2074 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::InsertStmt::InsertStmt ( std::string *  t,
std::list< std::string * > *  c 
)
inline

Definition at line 2076 of file ParserNode.h.

References column_list_.

2076  : table_(t) {
2077  if (c) {
2078  for (const auto e : *c) {
2079  column_list_.emplace_back(e);
2080  }
2081  delete c;
2082  }
2083  }
std::unique_ptr< std::string > table_
Definition: ParserNode.h:2092
std::list< std::unique_ptr< std::string > > column_list_
Definition: ParserNode.h:2093

Member Function Documentation

void Parser::InsertStmt::analyze ( const Catalog_Namespace::Catalog catalog,
Analyzer::Query query 
) const
overridepure virtual

Implements Parser::DMLStmt.

Implemented in Parser::InsertValuesStmt.

Definition at line 2366 of file ParserNode.cpp.

References CHECK, ColumnDescriptor::columnId, ColumnDescriptor::columnType, Catalog_Namespace::Catalog::getAllColumnMetadataForTable(), Catalog_Namespace::Catalog::getMetadataForColumn(), Catalog_Namespace::Catalog::getMetadataForTable(), SQLTypeInfo::is_geometry(), TableDescriptor::isView, kINSERT, Analyzer::Query::set_result_col_list(), Analyzer::Query::set_result_table_id(), Analyzer::Query::set_stmt_type(), TableDescriptor::tableId, and foreign_storage::validate_non_foreign_table_write().

Referenced by Parser::InsertValuesStmt::analyze().

2367  {
2368  query.set_stmt_type(kINSERT);
2369  const TableDescriptor* td = catalog.getMetadataForTable(*table_);
2370  if (td == nullptr) {
2371  throw std::runtime_error("Table " + *table_ + " does not exist.");
2372  }
2373  if (td->isView) {
2374  throw std::runtime_error("Insert to views is not supported yet.");
2375  }
2377  query.set_result_table_id(td->tableId);
2378  std::list<int> result_col_list;
2379  if (column_list_.empty()) {
2380  const std::list<const ColumnDescriptor*> all_cols =
2381  catalog.getAllColumnMetadataForTable(td->tableId, false, false, true);
2382  for (auto cd : all_cols) {
2383  result_col_list.push_back(cd->columnId);
2384  }
2385  } else {
2386  for (auto& c : column_list_) {
2387  const ColumnDescriptor* cd = catalog.getMetadataForColumn(td->tableId, *c);
2388  if (cd == nullptr) {
2389  throw std::runtime_error("Column " + *c + " does not exist.");
2390  }
2391  result_col_list.push_back(cd->columnId);
2392  const auto& col_ti = cd->columnType;
2393  if (col_ti.get_physical_cols() > 0) {
2394  CHECK(cd->columnType.is_geometry());
2395  for (auto i = 1; i <= col_ti.get_physical_cols(); i++) {
2396  const ColumnDescriptor* pcd =
2397  catalog.getMetadataForColumn(td->tableId, cd->columnId + i);
2398  if (pcd == nullptr) {
2399  throw std::runtime_error("Column " + *c + "'s metadata is incomplete.");
2400  }
2401  result_col_list.push_back(pcd->columnId);
2402  }
2403  }
2404  }
2405  }
2406  query.set_result_col_list(result_col_list);
2407 }
void validate_non_foreign_table_write(const TableDescriptor *table_descriptor)
Definition: FsiUtils.h:22
void set_result_col_list(const std::list< int > &col_list)
Definition: Analyzer.h:3175
std::unique_ptr< std::string > table_
Definition: ParserNode.h:2092
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
specifies the content in-memory of a row in the column metadata table
void set_result_table_id(int id)
Definition: Analyzer.h:3176
std::list< const ColumnDescriptor * > getAllColumnMetadataForTable(const int tableId, const bool fetchSystemColumns, const bool fetchVirtualColumns, const bool fetchPhysicalColumns) const
Returns a list of pointers to constant ColumnDescriptor structs for all the columns from a particular...
Definition: Catalog.cpp:2175
std::list< std::unique_ptr< std::string > > column_list_
Definition: ParserNode.h:2093
void set_stmt_type(SQLStmtType t)
Definition: Analyzer.h:3184
#define CHECK(condition)
Definition: Logger.h:291
bool is_geometry() const
Definition: sqltypes.h:597
SQLTypeInfo columnType
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::list<std::unique_ptr<std::string> >& Parser::InsertStmt::get_column_list ( ) const
inline

Definition at line 2085 of file ParserNode.h.

References column_list_.

2085  {
2086  return column_list_;
2087  }
std::list< std::unique_ptr< std::string > > column_list_
Definition: ParserNode.h:2093
const std::string* Parser::InsertStmt::get_table ( ) const
inline

Definition at line 2084 of file ParserNode.h.

References table_.

2084 { return table_.get(); }
std::unique_ptr< std::string > table_
Definition: ParserNode.h:2092

Member Data Documentation

std::list<std::unique_ptr<std::string> > Parser::InsertStmt::column_list_
protected
std::unique_ptr<std::string> Parser::InsertStmt::table_
protected

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