OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::RenameUserStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::RenameUserStmt:
+ Collaboration diagram for Parser::RenameUserStmt:

Public Member Functions

 RenameUserStmt (const rapidjson::Value &payload)
 
 RenameUserStmt (std::string *username, std::string *new_username)
 
auto const & getOldUserName ()
 
auto const & getNewUserName ()
 
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 > username_
 
std::unique_ptr< std::string > new_username_
 

Detailed Description

Definition at line 1309 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::RenameUserStmt::RenameUserStmt ( const rapidjson::Value &  payload)

Definition at line 5114 of file ParserNode.cpp.

References CHECK, json_str(), new_username_, and username_.

5114  {
5115  CHECK(payload.HasMember("name"));
5116  username_ = std::make_unique<std::string>(json_str(payload["name"]));
5117  CHECK(payload.HasMember("newName"));
5118  new_username_ = std::make_unique<std::string>(json_str(payload["newName"]));
5119 }
std::unique_ptr< std::string > username_
Definition: ParserNode.h:1320
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:46
std::unique_ptr< std::string > new_username_
Definition: ParserNode.h:1321
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

Parser::RenameUserStmt::RenameUserStmt ( std::string *  username,
std::string *  new_username 
)
inline

Definition at line 1312 of file ParserNode.h.

1313  : username_(username), new_username_(new_username) {}
std::unique_ptr< std::string > username_
Definition: ParserNode.h:1320
std::unique_ptr< std::string > new_username_
Definition: ParserNode.h:1321

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 5121 of file ParserNode.cpp.

References Catalog_Namespace::SessionInfo::get_currentUser(), lockmgr::instance(), Catalog_Namespace::UserMetadata::isSuper, new_username_, and username_.

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

5122  {
5123  if (read_only_mode) {
5124  throw std::runtime_error("RENAME TABLE invalid in read only mode.");
5125  }
5126  if (!session.get_currentUser().isSuper) {
5127  throw std::runtime_error("Only a super user can rename users.");
5128  }
5129 
5131  if (!SysCatalog::instance().getMetadataForUser(*username_, user)) {
5132  throw std::runtime_error("User " + *username_ + " does not exist.");
5133  }
5134 
5135  SysCatalog::instance().renameUser(*username_, *new_username_);
5136 }
std::unique_ptr< std::string > username_
Definition: ParserNode.h:1320
std::unique_ptr< std::string > new_username_
Definition: ParserNode.h:1321
T & instance()
Definition: LockMgr.cpp:101
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:88
std::atomic< bool > isSuper
Definition: SysCatalog.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

auto const& Parser::RenameUserStmt::getNewUserName ( )
inline

Definition at line 1315 of file ParserNode.h.

References new_username_.

1315 { return new_username_; }
std::unique_ptr< std::string > new_username_
Definition: ParserNode.h:1321
auto const& Parser::RenameUserStmt::getOldUserName ( )
inline

Definition at line 1314 of file ParserNode.h.

References username_.

1314 { return username_; }
std::unique_ptr< std::string > username_
Definition: ParserNode.h:1320

Member Data Documentation

std::unique_ptr<std::string> Parser::RenameUserStmt::new_username_
private

Definition at line 1321 of file ParserNode.h.

Referenced by execute(), getNewUserName(), and RenameUserStmt().

std::unique_ptr<std::string> Parser::RenameUserStmt::username_
private

Definition at line 1320 of file ParserNode.h.

Referenced by execute(), getOldUserName(), and RenameUserStmt().


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