OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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, bool read_only_mode) 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 1615 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1617 of file ParserNode.h.

1618  : object_type_(t), object_(o), role_(r) {}
std::unique_ptr< std::string > object_
Definition: ParserNode.h:1627
std::unique_ptr< std::string > role_
Definition: ParserNode.h:1628
std::unique_ptr< std::string > object_type_
Definition: ParserNode.h:1626

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 6290 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(), get_object(), get_object_type(), get_role(), Catalog_Namespace::SessionInfo::getCatalog(), DBObject::getPrivileges(), AccessPrivileges::hasPermission(), TablePrivileges::INSERT_INTO_TABLE, ViewPrivileges::INSERT_INTO_VIEW, lockmgr::instance(), TablePrivileges::SELECT_FROM_TABLE, ViewPrivileges::SELECT_FROM_VIEW, TableDBObjectType, TablePrivileges::TRUNCATE_TABLE, TablePrivileges::UPDATE_IN_TABLE, ViewPrivileges::UPDATE_IN_VIEW, Parser::verifyObject(), DashboardPrivileges::VIEW_DASHBOARD, and ViewDBObjectType.

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

6291  {
6292  // valid in read_only_mode
6293 
6294  auto& catalog = session.getCatalog();
6295  const auto& currentUser = session.get_currentUser();
6296  const auto parserObjectType = boost::to_upper_copy<std::string>(get_object_type());
6297  const auto objectName =
6298  extractObjectNameFromHierName(get_object(), parserObjectType, catalog);
6299  auto objectType = DBObjectTypeFromString(parserObjectType);
6300  /* verify object exists and is of proper type *before* trying to execute */
6301  verifyObject(catalog, objectName, objectType, "SHOW");
6302 
6303  DBObject dbObject = createObject(objectName, objectType);
6304  /* verify object ownership if not suser */
6305  if (!currentUser.isSuper) {
6306  if (!SysCatalog::instance().verifyDBObjectOwnership(currentUser, dbObject, catalog)) {
6307  throw std::runtime_error(
6308  "SHOW ON " + get_object() + " FOR " + get_role() +
6309  " failed. It can only be executed by super user or owner of the object.");
6310  }
6311  }
6312  /* get values of privileges for the object and report them */
6313  SysCatalog::instance().getDBObjectPrivileges(get_role(), dbObject, catalog);
6314  AccessPrivileges privs = dbObject.getPrivileges();
6315  printf("\nPRIVILEGES ON %s FOR %s ARE SET AS FOLLOWING: ",
6316  get_object().c_str(),
6317  get_role().c_str());
6318 
6319  if (objectType == DBObjectType::DatabaseDBObjectType) {
6321  printf(" CREATE");
6322  }
6324  printf(" DROP");
6325  }
6326  } else if (objectType == DBObjectType::TableDBObjectType) {
6328  printf(" CREATE");
6329  }
6331  printf(" DROP");
6332  }
6334  printf(" SELECT");
6335  }
6337  printf(" INSERT");
6338  }
6340  printf(" UPDATE");
6341  }
6343  printf(" DELETE");
6344  }
6346  printf(" TRUNCATE");
6347  }
6349  printf(" ALTER");
6350  }
6351  } else if (objectType == DBObjectType::DashboardDBObjectType) {
6353  printf(" CREATE");
6354  }
6356  printf(" DELETE");
6357  }
6359  printf(" VIEW");
6360  }
6362  printf(" EDIT");
6363  }
6364  } else if (objectType == DBObjectType::ViewDBObjectType) {
6366  printf(" CREATE");
6367  }
6369  printf(" DROP");
6370  }
6372  printf(" SELECT");
6373  }
6375  printf(" INSERT");
6376  }
6378  printf(" UPDATE");
6379  }
6381  printf(" DELETE");
6382  }
6383  }
6384  printf(".\n");
6385 }
static const int32_t DROP_VIEW
Definition: DBObject.h:113
static const int32_t SELECT_FROM_VIEW
Definition: DBObject.h:114
static const int32_t UPDATE_IN_VIEW
Definition: DBObject.h:116
static const int32_t CREATE_VIEW
Definition: DBObject.h:112
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:93
const std::string & get_object() const
Definition: ParserNode.h:1620
DBObjectType DBObjectTypeFromString(const std::string &type)
Definition: DBObject.cpp:110
const std::string & get_role() const
Definition: ParserNode.h:1621
static const int32_t DROP_DATABASE
Definition: DBObject.h:79
static const int32_t DELETE_FROM_TABLE
Definition: DBObject.h:91
static const int32_t TRUNCATE_TABLE
Definition: DBObject.h:92
static const int32_t EDIT_DASHBOARD
Definition: DBObject.h:104
static const int32_t DELETE_DASHBOARD
Definition: DBObject.h:102
static const int32_t INSERT_INTO_TABLE
Definition: DBObject.h:89
const AccessPrivileges & getPrivileges() const
Definition: DBObject.h:226
Catalog & getCatalog() const
Definition: SessionInfo.h:75
T & instance()
Definition: LockMgr.cpp:101
static const int32_t CREATE_DATABASE
Definition: DBObject.h:78
static const int32_t VIEW_DASHBOARD
Definition: DBObject.h:103
static void verifyObject(Catalog_Namespace::Catalog &sessionCatalog, const std::string &objectName, DBObjectType objectType, const std::string &command)
static const int32_t DROP_TABLE
Definition: DBObject.h:87
static const int32_t INSERT_INTO_VIEW
Definition: DBObject.h:115
static const int32_t DELETE_FROM_VIEW
Definition: DBObject.h:117
static const int32_t CREATE_TABLE
Definition: DBObject.h:86
static const int32_t CREATE_DASHBOARD
Definition: DBObject.h:101
const std::string & get_object_type() const
Definition: ParserNode.h:1619
static DBObject createObject(const std::string &objectName, DBObjectType objectType)
static const int32_t SELECT_FROM_TABLE
Definition: DBObject.h:88
static const int32_t UPDATE_IN_TABLE
Definition: DBObject.h:90
bool hasPermission(int permission) const
Definition: DBObject.h:141
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:88

+ 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 1620 of file ParserNode.h.

References object_.

Referenced by execute().

1620 { return *object_; }
std::unique_ptr< std::string > object_
Definition: ParserNode.h:1627

+ Here is the caller graph for this function:

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

Definition at line 1619 of file ParserNode.h.

References object_type_.

Referenced by execute().

1619 { return *object_type_; }
std::unique_ptr< std::string > object_type_
Definition: ParserNode.h:1626

+ Here is the caller graph for this function:

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

Definition at line 1621 of file ParserNode.h.

References role_.

Referenced by execute().

1621 { return *role_; }
std::unique_ptr< std::string > role_
Definition: ParserNode.h:1628

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 1627 of file ParserNode.h.

Referenced by get_object().

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

Definition at line 1626 of file ParserNode.h.

Referenced by get_object_type().

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

Definition at line 1628 of file ParserNode.h.

Referenced by get_role().


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