OmniSciDB  04ee39c94c
Parser Namespace Reference

Namespaces

 anonymous_namespace{ParserNode.cpp}
 

Classes

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

Typedefs

using dbl = std::numeric_limits< double >
 

Functions

std::shared_ptr< ResultSetgetResultSet (const Catalog_Namespace::SessionInfo &session, const std::string select_stmt, std::vector< TargetMetaInfo > &targets, bool validate_only=false)
 
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, DBObjectTypeparseStringPrivs (const std::string &privs, const DBObjectType &objectType, const std::string &object_name)
 
static DBObject createObject (const std::string &objectName, DBObjectType objectType)
 
void parser_slistval_to_vector (std::list< std::string *> *l, std::vector< std::string > &v)
 

Typedef Documentation

◆ dbl

using Parser::dbl = typedef std::numeric_limits<double>

Definition at line 4059 of file ParserNode.cpp.

Function Documentation

◆ check_alter_table_privilege()

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

Definition at line 2815 of file ParserNode.cpp.

References AccessPrivileges::ALTER_TABLE, Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::SessionInfo::getCatalog(), Catalog_Namespace::UserMetadata::isSuper, DBObject::loadKey(), anonymous_namespace{DBObjectPrivilegesTest.cpp}::privObjects, DBObject::setPrivileges(), TableDBObjectType, TableDescriptor::tableName, TableDescriptor::userId, and Catalog_Namespace::UserMetadata::userId.

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

2816  {
2817  if (session.get_currentUser().isSuper ||
2818  session.get_currentUser().userId == td->userId) {
2819  return;
2820  }
2821  std::vector<DBObject> privObjects;
2822  DBObject dbObject(td->tableName, TableDBObjectType);
2823  dbObject.loadKey(session.getCatalog());
2824  dbObject.setPrivileges(AccessPrivileges::ALTER_TABLE);
2825  privObjects.push_back(dbObject);
2826  if (!SysCatalog::instance().checkPrivileges(session.get_currentUser(), privObjects)) {
2827  throw std::runtime_error("Current user does not have the privilege to alter table: " +
2828  td->tableName);
2829  }
2830 }
std::string tableName
static const AccessPrivileges ALTER_TABLE
Definition: DBObject.h:158
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93
Catalog & getCatalog() const
Definition: SessionInfo.h:90
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createObject()

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

Definition at line 3863 of file ParserNode.cpp.

References DashboardDBObjectType.

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

3863  {
3864  if (objectType == DashboardDBObjectType) {
3865  int32_t dashboard_id = -1;
3866  if (!objectName.empty()) {
3867  try {
3868  dashboard_id = stoi(objectName);
3869  } catch (const std::exception&) {
3870  throw std::runtime_error(
3871  "Privileges on dashboards should be changed via integer dashboard ID");
3872  }
3873  }
3874  return DBObject(dashboard_id, objectType);
3875  } else {
3876  return DBObject(objectName, objectType);
3877  }
3878 }
+ Here is the caller graph for this function:

◆ extractObjectNameFromHierName()

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

Definition at line 3743 of file ParserNode.cpp.

References splitObjectHierName().

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

3745  {
3746  std::string objectName;
3747  std::vector<std::string> componentNames = splitObjectHierName(objectHierName);
3748  if (objectType.compare("DATABASE") == 0) {
3749  if (componentNames.size() == 1) {
3750  objectName = componentNames[0];
3751  } else {
3752  throw std::runtime_error("DB object name is not correct " + objectHierName);
3753  }
3754  } else {
3755  if (objectType.compare("TABLE") == 0 || objectType.compare("DASHBOARD") == 0 ||
3756  objectType.compare("VIEW") == 0) {
3757  switch (componentNames.size()) {
3758  case (1): {
3759  objectName = componentNames[0];
3760  break;
3761  }
3762  case (2): {
3763  objectName = componentNames[1];
3764  break;
3765  }
3766  default: {
3767  throw std::runtime_error("DB object name is not correct " + objectHierName);
3768  }
3769  }
3770  } else {
3771  throw std::runtime_error("DB object type " + objectType + " is not supported.");
3772  }
3773  }
3774  return objectName;
3775 }
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:

◆ getResultSet()

std::shared_ptr<ResultSet> Parser::getResultSet ( const Catalog_Namespace::SessionInfo session,
const std::string  select_stmt,
std::vector< TargetMetaInfo > &  targets,
bool  validate_only = false 
)

Definition at line 2223 of file ParserNode.cpp.

References CPU, Catalog_Namespace::SessionInfo::get_executor_device_type(), Catalog_Namespace::SessionInfo::getCatalog(), Executor::getExecutor(), LoopStrengthReduction, pg_shim(), and run-benchmark-import::result.

Referenced by Parser::ExportQueryStmt::execute(), and Parser::InsertIntoTableAsSelectStmt::LocalConnector::query().

2226  {
2227  auto& catalog = session.getCatalog();
2228 
2229  auto executor = Executor::getExecutor(catalog.getCurrentDB().dbId);
2230 
2231 #ifdef HAVE_CUDA
2232  const auto device_type = session.get_executor_device_type();
2233 #else
2234  const auto device_type = ExecutorDeviceType::CPU;
2235 #endif // HAVE_CUDA
2236  auto calcite_mgr = catalog.getCalciteMgr();
2237 
2238  // TODO MAT this should actually get the global or the session parameter for
2239  // view optimization
2240  const auto query_ra =
2241  calcite_mgr->process(session, pg_shim(select_stmt), {}, true, false, false)
2242  .plan_result;
2243  CompilationOptions co = {
2244  device_type, true, ExecutorOptLevel::LoopStrengthReduction, false};
2245  // TODO(adb): Need a better method of dropping constants into this ExecutionOptions
2246  // struct
2247  ExecutionOptions eo = {false,
2248  true,
2249  false,
2250  true,
2251  false,
2252  false,
2253  validate_only,
2254  false,
2255  10000,
2256  false,
2257  false,
2258  0.9};
2259  RelAlgExecutor ra_executor(executor.get(), catalog);
2260  ExecutionResult result{std::make_shared<ResultSet>(std::vector<TargetInfo>{},
2263  nullptr,
2264  nullptr),
2265  {}};
2266  result = ra_executor.executeRelAlgQuery(query_ra, co, eo, nullptr);
2267  targets = result.getTargetsMeta();
2268 
2269  return result.getRows();
2270 }
static std::shared_ptr< Executor > getExecutor(const int db_id, const std::string &debug_dir="", const std::string &debug_file="", const MapDParameters mapd_parameters=MapDParameters(), ::QueryRenderer::QueryRenderManager *render_manager=nullptr)
Definition: Execute.cpp:122
Catalog & getCatalog() const
Definition: SessionInfo.h:90
std::string pg_shim(const std::string &query)
const ExecutorDeviceType get_executor_device_type() const
Definition: SessionInfo.h:94
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parser_slistval_to_vector()

void Parser::parser_slistval_to_vector ( std::list< std::string *> *  l,
std::vector< std::string > &  v 
)
inline

Definition at line 1347 of file ParserNode.h.

References CHECK.

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

1348  {
1349  CHECK(l);
1350  for (auto str : *l) {
1351  v.push_back(*str);
1352  delete str;
1353  }
1354  delete l;
1355 }
T v(const TargetValue &r)
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the caller graph for this function:

◆ parseStringPrivs()

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

Definition at line 3777 of file ParserNode.cpp.

References AccessPrivileges::ACCESS, AccessPrivileges::ALL_DASHBOARD, AccessPrivileges::ALL_DATABASE, AccessPrivileges::ALL_TABLE, AccessPrivileges::ALL_VIEW, AccessPrivileges::ALTER_TABLE, AccessPrivileges::CREATE_DASHBOARD, AccessPrivileges::CREATE_TABLE, AccessPrivileges::CREATE_VIEW, DashboardDBObjectType, DatabaseDBObjectType, AccessPrivileges::DELETE_DASHBOARD, AccessPrivileges::DELETE_FROM_TABLE, 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, 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().

