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

#include <ParserNode.h>

+ Inheritance diagram for Parser::DropViewStmt:
+ Collaboration diagram for Parser::DropViewStmt:

Public Member Functions

 DropViewStmt (std::string *v, bool i)
 
 DropViewStmt (const rapidjson::Value &payload)
 
const std::string * get_view_name () const
 
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 > view_name_
 
bool if_exists_
 

Detailed Description

Definition at line 1909 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::DropViewStmt::DropViewStmt ( std::string *  v,
bool  i 
)
inline

Definition at line 1911 of file ParserNode.h.

1911 : view_name_(v), if_exists_(i) {}
std::unique_ptr< std::string > view_name_
Definition: ParserNode.h:1919
Parser::DropViewStmt::DropViewStmt ( const rapidjson::Value &  payload)

Definition at line 6485 of file ParserNode.cpp.

References CHECK, if_exists_, json_bool(), json_str(), and view_name_.

6485  {
6486  CHECK(payload.HasMember("viewName"));
6487  view_name_ = std::make_unique<std::string>(json_str(payload["viewName"]));
6488 
6489  if_exists_ = false;
6490  if (payload.HasMember("ifExists")) {
6491  if_exists_ = json_bool(payload["ifExists"]);
6492  }
6493 }
std::unique_ptr< std::string > view_name_
Definition: ParserNode.h:1919
const bool json_bool(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:49
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 6495 of file ParserNode.cpp.

References CHECK, Catalog_Namespace::SessionInfo::checkDBAccessPrivileges(), AccessPrivileges::DROP_VIEW, legacylockmgr::ExecutorOuterLock, Catalog_Namespace::SessionInfo::getCatalog(), legacylockmgr::LockMgr< MutexType, KeyType >::getMutex(), if_exists_, ddl_utils::validate_table_type(), ddl_utils::VIEW, view_name_, and ViewDBObjectType.

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

6496  {
6497  if (read_only_mode) {
6498  throw std::runtime_error("DROP VIEW invalid in read only mode.");
6499  }
6500  auto& catalog = session.getCatalog();
6501 
6502  const auto execute_read_lock =
6506 
6507  const TableDescriptor* td{nullptr};
6508  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
6509 
6510  try {
6511  td_with_lock =
6512  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
6514  catalog, *view_name_, false));
6515  td = (*td_with_lock)();
6516  } catch (const std::runtime_error& e) {
6517  if (if_exists_) {
6518  return;
6519  } else {
6520  throw e;
6521  }
6522  }
6523 
6524  CHECK(td);
6525  CHECK(td_with_lock);
6526 
6527  if (!session.checkDBAccessPrivileges(
6529  throw std::runtime_error("View " + *view_name_ +
6530  " will not be dropped. User has no drop view privileges.");
6531  }
6532 
6534  catalog.dropTable(td);
6535 }
static std::shared_ptr< WrapperType< MutexType > > getMutex(const LockType lockType, const KeyType &key)
std::unique_ptr< std::string > view_name_
Definition: ParserNode.h:1919
std::shared_lock< T > shared_lock
Catalog & getCatalog() const
Definition: SessionInfo.h:75
void validate_table_type(const TableDescriptor *td, const TableType expected_table_type, const std::string &command)
Definition: DdlUtils.cpp:708
static const AccessPrivileges DROP_VIEW
Definition: DBObject.h:179
#define CHECK(condition)
Definition: Logger.h:291
bool checkDBAccessPrivileges(const DBObjectType &permissionType, const AccessPrivileges &privs, const std::string &objectName="") const
Definition: SessionInfo.cpp:24

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::string* Parser::DropViewStmt::get_view_name ( ) const
inline

Definition at line 1914 of file ParserNode.h.

References view_name_.

1914 { return view_name_.get(); }
std::unique_ptr< std::string > view_name_
Definition: ParserNode.h:1919

Member Data Documentation

bool Parser::DropViewStmt::if_exists_
private

Definition at line 1920 of file ParserNode.h.

Referenced by DropViewStmt(), and execute().

std::unique_ptr<std::string> Parser::DropViewStmt::view_name_
private

Definition at line 1919 of file ParserNode.h.

Referenced by DropViewStmt(), execute(), and get_view_name().


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