OmniSciDB  04ee39c94c
MapDHandler.cpp File Reference
#include "MapDHandler.h"
#include "DistributedLoader.h"
#include "MapDServer.h"
#include "QueryEngine/UDFCompiler.h"
#include "TokenCompletionHints.h"
#include <thrift/concurrency/PlatformThreadFactory.h>
#include <thrift/concurrency/ThreadManager.h>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/protocol/TJSONProtocol.h>
#include <thrift/server/TThreadedServer.h>
#include <thrift/transport/TBufferTransports.h>
#include <thrift/transport/THttpServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TTransportException.h>
#include "MapDRelease.h"
#include "Calcite/Calcite.h"
#include "gen-cpp/CalciteServer.h"
#include "QueryEngine/RelAlgExecutor.h"
#include "Catalog/Catalog.h"
#include "Fragmenter/InsertOrderFragmenter.h"
#include "Import/Importer.h"
#include "LockMgr/TableLockMgr.h"
#include "MapDDistributedHandler.h"
#include "MapDRenderHandler.h"
#include "Parser/ParserWrapper.h"
#include "Parser/ReservedKeywords.h"
#include "Parser/parser.h"
#include "Planner/Planner.h"
#include "QueryEngine/ArrowResultSet.h"
#include "QueryEngine/CalciteAdapter.h"
#include "QueryEngine/Execute.h"
#include "QueryEngine/ExtensionFunctionsWhitelist.h"
#include "QueryEngine/GpuMemUtils.h"
#include "QueryEngine/JoinFilterPushDown.h"
#include "QueryEngine/JsonAccessors.h"
#include "QueryEngine/TableOptimizer.h"
#include "QueryEngine/ThriftSerializers.h"
#include "Shared/SQLTypeUtilities.h"
#include "Shared/StringTransform.h"
#include "Shared/SysInfo.h"
#include "Shared/geo_types.h"
#include "Shared/geosupport.h"
#include "Shared/import_helpers.h"
#include "Shared/mapd_shared_mutex.h"
#include "Shared/measure.h"
#include "Shared/scope.h"
#include <fcntl.h>
#include <picosha2.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/make_shared.hpp>
#include <boost/process/search_path.hpp>
#include <boost/program_options.hpp>
#include <boost/regex.hpp>
#include <boost/tokenizer.hpp>
#include <cmath>
#include <csignal>
#include <fstream>
#include <future>
#include <map>
#include <memory>
#include <random>
#include <regex>
#include <string>
#include <thread>
#include <typeinfo>
#include <arrow/api.h>
#include <arrow/io/api.h>
#include <arrow/ipc/api.h>
#include "QueryEngine/ArrowUtil.h"

Go to the source code of this file.

Classes

struct  anonymous_namespace{MapDHandler.cpp}::ProjectionTokensForCompletion
 

Namespaces

 anonymous_namespace{MapDHandler.cpp}
 

Macros

#define ENABLE_GEO_IMPORT_COLUMN_MATCHING   0
 
#define INVALID_SESSION_ID   ""
 
#define THROW_MAPD_EXCEPTION(errstr)
 
#define ARROW_THRIFT_THROW_NOT_OK(s)
 
#define THROW_COLUMN_ATTR_MISMATCH_EXCEPTION(attr, got, expected)
 

Typedefs

using RecordBatchVector = std::vector< std::shared_ptr< arrow::RecordBatch > >
 

Functions

SessionMap::iterator anonymous_namespace{MapDHandler.cpp}::get_session_from_map (const TSessionId &session, SessionMap &session_map)
 
ProjectionTokensForCompletion anonymous_namespace{MapDHandler.cpp}::extract_projection_tokens_for_completion (const std::string &sql)
 
static TDBObject serialize_db_object (const std::string &roleName, const DBObject &inObject)
 
void anonymous_namespace{MapDHandler.cpp}::fixup_geo_column_descriptor (TColumnType &col_type, const SQLTypes subtype, const int output_srid)
 
void anonymous_namespace{MapDHandler.cpp}::check_table_not_sharded (const Catalog &cat, const std::string &table_name)
 
RecordBatchVector anonymous_namespace{MapDHandler.cpp}::loadArrowStream (const std::string &stream)
 
