OmniSciDB  dfae7c3b14
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 1281 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 1283 of file ParserNode.h.

1284  : table(tab), column(col), new_column_name(new_col_name) {}
std::unique_ptr< std::string > table
Definition: ParserNode.h:1288
std::unique_ptr< std::string > new_column_name
Definition: ParserNode.h:1290
std::unique_ptr< std::string > column
Definition: ParserNode.h:1289

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 3525 of file ParserNode.cpp.

References CHECK, Parser::check_alter_table_privilege(), and Catalog_Namespace::SessionInfo::getCatalog().

Referenced by omnisci.cursor.Cursor::executemany().

3525  {
3526  auto& catalog = session.getCatalog();
3527 
3528  const auto td_with_lock =
3530  catalog, *table, false);
3531  const auto td = td_with_lock();
3532  CHECK(td);
3533 
3534  check_alter_table_privilege(session, td);
3535  const ColumnDescriptor* cd = catalog.getMetadataForColumn(td->tableId, *column);
3536  if (cd == nullptr) {
3537  throw std::runtime_error("Column " + *column + " does not exist.");
3538  }
3539  if (catalog.getMetadataForColumn(td->tableId, *new_column_name) != nullptr) {
3540  throw std::runtime_error("Column " + *new_column_name + " already exists.");
3541  }
3542  catalog.renameColumn(td, cd, *new_column_name);
3543 }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1288
std::unique_ptr< std::string > new_column_name
Definition: ParserNode.h:1290
Catalog & getCatalog() const
Definition: SessionInfo.h:65
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:1289
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ column

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

Definition at line 1289 of file ParserNode.h.

◆ new_column_name

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

Definition at line 1290 of file ParserNode.h.

◆ table

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

Definition at line 1288 of file ParserNode.h.


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