OmniSciDB  06b3bd477c
 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 1578 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1580 of file ParserNode.h.

1581  : object_type(t), object(o), role(r) {}
std::unique_ptr< std::string > object
Definition: ParserNode.h:1589
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1588
std::unique_ptr< std::string > role
Definition: ParserNode.h:1590

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 4197 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.

4197  {
4198  auto& catalog = session.getCatalog();
4199  const auto& currentUser = session.get_currentUser();
4200  const auto parserObjectType = boost::to_upper_copy<std::string>(get_object_type());
4201  const auto objectName =
4202  extractObjectNameFromHierName(get_object(), parserObjectType, catalog);
4203  auto objectType = DBObjectTypeFromString(parserObjectType);
4204  DBObject dbObject = createObject(objectName, objectType);
4205  /* verify object ownership if not suser */
4206  if (!currentUser.isSuper) {
4207  if (!SysCatalog::instance().verifyDBObjectOwnership(currentUser, dbObject, catalog)) {
4208  throw std::runtime_error(
4209  "SHOW ON " + get_object() + " FOR " + get_role() +
4210  " failed. It can only be executed by super user or owner of the object.");
4211  }
4212  }
4213  /* get values of privileges for the object and report them */
4214  SysCatalog::instance().getDBObjectPrivileges(get_role(), dbObject, catalog);
4215  AccessPrivileges privs = dbObject.getPrivileges();
4216  printf("\nPRIVILEGES ON %s FOR %s ARE SET AS FOLLOWING: ",
4217  get_object().c_str(),
4218  get_role().c_str());
4219 
4220  if (objectType == DBObjectType::DatabaseDBObjectType) {
4222  printf(" CREATE");
4223  }
4225  printf(" DROP");
4226  }
4227  } else if (objectType == DBObjectType::TableDBObjectType) {
4229  printf(" CREATE");
4230  }
4232  printf(" DROP");
4233  }
4235  printf(" SELECT");
4236  }
4238  printf(" INSERT");
4239  }
4241  printf(" UPDATE");
4242  }
4244  printf(" DELETE");
4245  }
4247  printf(" TRUNCATE");
4248  }
4250  printf(" ALTER");
4251  }
4252  } else if (objectType == DBObjectType::DashboardDBObjectType) {
4254  printf(" CREATE");
4255  }
4257  printf(" DELETE");
4258  }
4260  printf(" VIEW");
4261  }
4263  printf(" EDIT");
4264  }
4265  } else if (objectType == DBObjectType::ViewDBObjectType) {
4267  printf(" CREATE");
4268  }
4270  printf(" DROP");
4271  }
4273  printf(" SELECT");
4274  }
4276  printf(" INSERT");
4277  }
4279  printf(" UPDATE");
4280  }
4282  printf(" DELETE");
4283  }
4284  }
4285  printf(".\n");
4286 }
static const int32_t DROP_VIEW
Definition: DBObject.h:115
static const int32_t SELECT_FROM_VIEW
Definition: DBObject.h:116
static const int32_t UPDATE_IN_VIEW
Definition: DBObject.h:118
static const int32_t CREATE_VIEW
Definition: DBObject.h:114
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:95
const std::string & get_object() const
Definition: ParserNode.h:1583
DBObjectType DBObjectTypeFromString(const std::string &type)
Definition: DBObject.cpp:99
const std::string & get_role() const
Definition: ParserNode.h:1584
static const int32_t DROP_DATABASE
Definition: DBObject.h:81
static const int32_t DELETE_FROM_TABLE
Definition: DBObject.h:93
static const int32_t TRUNCATE_TABLE
Definition: DBObject.h:94
static const int32_t EDIT_DASHBOARD
Definition: DBObject.h:106
static const int32_t DELETE_DASHBOARD
Definition: DBObject.h:104
static const int32_t INSERT_INTO_TABLE
Definition: DBObject.h:91
const AccessPrivileges & getPrivileges() const
Definition: DBObject.h:216
Catalog & getCatalog() const
Definition: SessionInfo.h:65
static const int32_t CREATE_DATABASE
Definition: DBObject.h:80
static const int32_t VIEW_DASHBOARD
Definition: DBObject.h:105
static const int32_t DROP_TABLE
Definition: DBObject.h:89
static const int32_t INSERT_INTO_VIEW
Definition: DBObject.h:117
static const int32_t DELETE_FROM_VIEW
Definition: DBObject.h:119
static const int32_t CREATE_TABLE
Definition: DBObject.h:88
static const int32_t CREATE_DASHBOARD
Definition: DBObject.h:103
const std::string & get_object_type() const
Definition: ParserNode.h:1582
static DBObject createObject(const std::string &objectName, DBObjectType objectType)
static const int32_t SELECT_FROM_TABLE
Definition: DBObject.h:90
static const int32_t UPDATE_IN_TABLE
Definition: DBObject.h:92
bool hasPermission(int permission) const
Definition: DBObject.h:142
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:68

+ Here is the call graph for this function:

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

Definition at line 1583 of file ParserNode.h.

References object.

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

Definition at line 1582 of file ParserNode.h.

References object_type.

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

Definition at line 1584 of file ParserNode.h.

References role.

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

Member Data Documentation

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

Definition at line 1589 of file ParserNode.h.

Referenced by get_object().

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

Definition at line 1588 of file ParserNode.h.

Referenced by get_object_type().

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

Definition at line 1590 of file ParserNode.h.

Referenced by get_role().


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