OmniSciDB  d2f719934e
 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 () 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 Member Functions inherited from DdlCommand
bool isDefaultServer (const std::string &server_name)
 
- Protected Attributes inherited from DdlCommand
const DdlCommandDataddl_data_
 
std::shared_ptr
< Catalog_Namespace::SessionInfo
const
session_ptr_
 

Detailed Description

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

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

1801  : DdlCommand(ddl_data, session_ptr) {
1802  auto& ddl_payload = extractPayload(ddl_data_);
1803  CHECK(ddl_payload.HasMember("oldOwners"));
1804  CHECK(ddl_payload["oldOwners"].IsArray());
1805  for (const auto& old_owner : ddl_payload["oldOwners"].GetArray()) {
1806  CHECK(old_owner.IsString());
1807  old_owners_.emplace(old_owner.GetString());
1808  }
1809  CHECK(ddl_payload.HasMember("newOwner"));
1810  CHECK(ddl_payload["newOwner"].IsString());
1811  new_owner_ = ddl_payload["newOwner"].GetString();
1812 }
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:211

+ Here is the call graph for this function:

Member Function Documentation

ExecutionResult ReassignOwnedCommand::execute ( )
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 1814 of file DdlCommandExecutor.cpp.

References new_owner_, old_owners_, and DdlCommand::session_ptr_.

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

1814  {
1815  if (!session_ptr_->get_currentUser().isSuper) {
1816  throw std::runtime_error{
1817  "Only super users can reassign ownership of database objects."};
1818  }
1819  const auto catalog = session_ptr_->get_catalog_ptr();
1820  catalog->reassignOwners(old_owners_, new_owner_);
1821  return ExecutionResult();
1822 }
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_
private

Definition at line 210 of file DdlCommandExecutor.h.

Referenced by execute(), and ReassignOwnedCommand().

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

Definition at line 211 of file DdlCommandExecutor.h.

Referenced by execute(), and ReassignOwnedCommand().


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