OmniSciDB  bf83d84833
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DBHandler.cpp File Reference
#include "DBHandler.h"
#include "DistributedLoader.h"
#include "QueryEngine/UDFCompiler.h"
#include "TokenCompletionHints.h"
#include "MapDRelease.h"
#include "Calcite/Calcite.h"
#include "gen-cpp/CalciteServer.h"
#include "QueryEngine/RelAlgExecutor.h"
#include "Catalog/Catalog.h"
#include "Catalog/DdlCommandExecutor.h"
#include "DataMgr/ForeignStorage/ArrowForeignStorage.h"
#include "DataMgr/ForeignStorage/DummyForeignStorage.h"
#include "DataMgr/ForeignStorage/ForeignStorageInterface.h"
#include "DistributedHandler.h"
#include "Fragmenter/InsertOrderFragmenter.h"
#include "Geospatial/GDAL.h"
#include "Geospatial/Transforms.h"
#include "Geospatial/Types.h"
#include "ImportExport/Importer.h"
#include "LockMgr/LockMgr.h"
#include "OSDependent/omnisci_hostname.h"
#include "Parser/ParserWrapper.h"
#include "Parser/ReservedKeywords.h"
#include "Parser/parser.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/QueryDispatchQueue.h"
#include "QueryEngine/ResultSetBuilder.h"
#include "QueryEngine/TableFunctions/TableFunctionsFactory.h"
#include "QueryEngine/TableOptimizer.h"
#include "QueryEngine/ThriftSerializers.h"
#include "Shared/ArrowUtil.h"
#include "Shared/StringTransform.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 <algorithm>
#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>

Go to the source code of this file.

Classes

struct  anonymous_namespace{DBHandler.cpp}::ForceDisconnect
 
struct  anonymous_namespace{DBHandler.cpp}::ProjectionTokensForCompletion
 

Namespaces

 anonymous_namespace{DBHandler.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)
 
#define EXPOSE_THRIFT_MAP(TYPENAME)
 

Typedefs

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

Functions

SessionMap::iterator anonymous_namespace{DBHandler.cpp}::get_session_from_map (const TSessionId &session, SessionMap &session_map)
 
ProjectionTokensForCompletion anonymous_namespace{DBHandler.cpp}::extract_projection_tokens_for_completion (const std::string &sql)
 
static TDBObject serialize_db_object (const std::string &roleName, const DBObject &inObject)
 
std::string anonymous_namespace{DBHandler.cpp}::dump_table_col_names (const std::map< std::string, std::vector< std::string >> &table_col_names)
 
void anonymous_namespace{DBHandler.cpp}::check_table_not_sharded (const TableDescriptor *td)
 
void anonymous_namespace{DBHandler.cpp}::check_valid_column_names (const std::list< const ColumnDescriptor * > &descs, const std::vector< std::string > &column_names)
 
std::vector< int > anonymous_namespace{DBHandler.cpp}::column_ids_by_names (const std::list< const ColumnDescriptor * > &descs, const std::vector< std::string > &column_names)
 
size_t anonymous_namespace{DBHandler.cpp}::get_column_size (const TColumn &column)
 
RecordBatchVector anonymous_namespace{DBHandler.cpp}::loadArrowStream (const std::string &stream)
 
void anonymous_namespace{DBHandler.cpp}::add_vsi_network_prefix (std::string &path)
 
void anonymous_namespace{DBHandler.cpp}::add_vsi_geo_prefix (std::string &path)
 
void anonymous_namespace{DBHandler.cpp}::add_vsi_archive_prefix (std::string &path)
 
std::string anonymous_namespace{DBHandler.cpp}::remove_vsi_prefixes (const std::string &path_in)
 
bool anonymous_namespace{DBHandler.cpp}::path_is_relative (const std::string &path)
 
bool anonymous_namespace{DBHandler.cpp}::path_has_valid_filename (const std::string &path)
 
bool anonymous_namespace{DBHandler.cpp}::is_a_supported_geo_file (const std::string &path, bool include_gz)
 
bool anonymous_namespace{DBHandler.cpp}::is_a_supported_archive_file (const std::string &path)
 
std::string anonymous_namespace{DBHandler.cpp}::find_first_geo_file_in_archive (const std::string &archive_path, const import_export::CopyParams &copy_params)
 
bool anonymous_namespace{DBHandler.cpp}::is_local_file (const std::string &file_path)
 
void anonymous_namespace{DBHandler.cpp}::validate_import_file_path_if_local (const std::string &file_path)
 
static bool is_allowed_on_dashboard (const Catalog_Namespace::SessionInfo &session_info, int32_t dashboard_id, AccessPrivileges requestedPermissions)
 
bool anonymous_namespace{DBHandler.cpp}::TTypeInfo_IsGeo (const TDatumType::type &t)
 
std::map< std::string,
std::string > 
get_device_parameters (bool cpu_only)
 
ExtArgumentType mapfrom (const TExtArgumentType::type &t)
 
table_functions::OutputBufferSizeType mapfrom (const TOutputBufferSizeType::type &t)
 
std::vector< ExtArgumentTypemapfrom (const std::vector< TExtArgumentType::type > &v)
 
static std::unique_ptr
< RexLiteral
genLiteralStr (std::string val)
 

Macro Definition Documentation

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

Definition at line 2726 of file DBHandler.cpp.

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

#define ENABLE_GEO_IMPORT_COLUMN_MATCHING   0

Definition at line 107 of file DBHandler.cpp.

#define EXPOSE_THRIFT_MAP (   TYPENAME)
Value:
{ \
std::map<int, const char*>::const_iterator it = \
_##TYPENAME##_VALUES_TO_NAMES.begin(); \
while (it != _##TYPENAME##_VALUES_TO_NAMES.end()) { \
_return.insert(std::pair<std::string, std::string>( \
#TYPENAME "." + std::string(it->second), std::to_string(it->first))); \
it++; \
} \
}
std::string to_string(char const *&&v)

Definition at line 6185 of file DBHandler.cpp.

Referenced by DBHandler::get_device_parameters().

#define INVALID_SESSION_ID   ""

Definition at line 112 of file DBHandler.cpp.

Referenced by DBHandler::getInvalidSessionId().

#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: DBHandler.cpp:114

Definition at line 4162 of file DBHandler.cpp.

Referenced by DBHandler::import_geo_table().

#define THROW_MAPD_EXCEPTION (   errstr)
Value:
{ \
TOmniSciException ex; \
ex.error_msg = errstr; \
LOG(ERROR) << ex.error_msg; \
throw ex; \
}
#define LOG(tag)
Definition: Logger.h:188

Definition at line 114 of file DBHandler.cpp.

Referenced by anonymous_namespace{DBHandler.cpp}::add_vsi_network_prefix(), DBHandler::broadcast_serialized_rows(), DBHandler::check_read_only(), DBHandler::check_table_consistency(), DBHandler::check_table_load_privileges(), anonymous_namespace{DBHandler.cpp}::check_valid_column_names(), DBHandler::clear_cpu_memory(), DBHandler::clear_gpu_memory(), DBHandler::clone_session(), anonymous_namespace{DBHandler.cpp}::column_ids_by_names(), DBHandler::connect(), DBHandler::convert_rows(), DBHandler::create_dashboard(), DBHandler::create_link(), DBHandler::create_table(), DBHandler::delete_dashboards(), DBHandler::detect_column_types(), DBHandler::execute_next_render_step(), DBHandler::execute_query_step(), DBHandler::get_all_files_in_archive(), DBHandler::get_all_roles_for_user(), DBHandler::get_dashboard(), DBHandler::get_dashboard_grantees(), DBHandler::get_db_object_privs(), DBHandler::get_db_objects_for_grantee(), DBHandler::get_first_geo_file_in_archive(), DBHandler::get_heap_profile(), DBHandler::get_layers_in_geo_file(), DBHandler::get_link_view(), DBHandler::get_result_row_for_pixel(), anonymous_namespace{DBHandler.cpp}::get_session_from_map(), DBHandler::get_session_it_unsafe(), DBHandler::get_table_details_impl(), DBHandler::get_table_epoch(), DBHandler::get_table_epoch_by_name(), DBHandler::get_tables_meta(), DBHandler::get_tables_meta_impl(), DBHandler::get_valid_groups(), DBHandler::has_dashboard_permission(), DBHandler::has_database_permission(), DBHandler::has_object_privilege(), DBHandler::has_role(), DBHandler::has_table_permission(), DBHandler::has_view_permission(), DBHandler::import_geo_table(), DBHandler::import_table(), DBHandler::insert_data(), DBHandler::internal_connect(), DBHandler::krb5_connect(), DBHandler::load_table(), DBHandler::load_table_binary(), DBHandler::load_table_binary_arrow(), DBHandler::load_table_binary_columnar(), DBHandler::populateThriftColumnType(), DBHandler::prepare_columnar_loader(), DBHandler::query_get_outer_fragment_count(), DBHandler::register_runtime_extension_functions(), DBHandler::render_vega(), DBHandler::replace_dashboard(), DBHandler::set_license_key(), DBHandler::set_table_epoch(), DBHandler::set_table_epoch_by_name(), DBHandler::set_table_epochs(), DBHandler::shareOrUnshareDashboards(), DBHandler::sql_execute(), DBHandler::sql_execute_df(), DBHandler::sql_execute_impl(), DBHandler::sql_validate(), DBHandler::start_heap_profile(), DBHandler::start_query(), DBHandler::start_render_query(), DBHandler::stop_heap_profile(), DBHandler::switch_database(), DBHandler::thrift_to_copyparams(), DBHandler::validateDashboardIdsForSharing(), and DBHandler::validateGroups().

Typedef Documentation

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

Definition at line 2724 of file DBHandler.cpp.

Function Documentation

static std::unique_ptr<RexLiteral> genLiteralStr ( std::string  val)
static

Definition at line 6399 of file DBHandler.cpp.

References kTEXT.

Referenced by anonymous_namespace{DdlCommandExecutor.cpp}::add_table_details(), ShowForeignServersCommand::execute(), ShowTablesCommand::execute(), ShowDatabasesCommand::execute(), ShowDiskCacheUsageCommand::execute(), DBHandler::getQueries(), and DBHandler::getUserSessions().

6399  {
6400  return std::unique_ptr<RexLiteral>(
6401  new RexLiteral(val, SQLTypes::kTEXT, SQLTypes::kTEXT, 0, 0, 0, 0));
6402 }
Definition: sqltypes.h:51

+ Here is the caller graph for this function:

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

Definition at line 860 of file NativeCodegen.cpp.

860  {
861  std::map<std::string, std::string> result;
862 
863  result.insert(std::make_pair("cpu_name", llvm::sys::getHostCPUName()));
864  result.insert(std::make_pair("cpu_triple", llvm::sys::getProcessTriple()));
865  result.insert(
866  std::make_pair("cpu_cores", std::to_string(llvm::sys::getHostNumPhysicalCores())));
867  result.insert(std::make_pair("cpu_threads", std::to_string(cpu_threads())));
868 
869  std::string null_values;
870  null_values += "boolean1:" + std::to_string(serialized_null_value<bool>()) + ";";
871  null_values += "boolean8:" + std::to_string(serialized_null_value<int8_t>()) + ";";
872  null_values += "int8:" + std::to_string(serialized_null_value<int8_t>()) + ";";
873  null_values += "int16:" + std::to_string(serialized_null_value<int16_t>()) + ";";
874  null_values += "int32:" + std::to_string(serialized_null_value<int32_t>()) + ";";
875  null_values += "int64:" + std::to_string(serialized_null_value<int64_t>()) + ";";
876  null_values += "uint8:" + std::to_string(serialized_null_value<uint8_t>()) + ";";
877  null_values += "uint16:" + std::to_string(serialized_null_value<uint16_t>()) + ";";
878  null_values += "uint32:" + std::to_string(serialized_null_value<uint32_t>()) + ";";
879  null_values += "uint64:" + std::to_string(serialized_null_value<uint64_t>()) + ";";
880  null_values += "float32:" + std::to_string(serialized_null_value<float>()) + ";";
881  null_values += "float64:" + std::to_string(serialized_null_value<double>()) + ";";
882  null_values +=
883  "Array<boolean8>:" + std::to_string(serialized_null_value<int8_t, true>()) + ";";
884  null_values +=
885  "Array<int8>:" + std::to_string(serialized_null_value<int8_t, true>()) + ";";
886  null_values +=
887  "Array<int16>:" + std::to_string(serialized_null_value<int16_t, true>()) + ";";
888  null_values +=
889  "Array<int32>:" + std::to_string(serialized_null_value<int32_t, true>()) + ";";
890  null_values +=
891  "Array<int64>:" + std::to_string(serialized_null_value<int64_t, true>()) + ";";
892  null_values +=
893  "Array<float32>:" + std::to_string(serialized_null_value<float, true>()) + ";";
894  null_values +=
895  "Array<float64>:" + std::to_string(serialized_null_value<double, true>()) + ";";
896 
897  result.insert(std::make_pair("null_values", null_values));
898 
899  llvm::StringMap<bool> cpu_features;
900  if (llvm::sys::getHostCPUFeatures(cpu_features)) {
901  std::string features_str = "";
902  for (auto it = cpu_features.begin(); it != cpu_features.end(); ++it) {
903  features_str += (it->getValue() ? " +" : " -");
904  features_str += it->getKey().str();
905  }
906  result.insert(std::make_pair("cpu_features", features_str));
907  }
908 
909  result.insert(std::make_pair("llvm_version",
910  std::to_string(LLVM_VERSION_MAJOR) + "." +
911  std::to_string(LLVM_VERSION_MINOR) + "." +
912  std::to_string(LLVM_VERSION_PATCH)));
913 
914 #ifdef HAVE_CUDA
915  if (!cpu_only) {
916  int device_count = 0;
917  checkCudaErrors(cuDeviceGetCount(&device_count));
918  if (device_count) {
919  CUdevice device{};
920  char device_name[256];
921  int major = 0, minor = 0;
922  int driver_version;
923  checkCudaErrors(cuDeviceGet(&device, 0)); // assuming homogeneous multi-GPU system
924  checkCudaErrors(cuDeviceGetName(device_name, 256, device));
925  checkCudaErrors(cuDeviceGetAttribute(
926  &major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, device));
927  checkCudaErrors(cuDeviceGetAttribute(
928  &minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, device));
929  checkCudaErrors(cuDriverGetVersion(&driver_version));
930 
931  result.insert(std::make_pair("gpu_name", device_name));
932  result.insert(std::make_pair("gpu_count", std::to_string(device_count)));
933  result.insert(std::make_pair("gpu_compute_capability",
934  std::to_string(major) + "." + std::to_string(minor)));
935  result.insert(std::make_pair("gpu_triple", get_gpu_target_triple_string()));
936  result.insert(std::make_pair("gpu_datalayout", get_gpu_data_layout()));
937  result.insert(std::make_pair("gpu_driver",
938  "CUDA " + std::to_string(driver_version / 1000) + "." +
939  std::to_string((driver_version % 1000) / 10)));
940  }
941  }
942 #endif
943 
944  return result;
945 }
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:24
static bool is_allowed_on_dashboard ( const Catalog_Namespace::SessionInfo session_info,
int32_t  dashboard_id,
AccessPrivileges  requestedPermissions 
)
static

Definition at line 3524 of file DBHandler.cpp.

References DashboardDBObjectType, Catalog_Namespace::SessionInfo::get_currentUser(), and Catalog_Namespace::SessionInfo::getCatalog().

Referenced by DBHandler::get_dashboard(), DBHandler::get_dashboards(), and DBHandler::replace_dashboard().

3526  {
3527  DBObject object(dashboard_id, DashboardDBObjectType);
3528  auto& catalog = session_info.getCatalog();
3529  auto& user = session_info.get_currentUser();
3530  object.loadKey(catalog);
3531  object.setPrivileges(requestedPermissions);
3532  std::vector<DBObject> privs = {object};
3533  return SysCatalog::instance().checkPrivileges(user, privs);
3534 }
Catalog & getCatalog() const
Definition: SessionInfo.h:65
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:68

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ExtArgumentType mapfrom ( const TExtArgumentType::type &  t)

Definition at line 6210 of file DBHandler.cpp.

References ArrayBool, ArrayDouble, ArrayFloat, ArrayInt16, ArrayInt32, ArrayInt64, ArrayInt8, Bool, ColumnBool, ColumnDouble, ColumnFloat, ColumnInt16, ColumnInt32, ColumnInt64, ColumnInt8, Cursor, Double, Float, GeoLineString, GeoMultiPolygon, GeoPoint, GeoPolygon, Int16, Int32, Int64, Int8, PBool, PDouble, PFloat, PInt16, PInt32, PInt64, PInt8, TextEncodingDict16, TextEncodingDict32, TextEncodingDict8, TextEncodingNone, UNREACHABLE, and Void.

Referenced by mapfrom(), and DBHandler::register_runtime_extension_functions().

6210  {
6211  switch (t) {
6212  case TExtArgumentType::Int8:
6213  return ExtArgumentType::Int8;
6214  case TExtArgumentType::Int16:
6215  return ExtArgumentType::Int16;
6216  case TExtArgumentType::Int32:
6217  return ExtArgumentType::Int32;
6218  case TExtArgumentType::Int64:
6219  return ExtArgumentType::Int64;
6220  case TExtArgumentType::Float:
6221  return ExtArgumentType::Float;
6223  return ExtArgumentType::Double;
6224  case TExtArgumentType::Void:
6225  return ExtArgumentType::Void;
6226  case TExtArgumentType::PInt8:
6227  return ExtArgumentType::PInt8;
6228  case TExtArgumentType::PInt16:
6229  return ExtArgumentType::PInt16;
6230  case TExtArgumentType::PInt32:
6231  return ExtArgumentType::PInt32;
6232  case TExtArgumentType::PInt64:
6233  return ExtArgumentType::PInt64;
6234  case TExtArgumentType::PFloat:
6235  return ExtArgumentType::PFloat;
6236  case TExtArgumentType::PDouble:
6237  return ExtArgumentType::PDouble;
6238  case TExtArgumentType::PBool:
6239  return ExtArgumentType::PBool;
6240  case TExtArgumentType::Bool:
6241  return ExtArgumentType::Bool;
6242  case TExtArgumentType::ArrayInt8:
6244  case TExtArgumentType::ArrayInt16:
6246  case TExtArgumentType::ArrayInt32:
6248  case TExtArgumentType::ArrayInt64:
6250  case TExtArgumentType::ArrayFloat:
6252  case TExtArgumentType::ArrayDouble:
6254  case TExtArgumentType::ArrayBool:
6256  case TExtArgumentType::GeoPoint:
6258  case TExtArgumentType::GeoLineString:
6260  case TExtArgumentType::Cursor:
6261  return ExtArgumentType::Cursor;
6262  case TExtArgumentType::GeoPolygon:
6264  case TExtArgumentType::GeoMultiPolygon:
6266  case TExtArgumentType::ColumnInt8:
6268  case TExtArgumentType::ColumnInt16:
6270  case TExtArgumentType::ColumnInt32:
6272  case TExtArgumentType::ColumnInt64:
6274  case TExtArgumentType::ColumnFloat:
6276  case TExtArgumentType::ColumnDouble:
6278  case TExtArgumentType::ColumnBool:
6280  case TExtArgumentType::TextEncodingNone:
6282  case TExtArgumentType::TextEncodingDict8:
6284  case TExtArgumentType::TextEncodingDict16:
6286  case TExtArgumentType::TextEncodingDict32:
6288  }
6289  UNREACHABLE();
6290  return ExtArgumentType{};
6291 }
#define UNREACHABLE()
Definition: Logger.h:241

+ Here is the caller graph for this function:

table_functions::OutputBufferSizeType mapfrom ( const TOutputBufferSizeType::type &  t)
std::vector<ExtArgumentType> mapfrom ( const std::vector< TExtArgumentType::type > &  v)

Definition at line 6306 of file DBHandler.cpp.

References mapfrom(), run_benchmark_import::result, and run_benchmark_import::type.

6306  {
6307  std::vector<ExtArgumentType> result;
6308  std::transform(v.begin(),
6309  v.end(),
6310  std::back_inserter(result),
6311  [](TExtArgumentType::type c) -> ExtArgumentType { return mapfrom(c); });
6312  return result;
6313 }
ExtArgumentType mapfrom(const TExtArgumentType::type &t)
Definition: DBHandler.cpp:6210

+ Here is the call graph for this function:

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

Definition at line 1520 of file DBHandler.cpp.

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

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

1521  {
1522  TDBObject outObject;
1523  outObject.objectName = inObject.getName();
1524  outObject.grantee = roleName;
1525  const auto ap = inObject.getPrivileges();
1526  switch (inObject.getObjectKey().permissionType) {
1527  case DatabaseDBObjectType:
1528  outObject.privilegeObjectType = TDBObjectType::DatabaseDBObjectType;
1529  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::CREATE_DATABASE));
1530  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::DROP_DATABASE));
1531  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::VIEW_SQL_EDITOR));
1532  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::ACCESS));
1533 
1534  break;
1535  case TableDBObjectType:
1536  outObject.privilegeObjectType = TDBObjectType::TableDBObjectType;
1537  outObject.privs.push_back(ap.hasPermission(TablePrivileges::CREATE_TABLE));
1538  outObject.privs.push_back(ap.hasPermission(TablePrivileges::DROP_TABLE));
1539  outObject.privs.push_back(ap.hasPermission(TablePrivileges::SELECT_FROM_TABLE));
1540  outObject.privs.push_back(ap.hasPermission(TablePrivileges::INSERT_INTO_TABLE));
1541  outObject.privs.push_back(ap.hasPermission(TablePrivileges::UPDATE_IN_TABLE));
1542  outObject.privs.push_back(ap.hasPermission(TablePrivileges::DELETE_FROM_TABLE));
1543  outObject.privs.push_back(ap.hasPermission(TablePrivileges::TRUNCATE_TABLE));
1544  outObject.privs.push_back(ap.hasPermission(TablePrivileges::ALTER_TABLE));
1545 
1546  break;
1547  case DashboardDBObjectType:
1548  outObject.privilegeObjectType = TDBObjectType::DashboardDBObjectType;
1549  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::CREATE_DASHBOARD));
1550  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::DELETE_DASHBOARD));
1551  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::VIEW_DASHBOARD));
1552  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::EDIT_DASHBOARD));
1553 
1554  break;
1555  case ViewDBObjectType:
1556  outObject.privilegeObjectType = TDBObjectType::ViewDBObjectType;
1557  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::CREATE_VIEW));
1558  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::DROP_VIEW));
1559  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::SELECT_FROM_VIEW));
1560  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::INSERT_INTO_VIEW));
1561  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::UPDATE_IN_VIEW));
1562  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::DELETE_FROM_VIEW));
1563 
1564  break;
1565  case ServerDBObjectType:
1566  outObject.privilegeObjectType = TDBObjectType::ServerDBObjectType;
1567  outObject.privs.push_back(ap.hasPermission(ServerPrivileges::CREATE_SERVER));
1568  outObject.privs.push_back(ap.hasPermission(ServerPrivileges::DROP_SERVER));
1569  outObject.privs.push_back(ap.hasPermission(ServerPrivileges::ALTER_SERVER));
1570 
1571  break;
1572  default:
1573  CHECK(false);
1574  }
1575  const int type_val = static_cast<int>(inObject.getType());
1576  CHECK(type_val >= 0 && type_val < 6);
1577  outObject.objectType = static_cast<TDBObjectType::type>(type_val);
1578  return outObject;
1579 }
static const int32_t DROP_VIEW
Definition: DBObject.h:115
static const int32_t ALTER_SERVER
Definition: DBObject.h:130
DBObjectKey getObjectKey() const
Definition: DBObject.h:211
static const int32_t SELECT_FROM_VIEW
Definition: DBObject.h:116
static const int32_t UPDATE_IN_VIEW
Definition: DBObject.h:118
static const int32_t CREATE_VIEW
Definition: DBObject.h:114
static const int32_t ALTER_TABLE
Definition: DBObject.h:95
static const int32_t DROP_DATABASE
Definition: DBObject.h:81
static const int32_t DELETE_FROM_TABLE
Definition: DBObject.h:93
static const int32_t TRUNCATE_TABLE
Definition: DBObject.h:94
std::string getName() const
Definition: DBObject.h:209
static const int32_t EDIT_DASHBOARD
Definition: DBObject.h:106
static const int32_t DELETE_DASHBOARD
Definition: DBObject.h:104
static const int32_t INSERT_INTO_TABLE
Definition: DBObject.h:91
DBObjectType getType() const
Definition: DBObject.h:210
static const int32_t CREATE_SERVER
Definition: DBObject.h:128
const AccessPrivileges & getPrivileges() const
Definition: DBObject.h:216
static const int32_t ACCESS
Definition: DBObject.h:83
static const int32_t CREATE_DATABASE
Definition: DBObject.h:80
static const int32_t VIEW_DASHBOARD
Definition: DBObject.h:105
static const int32_t VIEW_SQL_EDITOR
Definition: DBObject.h:82
static const int32_t DROP_TABLE
Definition: DBObject.h:89
static const int32_t INSERT_INTO_VIEW
Definition: DBObject.h:117
#define CHECK(condition)
Definition: Logger.h:197
static const int32_t DELETE_FROM_VIEW
Definition: DBObject.h:119
static const int32_t CREATE_TABLE
Definition: DBObject.h:88
static const int32_t CREATE_DASHBOARD
Definition: DBObject.h:103
int32_t permissionType
Definition: DBObject.h:55
static const int32_t SELECT_FROM_TABLE
Definition: DBObject.h:90
static const int32_t UPDATE_IN_TABLE
Definition: DBObject.h:92
static const int32_t DROP_SERVER
Definition: DBObject.h:129

+ Here is the call graph for this function:

+ Here is the caller graph for this function: