OmniSciDB  c07336695a
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 1800 of file ParserNode.h.

Constructor & Destructor Documentation

◆ InsertStmt()

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

Definition at line 1802 of file ParserNode.h.

References anonymous_namespace{ExecuteTest.cpp}::c().

1802  : table(t) {
1803  if (c) {
1804  for (const auto e : *c) {
1805  column_list.emplace_back(e);
1806  }
1807  delete c;
1808  }
1809  }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1818
void c(const std::string &query_string, const ExecutorDeviceType device_type)
std::list< std::unique_ptr< std::string > > column_list
Definition: ParserNode.h:1819
+ Here is the call graph for this function:

Member Function Documentation

◆ analyze()

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

Implements Parser::DMLStmt.

Implemented in Parser::InsertQueryStmt, and Parser::InsertValuesStmt.

Definition at line 1526 of file ParserNode.cpp.

References anonymous_namespace{ExecuteTest.cpp}::c(), CHECK, ColumnDescriptor::columnId, ColumnDescriptor::columnType, Catalog_Namespace::Catalog::getAllColumnMetadataForTable(), Catalog_Namespace::Catalog::getMetadataForColumn(), Catalog_Namespace::Catalog::getMetadataForTable(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_geometry(), TableDescriptor::isView, kINSERT, Analyzer::Query::set_result_col_list(), Analyzer::Query::set_result_table_id(), Analyzer::Query::set_stmt_type(), and TableDescriptor::tableId.

1527  {
1528  query.set_stmt_type(kINSERT);
1529  const TableDescriptor* td = catalog.getMetadataForTable(*table);
1530  if (td == nullptr) {
1531  throw std::runtime_error("Table " + *table + " does not exist.");
1532  }
1533  if (td->isView) {
1534  throw std::runtime_error("Insert to views is not supported yet.");
1535  }
1536  query.set_result_table_id(td->tableId);
1537  std::list<int> result_col_list;
1538  if (column_list.empty()) {
1539  const std::list<const ColumnDescriptor*> all_cols =
1540  catalog.getAllColumnMetadataForTable(td->tableId, false, false, true);
1541  for (auto cd : all_cols) {
1542  result_col_list.push_back(cd->columnId);
1543  }
1544  } else {
1545  for (auto& c : column_list) {
1546  const ColumnDescriptor* cd = catalog.getMetadataForColumn(td->tableId, *c);
1547  if (cd == nullptr) {
1548  throw std::runtime_error("Column " + *c + " does not exist.");
1549  }
1550  result_col_list.push_back(cd->columnId);
1551  const auto& col_ti = cd->columnType;
1552  if (col_ti.get_physical_cols() > 0) {
1553  CHECK(cd->columnType.is_geometry());
1554  for (auto i = 1; i <= col_ti.get_physical_cols(); i++) {
1555  const ColumnDescriptor* pcd =
1556  catalog.getMetadataForColumn(td->tableId, cd->columnId + i);
1557  if (pcd == nullptr) {
1558  throw std::runtime_error("Column " + *c + "'s metadata is incomplete.");
1559  }
1560  result_col_list.push_back(pcd->columnId);
1561  }
1562  }
1563  }
1564  if (catalog.getAllColumnMetadataForTable(td->tableId, false, false, true).size() !=
1565  result_col_list.size()) {
1566  throw std::runtime_error("Insert into a subset of columns is not supported yet.");
1567  }
1568  }
1569  query.set_result_col_list(result_col_list);
1570 }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1818
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
void c(const std::string &query_string, const ExecutorDeviceType device_type)
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
void set_result_col_list(const std::list< int > &col_list)
Definition: Analyzer.h:1467
std::list< std::unique_ptr< std::string > > column_list
Definition: ParserNode.h:1819
specifies the content in-memory of a row in the column metadata table
void set_result_table_id(int id)
Definition: Analyzer.h:1468
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:1579
void set_stmt_type(SQLStmtType t)
Definition: Analyzer.h:1476
#define CHECK(condition)
Definition: Logger.h:187
bool is_geometry() const
Definition: sqltypes.h:458
SQLTypeInfo columnType
specifies the content in-memory of a row in the table metadata table
+ Here is the call graph for this function:

◆ get_column_list()

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

Definition at line 1811 of file ParserNode.h.

References anonymous_namespace{UpdateMetadataTest.cpp}::query.

1811  {
1812  return column_list;
1813  }
std::list< std::unique_ptr< std::string > > column_list
Definition: ParserNode.h:1819

◆ get_table()

const std::string* Parser::InsertStmt::get_table ( ) const
inline

Definition at line 1810 of file ParserNode.h.

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

Member Data Documentation

◆ column_list

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

Definition at line 1819 of file ParserNode.h.

◆ table

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

Definition at line 1818 of file ParserNode.h.


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