OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ReassignOwnedCommand Class Reference

#include <DdlCommandExecutor.h>

+ Inheritance diagram for ReassignOwnedCommand:
+ Collaboration diagram for ReassignOwnedCommand:

Public Member Functions

 ReassignOwnedCommand (const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
ExecutionResult execute (bool read_only_mode) override
- Public Member Functions inherited from DdlCommand
 DdlCommand (const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)

Private Attributes

std::string new_owner_
std::set< std::string > old_owners_

Additional Inherited Members

- Protected Attributes inherited from DdlCommand
const DdlCommandDataddl_data_
< Catalog_Namespace::SessionInfo
const > 

Detailed Description

Definition at line 293 of file DdlCommandExecutor.h.

Constructor & Destructor Documentation

ReassignOwnedCommand::ReassignOwnedCommand ( const DdlCommandData ddl_data,
std::shared_ptr< Catalog_Namespace::SessionInfo const >  session_ptr 

Definition at line 2378 of file DdlCommandExecutor.cpp.

References CHECK, DdlCommand::ddl_data_, anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload(), new_owner_, and old_owners_.

2381  : DdlCommand(ddl_data, session_ptr) {
2382  auto& ddl_payload = extractPayload(ddl_data_);
2383  CHECK(ddl_payload.HasMember("oldOwners"));
2384  CHECK(ddl_payload["oldOwners"].IsArray());
2385  for (const auto& old_owner : ddl_payload["oldOwners"].GetArray()) {
2386  CHECK(old_owner.IsString());
2387  old_owners_.emplace(old_owner.GetString());
2388  }
2389  CHECK(ddl_payload.HasMember("newOwner"));
2390  CHECK(ddl_payload["newOwner"].IsString());
2391  new_owner_ = ddl_payload["newOwner"].GetString();
2392 }
std::set< std::string > old_owners_
const DdlCommandData & ddl_data_
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
DdlCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

Member Function Documentation

ExecutionResult ReassignOwnedCommand::execute ( bool  read_only_mode)

Executes the DDL command corresponding to provided JSON payload.

_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 2394 of file DdlCommandExecutor.cpp.

References new_owner_, old_owners_, and DdlCommand::session_ptr_.

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

2394  {
2395  if (read_only_mode) {
2396  throw std::runtime_error("REASSIGN OWNER invalid in read only mode.");
2397  }
2398  if (!session_ptr_->get_currentUser().isSuper) {
2399  throw std::runtime_error{
2400  "Only super users can reassign ownership of database objects."};
2401  }
2402  const auto catalog = session_ptr_->get_catalog_ptr();
2403  catalog->reassignOwners(old_owners_, new_owner_);
2404  return ExecutionResult();
2405 }
std::set< std::string > old_owners_
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_

+ Here is the caller graph for this function:

Member Data Documentation

std::string ReassignOwnedCommand::new_owner_

Definition at line 301 of file DdlCommandExecutor.h.

Referenced by execute(), and ReassignOwnedCommand().

std::set<std::string> ReassignOwnedCommand::old_owners_

Definition at line 302 of file DdlCommandExecutor.h.

Referenced by execute(), and ReassignOwnedCommand().

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