3780  {
3781  static const std::map<std::pair<const std::string, const DBObjectType>,
3782  std::pair<const AccessPrivileges, const DBObjectType>>
3783  privileges_lookup{
3784  {{"ALL"s, DatabaseDBObjectType},
3785  {AccessPrivileges::ALL_DATABASE, DatabaseDBObjectType}},
3786  {{"ALL"s, TableDBObjectType}, {AccessPrivileges::ALL_TABLE, TableDBObjectType}},
3787  {{"ALL"s, DashboardDBObjectType},
3788  {AccessPrivileges::ALL_DASHBOARD, DashboardDBObjectType}},
3789  {{"ALL"s, ViewDBObjectType}, {AccessPrivileges::ALL_VIEW, ViewDBObjectType}},
3790 
3791  {{"CREATE TABLE"s, DatabaseDBObjectType},
3792  {AccessPrivileges::CREATE_TABLE, TableDBObjectType}},
3793  {{"CREATE"s, DatabaseDBObjectType},
3794  {AccessPrivileges::CREATE_TABLE, TableDBObjectType}},
3795  {{"SELECT"s, DatabaseDBObjectType},
3796  {AccessPrivileges::SELECT_FROM_TABLE, TableDBObjectType}},
3797  {{"INSERT"s, DatabaseDBObjectType},
3798  {AccessPrivileges::INSERT_INTO_TABLE, TableDBObjectType}},
3799  {{"TRUNCATE"s, DatabaseDBObjectType},
3800  {AccessPrivileges::TRUNCATE_TABLE, TableDBObjectType}},
3801  {{"UPDATE"s, DatabaseDBObjectType},
3802  {AccessPrivileges::UPDATE_IN_TABLE, TableDBObjectType}},
3803  {{"DELETE"s, DatabaseDBObjectType},
3804  {AccessPrivileges::DELETE_FROM_TABLE, TableDBObjectType}},
3805  {{"DROP"s, DatabaseDBObjectType},
3806  {AccessPrivileges::DROP_TABLE, TableDBObjectType}},
3807  {{"ALTER"s, DatabaseDBObjectType},
3808  {AccessPrivileges::ALTER_TABLE, TableDBObjectType}},
3809 
3810  {{"SELECT"s, TableDBObjectType},
3811  {AccessPrivileges::SELECT_FROM_TABLE, TableDBObjectType}},
3812  {{"INSERT"s, TableDBObjectType},
3813  {AccessPrivileges::INSERT_INTO_TABLE, TableDBObjectType}},
3814  {{"TRUNCATE"s, TableDBObjectType},
3815  {AccessPrivileges::TRUNCATE_TABLE, TableDBObjectType}},
3816  {{"UPDATE"s, TableDBObjectType},
3817  {AccessPrivileges::UPDATE_IN_TABLE, TableDBObjectType}},
3818  {{"DELETE"s, TableDBObjectType},
3819  {AccessPrivileges::DELETE_FROM_TABLE, TableDBObjectType}},
3820  {{"DROP"s, TableDBObjectType},
3821  {AccessPrivileges::DROP_TABLE, TableDBObjectType}},
3822  {{"ALTER"s, TableDBObjectType},
3823  {AccessPrivileges::ALTER_TABLE, TableDBObjectType}},
3824 
3825  {{"CREATE VIEW"s, DatabaseDBObjectType},
3826  {AccessPrivileges::CREATE_VIEW, ViewDBObjectType}},
3827  {{"SELECT VIEW"s, DatabaseDBObjectType},
3828  {AccessPrivileges::SELECT_FROM_VIEW, ViewDBObjectType}},
3829  {{"DROP VIEW"s, DatabaseDBObjectType},
3830  {AccessPrivileges::DROP_VIEW, ViewDBObjectType}},
3831  {{"SELECT"s, ViewDBObjectType},
3832  {AccessPrivileges::SELECT_FROM_VIEW, ViewDBObjectType}},
3833  {{"DROP"s, ViewDBObjectType}, {AccessPrivileges::DROP_VIEW, ViewDBObjectType}},
3834 
3835  {{"CREATE DASHBOARD"s, DatabaseDBObjectType},
3836  {AccessPrivileges::CREATE_DASHBOARD, DashboardDBObjectType}},
3837  {{"EDIT DASHBOARD"s, DatabaseDBObjectType},
3838  {AccessPrivileges::EDIT_DASHBOARD, DashboardDBObjectType}},
3839  {{"VIEW DASHBOARD"s, DatabaseDBObjectType},
3840  {AccessPrivileges::VIEW_DASHBOARD, DashboardDBObjectType}},
3841  {{"DELETE DASHBOARD"s, DatabaseDBObjectType},
3842  {AccessPrivileges::DELETE_DASHBOARD, DashboardDBObjectType}},
3843  {{"VIEW"s, DashboardDBObjectType},
3844  {AccessPrivileges::VIEW_DASHBOARD, DashboardDBObjectType}},
3845  {{"EDIT"s, DashboardDBObjectType},
3846  {AccessPrivileges::EDIT_DASHBOARD, DashboardDBObjectType}},
3847  {{"DELETE"s, DashboardDBObjectType},
3848  {AccessPrivileges::DELETE_DASHBOARD, DashboardDBObjectType}},
3849 
3850  {{"VIEW SQL EDITOR"s, DatabaseDBObjectType},
3851  {AccessPrivileges::VIEW_SQL_EDITOR, DatabaseDBObjectType}},
3852  {{"ACCESS"s, DatabaseDBObjectType},
3853  {AccessPrivileges::ACCESS, DatabaseDBObjectType}}};
3854 
3855  auto result = privileges_lookup.find(std::make_pair(privs, objectType));
3856  if (result == privileges_lookup.end()) {
3857  throw std::runtime_error("Privileges " + privs + " on DB object " + object_name +
3858  " are not correct.");
3859  }
3860  return result->second;
3861 }
static const AccessPrivileges VIEW_SQL_EDITOR
Definition: DBObject.h:145
static const AccessPrivileges VIEW_DASHBOARD
Definition: DBObject.h:164
static const AccessPrivileges ALL_DATABASE
Definition: DBObject.h:144
static const AccessPrivileges ALTER_TABLE
Definition: DBObject.h:158
static const AccessPrivileges TRUNCATE_TABLE
Definition: DBObject.h:157
static const AccessPrivileges INSERT_INTO_TABLE
Definition: DBObject.h:154
static const AccessPrivileges CREATE_DASHBOARD
Definition: DBObject.h:163
static const AccessPrivileges SELECT_FROM_TABLE
Definition: DBObject.h:153
static const AccessPrivileges ALL_VIEW
Definition: DBObject.h:170
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:152
static const AccessPrivileges DELETE_FROM_TABLE
Definition: DBObject.h:156
static const AccessPrivileges CREATE_TABLE
Definition: DBObject.h:151
static const AccessPrivileges SELECT_FROM_VIEW
Definition: DBObject.h:173
static const AccessPrivileges ALL_DASHBOARD
Definition: DBObject.h:162
static const AccessPrivileges ACCESS
Definition: DBObject.h:146
static const AccessPrivileges ALL_TABLE
Definition: DBObject.h:150
static const AccessPrivileges DROP_VIEW
Definition: DBObject.h:172
static const AccessPrivileges CREATE_VIEW
Definition: DBObject.h:171
static const AccessPrivileges DELETE_DASHBOARD
Definition: DBObject.h:166
static const AccessPrivileges EDIT_DASHBOARD
Definition: DBObject.h:165
static const AccessPrivileges UPDATE_IN_TABLE
Definition: DBObject.h:155
+ Here is the caller graph for this function:

◆ splitObjectHierName()

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

Definition at line 3737 of file ParserNode.cpp.

References split().

Referenced by extractObjectNameFromHierName().

3737  {
3738  std::vector<std::string> componentNames;
3739  boost::split(componentNames, hierName, boost::is_any_of("."));
3740  return componentNames;
3741 }
std::vector< std::string > split(const std::string &str, const std::string &delim)
+ Here is the call graph for this function:
+ Here is the caller graph for this function: