OmniSciDB  a5dc49c757
 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 6802 of file ParserNode.cpp.

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

6802  {
6803  CHECK(payload.HasMember("viewName"));
6804  view_name_ = std::make_unique<std::string>(json_str(payload["viewName"]));
6805 
6806  if_exists_ = false;
6807  if (payload.HasMember("ifExists")) {
6808  if_exists_ = json_bool(payload["ifExists"]);
6809  }
6810 }
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 6812 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().

6813  {
6814  if (read_only_mode) {
6815  throw std::runtime_error("DROP VIEW invalid in read only mode.");
6816  }
6817  auto& catalog = session.getCatalog();
6818 
6819  const auto execute_read_lock = legacylockmgr::getExecuteReadLock();
6820 
6821  const TableDescriptor* td{nullptr};
6822  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
6823 
6824  try {
6825  td_with_lock =
6826  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
6828  catalog, *view_name_, false));
6829  td = (*td_with_lock)();
6830  } catch (const std::runtime_error& e) {
6831  if (if_exists_) {
6832  return;
6833  } else {
6834  throw e;
6835  }
6836  }
6837 
6838  CHECK(td);
6839  CHECK(td_with_lock);
6840 
6841  if (!session.checkDBAccessPrivileges(
6843  throw std::runtime_error("View " + *view_name_ +
6844  " will not be dropped. User has no drop view privileges.");
6845  }
6846 
6848  catalog.dropTable(td);
6849 }
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: