OmniSciDB  ba1bac9284
 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 1325 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 1327 of file ParserNode.h.

1328  : table(tab), column(col), new_column_name(new_col_name) {}
std::unique_ptr< std::string > table
Definition: ParserNode.h:1332
std::unique_ptr< std::string > new_column_name
Definition: ParserNode.h:1334
std::unique_ptr< std::string > column
Definition: ParserNode.h:1333

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 4352 of file ParserNode.cpp.

References CHECK, Parser::check_alter_table_privilege(), Catalog_Namespace::SessionInfo::getCatalog(), test_readcsv::table, ddl_utils::TABLE, TableDescriptor::tableId, and ddl_utils::validate_table_type().

Referenced by Parser::AlterTableStmt::delegateExecute(), and omnisci.cursor.Cursor::executemany().

4352  {
4353  auto& catalog = session.getCatalog();
4354 
4355  const auto td_with_lock =
4357  catalog, *table, false);
4358  const auto td = td_with_lock();
4359  CHECK(td);
4361 
4362  check_alter_table_privilege(session, td);
4363  const ColumnDescriptor* cd = catalog.getMetadataForColumn(td->tableId, *column);
4364  if (cd == nullptr) {
4365  throw std::runtime_error("Column " + *column + " does not exist.");
4366  }
4367  if (catalog.getMetadataForColumn(td->tableId, *new_column_name) != nullptr) {
4368  throw std::runtime_error("Column " + *new_column_name + " already exists.");
4369  }
4370  catalog.renameColumn(td, cd, *new_column_name);
4371 }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1332
std::unique_ptr< std::string > new_column_name
Definition: ParserNode.h:1334
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:67
std::unique_ptr< std::string > column
Definition: ParserNode.h:1333
void validate_table_type(const TableDescriptor *td, const TableType expected_table_type, const std::string &command)
Definition: DdlUtils.cpp:554
#define CHECK(condition)
Definition: Logger.h:206

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 1333 of file ParserNode.h.

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

Definition at line 1334 of file ParserNode.h.

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

Definition at line 1332 of file ParserNode.h.


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