void add_vsi_network_prefix (std::string &path)
 
void add_vsi_geo_prefix (std::string &path)
 
void add_vsi_archive_prefix (std::string &path)
 
std::string remove_vsi_prefixes (const std::string &path_in)
 
bool path_is_relative (const std::string &path)
 
bool path_has_valid_filename (const std::string &path)
 
bool is_a_supported_geo_file (const std::string &path, bool include_gz)
 
bool is_a_supported_archive_file (const std::string &path)
 
std::string find_first_geo_file_in_archive (const std::string &archive_path, const Importer_NS::CopyParams &copy_params)
 
static bool is_allowed_on_dashboard (const Catalog_Namespace::SessionInfo &session_info, int32_t dashboard_id, AccessPrivileges requestedPermissions)
 
bool anonymous_namespace{MapDHandler.cpp}::TTypeInfo_IsGeo (const TDatumType::type &t)
 
std::map< std::string, std::string > get_device_parameters ()
 

Macro Definition Documentation

◆ ARROW_THRIFT_THROW_NOT_OK

#define ARROW_THRIFT_THROW_NOT_OK (   s)
Value:
do { \
::arrow::Status _s = (s); \
if (UNLIKELY(!_s.ok())) { \
TMapDException ex; \
ex.error_msg = _s.ToString(); \
LOG(ERROR) << s.ToString(); \
throw ex; \
} \
} while (0)
#define UNLIKELY(x)
Definition: likely.h:20

Definition at line 2207 of file MapDHandler.cpp.

Referenced by anonymous_namespace{MapDHandler.cpp}::loadArrowStream().

◆ ENABLE_GEO_IMPORT_COLUMN_MATCHING

#define ENABLE_GEO_IMPORT_COLUMN_MATCHING   0

Definition at line 109 of file MapDHandler.cpp.

◆ INVALID_SESSION_ID

◆ THROW_COLUMN_ATTR_MISMATCH_EXCEPTION

#define THROW_COLUMN_ATTR_MISMATCH_EXCEPTION (   attr,
  got,
  expected 
)
Value:
THROW_MAPD_EXCEPTION("Could not append geo file '" + file_path.filename().string() + \
"' to table '" + table_name + "'. Column '" + cd->columnName + \
"' " + attr + " mismatch (got '" + got + "', expected '" + \
expected + "')");
#define THROW_MAPD_EXCEPTION(errstr)

Definition at line 3553 of file MapDHandler.cpp.

Referenced by MapDHandler::import_geo_table().

◆ THROW_MAPD_EXCEPTION

#define THROW_MAPD_EXCEPTION (   errstr)
Value:
TMapDException ex; \
ex.error_msg = errstr; \
LOG(ERROR) << ex.error_msg; \
throw ex;

Definition at line 117 of file MapDHandler.cpp.

Referenced by add_vsi_network_prefix(), MapDHandler::broadcast_serialized_rows(), MapDHandler::check_read_only(), MapDHandler::check_session_exp_unsafe(), MapDHandler::check_table_consistency(), MapDHandler::check_table_load_privileges(), MapDHandler::clear_cpu_memory(), MapDHandler::clear_gpu_memory(), MapDHandler::connect(), MapDHandler::convert_rows(), MapDHandler::create_dashboard(), MapDHandler::create_link(), MapDHandler::create_table(), MapDHandler::delete_dashboard(), MapDHandler::detect_column_types(), MapDHandler::execute_first_step(), MapDHandler::execute_next_render_step(), MapDHandler::get_all_files_in_archive(), MapDHandler::get_all_roles_for_user(), MapDHandler::get_dashboard(), MapDHandler::get_dashboard_grantees(), MapDHandler::get_db_object_privs(), MapDHandler::get_db_objects_for_grantee(), MapDHandler::get_first_geo_file_in_archive(), MapDHandler::get_heap_profile(), MapDHandler::get_layers_in_geo_file(), MapDHandler::get_link_view(), MapDHandler::get_result_row_for_pixel(), anonymous_namespace{MapDHandler.cpp}::get_session_from_map(), MapDHandler::get_table_details_impl(), MapDHandler::get_tables_meta(), MapDHandler::get_valid_groups(), MapDHandler::has_dashboard_permission(), MapDHandler::has_database_permission(), MapDHandler::has_object_privilege(), MapDHandler::has_table_permission(), MapDHandler::has_view_permission(), MapDHandler::import_geo_table(), MapDHandler::import_table(), MapDHandler::insert_data(), MapDHandler::internal_connect(), MapDHandler::load_table(), MapDHandler::load_table_binary(), MapDHandler::load_table_binary_arrow(), MapDHandler::load_table_binary_columnar(), MapDHandler::parse_to_plan_legacy(), MapDHandler::populateThriftColumnType(), MapDHandler::prepare_columnar_loader(), MapDHandler::register_runtime_udf(), MapDHandler::render_vega(), MapDHandler::replace_dashboard(), MapDHandler::set_license_key(), MapDHandler::share_dashboard(), MapDHandler::sql_execute(), MapDHandler::sql_execute_df(), MapDHandler::sql_execute_impl(), MapDHandler::sql_validate(), MapDHandler::start_heap_profile(), MapDHandler::start_query(), MapDHandler::start_render_query(), MapDHandler::stop_heap_profile(), MapDHandler::switch_database(), MapDHandler::thrift_to_copyparams(), MapDHandler::unshare_dashboard(), and MapDHandler::validate_rel_alg().

Typedef Documentation

◆ RecordBatchVector

using RecordBatchVector = std::vector<std::shared_ptr<arrow::RecordBatch> >

Definition at line 2205 of file MapDHandler.cpp.

Function Documentation

◆ add_vsi_archive_prefix()

void add_vsi_archive_prefix ( std::string &  path)

Definition at line 2633 of file MapDHandler.cpp.

Referenced by MapDHandler::detect_column_types(), MapDHandler::get_all_files_in_archive(), MapDHandler::get_first_geo_file_in_archive(), MapDHandler::get_layers_in_geo_file(), and MapDHandler::import_geo_table().

2633  {
2634  // check for compressed file or file bundle
2635  if (boost::iends_with(path, ".zip")) {
2636  // zip archive
2637  path = "/vsizip/" + path;
2638  } else if (boost::iends_with(path, ".tar") || boost::iends_with(path, ".tgz") ||
2639  boost::iends_with(path, ".tar.gz")) {
2640  // tar archive (compressed or uncompressed)
2641  path = "/vsitar/" + path;
2642  }
2643 }
+ Here is the caller graph for this function:

◆ add_vsi_geo_prefix()

void add_vsi_geo_prefix ( std::string &  path)

Definition at line 2626 of file MapDHandler.cpp.

Referenced by MapDHandler::detect_column_types(), MapDHandler::get_layers_in_geo_file(), and MapDHandler::import_geo_table().

2626  {
2627  // single gzip'd file (not an archive)?
2628  if (boost::iends_with(path, ".gz") && !boost::iends_with(path, ".tar.gz")) {
2629  path = "/vsigzip/" + path;
2630  }
2631 }
+ Here is the caller graph for this function:

◆ add_vsi_network_prefix()

void add_vsi_network_prefix ( std::string &  path)

Definition at line 2604 of file MapDHandler.cpp.

References Importer_NS::Importer::gdalSupportsNetworkFileAccess(), and THROW_MAPD_EXCEPTION.

Referenced by MapDHandler::detect_column_types(), MapDHandler::get_all_files_in_archive(), MapDHandler::get_first_geo_file_in_archive(), MapDHandler::get_layers_in_geo_file(), and MapDHandler::import_geo_table().

2604  {
2605  // do we support network file access?
2607 
2608  // modify head of filename based on source location
2609  if (boost::istarts_with(path, "http://") || boost::istarts_with(path, "https://")) {
2610  if (!gdal_network) {
2612  "HTTP geo file import not supported! Update to GDAL 2.2 or later!");
2613  }
2614  // invoke GDAL CURL virtual file reader
2615  path = "/vsicurl/" + path;
2616  } else if (boost::istarts_with(path, "s3://")) {
2617  if (!gdal_network) {
2619  "S3 geo file import not supported! Update to GDAL 2.2 or later!");
2620  }
2621  // invoke GDAL S3 virtual file reader
2622  boost::replace_first(path, "s3://", "/vsis3/");
2623  }
2624 }
#define THROW_MAPD_EXCEPTION(errstr)
static bool gdalSupportsNetworkFileAccess()
Definition: Importer.cpp:4530
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_first_geo_file_in_archive()

std::string find_first_geo_file_in_archive ( const std::string &  archive_path,
const Importer_NS::CopyParams copy_params 
)

Definition at line 2714 of file MapDHandler.cpp.

References Importer_NS::Importer::gdalGetAllFilesInArchive(), logger::INFO, is_a_supported_geo_file(), LOG, and remove_vsi_prefixes().

Referenced by MapDHandler::detect_column_types(), MapDHandler::get_first_geo_file_in_archive(), MapDHandler::get_layers_in_geo_file(), and MapDHandler::import_geo_table().

2715  {
2716  // get the recursive list of all files in the archive
2717  std::vector<std::string> files =
2718  Importer_NS::Importer::gdalGetAllFilesInArchive(archive_path, copy_params);
2719 
2720  // report the list
2721  LOG(INFO) << "Found " << files.size() << " files in Archive "
2722  << remove_vsi_prefixes(archive_path);
2723  for (const auto& file : files) {
2724  LOG(INFO) << " " << file;
2725  }
2726 
2727  // scan the list for the first candidate file
2728  bool found_suitable_file = false;
2729  std::string file_name;
2730  for (const auto& file : files) {
2731  if (is_a_supported_geo_file(file, false)) {
2732  file_name = file;
2733  found_suitable_file = true;
2734  break;
2735  }
2736  }
2737 
2738  // if we didn't find anything
2739  if (!found_suitable_file) {
2740  LOG(INFO) << "Failed to find any supported geo files in Archive: " +
2741  remove_vsi_prefixes(archive_path);
2742  file_name.clear();
2743  }
2744 
2745  // done
2746  return file_name;
2747 }
std::string remove_vsi_prefixes(const std::string &path_in)
#define LOG(tag)
Definition: Logger.h:182
bool is_a_supported_geo_file(const std::string &path, bool include_gz)
static std::vector< std::string > gdalGetAllFilesInArchive(const std::string &archive_path, const CopyParams &copy_params)
Definition: Importer.cpp:4444
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_device_parameters()

std::map<std::string, std::string> get_device_parameters ( )

Definition at line 604 of file NativeCodegen.cpp.

References checkCudaErrors(), cpu_threads(), get_gpu_data_layout(), get_gpu_target_triple_string(), run-benchmark-import::result, and to_string().

Referenced by MapDHandler::max_bytes_for_thrift().

604  {
605  std::map<std::string, std::string> result;
606 
607  result.insert(std::make_pair("cpu_name", llvm::sys::getHostCPUName()));
608  result.insert(std::make_pair("cpu_triple", llvm::sys::getProcessTriple()));
609  result.insert(
610  std::make_pair("cpu_cores", std::to_string(llvm::sys::getHostNumPhysicalCores())));
611  result.insert(std::make_pair("cpu_threads", std::to_string(cpu_threads())));
612 
613  llvm::StringMap<bool> cpu_features;
614  if (llvm::sys::getHostCPUFeatures(cpu_features)) {
615  std::string features_str = "";
616  for (auto it = cpu_features.begin(); it != cpu_features.end(); ++it) {
617  features_str += (it->getValue() ? " +" : " -");
618  features_str += it->getKey().str();
619  }
620  result.insert(std::make_pair("cpu_features", features_str));
621  }
622 
623 #ifdef HAVE_CUDA
624  int device_count = 0;
625  checkCudaErrors(cuDeviceGetCount(&device_count));
626  if (device_count) {
627  CUdevice device{};
628  char device_name[256];
629  int major = 0, minor = 0;
630  checkCudaErrors(cuDeviceGet(&device, 0)); // assuming homogeneous multi-GPU system
631  checkCudaErrors(cuDeviceGetName(device_name, 256, device));
632  checkCudaErrors(cuDeviceGetAttribute(
633  &major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, device));
634  checkCudaErrors(cuDeviceGetAttribute(
635  &minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, device));
636 
637  result.insert(std::make_pair("gpu_name", device_name));
638  result.insert(std::make_pair("gpu_count", std::to_string(device_count)));
639  result.insert(std::make_pair("gpu_compute_capability",
640  std::to_string(major) + "." + std::to_string(minor)));
641  result.insert(std::make_pair("gpu_triple", get_gpu_target_triple_string()));
642  result.insert(std::make_pair("gpu_datalayout", get_gpu_data_layout()));
643  }
644 #endif
645 
646  return result;
647 }
void checkCudaErrors(CUresult err)
Definition: sample.cpp:38
llvm::StringRef get_gpu_data_layout()
std::string to_string(char const *&&v)
llvm::StringRef get_gpu_target_triple_string()
int CUdevice
Definition: nocuda.h:20
int cpu_threads()
Definition: thread_count.h:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_a_supported_archive_file()

bool is_a_supported_archive_file ( const std::string &  path)

Definition at line 2701 of file MapDHandler.cpp.

References path_has_valid_filename().

Referenced by MapDHandler::detect_column_types(), MapDHandler::get_all_files_in_archive(), MapDHandler::get_first_geo_file_in_archive(), MapDHandler::get_layers_in_geo_file(), and MapDHandler::import_geo_table().

2701  {
2702  if (!path_has_valid_filename(path)) {
2703  return false;
2704  }
2705  if (boost::iends_with(path, ".zip") && !boost::iends_with(path, ".gdb.zip")) {
2706  return true;
2707  } else if (boost::iends_with(path, ".tar") || boost::iends_with(path, ".tgz") ||
2708  boost::iends_with(path, ".tar.gz")) {
2709  return true;
2710  }
2711  return false;
2712 }
bool path_has_valid_filename(const std::string &path)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_a_supported_geo_file()

bool is_a_supported_geo_file ( const std::string &  path,
bool  include_gz 
)

Definition at line 2683 of file MapDHandler.cpp.

References path_has_valid_filename().

Referenced by MapDHandler::detect_column_types(), find_first_geo_file_in_archive(), MapDHandler::get_layers_in_geo_file(), and MapDHandler::import_geo_table().

2683  {
2684  if (!path_has_valid_filename(path)) {
2685  return false;
2686  }
2687  if (include_gz) {
2688  if (boost::iends_with(path, ".geojson.gz") || boost::iends_with(path, ".json.gz")) {
2689  return true;
2690  }
2691  }
2692  if (boost::iends_with(path, ".shp") || boost::iends_with(path, ".geojson") ||
2693  boost::iends_with(path, ".json") || boost::iends_with(path, ".kml") ||
2694  boost::iends_with(path, ".kmz") || boost::iends_with(path, ".gdb") ||
2695  boost::iends_with(path, ".gdb.zip")) {
2696  return true;
2697  }
2698  return false;
2699 }
bool path_has_valid_filename(const std::string &path)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_allowed_on_dashboard()

static bool is_allowed_on_dashboard ( const Catalog_Namespace::SessionInfo session_info,
int32_t  dashboard_id,
AccessPrivileges  requestedPermissions 
)
static

Definition at line 2963 of file MapDHandler.cpp.

References DashboardDBObjectType, Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::SessionInfo::getCatalog(), and anonymous_namespace{DBObjectPrivilegesTest.cpp}::user.

Referenced by MapDHandler::delete_dashboard(), MapDHandler::get_dashboard(), MapDHandler::get_dashboards(), and MapDHandler::replace_dashboard().

2965  {
2966  DBObject object(dashboard_id, DashboardDBObjectType);
2967  auto& catalog = session_info.getCatalog();
2968  auto& user = session_info.get_currentUser();
2969  object.loadKey(catalog);
2970  object.setPrivileges(requestedPermissions);
2971  std::vector<DBObject> privs = {object};
2972  return SysCatalog::instance().checkPrivileges(user, privs);
2973 }
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:

◆ path_has_valid_filename()

bool path_has_valid_filename ( const std::string &  path)

Definition at line 2675 of file MapDHandler.cpp.

Referenced by is_a_supported_archive_file(), and is_a_supported_geo_file().

2675  {
2676  auto filename = boost::filesystem::path(path).filename().string();
2677  if (filename.size() == 0 || filename[0] == '.' || filename[0] == '/') {
2678  return false;
2679  }
2680  return true;
2681 }
+ Here is the caller graph for this function:

◆ path_is_relative()

bool path_is_relative ( const std::string &  path)

Definition at line 2667 of file MapDHandler.cpp.

Referenced by MapDHandler::detect_column_types(), MapDHandler::get_all_files_in_archive(), MapDHandler::get_first_geo_file_in_archive(), MapDHandler::get_layers_in_geo_file(), and MapDHandler::import_geo_table().

2667  {
2668  if (boost::istarts_with(path, "s3://") || boost::istarts_with(path, "http://") ||
2669  boost::istarts_with(path, "https://")) {
2670  return false;
2671  }
2672  return !boost::filesystem::path(path).is_absolute();
2673 }
+ Here is the caller graph for this function:

◆ remove_vsi_prefixes()

std::string remove_vsi_prefixes ( const std::string &  path_in)

Definition at line 2645 of file MapDHandler.cpp.

Referenced by find_first_geo_file_in_archive().

2645  {
2646  std::string path(path_in);
2647 
2648  // these will be first
2649  if (boost::istarts_with(path, "/vsizip/")) {
2650  boost::replace_first(path, "/vsizip/", "");
2651  } else if (boost::istarts_with(path, "/vsitar/")) {
2652  boost::replace_first(path, "/vsitar/", "");
2653  } else if (boost::istarts_with(path, "/vsigzip/")) {
2654  boost::replace_first(path, "/vsigzip/", "");
2655  }
2656 
2657  // then these
2658  if (boost::istarts_with(path, "/vsicurl/")) {
2659  boost::replace_first(path, "/vsicurl/", "");
2660  } else if (boost::istarts_with(path, "/vsis3/")) {
2661  boost::replace_first(path, "/vsis3/", "s3://");
2662  }
2663 
2664  return path;
2665 }
+ Here is the caller graph for this function:

◆ serialize_db_object()

static TDBObject serialize_db_object ( const std::string &  roleName,
const DBObject inObject 
)
static

Definition at line 1189 of file MapDHandler.cpp.

References DatabasePrivileges::ACCESS, TablePrivileges::ALTER_TABLE, CHECK, DashboardPrivileges::CREATE_DASHBOARD, DatabasePrivileges::CREATE_DATABASE, TablePrivileges::CREATE_TABLE, ViewPrivileges::CREATE_VIEW, DashboardDBObjectType, DatabaseDBObjectType, DashboardPrivileges::DELETE_DASHBOARD, TablePrivileges::DELETE_FROM_TABLE, ViewPrivileges::DELETE_FROM_VIEW, DatabasePrivileges::DROP_DATABASE, TablePrivileges::DROP_TABLE, ViewPrivileges::DROP_VIEW, DashboardPrivileges::EDIT_DASHBOARD, DBObject::getName(), DBObject::getObjectKey(), DBObject::getPrivileges(), TablePrivileges::INSERT_INTO_TABLE, ViewPrivileges::INSERT_INTO_VIEW, DBObjectKey::permissionType, TablePrivileges::SELECT_FROM_TABLE, ViewPrivileges::SELECT_FROM_VIEW, TableDBObjectType, TablePrivileges::TRUNCATE_TABLE, TablePrivileges::UPDATE_IN_TABLE, ViewPrivileges::UPDATE_IN_VIEW, DashboardPrivileges::VIEW_DASHBOARD, DatabasePrivileges::VIEW_SQL_EDITOR, and ViewDBObjectType.

Referenced by MapDHandler::get_db_object_privs(), and MapDHandler::get_db_objects_for_grantee().

1190  {
1191  TDBObject outObject;
1192  outObject.objectName = inObject.getName();
1193  outObject.grantee = roleName;
1194  const auto ap = inObject.getPrivileges();
1195  switch (inObject.getObjectKey().permissionType) {
1196  case DatabaseDBObjectType:
1197  outObject.objectType = TDBObjectType::DatabaseDBObjectType;
1198  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::CREATE_DATABASE));
1199  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::DROP_DATABASE));
1200  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::VIEW_SQL_EDITOR));
1201  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::ACCESS));
1202 
1203  break;
1204  case TableDBObjectType:
1205  outObject.objectType = TDBObjectType::TableDBObjectType;
1206  outObject.privs.push_back(ap.hasPermission(TablePrivileges::CREATE_TABLE));
1207  outObject.privs.push_back(ap.hasPermission(TablePrivileges::DROP_TABLE));
1208  outObject.privs.push_back(ap.hasPermission(TablePrivileges::SELECT_FROM_TABLE));
1209  outObject.privs.push_back(ap.hasPermission(TablePrivileges::INSERT_INTO_TABLE));
1210  outObject.privs.push_back(ap.hasPermission(TablePrivileges::UPDATE_IN_TABLE));
1211  outObject.privs.push_back(ap.hasPermission(TablePrivileges::DELETE_FROM_TABLE));
1212  outObject.privs.push_back(ap.hasPermission(TablePrivileges::TRUNCATE_TABLE));
1213  outObject.privs.push_back(ap.hasPermission(TablePrivileges::ALTER_TABLE));
1214 
1215  break;
1216  case DashboardDBObjectType:
1217  outObject.objectType = TDBObjectType::DashboardDBObjectType;
1218  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::CREATE_DASHBOARD));
1219  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::DELETE_DASHBOARD));
1220  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::VIEW_DASHBOARD));
1221  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::EDIT_DASHBOARD));
1222 
1223  break;
1224  case ViewDBObjectType:
1225  outObject.objectType = TDBObjectType::ViewDBObjectType;
1226  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::CREATE_VIEW));
1227  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::DROP_VIEW));
1228  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::SELECT_FROM_VIEW));
1229  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::INSERT_INTO_VIEW));
1230  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::UPDATE_IN_VIEW));
1231  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::DELETE_FROM_VIEW));
1232 
1233  break;
1234  default:
1235  CHECK(false);
1236  }
1237  return outObject;
1238 }
static const int32_t DROP_VIEW
Definition: DBObject.h:114
static const int32_t SELECT_FROM_VIEW
Definition: DBObject.h:115
static const int32_t UPDATE_IN_VIEW
Definition: DBObject.h:117
static const int32_t CREATE_VIEW
Definition: DBObject.h:113
static const int32_t ALTER_TABLE
Definition: DBObject.h:94
DBObjectKey getObjectKey() const
Definition: DBObject.h:196
std::string getName() const
Definition: DBObject.h:195
static const int32_t DROP_DATABASE
Definition: DBObject.h:80
static const int32_t DELETE_FROM_TABLE
Definition: DBObject.h:92
static const int32_t TRUNCATE_TABLE
Definition: DBObject.h:93
static const int32_t EDIT_DASHBOARD
Definition: DBObject.h:105
static const int32_t DELETE_DASHBOARD
Definition: DBObject.h:103
static const int32_t INSERT_INTO_TABLE
Definition: DBObject.h:90
const AccessPrivileges & getPrivileges() const
Definition: DBObject.h:201
static const int32_t ACCESS
Definition: DBObject.h:82
static const int32_t CREATE_DATABASE
Definition: DBObject.h:79
static const int32_t VIEW_DASHBOARD
Definition: DBObject.h:104
static const int32_t VIEW_SQL_EDITOR
Definition: DBObject.h:81
static const int32_t DROP_TABLE
Definition: DBObject.h:88
static const int32_t INSERT_INTO_VIEW
Definition: DBObject.h:116
#define CHECK(condition)
Definition: Logger.h:187
static const int32_t DELETE_FROM_VIEW
Definition: DBObject.h:118
static const int32_t CREATE_TABLE
Definition: DBObject.h:87
static const int32_t CREATE_DASHBOARD
Definition: DBObject.h:102
int32_t permissionType
Definition: DBObject.h:54
static const int32_t SELECT_FROM_TABLE
Definition: DBObject.h:89
static const int32_t UPDATE_IN_TABLE
Definition: DBObject.h:91
+ Here is the call graph for this function:
+ Here is the caller graph for this function: