OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser Namespace Reference

Namespaces

 anonymous_namespace{ParserNode.cpp}
 

Classes

class  Node
 
class  SQLType
 
class  Expr
 
class  Literal
 
class  NullLiteral
 
class  StringLiteral
 
class  IntLiteral
 
class  FixedPtLiteral
 
class  FloatLiteral
 
class  DoubleLiteral
 
class  TimestampLiteral
 
class  UserLiteral
 
class  ArrayLiteral
 
class  OperExpr
 
class  SubqueryExpr
 
class  IsNullExpr
 
class  InExpr
 
class  InSubquery
 
class  InValues
 
class  BetweenExpr
 
class  CharLengthExpr
 
class  CardinalityExpr
 
class  LikeExpr
 
class  RegexpExpr
 
class  WidthBucketExpr
 
class  LikelihoodExpr
 
class  ExistsExpr
 
class  ColumnRef
 
class  FunctionRef
 
class  CastExpr
 
class  ExprPair
 
class  CaseExpr
 
class  TableRef
 
class  Stmt
 
class  DMLStmt
 
class  DDLStmt
 
class  TableElement
 
class  ColumnConstraintDef
 
class  CompressDef
 
class  ColumnDef
 
class  TableConstraintDef
 
class  UniqueDef
 
class  ForeignKeyDef
 
class  CheckDef
 
class  SharedDictionaryDef
 
class  ShardKeyDef
 
class  NameValueAssign
 
class  CreateTableBaseStmt
 
class  CreateTableStmt
 
struct  DistributedConnector
 
struct  LocalConnector
 
class  CreateDataframeStmt
 
class  InsertIntoTableAsSelectStmt
 
class  CreateTableAsSelectStmt
 
class  AlterTableStmt
 
class  DropTableStmt
 
class  TruncateTableStmt
 
class  OptimizeTableStmt
 
class  ValidateStmt
 
class  RenameDBStmt
 
class  RenameUserStmt
 
class  RenameTableStmt
 
class  RenameColumnStmt
 
class  AddColumnStmt
 
class  DropColumnStmt
 
class  AlterTableParamStmt
 
class  DumpRestoreTableStmtBase
 
class  DumpTableStmt
 
class  RestoreTableStmt
 
class  CopyTableStmt
 
class  CreateRoleStmt
 
class  DropRoleStmt
 
class  GrantPrivilegesStmt
 
class  RevokePrivilegesStmt
 
class  ShowPrivilegesStmt
 
class  GrantRoleStmt
 
class  RevokeRoleStmt
 
class  QueryExpr
 
class  UnionQuery
 
class  SelectEntry
 
class  QuerySpec
 
class  OrderSpec
 
class  SelectStmt
 
class  ShowCreateTableStmt
 
class  ExportQueryStmt
 
class  CreateViewStmt
 
class  DropViewStmt
 
class  CreateDBStmt
 
class  DropDBStmt
 
class  CreateUserStmt
 
class  AlterUserStmt
 
class  DropUserStmt
 
class  InsertStmt
 
class  InsertValuesStmt
 
class  Assignment
 
class  UpdateStmt
 
class  DeleteStmt
 
struct  DefaultValidate
 
struct  DefaultValidate< IntLiteral >
 
struct  PositiveOrZeroValidate
 
struct  DefaultValidate< StringLiteral >
 
struct  CaseSensitiveValidate
 
struct  ShouldInvalidateSessionsByDB
 
struct  ShouldInvalidateSessionsByUser
 
struct  ShouldInvalidateSessionsByDB< DropDBStmt >
 
struct  ShouldInvalidateSessionsByUser< DropUserStmt >
 
struct  ShouldInvalidateSessionsByDB< RenameDBStmt >
 
struct  ShouldInvalidateSessionsByUser< RenameUserStmt >
 
class  TrackedPtr
 
class  TrackedListPtr
 

Typedefs

using SubstituteMap = std::map< std::string, std::string >
 

Functions

template<typename DDLSTMT >
auto parseDDL (const std::string &stmt_type, const std::string &stmt_str)
 
bool check_session_interrupted (const QuerySessionId &query_session, Executor *executor)
 
