OmniSciDB  467d548b97
 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)
 
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 1861 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1863 of file ParserNode.h.

1863 : view_name(v), if_exists(i) {}
std::unique_ptr< std::string > view_name
Definition: ParserNode.h:1868

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 4649 of file ParserNode.cpp.

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

4649  {
4650  auto& catalog = session.getCatalog();
4651 
4652  const TableDescriptor* td{nullptr};
4653  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
4654 
4655  try {
4656  td_with_lock =
4657  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
4659  catalog, *view_name, false));
4660  td = (*td_with_lock)();
4661  } catch (const std::runtime_error& e) {
4662  if (if_exists) {
4663  return;
4664  } else {
4665  throw e;
4666  }
4667  }
4668 
4669  CHECK(td);
4670  CHECK(td_with_lock);
4671 
4672  if (!session.checkDBAccessPrivileges(
4674  throw std::runtime_error("View " + *view_name +
4675  " will not be dropped. User has no drop view privileges.");
4676  }
4677 
4679  catalog.dropTable(td);
4680 }
std::unique_ptr< std::string > view_name
Definition: ParserNode.h:1868
void validate_drop_table_type(const TableDescriptor *td, const TableType expected_table_type)
Definition: DdlUtils.cpp:537
Catalog & getCatalog() const
Definition: SessionInfo.h:65
static const AccessPrivileges DROP_VIEW
Definition: DBObject.h:180
#define CHECK(condition)
Definition: Logger.h:197
specifies the content in-memory of a row in the table metadata table
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:

const std::string* Parser::DropViewStmt::get_view_name ( ) const
inline

Definition at line 1864 of file ParserNode.h.

References view_name.

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

Member Data Documentation

bool Parser::DropViewStmt::if_exists
private

Definition at line 1869 of file ParserNode.h.

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

Definition at line 1868 of file ParserNode.h.

Referenced by get_view_name().


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