OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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

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

Implements Parser::DDLStmt.

Definition at line 3245 of file ParserNode.cpp.

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

3245  {
3246  auto& catalog = session.getCatalog();
3247 
3248  // TODO(adb): the catalog should be handling this locking (see AddColumStmt)
3249  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
3252 
3253  const auto td_with_lock =
3255  catalog, *table, false);
3256  const auto td = td_with_lock();
3257  CHECK(td);
3258 
3259  check_alter_table_privilege(session, td);
3260  if (catalog.getMetadataForTable(*new_table_name) != nullptr) {
3261  throw std::runtime_error("Table or View " + *new_table_name + " already exists.");
3262  }
3263  catalog.renameTable(td, *new_table_name);
3264 }
CHECK(cgen_state)
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)
Catalog & getCatalog() const
Definition: SessionInfo.h:65
static std::shared_ptr< MutexType > getMutex(const LockType lockType, const KeyType &key)
Definition: LegacyLockMgr.h:51
std::unique_ptr< std::string > table
Definition: ParserNode.h:1277

+ Here is the call graph for this function:

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

Definition at line 1273 of file ParserNode.h.

References new_table_name.

1273 { return new_table_name.get(); }
std::unique_ptr< std::string > new_table_name
Definition: ParserNode.h:1278
const std::string* Parser::RenameTableStmt::get_prev_table ( ) const
inline

Definition at line 1272 of file ParserNode.h.

References table.

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

Member Data Documentation

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

Definition at line 1278 of file ParserNode.h.

Referenced by get_new_table().

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

Definition at line 1277 of file ParserNode.h.

Referenced by get_prev_table().


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