OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 1971 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1973 of file ParserNode.h.

References column_list.

1973  : table(t) {
1974  if (c) {
1975  for (const auto e : *c) {
1976  column_list.emplace_back(e);
1977  }
1978  delete c;
1979  }
1980  }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1989
std::list< std::unique_ptr< std::string > > column_list
Definition: ParserNode.h:1990

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 1485 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().

1486  {
1487  query.set_stmt_type(kINSERT);
1488  const TableDescriptor* td = catalog.getMetadataForTable(*table);
1489  if (td == nullptr) {
1490  throw std::runtime_error("Table " + *table + " does not exist.");
1491  }
1492  if (td->isView) {
1493  throw std::runtime_error("Insert to views is not supported yet.");
1494  }
1496  query.set_result_table_id(td->tableId);
1497  std::list<int> result_col_list;
1498  if (column_list.empty()) {
1499  const std::list<const ColumnDescriptor*> all_cols =
1500  catalog.getAllColumnMetadataForTable(td->tableId, false, false, true);
1501  for (auto cd : all_cols) {
1502  result_col_list.push_back(cd->columnId);
1503  }
1504  } else {
1505  for (auto& c : column_list) {
1506  const ColumnDescriptor* cd = catalog.getMetadataForColumn(td->tableId, *c);
1507  if (cd == nullptr) {
1508  throw std::runtime_error("Column " + *c + " does not exist.");
1509  }
1510  result_col_list.push_back(cd->columnId);
1511  const auto& col_ti = cd->columnType;
1512  if (col_ti.get_physical_cols() > 0) {
1513  CHECK(cd->columnType.is_geometry());
1514  for (auto i = 1; i <= col_ti.get_physical_cols(); i++) {
1515  const ColumnDescriptor* pcd =
1516  catalog.getMetadataForColumn(td->tableId, cd->columnId + i);
1517  if (pcd == nullptr) {
1518  throw std::runtime_error("Column " + *c + "'s metadata is incomplete.");
1519  }
1520  result_col_list.push_back(pcd->columnId);
1521  }
1522  }
1523  }
1524  if (catalog.getAllColumnMetadataForTable(td->tableId, false, false, true).size() !=
1525  result_col_list.size()) {
1526  throw std::runtime_error("Insert into a subset of columns is not supported yet.");
1527  }
1528  }
1529  query.set_result_col_list(result_col_list);
1530 }
void validate_non_foreign_table_write(const TableDescriptor *table_descriptor)
Definition: FsiUtils.h:22
std::unique_ptr< std::string > table
Definition: ParserNode.h:1989
void set_result_col_list(const std::list< int > &col_list)
Definition: Analyzer.h:1629
CHECK(cgen_state)
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
std::list< std::unique_ptr< std::string > > column_list
Definition: ParserNode.h:1990
specifies the content in-memory of a row in the column metadata table
void set_result_table_id(int id)
Definition: Analyzer.h:1630
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:1704
void set_stmt_type(SQLStmtType t)
Definition: Analyzer.h:1638
bool is_geometry() const
Definition: sqltypes.h:427
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.
specifies the content in-memory of a row in the table metadata table

+ Here is the call graph for this function:

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

Definition at line 1982 of file ParserNode.h.

References column_list.

1982  {
1983  return column_list;
1984  }
std::list< std::unique_ptr< std::string > > column_list
Definition: ParserNode.h:1990
const std::string* Parser::InsertStmt::get_table ( ) const
inline

Definition at line 1981 of file ParserNode.h.

References table.

1981 { return table.get(); }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1989

Member Data Documentation

std::list<std::unique_ptr<std::string> > Parser::InsertStmt::column_list
protected

Definition at line 1990 of file ParserNode.h.

Referenced by get_column_list(), and InsertStmt().

std::unique_ptr<std::string> Parser::InsertStmt::table
protected

Definition at line 1989 of file ParserNode.h.

Referenced by get_table().


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