OmniSciDB  4201147b46
 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 1953 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1955 of file ParserNode.h.

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

Definition at line 6390 of file ParserNode.cpp.

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

6390  {
6391  CHECK(payload.HasMember("viewName"));
6392  view_name_ = std::make_unique<std::string>(json_str(payload["viewName"]));
6393 
6394  if_exists_ = false;
6395  if (payload.HasMember("ifExists")) {
6396  if_exists_ = json_bool(payload["ifExists"]);
6397  }
6398 }
std::unique_ptr< std::string > view_name_
Definition: ParserNode.h:1963
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:222

+ 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 6400 of file ParserNode.cpp.

References CHECK, Catalog_Namespace::SessionInfo::checkDBAccessPrivileges(), AccessPrivileges::DROP_VIEW, Catalog_Namespace::Catalog::dropTable(), 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().

6401  {
6402  if (read_only_mode) {
6403  throw std::runtime_error("DROP VIEW invalid in read only mode.");
6404  }
6405  auto& catalog = session.getCatalog();
6406 
6407  const auto execute_read_lock = heavyai::shared_lock<heavyai::shared_mutex>(
6410 
6411  const TableDescriptor* td{nullptr};
6412  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
6413 
6414  try {
6415  td_with_lock =
6416  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
6418  catalog, *view_name_, false));
6419  td = (*td_with_lock)();
6420  } catch (const std::runtime_error& e) {
6421  if (if_exists_) {
6422  return;
6423  } else {
6424  throw e;
6425  }
6426  }
6427 
6428  CHECK(td);
6429  CHECK(td_with_lock);
6430 
6431  if (!session.checkDBAccessPrivileges(
6433  throw std::runtime_error("View " + *view_name_ +
6434  " will not be dropped. User has no drop view privileges.");
6435  }
6436 
6438  catalog.dropTable(td);
6439 }
std::unique_ptr< std::string > view_name_
Definition: ParserNode.h:1963
std::shared_lock< T > shared_lock
Catalog & getCatalog() const
Definition: SessionInfo.h:65
static std::shared_ptr< MutexType > getMutex(const LockType lockType, const KeyType &key)
Definition: LegacyLockMgr.h:51
void validate_table_type(const TableDescriptor *td, const TableType expected_table_type, const std::string &command)
Definition: DdlUtils.cpp:693
static const AccessPrivileges DROP_VIEW
Definition: DBObject.h:179
#define CHECK(condition)
Definition: Logger.h:222
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 1958 of file ParserNode.h.

References view_name_.

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

Member Data Documentation

bool Parser::DropViewStmt::if_exists_
private

Definition at line 1964 of file ParserNode.h.

Referenced by DropViewStmt(), and execute().

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

Definition at line 1963 of file ParserNode.h.

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


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