OmniSciDB  72c90bc290
 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, bool read_only_mode) 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 1345 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 1347 of file ParserNode.h.

1348  : table_(tab), column_(col), new_column_name_(new_col_name) {}
std::unique_ptr< std::string > column_
Definition: ParserNode.h:1354
std::unique_ptr< std::string > new_column_name_
Definition: ParserNode.h:1355
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1353

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 5608 of file ParserNode.cpp.

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

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

5609  {
5610  if (read_only_mode) {
5611  throw std::runtime_error("RENAME COLUMN invalid in read only mode.");
5612  }
5613  auto& catalog = session.getCatalog();
5614 
5615  const auto execute_read_lock = legacylockmgr::getExecuteReadLock();
5616 
5617  const auto td_with_lock =
5619  catalog, *table_, false);
5620  const auto td = td_with_lock();
5621  CHECK(td);
5623 
5624  check_alter_table_privilege(session, td);
5625  const ColumnDescriptor* cd = catalog.getMetadataForColumn(td->tableId, *column_);
5626  if (cd == nullptr) {
5627  throw std::runtime_error("Column " + *column_ + " does not exist.");
5628  }
5629  if (catalog.getMetadataForColumn(td->tableId, *new_column_name_) != nullptr) {
5630  throw std::runtime_error("Column " + *new_column_name_ + " already exists.");
5631  }
5632  catalog.renameColumn(td, cd, *new_column_name_);
5633 }
auto getExecuteReadLock()
std::unique_ptr< std::string > column_
Definition: ParserNode.h:1354
specifies the content in-memory of a row in the column metadata table
std::unique_ptr< std::string > new_column_name_
Definition: ParserNode.h:1355
void check_alter_table_privilege(const Catalog_Namespace::SessionInfo &session, const TableDescriptor *td)
Catalog & getCatalog() const
Definition: SessionInfo.h:75
void validate_table_type(const TableDescriptor *td, const TableType expected_table_type, const std::string &command)
Definition: DdlUtils.cpp:745
#define CHECK(condition)
Definition: Logger.h:291
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1353

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

Referenced by execute().

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

Definition at line 1355 of file ParserNode.h.

Referenced by execute().

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

Definition at line 1353 of file ParserNode.h.

Referenced by execute().


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