OmniSciDB  b24e664e58
 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 1901 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1903 of file ParserNode.h.

References column_list.

1903  : table(t) {
1904  if (c) {
1905  for (const auto e : *c) {
1906  column_list.emplace_back(e);
1907  }
1908  delete c;
1909  }
1910  }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1919
std::list< std::unique_ptr< std::string > > column_list
Definition: ParserNode.h:1920

Member Function Documentation

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 1541 of file ParserNode.cpp.

References 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.

1542  {
1543  query.set_stmt_type(kINSERT);
1544  const TableDescriptor* td = catalog.getMetadataForTable(*table);
1545  if (td == nullptr) {
1546  throw std::runtime_error("Table " + *table + " does not exist.");
1547  }
1548  if (td->isView) {
1549  throw std::runtime_error("Insert to views is not supported yet.");
1550  }
1551  query.set_result_table_id(td->tableId);
1552  std::list<int> result_col_list;
1553  if (column_list.empty()) {
1554  const std::list<const ColumnDescriptor*> all_cols =
1555  catalog.getAllColumnMetadataForTable(td->tableId, false, false, true);
1556  for (auto cd : all_cols) {
1557  result_col_list.push_back(cd->columnId);
1558  }
1559  } else {
1560  for (auto& c : column_list) {
1561  const ColumnDescriptor* cd = catalog.getMetadataForColumn(td->tableId, *c);
1562  if (cd == nullptr) {
1563  throw std::runtime_error("Column " + *c + " does not exist.");
1564  }
1565  result_col_list.push_back(cd->columnId);
1566  const auto& col_ti = cd->columnType;
1567  if (col_ti.get_physical_cols() > 0) {
1568  CHECK(cd->columnType.is_geometry());
1569  for (auto i = 1; i <= col_ti.get_physical_cols(); i++) {
1570  const ColumnDescriptor* pcd =
1571  catalog.getMetadataForColumn(td->tableId, cd->columnId + i);
1572  if (pcd == nullptr) {
1573  throw std::runtime_error("Column " + *c + "'s metadata is incomplete.");
1574  }
1575  result_col_list.push_back(pcd->columnId);
1576  }
1577  }
1578  }
1579  if (catalog.getAllColumnMetadataForTable(td->tableId, false, false, true).size() !=
1580  result_col_list.size()) {
1581  throw std::runtime_error("Insert into a subset of columns is not supported yet.");
1582  }
1583  }
1584  query.set_result_col_list(result_col_list);
1585 }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1919
void set_result_col_list(const std::list< int > &col_list)
Definition: Analyzer.h:1544
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:1920
specifies the content in-memory of a row in the column metadata table
bool is_geometry() const
Definition: sqltypes.h:489
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:1581
void set_result_table_id(int id)
Definition: Analyzer.h:1545
void set_stmt_type(SQLStmtType t)
Definition: Analyzer.h:1553
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 1912 of file ParserNode.h.

References column_list.

1912  {
1913  return column_list;
1914  }
std::list< std::unique_ptr< std::string > > column_list
Definition: ParserNode.h:1920
const std::string* Parser::InsertStmt::get_table ( ) const
inline

Definition at line 1911 of file ParserNode.h.

References table.

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

Member Data Documentation

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

Definition at line 1920 of file ParserNode.h.

Referenced by get_column_list(), and InsertStmt().

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

Definition at line 1919 of file ParserNode.h.

Referenced by get_table().


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