OmniSciDB  f632821e96
Parser::RenameTableStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::RenameTableStmt:
+ Collaboration diagram for Parser::RenameTableStmt:

Public Member Functions

 RenameTableStmt (std::string *tab, std::string *new_tab_name)
 
const std::string * get_prev_table () const
 
const std::string * get_new_table () const
 
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 > new_table_name
 

Detailed Description

Definition at line 1267 of file ParserNode.h.

Constructor & Destructor Documentation

◆ RenameTableStmt()

Parser::RenameTableStmt::RenameTableStmt ( std::string *  tab,
std::string *  new_tab_name 
)
inline

Definition at line 1269 of file ParserNode.h.

1270  : table(tab), new_table_name(new_tab_name) {}
std::unique_ptr< std::string > new_table_name
Definition: ParserNode.h:1278
std::unique_ptr< std::string > table
Definition: ParserNode.h:1277

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 3244 of file ParserNode.cpp.

References CHECK, Parser::check_alter_table_privilege(), legacylockmgr::ExecutorOuterLock, Catalog_Namespace::SessionInfo::getCatalog(), and legacylockmgr::LockMgr< MutexType, KeyType >::getMutex().

3244  {
3245  auto& catalog = session.getCatalog();
3246 
3247  // TODO(adb): the catalog should be handling this locking (see AddColumStmt)
3248  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
3251 
3252  const auto td_with_lock =
3254  catalog, *table, false);
3255  const auto td = td_with_lock();
3256  CHECK(td);
3257 
3258  check_alter_table_privilege(session, td);
3259  if (catalog.getMetadataForTable(*new_table_name) != nullptr) {
3260  throw std::runtime_error("Table or View " + *new_table_name + " already exists.");
3261  }
3262  catalog.renameTable(td, *new_table_name);
3263 }
Catalog & getCatalog() const
Definition: SessionInfo.h:65
std::unique_ptr< std::string > new_table_name
Definition: ParserNode.h:1278
void check_alter_table_privilege(const Catalog_Namespace::SessionInfo &session, const TableDescriptor *td)
static std::shared_ptr< MutexType > getMutex(const LockType lockType, const KeyType &key)
Definition: LegacyLockMgr.h:51
#define CHECK(condition)
Definition: Logger.h:197
std::unique_ptr< std::string > table
Definition: ParserNode.h:1277
+ Here is the call graph for this function:

◆ get_new_table()

const std::string* Parser::RenameTableStmt::get_new_table ( ) const
inline

Definition at line 1273 of file ParserNode.h.

1273 { return new_table_name.get(); }
std::unique_ptr< std::string > new_table_name
Definition: ParserNode.h:1278

◆ get_prev_table()

const std::string* Parser::RenameTableStmt::get_prev_table ( ) const
inline

Definition at line 1272 of file ParserNode.h.

1272 { return table.get(); }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1277

Member Data Documentation

◆ new_table_name

std::unique_ptr<std::string> Parser::RenameTableStmt::new_table_name
private

Definition at line 1278 of file ParserNode.h.

◆ table

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

Definition at line 1277 of file ParserNode.h.


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