OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Parser::RenameColumnStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::RenameColumnStmt:
+ Collaboration diagram for Parser::RenameColumnStmt:

Public Member Functions

 RenameColumnStmt (std::string *tab, std::string *col, std::string *new_col_name)
 
void execute (const Catalog_Namespace::SessionInfo &session) override
 
- Public Member Functions inherited from Parser::DDLStmt
void setColumnDescriptor (ColumnDescriptor &cd, const ColumnDef *coldef)
 
- Public Member Functions inherited from Parser::Node
virtual ~Node ()
 

Private Attributes

std::unique_ptr< std::string > table
 
std::unique_ptr< std::string > column
 
std::unique_ptr< std::string > new_column_name
 

Detailed Description

Definition at line 1241 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::RenameColumnStmt::RenameColumnStmt ( std::string *  tab,
std::string *  col,
std::string *  new_col_name 
)
inline

Definition at line 1243 of file ParserNode.h.

1244  : table(tab), column(col), new_column_name(new_col_name) {}
std::unique_ptr< std::string > table
Definition: ParserNode.h:1248
std::unique_ptr< std::string > new_column_name
Definition: ParserNode.h:1250
std::unique_ptr< std::string > column
Definition: ParserNode.h:1249

Member Function Documentation

void Parser::RenameColumnStmt::execute ( const Catalog_Namespace::SessionInfo session)
overridevirtual

Implements Parser::DDLStmt.

Definition at line 3407 of file ParserNode.cpp.

References Parser::check_alter_table_privilege(), Catalog_Namespace::SessionInfo::getCatalog(), reserved_keywords, and TableDescriptor::tableId.

3407  {
3408  auto& catalog = session.getCatalog();
3409  const TableDescriptor* td = catalog.getMetadataForTable(*table);
3410  if (td == nullptr) {
3411  throw std::runtime_error("Table " + *table + " does not exist.");
3412  }
3413  check_alter_table_privilege(session, td);
3414  const ColumnDescriptor* cd = catalog.getMetadataForColumn(td->tableId, *column);
3415  if (cd == nullptr) {
3416  throw std::runtime_error("Column " + *column + " does not exist.");
3417  }
3418  if (catalog.getMetadataForColumn(td->tableId, *new_column_name) != nullptr) {
3419  throw std::runtime_error("Column " + *new_column_name + " already exists.");
3420  }
3421  if (reserved_keywords.find(boost::to_upper_copy<std::string>(*new_column_name)) !=
3422  reserved_keywords.end()) {
3423  throw std::runtime_error("Cannot create column with reserved keyword '" +
3424  *new_column_name + "'");
3425  }
3426  catalog.renameColumn(td, cd, *new_column_name);
3427 }
static std::set< std::string > reserved_keywords
std::unique_ptr< std::string > table
Definition: ParserNode.h:1248
std::unique_ptr< std::string > new_column_name
Definition: ParserNode.h:1250
specifies the content in-memory of a row in the column metadata table
void check_alter_table_privilege(const Catalog_Namespace::SessionInfo &session, const TableDescriptor *td)
Catalog & getCatalog() const
Definition: SessionInfo.h:90
std::unique_ptr< std::string > column
Definition: ParserNode.h:1249
specifies the content in-memory of a row in the table metadata table

+ Here is the call graph for this function:

Member Data Documentation

std::unique_ptr<std::string> Parser::RenameColumnStmt::column
private

Definition at line 1249 of file ParserNode.h.

std::unique_ptr<std::string> Parser::RenameColumnStmt::new_column_name
private

Definition at line 1250 of file ParserNode.h.

std::unique_ptr<std::string> Parser::RenameColumnStmt::table
private

Definition at line 1248 of file ParserNode.h.


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