OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Parser::CreateUserStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::CreateUserStmt:
+ Collaboration diagram for Parser::CreateUserStmt:

Public Member Functions

 CreateUserStmt (std::string *n, std::list< NameValueAssign * > *l)
 
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 > user_name
 
std::list< std::unique_ptr
< NameValueAssign > > 
name_value_list
 

Detailed Description

Definition at line 1915 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::CreateUserStmt::CreateUserStmt ( std::string *  n,
std::list< NameValueAssign * > *  l 
)
inline

Definition at line 1917 of file ParserNode.h.

References name_value_list.

1917  : user_name(n) {
1918  if (l) {
1919  for (const auto e : *l) {
1920  name_value_list.emplace_back(e);
1921  }
1922  delete l;
1923  }
1924  }
std::unique_ptr< std::string > user_name
Definition: ParserNode.h:1928
std::list< std::unique_ptr< NameValueAssign > > name_value_list
Definition: ParserNode.h:1929

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 4761 of file ParserNode.cpp.

References Parser::checkStringLiteral(), Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::UserMetadata::isSuper, and Parser::readBooleanLiteral().

4761  {
4762  std::string passwd;
4763  bool is_super = false;
4764  std::string default_db;
4765  bool can_login = true;
4766  for (auto& p : name_value_list) {
4767  if (boost::iequals(*p->get_name(), "password")) {
4768  checkStringLiteral("Password", p);
4769  passwd = *static_cast<const StringLiteral*>(p->get_value())->get_stringval();
4770  } else if (boost::iequals(*p->get_name(), "is_super")) {
4771  checkStringLiteral("IS_SUPER", p);
4772  is_super = readBooleanLiteral("IS_SUPER", p);
4773  } else if (boost::iequals(*p->get_name(), "default_db")) {
4774  checkStringLiteral("DEFAULT_DB", p);
4775  default_db = *static_cast<const StringLiteral*>(p->get_value())->get_stringval();
4776  } else if (boost::iequals(*p->get_name(), "can_login")) {
4777  checkStringLiteral("CAN_LOGIN", p);
4778  can_login = readBooleanLiteral("can_login", p);
4779  } else {
4780  throw std::runtime_error("Invalid CREATE USER option " + *p->get_name() +
4781  ". Should be PASSWORD, IS_SUPER, CAN_LOGIN"
4782  " or DEFAULT_DB.");
4783  }
4784  }
4785  if (!session.get_currentUser().isSuper) {
4786  throw std::runtime_error("Only super user can create new users.");
4787  }
4788  SysCatalog::instance().createUser(*user_name, passwd, is_super, default_db, can_login);
4789 }
static void checkStringLiteral(const std::string &option_name, const std::unique_ptr< NameValueAssign > &p)
std::unique_ptr< std::string > user_name
Definition: ParserNode.h:1928
static bool readBooleanLiteral(const std::string &option_name, const std::unique_ptr< NameValueAssign > &p)
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:68
std::list< std::unique_ptr< NameValueAssign > > name_value_list
Definition: ParserNode.h:1929
std::atomic< bool > isSuper
Definition: SysCatalog.h:96

+ Here is the call graph for this function:

Member Data Documentation

std::list<std::unique_ptr<NameValueAssign> > Parser::CreateUserStmt::name_value_list
private

Definition at line 1929 of file ParserNode.h.

Referenced by CreateUserStmt().

std::unique_ptr<std::string> Parser::CreateUserStmt::user_name
private

Definition at line 1928 of file ParserNode.h.


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