std::shared_ptr< ResultSetgetResultSet (QueryStateProxy query_state_proxy, const std::string select_stmt, std::vector< TargetMetaInfo > &targets, bool validate_only=false, std::vector< size_t > outer_fragment_indices={}, bool allow_interrupt=false)
 
bool repair_type (std::list< std::unique_ptr< NameValueAssign >> &options)
 
void check_alter_table_privilege (const Catalog_Namespace::SessionInfo &session, const TableDescriptor *td)
 
std::vector< std::string > splitObjectHierName (const std::string &hierName)
 
std::string extractObjectNameFromHierName (const std::string &objectHierName, const std::string &objectType, const Catalog_Namespace::Catalog &cat)
 
static std::pair
< AccessPrivileges,
DBObjectType
parseStringPrivs (const std::string &privs, const DBObjectType &objectType, const std::string &object_name)
 
static DBObject createObject (const std::string &objectName, DBObjectType objectType)
 
static void verifyObject (Catalog_Namespace::Catalog &sessionCatalog, const std::string &objectName, DBObjectType objectType, const std::string &command)
 
static void checkStringLiteral (const std::string &option_name, const std::unique_ptr< NameValueAssign > &p)
 
static bool readBooleanLiteral (const std::string &option_name, const std::unique_ptr< NameValueAssign > &p)
 
std::unique_ptr< Parser::DDLStmtcreate_ddl_from_calcite (const std::string &query_json)
 
void execute_ddl_from_calcite (const std::string &query_json, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 
void parser_slistval_to_vector (std::list< std::string * > *l, std::vector< std::string > &v)
 

Typedef Documentation

using Parser::SubstituteMap = typedef std::map<std::string, std::string>

Definition at line 4092 of file ParserNode.cpp.

Function Documentation

void Parser::check_alter_table_privilege ( const Catalog_Namespace::SessionInfo session,
const TableDescriptor td 
)

Definition at line 4004 of file ParserNode.cpp.

References AccessPrivileges::ALTER_TABLE, Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::SessionInfo::getCatalog(), Catalog_Namespace::UserMetadata::isSuper, DBObject::loadKey(), DBObject::setPrivileges(), TableDBObjectType, TableDescriptor::tableName, TableDescriptor::userId, and Catalog_Namespace::UserMetadata::userId.

Referenced by Parser::AddColumnStmt::check_executable(), Parser::RenameTableStmt::execute(), Parser::RenameColumnStmt::execute(), Parser::DropColumnStmt::execute(), and Parser::AlterTableParamStmt::execute().

4005  {
4006  if (session.get_currentUser().isSuper ||
4007  session.get_currentUser().userId == td->userId) {
4008  return;
4009  }
4010  std::vector<DBObject> privObjects;
4011  DBObject dbObject(td->tableName, TableDBObjectType);
4012  dbObject.loadKey(session.getCatalog());
4013  dbObject.setPrivileges(AccessPrivileges::ALTER_TABLE);
4014  privObjects.push_back(dbObject);
4015  if (!SysCatalog::instance().checkPrivileges(session.get_currentUser(), privObjects)) {
4016  throw std::runtime_error("Current user does not have the privilege to alter table: " +
4017  td->tableName);
4018  }
4019 }
std::string tableName
static const AccessPrivileges ALTER_TABLE
Definition: DBObject.h:167
Catalog & getCatalog() const
Definition: SessionInfo.h:67
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:73
std::atomic< bool > isSuper
Definition: SysCatalog.h:120

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Parser::check_session_interrupted ( const QuerySessionId query_session,
Executor executor 
)

Definition at line 100 of file ParserNode.cpp.

References g_enable_non_kernel_time_query_interrupt.

100  {
101  // we call this function with unitary executor but is okay since
102  // we know the exact session info from a global session map object
103  // in the executor
105  mapd_shared_lock<mapd_shared_mutex> session_read_lock(executor->getSessionLock());
106  return executor->checkIsQuerySessionInterrupted(query_session, session_read_lock);
107  }
108  return false;
109 }
bool g_enable_non_kernel_time_query_interrupt
Definition: Execute.cpp:119
static void Parser::checkStringLiteral ( const std::string &  option_name,
const std::unique_ptr< NameValueAssign > &  p 
)
static

Definition at line 6021 of file ParserNode.cpp.

References CHECK.

Referenced by Parser::DumpRestoreTableStmtBase::DumpRestoreTableStmtBase(), Parser::CreateDBStmt::execute(), Parser::CreateUserStmt::execute(), and Parser::AlterUserStmt::execute().

6022  {
6023  CHECK(p);
6024  if (!dynamic_cast<const StringLiteral*>(p->get_value())) {
6025  throw std::runtime_error(option_name + " option must be a string literal.");
6026  }
6027 }
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

std::unique_ptr< Parser::DDLStmt > Parser::create_ddl_from_calcite ( const std::string &  query_json)

Helper functions for parsing the DDL returned from calcite as part of the plan result to a parser node in this class. Currently only used in QueryRunner/DistributedQueryRunner, where we do not want to link in the thrift dependencies wich DdlCommandExecutor currently brings along.

Definition at line 6360 of file ParserNode.cpp.

References CHECK, Parser::AlterTableStmt::delegate(), UNREACHABLE, and VLOG.

Referenced by QueryRunner::QueryRunner::createDDLStatement(), execute_ddl_from_calcite(), and DBHandler::sql_execute_impl().

6360  {
6361  CHECK(!query_json.empty());
6362  VLOG(2) << "Parsing JSON DDL from Calcite: " << query_json;
6363  rapidjson::Document ddl_query;
6364  ddl_query.Parse(query_json);
6365  CHECK(ddl_query.IsObject());
6366  CHECK(ddl_query.HasMember("payload"));
6367  CHECK(ddl_query["payload"].IsObject());
6368  const auto& payload = ddl_query["payload"].GetObject();
6369  CHECK(payload.HasMember("command"));
6370  CHECK(payload["command"].IsString());
6371 
6372  const auto& ddl_command = std::string_view(payload["command"].GetString());
6373 
6374  Parser::DDLStmt* stmt = nullptr;
6375  if (ddl_command == "CREATE_TABLE") {
6376  stmt = new Parser::CreateTableStmt(payload);
6377  } else if (ddl_command == "DROP_TABLE") {
6378  stmt = new Parser::DropTableStmt(payload);
6379  } else if (ddl_command == "RENAME_TABLE") {
6380  stmt = new Parser::RenameTableStmt(payload);
6381  } else if (ddl_command == "ALTER_TABLE") {
6382  std::unique_ptr<Parser::DDLStmt> ddlStmt;
6383  ddlStmt = Parser::AlterTableStmt::delegate(payload);
6384  if (ddlStmt != nullptr) {
6385  stmt = ddlStmt.get();
6386  ddlStmt.release();
6387  }
6388  } else if (ddl_command == "TRUNCATE_TABLE") {
6389  stmt = new Parser::TruncateTableStmt(payload);
6390  } else if (ddl_command == "DUMP_TABLE") {
6391  stmt = new Parser::DumpTableStmt(payload);
6392  } else if (ddl_command == "RESTORE_TABLE") {
6393  stmt = new Parser::RestoreTableStmt(payload);
6394  } else if (ddl_command == "OPTIMIZE_TABLE") {
6395  stmt = new Parser::OptimizeTableStmt(payload);
6396  } else if (ddl_command == "SHOW_CREATE_TABLE") {
6397  stmt = new Parser::ShowCreateTableStmt(payload);
6398  } else if (ddl_command == "COPY_TABLE") {
6399  stmt = new Parser::CopyTableStmt(payload);
6400  } else if (ddl_command == "EXPORT_QUERY") {
6401  stmt = new Parser::ExportQueryStmt(payload);
6402  } else if (ddl_command == "CREATE_VIEW") {
6403  stmt = new Parser::CreateViewStmt(payload);
6404  } else if (ddl_command == "DROP_VIEW") {
6405  stmt = new Parser::DropViewStmt(payload);
6406  } else if (ddl_command == "CREATE_DB") {
6407  stmt = new Parser::CreateDBStmt(payload);
6408  } else if (ddl_command == "DROP_DB") {
6409  stmt = new Parser::DropDBStmt(payload);
6410  } else if (ddl_command == "RENAME_DB") {
6411  stmt = new Parser::RenameDBStmt(payload);
6412  } else if (ddl_command == "CREATE_USER") {
6413  stmt = new Parser::CreateUserStmt(payload);
6414  } else if (ddl_command == "DROP_USER") {
6415  stmt = new Parser::DropUserStmt(payload);
6416  } else if (ddl_command == "ALTER_USER") {
6417  stmt = new Parser::AlterUserStmt(payload);
6418  } else if (ddl_command == "RENAME_USER") {
6419  stmt = new Parser::RenameUserStmt(payload);
6420  } else if (ddl_command == "CREATE_ROLE") {
6421  stmt = new Parser::CreateRoleStmt(payload);
6422  } else if (ddl_command == "DROP_ROLE") {
6423  stmt = new Parser::DropRoleStmt(payload);
6424  } else if (ddl_command == "GRANT_ROLE") {
6425  stmt = new Parser::GrantRoleStmt(payload);
6426  } else if (ddl_command == "REVOKE_ROLE") {
6427  stmt = new Parser::RevokeRoleStmt(payload);
6428  } else if (ddl_command == "GRANT_PRIVILEGE") {
6429  stmt = new Parser::GrantPrivilegesStmt(payload);
6430  } else if (ddl_command == "REVOKE_PRIVILEGE") {
6431  stmt = new Parser::RevokePrivilegesStmt(payload);
6432  } else if (ddl_command == "CREATE_DATAFRAME") {
6433  stmt = new Parser::CreateDataframeStmt(payload);
6434  } else if (ddl_command == "VALIDATE_SYSTEM") {
6435  // VALIDATE should have been excuted in outer context before it reaches here
6436  UNREACHABLE(); // not-implemented alterType
6437  } else {
6438  throw std::runtime_error("Unsupported DDL command");
6439  }
6440  return std::unique_ptr<Parser::DDLStmt>(stmt);
6441 }
#define UNREACHABLE()
Definition: Logger.h:253
#define CHECK(condition)
Definition: Logger.h:209
#define VLOG(n)
Definition: Logger.h:303
static std::unique_ptr< Parser::DDLStmt > delegate(const rapidjson::Value &payload)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static DBObject Parser::createObject ( const std::string &  objectName,
DBObjectType  objectType 
)
static

Definition at line 5272 of file ParserNode.cpp.

References DashboardDBObjectType.

Referenced by Parser::GrantPrivilegesStmt::execute(), Parser::RevokePrivilegesStmt::execute(), and Parser::ShowPrivilegesStmt::execute().

5272  {
5273  if (objectType == DashboardDBObjectType) {
5274  int32_t dashboard_id = -1;
5275  if (!objectName.empty()) {
5276  try {
5277  dashboard_id = stoi(objectName);
5278  } catch (const std::exception&) {
5279  throw std::runtime_error(
5280  "Privileges on dashboards should be changed via integer dashboard ID");
5281  }
5282  }
5283  return DBObject(dashboard_id, objectType);
5284  } else {
5285  return DBObject(objectName, objectType);
5286  }
5287 }

+ Here is the caller graph for this function:

void Parser::execute_ddl_from_calcite ( const std::string &  query_json,
std::shared_ptr< Catalog_Namespace::SessionInfo const session_ptr 
)

Definition at line 6443 of file ParserNode.cpp.

References create_ddl_from_calcite().

6445  {
6446  std::unique_ptr<Parser::DDLStmt> stmt = create_ddl_from_calcite(query_json);
6447  if (stmt != nullptr) {
6448  (*stmt).execute(*session_ptr);
6449  }
6450 }
std::unique_ptr< Parser::DDLStmt > create_ddl_from_calcite(const std::string &query_json)

+ Here is the call graph for this function:

std::string Parser::extractObjectNameFromHierName ( const std::string &  objectHierName,
const std::string &  objectType,
const Catalog_Namespace::Catalog cat 
)

Definition at line 5135 of file ParserNode.cpp.

References splitObjectHierName().

Referenced by Parser::GrantPrivilegesStmt::execute(), Parser::RevokePrivilegesStmt::execute(), and Parser::ShowPrivilegesStmt::execute().

5137  {
5138  std::string objectName;
5139  std::vector<std::string> componentNames = splitObjectHierName(objectHierName);
5140  if (objectType.compare("DATABASE") == 0) {
5141  if (componentNames.size() == 1) {
5142  objectName = componentNames[0];
5143  } else {
5144  throw std::runtime_error("DB object name is not correct " + objectHierName);
5145  }
5146  } else {
5147  if (objectType.compare("TABLE") == 0 || objectType.compare("DASHBOARD") == 0 ||
5148  objectType.compare("VIEW") == 0 || objectType.compare("SERVER") == 0) {
5149  switch (componentNames.size()) {
5150  case (1): {
5151  objectName = componentNames[0];
5152  break;
5153  }
5154  case (2): {
5155  objectName = componentNames[1];
5156  break;
5157  }
5158  default: {
5159  throw std::runtime_error("DB object name is not correct " + objectHierName);
5160  }
5161  }
5162  } else {
5163  throw std::runtime_error("DB object type " + objectType + " is not supported.");
5164  }
5165  }
5166  return objectName;
5167 }
std::vector< std::string > splitObjectHierName(const std::string &hierName)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<ResultSet> Parser::getResultSet ( QueryStateProxy  query_state_proxy,
const std::string  select_stmt,
std::vector< TargetMetaInfo > &  targets,
bool  validate_only = false,
std::vector< size_t >  outer_fragment_indices = {},
bool  allow_interrupt = false 
)

Definition at line 2685 of file ParserNode.cpp.

Referenced by Parser::LocalConnector::query().

2689  {},
2690  bool allow_interrupt = false) {
2691  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
2692  auto& catalog = session->getCatalog();
2693 
2695 #ifdef HAVE_CUDA
2696  const auto device_type = session->get_executor_device_type();
2697 #else
2698  const auto device_type = ExecutorDeviceType::CPU;
2699 #endif // HAVE_CUDA
2700  auto calcite_mgr = catalog.getCalciteMgr();
2701 
2702  // TODO MAT this should actually get the global or the session parameter for
2703  // view optimization
2704  const auto query_ra =
2705  calcite_mgr
2706  ->process(query_state_proxy, pg_shim(select_stmt), {}, true, false, false, true)
2707  .plan_result;
2708  RelAlgExecutor ra_executor(executor.get(),
2709  catalog,
2710  query_ra,
2711  query_state_proxy.getQueryState().shared_from_this());
2714  // TODO(adb): Need a better method of dropping constants into this ExecutionOptions
2715  // struct
2716  ExecutionOptions eo = {false,
2717  true,
2718  false,
2719  true,
2720  false,
2721  false,
2722  validate_only,
2723  false,
2724  10000,
2725  false,
2726  false,
2727  1000,
2728  allow_interrupt,
2732  outer_fragment_indices};
2733 
2734  ExecutionResult result{std::make_shared<ResultSet>(std::vector<TargetInfo>{},
2737  nullptr,
2738  nullptr,
2739  0,
2740  0),
2741  {}};
2742  result = ra_executor.executeRelAlgQuery(co, eo, false, nullptr);
2743  targets = result.getTargetsMeta();
2744 
2745  return result.getRows();
2746 }
double g_running_query_interrupt_freq
Definition: Execute.cpp:122
unsigned g_pending_query_interrupt_freq
Definition: Execute.cpp:121
static std::shared_ptr< Executor > getExecutor(const ExecutorId id, const std::string &debug_dir="", const std::string &debug_file="", const SystemParameters &system_parameters=SystemParameters())
Definition: Execute.cpp:176
QueryState & getQueryState()
Definition: QueryState.h:181
static CompilationOptions defaults(const ExecutorDeviceType device_type=ExecutorDeviceType::GPU)
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:81
std::string pg_shim(const std::string &query)
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:384

+ Here is the caller graph for this function:

template<typename DDLSTMT >
auto Parser::parseDDL ( const std::string &  stmt_type,
const std::string &  stmt_str 
)

Definition at line 29 of file ParseDDL.h.

References run_benchmark_import::parser.

29  {
30  std::list<std::unique_ptr<Parser::Stmt>> parse_trees;
31  std::string last_parsed;
32  SQLParser parser;
33  if (parser.parse(stmt_str, parse_trees, last_parsed) > 0) {
34  throw std::runtime_error("Syntax error in " + stmt_type + " \"" + stmt_str +
35  "\" at " + last_parsed);
36  }
37  if (auto ddl_stmt = dynamic_cast<DDLSTMT*>(parse_trees.front().get())) {
38  parse_trees.front().release();
39  return std::unique_ptr<DDLSTMT>(ddl_stmt);
40  }
41  throw std::runtime_error("Expected " + stmt_type + " is not found in \"" + stmt_str +
42  "\"");
43 }
void Parser::parser_slistval_to_vector ( std::list< std::string * > *  l,
std::vector< std::string > &  v 
)
inline

Definition at line 1544 of file ParserNode.h.

References CHECK.

Referenced by Parser::GrantPrivilegesStmt::GrantPrivilegesStmt(), Parser::GrantRoleStmt::GrantRoleStmt(), Parser::RevokePrivilegesStmt::RevokePrivilegesStmt(), and Parser::RevokeRoleStmt::RevokeRoleStmt().

1545  {
1546  CHECK(l);
1547  for (auto str : *l) {
1548  v.push_back(*str);
1549  delete str;
1550  }
1551  delete l;
1552 }
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

static std::pair<AccessPrivileges, DBObjectType> Parser::parseStringPrivs ( const std::string &  privs,
const DBObjectType objectType,
const std::string &  object_name 
)
static

Definition at line 5169 of file ParserNode.cpp.

References AccessPrivileges::ACCESS, AccessPrivileges::ALL_DASHBOARD, AccessPrivileges::ALL_DATABASE, AccessPrivileges::ALL_SERVER, AccessPrivileges::ALL_TABLE, AccessPrivileges::ALL_VIEW, AccessPrivileges::ALTER_SERVER, AccessPrivileges::ALTER_TABLE, AccessPrivileges::CREATE_DASHBOARD, AccessPrivileges::CREATE_SERVER, AccessPrivileges::CREATE_TABLE, AccessPrivileges::CREATE_VIEW, DashboardDBObjectType, DatabaseDBObjectType, AccessPrivileges::DELETE_DASHBOARD, AccessPrivileges::DELETE_FROM_TABLE, AccessPrivileges::DROP_SERVER, AccessPrivileges::DROP_TABLE, AccessPrivileges::DROP_VIEW, AccessPrivileges::EDIT_DASHBOARD, AccessPrivileges::INSERT_INTO_TABLE, run_benchmark_import::result, AccessPrivileges::SELECT_FROM_TABLE, AccessPrivileges::SELECT_FROM_VIEW, AccessPrivileges::SERVER_USAGE, ServerDBObjectType, TableDBObjectType, AccessPrivileges::TRUNCATE_TABLE, AccessPrivileges::UPDATE_IN_TABLE, AccessPrivileges::VIEW_DASHBOARD, AccessPrivileges::VIEW_SQL_EDITOR, and ViewDBObjectType.

Referenced by Parser::GrantPrivilegesStmt::execute(), and Parser::RevokePrivilegesStmt::execute().

5172  {
5173  static const std::map<std::pair<const std::string, const DBObjectType>,
5174  std::pair<const AccessPrivileges, const DBObjectType>>
5175  privileges_lookup{
5176  {{"ALL"s, DatabaseDBObjectType},
5179  {{"ALL"s, DashboardDBObjectType},
5182  {{"ALL"s, ServerDBObjectType},
5184 
5185  {{"CREATE TABLE"s, DatabaseDBObjectType},
5187  {{"CREATE"s, DatabaseDBObjectType},
5189  {{"SELECT"s, DatabaseDBObjectType},
5191  {{"INSERT"s, DatabaseDBObjectType},
5193  {{"TRUNCATE"s, DatabaseDBObjectType},
5195  {{"UPDATE"s, DatabaseDBObjectType},
5197  {{"DELETE"s, DatabaseDBObjectType},
5199  {{"DROP"s, DatabaseDBObjectType},
5201  {{"ALTER"s, DatabaseDBObjectType},
5203 
5204  {{"SELECT"s, TableDBObjectType},
5206  {{"INSERT"s, TableDBObjectType},
5208  {{"TRUNCATE"s, TableDBObjectType},
5210  {{"UPDATE"s, TableDBObjectType},
5212  {{"DELETE"s, TableDBObjectType},
5214  {{"DROP"s, TableDBObjectType},
5216  {{"ALTER"s, TableDBObjectType},
5218 
5219  {{"CREATE VIEW"s, DatabaseDBObjectType},
5221  {{"SELECT VIEW"s, DatabaseDBObjectType},
5223  {{"DROP VIEW"s, DatabaseDBObjectType},
5225  {{"SELECT"s, ViewDBObjectType},
5228 
5229  {{"CREATE DASHBOARD"s, DatabaseDBObjectType},
5231  {{"EDIT DASHBOARD"s, DatabaseDBObjectType},
5233  {{"VIEW DASHBOARD"s, DatabaseDBObjectType},
5235  {{"DELETE DASHBOARD"s, DatabaseDBObjectType},
5237  {{"VIEW"s, DashboardDBObjectType},
5239  {{"EDIT"s, DashboardDBObjectType},
5241  {{"DELETE"s, DashboardDBObjectType},
5243 
5244  {{"CREATE SERVER"s, DatabaseDBObjectType},
5246  {{"DROP SERVER"s, DatabaseDBObjectType},
5248  {{"DROP"s, ServerDBObjectType},
5250  {{"ALTER SERVER"s, DatabaseDBObjectType},
5252  {{"ALTER"s, ServerDBObjectType},
5254  {{"USAGE"s, ServerDBObjectType},
5256  {{"SERVER USAGE"s, DatabaseDBObjectType},
5258 
5259  {{"VIEW SQL EDITOR"s, DatabaseDBObjectType},
5261  {{"ACCESS"s, DatabaseDBObjectType},
5263 
5264  auto result = privileges_lookup.find(std::make_pair(privs, objectType));
5265  if (result == privileges_lookup.end()) {
5266  throw std::runtime_error("Privileges " + privs + " on DB object " + object_name +
5267  " are not correct.");
5268  }
5269  return result->second;
5270 }
static const AccessPrivileges VIEW_SQL_EDITOR
Definition: DBObject.h:154
static const AccessPrivileges VIEW_DASHBOARD
Definition: DBObject.h:173
static const AccessPrivileges DROP_SERVER
Definition: DBObject.h:191
static const AccessPrivileges ALL_DATABASE
Definition: DBObject.h:153
static const AccessPrivileges ALTER_TABLE
Definition: DBObject.h:167
static const AccessPrivileges TRUNCATE_TABLE
Definition: DBObject.h:166
static const AccessPrivileges INSERT_INTO_TABLE
Definition: DBObject.h:163
static const AccessPrivileges CREATE_DASHBOARD
Definition: DBObject.h:172
static const AccessPrivileges SERVER_USAGE
Definition: DBObject.h:193
static const AccessPrivileges SELECT_FROM_TABLE
Definition: DBObject.h:162
static const AccessPrivileges ALL_VIEW
Definition: DBObject.h:179
static const AccessPrivileges ALTER_SERVER
Definition: DBObject.h:192
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:161
static const AccessPrivileges ALL_SERVER
Definition: DBObject.h:189
static const AccessPrivileges CREATE_SERVER
Definition: DBObject.h:190
static const AccessPrivileges DELETE_FROM_TABLE
Definition: DBObject.h:165
static const AccessPrivileges CREATE_TABLE
Definition: DBObject.h:160
static const AccessPrivileges SELECT_FROM_VIEW
Definition: DBObject.h:182
static const AccessPrivileges ALL_DASHBOARD
Definition: DBObject.h:171
static const AccessPrivileges ACCESS
Definition: DBObject.h:155
static const AccessPrivileges ALL_TABLE
Definition: DBObject.h:159
static const AccessPrivileges DROP_VIEW
Definition: DBObject.h:181
static const AccessPrivileges CREATE_VIEW
Definition: DBObject.h:180
static const AccessPrivileges DELETE_DASHBOARD
Definition: DBObject.h:175
static const AccessPrivileges EDIT_DASHBOARD
Definition: DBObject.h:174
static const AccessPrivileges UPDATE_IN_TABLE
Definition: DBObject.h:164

+ Here is the caller graph for this function:

static bool Parser::readBooleanLiteral ( const std::string &  option_name,
const std::unique_ptr< NameValueAssign > &  p 
)
static

Definition at line 6109 of file ParserNode.cpp.

References CHECK.

Referenced by Parser::CreateUserStmt::execute(), and Parser::AlterUserStmt::execute().

6110  {
6111  CHECK(p);
6112  const std::string* str =
6113  static_cast<const StringLiteral*>(p->get_value())->get_stringval();
6114  if (boost::iequals(*str, "true")) {
6115  return true;
6116  } else if (boost::iequals(*str, "false")) {
6117  return false;
6118  } else {
6119  throw std::runtime_error("Value to " + option_name + " must be TRUE or FALSE.");
6120  }
6121 }
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

bool Parser::repair_type ( std::list< std::unique_ptr< NameValueAssign >> &  options)

Definition at line 3960 of file ParserNode.cpp.

References CHECK.

Referenced by Parser::ValidateStmt::ValidateStmt().

3960  {
3961  for (const auto& opt : options) {
3962  if (boost::iequals(*opt->get_name(), "REPAIR_TYPE")) {
3963  const auto repair_type =
3964  static_cast<const StringLiteral*>(opt->get_value())->get_stringval();
3965  CHECK(repair_type);
3966  if (boost::iequals(*repair_type, "REMOVE")) {
3967  return true;
3968  } else {
3969  throw std::runtime_error("REPAIR_TYPE must be REMOVE.");
3970  }
3971  } else {
3972  throw std::runtime_error("The only VALIDATE WITH options is REPAIR_TYPE.");
3973  }
3974  }
3975  return false;
3976 }
bool repair_type(std::list< std::unique_ptr< NameValueAssign >> &options)
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

std::vector<std::string> Parser::splitObjectHierName ( const std::string &  hierName)

Definition at line 5129 of file ParserNode.cpp.

References split().

Referenced by extractObjectNameFromHierName().

5129  {
5130  std::vector<std::string> componentNames;
5131  boost::split(componentNames, hierName, boost::is_any_of("."));
5132  return componentNames;
5133 }
std::vector< std::string > split(std::string_view str, std::string_view delim, std::optional< size_t > maxsplit)
split apart a string into a vector of substrings

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void Parser::verifyObject ( Catalog_Namespace::Catalog sessionCatalog,
const std::string &  objectName,
DBObjectType  objectType,
const std::string &  command 
)
static

Definition at line 5291 of file ParserNode.cpp.

References DBObjectTypeToString(), Catalog_Namespace::Catalog::getMetadataForTable(), TableDescriptor::isView, TableDBObjectType, and ViewDBObjectType.

Referenced by Parser::GrantPrivilegesStmt::execute(), Parser::RevokePrivilegesStmt::execute(), and Parser::ShowPrivilegesStmt::execute().

5294  {
5295  if (objectType == TableDBObjectType) {
5296  auto td = sessionCatalog.getMetadataForTable(objectName, false);
5297  if (!td || td->isView) {
5298  // expected TABLE, found VIEW
5299  throw std::runtime_error(command + " failed. Object '" + objectName + "' of type " +
5300  DBObjectTypeToString(objectType) + " not found.");
5301  }
5302 
5303  } else if (objectType == ViewDBObjectType) {
5304  auto td = sessionCatalog.getMetadataForTable(objectName, false);
5305  if (!td || !td->isView) {
5306  // expected VIEW, found TABLE
5307  throw std::runtime_error(command + " failed. Object '" + objectName + "' of type " +
5308  DBObjectTypeToString(objectType) + " not found.");
5309  }
5310  }
5311 }
std::string DBObjectTypeToString(DBObjectType type)
Definition: DBObject.cpp:83
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: