OmniSciDB  04ee39c94c
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 1221 of file ParserNode.h.

Constructor & Destructor Documentation

◆ RenameTableStmt()

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

Definition at line 1223 of file ParserNode.h.

1224  : table(tab), new_table_name(new_tab_name) {}
std::unique_ptr< std::string > new_table_name
Definition: ParserNode.h:1232
std::unique_ptr< std::string > table
Definition: ParserNode.h:1231

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 2859 of file ParserNode.cpp.

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

2859  {
2860  auto& catalog = session.getCatalog();
2861  const TableDescriptor* td = catalog.getMetadataForTable(*table);
2862  if (td == nullptr) {
2863  throw std::runtime_error("Table " + *table + " does not exist.");
2864  }
2865  check_alter_table_privilege(session, td);
2866  if (catalog.getMetadataForTable(*new_table_name) != nullptr) {
2867  throw std::runtime_error("Table or View " + *new_table_name + " already exists.");
2868  }
2869  catalog.renameTable(td, *new_table_name);
2870 }
Catalog & getCatalog() const
Definition: SessionInfo.h:90
std::unique_ptr< std::string > new_table_name
Definition: ParserNode.h:1232
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:1231
+ Here is the call graph for this function:

◆ get_new_table()

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

Definition at line 1227 of file ParserNode.h.

References session.

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

◆ get_prev_table()

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

Definition at line 1226 of file ParserNode.h.

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

Member Data Documentation

◆ new_table_name

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

Definition at line 1232 of file ParserNode.h.

◆ table

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

Definition at line 1231 of file ParserNode.h.


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