OmniSciDB  29e35f4d58
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 1227 of file ParserNode.h.

Constructor & Destructor Documentation

◆ RenameTableStmt()

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

Definition at line 1229 of file ParserNode.h.

1230  : table(tab), new_table_name(new_tab_name) {}
std::unique_ptr< std::string > new_table_name
Definition: ParserNode.h:1238
std::unique_ptr< std::string > table
Definition: ParserNode.h:1237

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 2958 of file ParserNode.cpp.

References Parser::check_alter_table_privilege(), and Catalog_Namespace::SessionInfo::getCatalog().

2958  {
2959  auto& catalog = session.getCatalog();
2960  const TableDescriptor* td = catalog.getMetadataForTable(*table);
2961  if (td == nullptr) {
2962  throw std::runtime_error("Table " + *table + " does not exist.");
2963  }
2964  check_alter_table_privilege(session, td);
2965  if (catalog.getMetadataForTable(*new_table_name) != nullptr) {
2966  throw std::runtime_error("Table or View " + *new_table_name + " already exists.");
2967  }
2968  catalog.renameTable(td, *new_table_name);
2969 }
Catalog & getCatalog() const
Definition: SessionInfo.h:90
std::unique_ptr< std::string > new_table_name
Definition: ParserNode.h:1238
void check_alter_table_privilege(const Catalog_Namespace::SessionInfo &session, const TableDescriptor *td)
specifies the content in-memory of a row in the table metadata table
std::unique_ptr< std::string > table
Definition: ParserNode.h:1237
+ Here is the call graph for this function:

◆ get_new_table()

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

Definition at line 1233 of file ParserNode.h.

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

◆ get_prev_table()

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

Definition at line 1232 of file ParserNode.h.

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

Member Data Documentation

◆ new_table_name

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

Definition at line 1238 of file ParserNode.h.

◆ table

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

Definition at line 1237 of file ParserNode.h.


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