OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Parser::ShowPrivilegesStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::ShowPrivilegesStmt:
+ Collaboration diagram for Parser::ShowPrivilegesStmt:

Public Member Functions

 ShowPrivilegesStmt (std::string *t, std::string *o, std::string *r)
 
const std::string & get_object_type () const
 
const std::string & get_object () const
 
const std::string & get_role () 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 > object_type
 
std::unique_ptr< std::string > object
 
std::unique_ptr< std::string > role
 

Detailed Description

Definition at line 1518 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::ShowPrivilegesStmt::ShowPrivilegesStmt ( std::string *  t,
std::string *  o,
std::string *  r 
)
inline

Definition at line 1520 of file ParserNode.h.

1521  : object_type(t), object(o), role(r) {}
std::unique_ptr< std::string > object
Definition: ParserNode.h:1529
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1528
std::unique_ptr< std::string > role
Definition: ParserNode.h:1530

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 4015 of file ParserNode.cpp.

References TablePrivileges::ALTER_TABLE, DashboardPrivileges::CREATE_DASHBOARD, DatabasePrivileges::CREATE_DATABASE, TablePrivileges::CREATE_TABLE, ViewPrivileges::CREATE_VIEW, Parser::createObject(), DashboardDBObjectType, DatabaseDBObjectType, DBObjectTypeFromString(), DashboardPrivileges::DELETE_DASHBOARD, TablePrivileges::DELETE_FROM_TABLE, ViewPrivileges::DELETE_FROM_VIEW, DatabasePrivileges::DROP_DATABASE, TablePrivileges::DROP_TABLE, ViewPrivileges::DROP_VIEW, DashboardPrivileges::EDIT_DASHBOARD, Parser::extractObjectNameFromHierName(), Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::SessionInfo::getCatalog(), DBObject::getPrivileges(), AccessPrivileges::hasPermission(), TablePrivileges::INSERT_INTO_TABLE, ViewPrivileges::INSERT_INTO_VIEW, TablePrivileges::SELECT_FROM_TABLE, ViewPrivileges::SELECT_FROM_VIEW, TableDBObjectType, TablePrivileges::TRUNCATE_TABLE, TablePrivileges::UPDATE_IN_TABLE, ViewPrivileges::UPDATE_IN_VIEW, DashboardPrivileges::VIEW_DASHBOARD, and ViewDBObjectType.

