OmniSciDB  c0231cc57d
 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 1358 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 1360 of file ParserNode.h.

1361  : table_(tab), column_(col), new_column_name_(new_col_name) {}
std::unique_ptr< std::string > column_
Definition: ParserNode.h:1367
std::unique_ptr< std::string > new_column_name_
Definition: ParserNode.h:1368
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1366

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 5269 of file ParserNode.cpp.

References CHECK, Parser::check_alter_table_privilege(), column_, legacylockmgr::ExecutorOuterLock, Catalog_Namespace::SessionInfo::getCatalog(), Catalog_Namespace::Catalog::getMetadataForColumn(), legacylockmgr::LockMgr< MutexType, KeyType >::getMutex(), new_column_name_, Catalog_Namespace::Catalog::renameColumn(), ddl_utils::TABLE, table_, TableDescriptor::tableId, and ddl_utils::validate_table_type().

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

5270  {
5271  if (read_only_mode) {
5272  throw std::runtime_error("RENAME COLUMN invalid in read only mode.");
5273  }
5274  auto& catalog = session.getCatalog();
5275 
5276  const auto execute_read_lock =
5280 
5281  const auto td_with_lock =
5283  catalog, *table_, false);
5284  const auto td = td_with_lock();
5285  CHECK(td);
5287 
5288  check_alter_table_privilege(session, td);
5289  const ColumnDescriptor* cd = catalog.getMetadataForColumn(td->tableId, *column_);
5290  if (cd == nullptr) {
5291  throw std::runtime_error("Column " + *column_ + " does not exist.");
5292  }
5293  if (catalog.getMetadataForColumn(td->tableId, *new_column_name_) != nullptr) {
5294  throw std::runtime_error("Column " + *new_column_name_ + " already exists.");
5295  }
5296  catalog.renameColumn(td, cd, *new_column_name_);
5297 }
static std::shared_ptr< WrapperType< MutexType > > getMutex(const LockType lockType, const KeyType &key)
std::unique_ptr< std::string > column_
Definition: ParserNode.h:1367
std::shared_lock< T > shared_lock
specifies the content in-memory of a row in the column metadata table
std::unique_ptr< std::string > new_column_name_
Definition: ParserNode.h:1368
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:708
#define CHECK(condition)
Definition: Logger.h:222
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1366

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

Referenced by execute().

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

Definition at line 1368 of file ParserNode.h.

Referenced by execute().

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

Definition at line 1366 of file ParserNode.h.

Referenced by execute().


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