OmniSciDB  72c90bc290
 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 1896 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1898 of file ParserNode.h.

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

Definition at line 6781 of file ParserNode.cpp.

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

6781  {
6782  CHECK(payload.HasMember("viewName"));
6783  view_name_ = std::make_unique<std::string>(json_str(payload["viewName"]));
6784 
6785  if_exists_ = false;
6786  if (payload.HasMember("ifExists")) {
6787  if_exists_ = json_bool(payload["ifExists"]);
6788  }
6789 }
std::unique_ptr< std::string > view_name_
Definition: ParserNode.h:1906
const bool json_bool(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:51
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:46
#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 6791 of file ParserNode.cpp.

References CHECK, Catalog_Namespace::SessionInfo::checkDBAccessPrivileges(), AccessPrivileges::DROP_VIEW, Catalog_Namespace::SessionInfo::getCatalog(), legacylockmgr::getExecuteReadLock(), if_exists_, ddl_utils::validate_table_type(), ddl_utils::VIEW, view_name_, and ViewDBObjectType.

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

6792  {
6793  if (read_only_mode) {
6794  throw std::runtime_error("DROP VIEW invalid in read only mode.");
6795  }
6796  auto& catalog = session.getCatalog();
6797 
6798  const auto execute_read_lock = legacylockmgr::getExecuteReadLock();
6799 
6800  const TableDescriptor* td{nullptr};
6801  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
6802 
6803  try {
6804  td_with_lock =
6805  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
6807  catalog, *view_name_, false));
6808  td = (*td_with_lock)();
6809  } catch (const std::runtime_error& e) {
6810  if (if_exists_) {
6811  return;
6812  } else {
6813  throw e;
6814  }
6815  }
6816 
6817  CHECK(td);
6818  CHECK(td_with_lock);
6819 
6820  if (!session.checkDBAccessPrivileges(
6822  throw std::runtime_error("View " + *view_name_ +
6823  " will not be dropped. User has no drop view privileges.");
6824  }
6825 
6827  catalog.dropTable(td);
6828 }
std::unique_ptr< std::string > view_name_
Definition: ParserNode.h:1906
auto getExecuteReadLock()
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:745
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 1901 of file ParserNode.h.

References view_name_.

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

Member Data Documentation

bool Parser::DropViewStmt::if_exists_
private

Definition at line 1907 of file ParserNode.h.

Referenced by DropViewStmt(), and execute().

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

Definition at line 1906 of file ParserNode.h.

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


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