OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 1918 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1920 of file ParserNode.h.

1920 : view_name(v), if_exists(i) {}
std::unique_ptr< std::string > view_name
Definition: ParserNode.h:1927
Parser::DropViewStmt::DropViewStmt ( const rapidjson::Value &  payload)

Definition at line 5581 of file ParserNode.cpp.

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

5581  {
5582  CHECK(payload.HasMember("viewName"));
5583  view_name = std::make_unique<std::string>(json_str(payload["viewName"]));
5584 
5585  if_exists = false;
5586  if (payload.HasMember("ifExists")) {
5587  if_exists = json_bool(payload["ifExists"]);
5588  }
5589 }
std::unique_ptr< std::string > view_name
Definition: ParserNode.h:1927
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:206

+ 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 5591 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().

5591  {
5592  auto& catalog = session.getCatalog();
5593 
5594  const TableDescriptor* td{nullptr};
5595  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
5596 
5597  try {
5598  td_with_lock =
5599  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
5601  catalog, *view_name, false));
5602  td = (*td_with_lock)();
5603  } catch (const std::runtime_error& e) {
5604  if (if_exists) {
5605  return;
5606  } else {
5607  throw e;
5608  }
5609  }
5610 
5611  CHECK(td);
5612  CHECK(td_with_lock);
5613 
5614  if (!session.checkDBAccessPrivileges(
5616  throw std::runtime_error("View " + *view_name +
5617  " will not be dropped. User has no drop view privileges.");
5618  }
5619 
5621  catalog.dropTable(td);
5622 }
std::unique_ptr< std::string > view_name
Definition: ParserNode.h:1927
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:554
static const AccessPrivileges DROP_VIEW
Definition: DBObject.h:181
#define CHECK(condition)
Definition: Logger.h:206
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 1923 of file ParserNode.h.

References view_name.

1923 { return view_name.get(); }
std::unique_ptr< std::string > view_name
Definition: ParserNode.h:1927

Member Data Documentation

bool Parser::DropViewStmt::if_exists
private

Definition at line 1928 of file ParserNode.h.

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

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