OmniSciDB  a5dc49c757
 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_
 
bool all_
 

Additional Inherited Members

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

Detailed Description

Definition at line 399 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 3615 of file DdlCommandExecutor.cpp.

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

3618  : DdlCommand(ddl_data, session_ptr) {
3619  auto& ddl_payload = extractPayload(ddl_data_);
3620  CHECK(ddl_payload.HasMember("all"));
3621  CHECK(ddl_payload["all"].IsBool());
3622  CHECK(ddl_payload.HasMember("oldOwners"));
3623  CHECK(ddl_payload["oldOwners"].IsArray());
3624  for (const auto& old_owner : ddl_payload["oldOwners"].GetArray()) {
3625  CHECK(old_owner.IsString());
3626  old_owners_.emplace(old_owner.GetString());
3627  }
3628  CHECK(ddl_payload.HasMember("newOwner"));
3629  CHECK(ddl_payload["newOwner"].IsString());
3630  new_owner_ = ddl_payload["newOwner"].GetString();
3631  all_ = ddl_payload["all"].GetBool();
3632 }
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:291

+ Here is the call graph for this function:

Member Function Documentation

ExecutionResult ReassignOwnedCommand::execute ( bool  read_only_mode)
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 3634 of file DdlCommandExecutor.cpp.

References all_, Catalog_Namespace::SysCatalog::getCatalogsForAllDbs(), legacylockmgr::getExecuteWriteLock(), Catalog_Namespace::SysCatalog::instance(), new_owner_, old_owners_, and DdlCommand::session_ptr_.

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

3634  {
3635  auto execute_write_lock = legacylockmgr::getExecuteWriteLock();
3636 
3637  if (read_only_mode) {
3638  throw std::runtime_error("REASSIGN OWNER invalid in read only mode.");
3639  }
3640  if (!session_ptr_->get_currentUser().isSuper) {
3641  throw std::runtime_error{
3642  "Only super users can reassign ownership of database objects."};
3643  }
3644  if (all_) {
3646  for (auto& catalog : catalogs) {
3647  catalog->reassignOwners(old_owners_, new_owner_);
3648  }
3649  } else {
3650  const auto catalog = session_ptr_->get_catalog_ptr();
3651  catalog->reassignOwners(old_owners_, new_owner_);
3652  }
3653  return ExecutionResult();
3654 }
std::vector< Catalog * > getCatalogsForAllDbs()
std::set< std::string > old_owners_
static SysCatalog & instance()
Definition: SysCatalog.h:343
auto getExecuteWriteLock()
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

bool ReassignOwnedCommand::all_
private

Definition at line 409 of file DdlCommandExecutor.h.

Referenced by execute(), and ReassignOwnedCommand().

std::string ReassignOwnedCommand::new_owner_
private

Definition at line 407 of file DdlCommandExecutor.h.

Referenced by execute(), and ReassignOwnedCommand().

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

Definition at line 408 of file DdlCommandExecutor.h.

Referenced by execute(), and ReassignOwnedCommand().


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