OmniSciDB  eb3a3d0a03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 1330 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 1332 of file ParserNode.h.

1333  : table_(tab), column_(col), new_column_name_(new_col_name) {}
std::unique_ptr< std::string > column_
Definition: ParserNode.h:1338
std::unique_ptr< std::string > new_column_name_
Definition: ParserNode.h:1339
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1337

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 4513 of file ParserNode.cpp.

References CHECK, Parser::check_alter_table_privilege(), column_, Catalog_Namespace::SessionInfo::getCatalog(), new_column_name_, ddl_utils::TABLE, table_, TableDescriptor::tableId, and ddl_utils::validate_table_type().

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

4513  {
4514  auto& catalog = session.getCatalog();
4515 
4516  const auto td_with_lock =
4518  catalog, *table_, false);
4519  const auto td = td_with_lock();
4520  CHECK(td);
4522 
4523  check_alter_table_privilege(session, td);
4524  const ColumnDescriptor* cd = catalog.getMetadataForColumn(td->tableId, *column_);
4525  if (cd == nullptr) {
4526  throw std::runtime_error("Column " + *column_ + " does not exist.");
4527  }
4528  if (catalog.getMetadataForColumn(td->tableId, *new_column_name_) != nullptr) {
4529  throw std::runtime_error("Column " + *new_column_name_ + " already exists.");
4530  }
4531  catalog.renameColumn(td, cd, *new_column_name_);
4532 }
std::unique_ptr< std::string > column_
Definition: ParserNode.h:1338
specifies the content in-memory of a row in the column metadata table
std::unique_ptr< std::string > new_column_name_
Definition: ParserNode.h:1339
void check_alter_table_privilege(const Catalog_Namespace::SessionInfo &session, const TableDescriptor *td)
Catalog & getCatalog() const
Definition: SessionInfo.h:67
void validate_table_type(const TableDescriptor *td, const TableType expected_table_type, const std::string &command)
Definition: DdlUtils.cpp:650
#define CHECK(condition)
Definition: Logger.h:209
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1337

+ 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 1338 of file ParserNode.h.

Referenced by execute().

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

Definition at line 1339 of file ParserNode.h.

Referenced by execute().

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

Definition at line 1337 of file ParserNode.h.

Referenced by execute().


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