OmniSciDB  eb3a3d0a03
 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) 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 1913 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1915 of file ParserNode.h.

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

Definition at line 5930 of file ParserNode.cpp.

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

5930  {
5931  CHECK(payload.HasMember("viewName"));
5932  view_name_ = std::make_unique<std::string>(json_str(payload["viewName"]));
5933 
5934  if_exists_ = false;
5935  if (payload.HasMember("ifExists")) {
5936  if_exists_ = json_bool(payload["ifExists"]);
5937  }
5938 }
std::unique_ptr< std::string > view_name_
Definition: ParserNode.h:1922
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:209

+ Here is the call graph for this function:

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 5940 of file ParserNode.cpp.

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

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

5940  {
5941  auto& catalog = session.getCatalog();
5942 
5943  const TableDescriptor* td{nullptr};
5944  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
5945 
5946  try {
5947  td_with_lock =
5948  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
5950  catalog, *view_name_, false));
5951  td = (*td_with_lock)();
5952  } catch (const std::runtime_error& e) {
5953  if (if_exists_) {
5954  return;
5955  } else {
5956  throw e;
5957  }
5958  }
5959 
5960  CHECK(td);
5961  CHECK(td_with_lock);
5962 
5963  if (!session.checkDBAccessPrivileges(
5965  throw std::runtime_error("View " + *view_name_ +
5966  " will not be dropped. User has no drop view privileges.");
5967  }
5968 
5970  catalog.dropTable(td);
5971 }
std::unique_ptr< std::string > view_name_
Definition: ParserNode.h:1922
Catalog & getCatalog() const
Definition: SessionInfo.h:67
void validate_table_type(const TableDescriptor *td, const TableType expected_table_type, const std::string &command)
Definition: DdlUtils.cpp:650
static const AccessPrivileges DROP_VIEW
Definition: DBObject.h:181
#define CHECK(condition)
Definition: Logger.h:209
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 1918 of file ParserNode.h.

References view_name_.

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

Member Data Documentation

bool Parser::DropViewStmt::if_exists_
private

Definition at line 1923 of file ParserNode.h.

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

Definition at line 1922 of file ParserNode.h.

Referenced by get_view_name().


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