4015  {
4016  auto& catalog = session.getCatalog();
4017  const auto& currentUser = session.get_currentUser();
4018  const auto parserObjectType = boost::to_upper_copy<std::string>(get_object_type());
4019  const auto objectName =
4020  extractObjectNameFromHierName(get_object(), parserObjectType, catalog);
4021  auto objectType = DBObjectTypeFromString(parserObjectType);
4022  DBObject dbObject = createObject(objectName, objectType);
4023  /* verify object ownership if not suser */
4024  if (!currentUser.isSuper) {
4025  if (!SysCatalog::instance().verifyDBObjectOwnership(currentUser, dbObject, catalog)) {
4026  throw std::runtime_error(
4027  "SHOW ON " + get_object() + " FOR " + get_role() +
4028  " failed. It can only be executed by super user or owner of the object.");
4029  }
4030  }
4031  /* get values of privileges for the object and report them */
4032  SysCatalog::instance().getDBObjectPrivileges(get_role(), dbObject, catalog);
4033  AccessPrivileges privs = dbObject.getPrivileges();
4034  printf("\nPRIVILEGES ON %s FOR %s ARE SET AS FOLLOWING: ",
4035  get_object().c_str(),
4036  get_role().c_str());
4037 
4038  if (objectType == DBObjectType::DatabaseDBObjectType) {
4040  printf(" CREATE");
4041  }
4043  printf(" DROP");
4044  }
4045  } else if (objectType == DBObjectType::TableDBObjectType) {
4047  printf(" CREATE");
4048  }
4050  printf(" DROP");
4051  }
4053  printf(" SELECT");
4054  }
4056  printf(" INSERT");
4057  }
4059  printf(" UPDATE");
4060  }
4062  printf(" DELETE");
4063  }
4065  printf(" TRUNCATE");
4066  }
4068  printf(" ALTER");
4069  }
4070  } else if (objectType == DBObjectType::DashboardDBObjectType) {
4072  printf(" CREATE");
4073  }
4075  printf(" DELETE");
4076  }
4078  printf(" VIEW");
4079  }
4081  printf(" EDIT");
4082  }
4083  } else if (objectType == DBObjectType::ViewDBObjectType) {
4085  printf(" CREATE");
4086  }
4088  printf(" DROP");
4089  }
4091  printf(" SELECT");
4092  }
4094  printf(" INSERT");
4095  }
4097  printf(" UPDATE");
4098  }
4100  printf(" DELETE");
4101  }
4102  }
4103  printf(".\n");
4104 }
static const int32_t DROP_VIEW
Definition: DBObject.h:114
static const int32_t SELECT_FROM_VIEW
Definition: DBObject.h:115
static const int32_t UPDATE_IN_VIEW
Definition: DBObject.h:117
static const int32_t CREATE_VIEW
Definition: DBObject.h:113
std::string extractObjectNameFromHierName(const std::string &objectHierName, const std::string &objectType, const Catalog_Namespace::Catalog &cat)
static const int32_t ALTER_TABLE
Definition: DBObject.h:94
const std::string & get_object() const
Definition: ParserNode.h:1523
DBObjectType DBObjectTypeFromString(const std::string &type)
Definition: DBObject.cpp:88
const std::string & get_role() const
Definition: ParserNode.h:1524
static const int32_t DROP_DATABASE
Definition: DBObject.h:80
static const int32_t DELETE_FROM_TABLE
Definition: DBObject.h:92
static const int32_t TRUNCATE_TABLE
Definition: DBObject.h:93
static const int32_t EDIT_DASHBOARD
Definition: DBObject.h:105
static const int32_t DELETE_DASHBOARD
Definition: DBObject.h:103
static const int32_t INSERT_INTO_TABLE
Definition: DBObject.h:90
const AccessPrivileges & getPrivileges() const
Definition: DBObject.h:202
Catalog & getCatalog() const
Definition: SessionInfo.h:90
static const int32_t CREATE_DATABASE
Definition: DBObject.h:79
static const int32_t VIEW_DASHBOARD
Definition: DBObject.h:104
static const int32_t DROP_TABLE
Definition: DBObject.h:88
static const int32_t INSERT_INTO_VIEW
Definition: DBObject.h:116
static const int32_t DELETE_FROM_VIEW
Definition: DBObject.h:118
static const int32_t CREATE_TABLE
Definition: DBObject.h:87
static const int32_t CREATE_DASHBOARD
Definition: DBObject.h:102
const std::string & get_object_type() const
Definition: ParserNode.h:1522
static DBObject createObject(const std::string &objectName, DBObjectType objectType)
static const int32_t SELECT_FROM_TABLE
Definition: DBObject.h:89
static const int32_t UPDATE_IN_TABLE
Definition: DBObject.h:91
bool hasPermission(int permission) const
Definition: DBObject.h:134
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93

+ Here is the call graph for this function:

const std::string& Parser::ShowPrivilegesStmt::get_object ( ) const
inline

Definition at line 1523 of file ParserNode.h.

References object.

1523 { return *object; }
std::unique_ptr< std::string > object
Definition: ParserNode.h:1529
const std::string& Parser::ShowPrivilegesStmt::get_object_type ( ) const
inline

Definition at line 1522 of file ParserNode.h.

References object_type.

1522 { return *object_type; }
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1528
const std::string& Parser::ShowPrivilegesStmt::get_role ( ) const
inline

Definition at line 1524 of file ParserNode.h.

References role.

1524 { return *role; }
std::unique_ptr< std::string > role
Definition: ParserNode.h:1530

Member Data Documentation

std::unique_ptr<std::string> Parser::ShowPrivilegesStmt::object
private

Definition at line 1529 of file ParserNode.h.

Referenced by get_object().

std::unique_ptr<std::string> Parser::ShowPrivilegesStmt::object_type
private

Definition at line 1528 of file ParserNode.h.

Referenced by get_object_type().

std::unique_ptr<std::string> Parser::ShowPrivilegesStmt::role
private

Definition at line 1530 of file ParserNode.h.

Referenced by get_role().


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