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

Constructor & Destructor Documentation

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

Definition at line 1976 of file ParserNode.h.

References name_value_list.

1976  : user_name(n) {
1977  if (l) {
1978  for (const auto e : *l) {
1979  name_value_list.emplace_back(e);
1980  }
1981  delete l;
1982  }
1983  }
std::unique_ptr< std::string > user_name
Definition: ParserNode.h:1987
std::list< std::unique_ptr< NameValueAssign > > name_value_list
Definition: ParserNode.h:1988

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 5703 of file ParserNode.cpp.

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

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

5703  {
5704  std::string passwd;
5705  bool is_super = false;
5706  std::string default_db;
5707  bool can_login = true;
5708  for (auto& p : name_value_list) {
5709  if (boost::iequals(*p->get_name(), "password")) {
5710  checkStringLiteral("Password", p);
5711  passwd = *static_cast<const StringLiteral*>(p->get_value())->get_stringval();
5712  } else if (boost::iequals(*p->get_name(), "is_super")) {
5713  checkStringLiteral("IS_SUPER", p);
5714  is_super = readBooleanLiteral("IS_SUPER", p);
5715  } else if (boost::iequals(*p->get_name(), "default_db")) {
5716  checkStringLiteral("DEFAULT_DB", p);
5717  default_db = *static_cast<const StringLiteral*>(p->get_value())->get_stringval();
5718  } else if (boost::iequals(*p->get_name(), "can_login")) {
5719  checkStringLiteral("CAN_LOGIN", p);
5720  can_login = readBooleanLiteral("can_login", p);
5721  } else {
5722  throw std::runtime_error("Invalid CREATE USER option " + *p->get_name() +
5723  ". Should be PASSWORD, IS_SUPER, CAN_LOGIN"
5724  " or DEFAULT_DB.");
5725  }
5726  }
5727  if (!session.get_currentUser().isSuper) {
5728  throw std::runtime_error("Only super user can create new users.");
5729  }
5730  SysCatalog::instance().createUser(*user_name, passwd, is_super, default_db, can_login);
5731 }
static void checkStringLiteral(const std::string &option_name, const std::unique_ptr< NameValueAssign > &p)
std::unique_ptr< std::string > user_name
Definition: ParserNode.h:1987
static bool readBooleanLiteral(const std::string &option_name, const std::unique_ptr< NameValueAssign > &p)
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:73
std::list< std::unique_ptr< NameValueAssign > > name_value_list
Definition: ParserNode.h:1988
std::atomic< bool > isSuper
Definition: SysCatalog.h:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 1988 of file ParserNode.h.

Referenced by CreateUserStmt().

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

Definition at line 1987 of file ParserNode.h.


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