OmniSciDB  c07336695a
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 1417 of file ParserNode.h.

Constructor & Destructor Documentation

◆ ShowPrivilegesStmt()

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

Definition at line 1419 of file ParserNode.h.

1420  : object_type(t), object(o), role(r) {}
std::unique_ptr< std::string > object
Definition: ParserNode.h:1428
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1427
std::unique_ptr< std::string > role
Definition: ParserNode.h:1429

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

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

3933  {
3934  auto& catalog = session.getCatalog();
3935  const auto& currentUser = session.get_currentUser();
3936  const auto parserObjectType = boost::to_upper_copy<std::string>(get_object_type());
3937  const auto objectName =
3938  extractObjectNameFromHierName(get_object(), parserObjectType, catalog);
3939  auto objectType = DBObjectTypeFromString(parserObjectType);
3940  DBObject dbObject = createObject(objectName, objectType);
3941  /* verify object ownership if not suser */
3942  if (!currentUser.isSuper) {
3943  if (!SysCatalog::instance().verifyDBObjectOwnership(currentUser, dbObject, catalog)) {
3944  throw std::runtime_error(
3945  "SHOW ON " + get_object() + " FOR " + get_role() +
3946  " failed. It can only be executed by super user or owner of the object.");
3947  }
3948  }
3949  /* get values of privileges for the object and report them */
3950  SysCatalog::instance().getDBObjectPrivileges(get_role(), dbObject, catalog);
3951  AccessPrivileges privs = dbObject.getPrivileges();
3952  printf("\nPRIVILEGES ON %s FOR %s ARE SET AS FOLLOWING: ",
3953  get_object().c_str(),
3954  get_role().c_str());
3955 
3956  if (objectType == DBObjectType::DatabaseDBObjectType) {
3958  printf(" CREATE");
3959  }
3961  printf(" DROP");
3962  }
3963  } else if (objectType == DBObjectType::TableDBObjectType) {
3965  printf(" CREATE");
3966  }
3968  printf(" DROP");
3969  }
3971  printf(" SELECT");
3972  }
3974  printf(" INSERT");
3975  }
3977  printf(" UPDATE");
3978  }
3980  printf(" DELETE");
3981  }
3983  printf(" TRUNCATE");
3984  }
3986  printf(" ALTER");
3987  }
3988  } else if (objectType == DBObjectType::DashboardDBObjectType) {
3990  printf(" CREATE");
3991  }
3993  printf(" DELETE");
3994  }
3996  printf(" VIEW");
3997  }
3999  printf(" EDIT");
4000  }
4001  } else if (objectType == DBObjectType::ViewDBObjectType) {
4003  printf(" CREATE");
4004  }
4006  printf(" DROP");
4007  }
4009  printf(" SELECT");
4010  }
4012  printf(" INSERT");
4013  }
4015  printf(" UPDATE");
4016  }
4018  printf(" DELETE");
4019  }
4020  }
4021  printf(".\n");
4022 }
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
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93
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
DBObjectType DBObjectTypeFromString(const std::string &type)
Definition: DBObject.cpp:88
const std::string & get_role() const
Definition: ParserNode.h:1423
static const int32_t DROP_DATABASE
Definition: DBObject.h:80
Catalog & getCatalog() const
Definition: SessionInfo.h:90
static const int32_t DELETE_FROM_TABLE
Definition: DBObject.h:92
static const int32_t TRUNCATE_TABLE
Definition: DBObject.h:93
const std::string & get_object() const
Definition: ParserNode.h:1422
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 std::string & get_object_type() const
Definition: ParserNode.h:1421
const AccessPrivileges & getPrivileges() const
Definition: DBObject.h:201
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
static DBObject createObject(const std::string &objectName, DBObjectType objectType)
bool hasPermission(int permission) const
Definition: DBObject.h:134
static const int32_t SELECT_FROM_TABLE
Definition: DBObject.h:89
static const int32_t UPDATE_IN_TABLE
Definition: DBObject.h:91
+ Here is the call graph for this function:

◆ get_object()

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

Definition at line 1422 of file ParserNode.h.

1422 { return *object; }
std::unique_ptr< std::string > object
Definition: ParserNode.h:1428

◆ get_object_type()

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

Definition at line 1421 of file ParserNode.h.

1421 { return *object_type; }
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1427

◆ get_role()

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

Definition at line 1423 of file ParserNode.h.

References session.

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

Member Data Documentation

◆ object

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

Definition at line 1428 of file ParserNode.h.

◆ object_type

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

Definition at line 1427 of file ParserNode.h.

◆ role

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

Definition at line 1429 of file ParserNode.h.


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