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

Constructor & Destructor Documentation

◆ RenameColumnStmt()

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

Definition at line 1237 of file ParserNode.h.

References session.

1238  : table(tab), column(col), new_column_name(new_col_name) {}
std::unique_ptr< std::string > table
Definition: ParserNode.h:1242
std::unique_ptr< std::string > new_column_name
Definition: ParserNode.h:1244
std::unique_ptr< std::string > column
Definition: ParserNode.h:1243

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 3304 of file ParserNode.cpp.

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

3304  {
3305  auto& catalog = session.getCatalog();
3306  const TableDescriptor* td = catalog.getMetadataForTable(*table);
3307  if (td == nullptr) {
3308  throw std::runtime_error("Table " + *table + " does not exist.");
3309  }
3310  check_alter_table_privilege(session, td);
3311  const ColumnDescriptor* cd = catalog.getMetadataForColumn(td->tableId, *column);
3312  if (cd == nullptr) {
3313  throw std::runtime_error("Column " + *column + " does not exist.");
3314  }
3315  if (catalog.getMetadataForColumn(td->tableId, *new_column_name) != nullptr) {
3316  throw std::runtime_error("Column " + *new_column_name + " already exists.");
3317  }
3318  if (reserved_keywords.find(boost::to_upper_copy<std::string>(*new_column_name)) !=
3319  reserved_keywords.end()) {
3320  throw std::runtime_error("Cannot create column with reserved keyword '" +
3321  *new_column_name + "'");
3322  }
3323  catalog.renameColumn(td, cd, *new_column_name);
3324 }
static std::set< std::string > reserved_keywords
std::unique_ptr< std::string > table
Definition: ParserNode.h:1242
std::unique_ptr< std::string > new_column_name
Definition: ParserNode.h:1244
Catalog & getCatalog() const
Definition: SessionInfo.h:90
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)
std::unique_ptr< std::string > column
Definition: ParserNode.h:1243
specifies the content in-memory of a row in the table metadata table
+ Here is the call graph for this function:

Member Data Documentation

◆ column

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

Definition at line 1243 of file ParserNode.h.

◆ new_column_name

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

Definition at line 1244 of file ParserNode.h.

◆ table

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

Definition at line 1242 of file ParserNode.h.


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