OmniSciDB  a5dc49c757
 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 5629 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().

5630  {
5631  if (read_only_mode) {
5632  throw std::runtime_error("RENAME COLUMN invalid in read only mode.");
5633  }
5634  auto& catalog = session.getCatalog();
5635 
5636  const auto execute_read_lock = legacylockmgr::getExecuteReadLock();
5637 
5638  const auto td_with_lock =
5640  catalog, *table_, false);
5641  const auto td = td_with_lock();
5642  CHECK(td);
5644 
5645  check_alter_table_privilege(session, td);
5646  const ColumnDescriptor* cd = catalog.getMetadataForColumn(td->tableId, *column_);
5647  if (cd == nullptr) {
5648  throw std::runtime_error("Column " + *column_ + " does not exist.");
5649  }
5650  if (catalog.getMetadataForColumn(td->tableId, *new_column_name_) != nullptr) {
5651  throw std::runtime_error("Column " + *new_column_name_ + " already exists.");
5652  }
5653  catalog.renameColumn(td, cd, *new_column_name_);
5654 }
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: