OmniSciDB  ba1bac9284
 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 1632 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1634 of file ParserNode.h.

1635  : object_type(t), object(o), role(r) {}
std::unique_ptr< std::string > object
Definition: ParserNode.h:1643
tuple r
Definition: test_fsi.py:16
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1642
std::unique_ptr< std::string > role
Definition: ParserNode.h:1644
char * t

Member Function Documentation

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

Implements Parser::DDLStmt.

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

Referenced by omnisci.cursor.Cursor::executemany().

5115  {
5116  auto& catalog = session.getCatalog();
5117  const auto& currentUser = session.get_currentUser();
5118  const auto parserObjectType = boost::to_upper_copy<std::string>(get_object_type());
5119  const auto objectName =
5120  extractObjectNameFromHierName(get_object(), parserObjectType, catalog);
5121  auto objectType = DBObjectTypeFromString(parserObjectType);
5122  DBObject dbObject = createObject(objectName, objectType);
5123  /* verify object ownership if not suser */
5124  if (!currentUser.isSuper) {
5125  if (!SysCatalog::instance().verifyDBObjectOwnership(currentUser, dbObject, catalog)) {
5126  throw std::runtime_error(
5127  "SHOW ON " + get_object() + " FOR " + get_role() +
5128  " failed. It can only be executed by super user or owner of the object.");
5129  }
5130  }
5131  /* get values of privileges for the object and report them */
5132  SysCatalog::instance().getDBObjectPrivileges(get_role(), dbObject, catalog);
5133  AccessPrivileges privs = dbObject.getPrivileges();
5134  printf("\nPRIVILEGES ON %s FOR %s ARE SET AS FOLLOWING: ",
5135  get_object().c_str(),
5136  get_role().c_str());
5137 
5138  if (objectType == DBObjectType::DatabaseDBObjectType) {
5140  printf(" CREATE");
5141  }
5143  printf(" DROP");
5144  }
5145  } else if (objectType == DBObjectType::TableDBObjectType) {
5147  printf(" CREATE");
5148  }
5150  printf(" DROP");
5151  }
5153  printf(" SELECT");
5154  }
5156  printf(" INSERT");
5157  }
5159  printf(" UPDATE");
5160  }
5162  printf(" DELETE");
5163  }
5165  printf(" TRUNCATE");
5166  }
5168  printf(" ALTER");
5169  }
5170  } else if (objectType == DBObjectType::DashboardDBObjectType) {
5172  printf(" CREATE");
5173  }
5175  printf(" DELETE");
5176  }
5178  printf(" VIEW");
5179  }
5181  printf(" EDIT");
5182  }
5183  } else if (objectType == DBObjectType::ViewDBObjectType) {
5185  printf(" CREATE");
5186  }
5188  printf(" DROP");
5189  }
5191  printf(" SELECT");
5192  }
5194  printf(" INSERT");
5195  }
5197  printf(" UPDATE");
5198  }
5200  printf(" DELETE");
5201  }
5202  }
5203  printf(".\n");
5204 }
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:1637
DBObjectType DBObjectTypeFromString(const std::string &type)
Definition: DBObject.cpp:101
const std::string & get_role() const
Definition: ParserNode.h:1638
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:218
Catalog & getCatalog() const
Definition: SessionInfo.h:67
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:1636
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:143
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:73

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1637 of file ParserNode.h.

References object.

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

Definition at line 1636 of file ParserNode.h.

References object_type.

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

Definition at line 1638 of file ParserNode.h.

References role.

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

Member Data Documentation

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

Definition at line 1643 of file ParserNode.h.

Referenced by get_object().

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

Definition at line 1642 of file ParserNode.h.

Referenced by get_object_type().

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

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