OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DBHandler.cpp File Reference
#include "DBHandler.h"
#include "DistributedLoader.h"
#include "TokenCompletionHints.h"
#include "MapDRelease.h"
#include "Calcite/Calcite.h"
#include "gen-cpp/CalciteServer.h"
#include "QueryEngine/ErrorHandling.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/PassThroughBuffer.h"
#include "DistributedHandler.h"
#include "Fragmenter/InsertOrderFragmenter.h"
#include "Geospatial/ColumnNames.h"
#include "Geospatial/Compression.h"
#include "Geospatial/GDAL.h"
#include "Geospatial/Types.h"
#include "ImportExport/Importer.h"
#include "LockMgr/LockMgr.h"
#include "OSDependent/heavyai_hostname.h"
#include "Parser/ParserWrapper.h"
#include "Parser/ReservedKeywords.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 "RequestInfo.h"
#include "Shared/ArrowUtil.h"
#include "Shared/DateTimeParser.h"
#include "Shared/StringTransform.h"
#include "Shared/SysDefinitions.h"
#include "Shared/file_path_util.h"
#include "Shared/heavyai_shared_mutex.h"
#include "Shared/import_helpers.h"
#include "Shared/measure.h"
#include "Shared/misc.h"
#include "Shared/scope.h"
#include "UdfCompiler/UdfCompiler.h"
#include <fcntl.h>
#include <picosha2.h>
#include <sys/types.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/tokenizer.hpp>
#include <chrono>
#include <cmath>
#include <csignal>
#include <fstream>
#include <future>
#include <map>
#include <memory>
#include <random>
#include <string>
#include <thread>
#include <typeinfo>
#include <arrow/api.h>
#include <arrow/io/api.h>
#include <arrow/ipc/api.h>
#include "Shared/distributed.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}
 
 dbhandler
 

Macros

#define INVALID_SESSION_ID   ""
 
#define SET_REQUEST_ID(parent_request_id)
 
#define THROW_DB_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

bool anonymous_namespace{DBHandler.cpp}::dashboard_exists (const Catalog_Namespace::Catalog &cat, const int32_t user_id, const std::string &dashboard_name)
 
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)
 
TTableRefreshInfo anonymous_namespace{DBHandler.cpp}::get_refresh_info (const TableDescriptor *td)
 
ScopeGuard anonymous_namespace{DBHandler.cpp}::pause_and_resume_executor_queue ()
 
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)
 
void anonymous_namespace{DBHandler.cpp}::log_cache_size (const Catalog_Namespace::Catalog &cat)
 
void anonymous_namespace{DBHandler.cpp}::log_system_cpu_memory_status (std::string const &query, const Catalog_Namespace::Catalog &cat)
 
std::string anonymous_namespace{DBHandler.cpp}::get_load_tag (const std::string &load_tag, const std::string &table_name)
 
std::string anonymous_namespace{DBHandler.cpp}::get_import_tag (const std::string &import_tag, const std::string &table_name, const std::string &file_path)
 
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 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)
 
std::unique_ptr
< Catalog_Namespace::CustomExpression
anonymous_namespace{DBHandler.cpp}::create_custom_expr_from_thrift_obj (const TCustomExpression &t_custom_expr, const Catalog &catalog)
 
TCustomExpression anonymous_namespace{DBHandler.cpp}::create_thrift_obj_from_custom_expr (const CustomExpression &custom_expr, const Catalog &catalog)
 
bool dbhandler::is_info_schema_db (const std::string &db_name)
 
void dbhandler::check_not_info_schema_db (const std::string &db_name, bool throw_db_exception)
 
bool anonymous_namespace{DBHandler.cpp}::TTypeInfo_IsGeo (const TDatumType::type &t)
 
std::string anonymous_namespace{DBHandler.cpp}::TTypeInfo_TypeToString (const TDatumType::type &t)
 
std::string anonymous_namespace{DBHandler.cpp}::get_mismatch_attr_warning_text (const std::string &table_name, const std::string &file_path, const std::string &column_name, const std::string &attr, const std::string &got, const std::string &expected)
 
bool anonymous_namespace{DBHandler.cpp}::check_and_reset_in_memory_system_table (const Catalog &catalog, const TableDescriptor &td)
 
void anonymous_namespace{DBHandler.cpp}::check_in_memory_system_table_query (const std::vector< std::vector< std::string >> &selected_tables)
 
std::map< std::string,
std::string > 
get_device_parameters (bool cpu_only)
 
static std::unique_ptr
< RexLiteral
genLiteralStr (std::string val)
 

Variables

bool g_enable_system_tables
 
bool g_allow_system_dashboard_update {false}
 
bool g_uniform_request_ids_per_thrift_call {true}
 
bool g_allow_memory_status_log
 

Macro Definition Documentation

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

Definition at line 3563 of file DBHandler.cpp.

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

#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 7555 of file DBHandler.cpp.

Referenced by DBHandler::get_device_parameters().

#define INVALID_SESSION_ID   ""

Definition at line 131 of file DBHandler.cpp.

Referenced by DBHandler::getInvalidSessionId().

#define SET_REQUEST_ID (   parent_request_id)
Value:
if (g_uniform_request_ids_per_thrift_call && parent_request_id) \
logger::set_request_id(parent_request_id); \
else if (logger::set_new_request_id(); parent_request_id) \
LOG(INFO) << "This request has parent request_id(" << parent_request_id << ')'
#define LOG(tag)
Definition: Logger.h:285
RequestId set_new_request_id()
Definition: Logger.cpp:889
void set_request_id(RequestId const request_id)
Definition: Logger.cpp:897
bool g_uniform_request_ids_per_thrift_call
Definition: DBHandler.cpp:125

Definition at line 133 of file DBHandler.cpp.

Referenced by DBHandler::check_table_consistency(), DBHandler::checkpoint(), DBHandler::clear_cpu_memory(), DBHandler::clear_gpu_memory(), DBHandler::clearRenderMemory(), DBHandler::clone_session(), DBHandler::create_custom_expression(), DBHandler::create_dashboard(), DBHandler::create_link(), DBHandler::create_table(), DBHandler::deallocate_df(), DBHandler::delete_custom_expressions(), DBHandler::delete_dashboards(), DBHandler::detect_column_types(), DBHandler::disconnect(), DBHandler::execute_next_render_step(), DBHandler::execute_query_step(), DBHandler::get_all_effective_roles_for_user(), DBHandler::get_all_files_in_archive(), DBHandler::get_all_roles_for_user(), DBHandler::get_completion_hints(), DBHandler::get_custom_expressions(), DBHandler::get_dashboard(), DBHandler::get_dashboard_grantees(), DBHandler::get_dashboards(), DBHandler::get_databases(), DBHandler::get_db_object_privs(), DBHandler::get_db_objects_for_grantee(), DBHandler::get_device_parameters(), DBHandler::get_first_geo_file_in_archive(), DBHandler::get_hardware_info(), DBHandler::get_heap_profile(), DBHandler::get_internal_table_details(), DBHandler::get_internal_table_details_for_database(), DBHandler::get_layers_in_geo_file(), DBHandler::get_license_claims(), DBHandler::get_link_view(), DBHandler::get_memory(), DBHandler::get_physical_tables(), DBHandler::get_queries_info(), DBHandler::get_result_row_for_pixel(), DBHandler::get_roles(), DBHandler::get_server_status(), DBHandler::get_session_info(), DBHandler::get_status(), DBHandler::get_table_details(), DBHandler::get_table_details_for_database(), DBHandler::get_table_epoch(), DBHandler::get_table_epoch_by_name(), DBHandler::get_table_epochs(), DBHandler::get_tables(), DBHandler::get_tables_for_database(), DBHandler::get_tables_meta(), DBHandler::get_users(), DBHandler::get_valid_groups(), DBHandler::get_views(), DBHandler::has_object_privilege(), DBHandler::has_role(), DBHandler::import_geo_table(), DBHandler::import_table(), DBHandler::import_table_status(), DBHandler::insert_chunks(), DBHandler::insert_data(), DBHandler::interrupt(), DBHandler::invalidate_cur_session(), DBHandler::load_table(), DBHandler::load_table_binary(), DBHandler::load_table_binary_arrow(), DBHandler::load_table_binary_columnar(), DBHandler::query_get_outer_fragment_count(), DBHandler::register_runtime_extension_functions(), DBHandler::render_vega(), DBHandler::replace_dashboard(), DBHandler::set_cur_session(), DBHandler::set_execution_mode(), DBHandler::set_license_key(), DBHandler::set_table_epoch(), DBHandler::set_table_epoch_by_name(), DBHandler::set_table_epochs(), DBHandler::share_dashboards(), DBHandler::sql_execute(), DBHandler::sql_execute_df(), DBHandler::sql_execute_gdf(), DBHandler::sql_validate(), DBHandler::start_heap_profile(), DBHandler::start_query(), DBHandler::start_render_query(), DBHandler::stop_heap_profile(), DBHandler::switch_database(), DBHandler::unshare_dashboards(), and DBHandler::update_custom_expression().

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

Definition at line 5396 of file DBHandler.cpp.

Referenced by DBHandler::importGeoTableSingle().

#define THROW_DB_EXCEPTION (   errstr)
Value:
{ \
TDBException ex; \
ex.error_msg = errstr; \
LOG(ERROR) << ex.error_msg; \
throw ex; \
}
#define LOG(tag)
Definition: Logger.h:285

Definition at line 139 of file DBHandler.cpp.

Referenced by anonymous_namespace{DBHandler.cpp}::add_vsi_network_prefix(), DBHandler::broadcast_serialized_rows(), dbhandler::check_not_info_schema_db(), 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::clearRenderMemory(), DBHandler::clone_session(), anonymous_namespace{DBHandler.cpp}::column_ids_by_names(), DBHandler::connect(), DBHandler::convertRows(), anonymous_namespace{DBHandler.cpp}::create_custom_expr_from_thrift_obj(), DBHandler::create_custom_expression(), DBHandler::create_dashboard(), DBHandler::create_link(), DBHandler::create_table(), DBHandler::delete_custom_expressions(), DBHandler::delete_dashboards(), DBHandler::detect_column_types(), DBHandler::execute_next_render_step(), DBHandler::execute_query_step(), DBHandler::fillGeoColumns(), DBHandler::get_all_files_in_archive(), 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(), DBHandler::get_session_ptr(), DBHandler::get_table_details_impl(), DBHandler::get_table_epoch(), DBHandler::get_table_epoch_by_name(), DBHandler::get_tables_impl(), DBHandler::get_tables_meta(), DBHandler::get_tables_meta_impl(), DBHandler::get_valid_groups(), DBHandler::getAllRolesForUserImpl(), 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_table(), DBHandler::importGeoTableSingle(), DBHandler::initialize(), DBHandler::insert_chunks(), 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::pause_executor_queue(), DBHandler::populateThriftColumnType(), DBHandler::prepare_loader_generic(), DBHandler::query_get_outer_fragment_count(), DBHandler::register_runtime_extension_functions(), DBHandler::render_vega(), DBHandler::replace_dashboard(), DBHandler::resume_executor_queue(), 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::update_custom_expression(), DBHandler::validateDashboardIdsForSharing(), and DBHandler::validateGroups().

Typedef Documentation

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

Definition at line 3561 of file DBHandler.cpp.

Function Documentation

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

Definition at line 968 of file NativeCodegen.cpp.

968  {
969  std::map<std::string, std::string> result;
970 
971  result.insert(std::make_pair("cpu_name", llvm::sys::getHostCPUName()));
972  result.insert(std::make_pair("cpu_triple", llvm::sys::getProcessTriple()));
973  result.insert(
974  std::make_pair("cpu_cores", std::to_string(llvm::sys::getHostNumPhysicalCores())));
975  result.insert(std::make_pair("cpu_threads", std::to_string(cpu_threads())));
976 
977  // https://en.cppreference.com/w/cpp/language/types
978  std::string sizeof_types;
979  sizeof_types += "bool:" + std::to_string(sizeof(bool)) + ";";
980  sizeof_types += "size_t:" + std::to_string(sizeof(size_t)) + ";";
981  sizeof_types += "ssize_t:" + std::to_string(sizeof(ssize_t)) + ";";
982  sizeof_types += "char:" + std::to_string(sizeof(char)) + ";";
983  sizeof_types += "uchar:" + std::to_string(sizeof(unsigned char)) + ";";
984  sizeof_types += "short:" + std::to_string(sizeof(short)) + ";";
985  sizeof_types += "ushort:" + std::to_string(sizeof(unsigned short int)) + ";";
986  sizeof_types += "int:" + std::to_string(sizeof(int)) + ";";
987  sizeof_types += "uint:" + std::to_string(sizeof(unsigned int)) + ";";
988  sizeof_types += "long:" + std::to_string(sizeof(long int)) + ";";
989  sizeof_types += "ulong:" + std::to_string(sizeof(unsigned long int)) + ";";
990  sizeof_types += "longlong:" + std::to_string(sizeof(long long int)) + ";";
991  sizeof_types += "ulonglong:" + std::to_string(sizeof(unsigned long long int)) + ";";
992  sizeof_types += "float:" + std::to_string(sizeof(float)) + ";";
993  sizeof_types += "double:" + std::to_string(sizeof(double)) + ";";
994  sizeof_types += "longdouble:" + std::to_string(sizeof(long double)) + ";";
995  sizeof_types += "voidptr:" + std::to_string(sizeof(void*)) + ";";
996 
997  result.insert(std::make_pair("type_sizeof", sizeof_types));
998 
999  std::string null_values;
1000  null_values += "boolean1:" + std::to_string(serialized_null_value<bool>()) + ";";
1001  null_values += "boolean8:" + std::to_string(serialized_null_value<int8_t>()) + ";";
1002  null_values += "int8:" + std::to_string(serialized_null_value<int8_t>()) + ";";
1003  null_values += "int16:" + std::to_string(serialized_null_value<int16_t>()) + ";";
1004  null_values += "int32:" + std::to_string(serialized_null_value<int32_t>()) + ";";
1005  null_values += "int64:" + std::to_string(serialized_null_value<int64_t>()) + ";";
1006  null_values += "uint8:" + std::to_string(serialized_null_value<uint8_t>()) + ";";
1007  null_values += "uint16:" + std::to_string(serialized_null_value<uint16_t>()) + ";";
1008  null_values += "uint32:" + std::to_string(serialized_null_value<uint32_t>()) + ";";
1009  null_values += "uint64:" + std::to_string(serialized_null_value<uint64_t>()) + ";";
1010  null_values += "float32:" + std::to_string(serialized_null_value<float>()) + ";";
1011  null_values += "float64:" + std::to_string(serialized_null_value<double>()) + ";";
1012  null_values +=
1013  "Array<boolean8>:" + std::to_string(serialized_null_value<int8_t, true>()) + ";";
1014  null_values +=
1015  "Array<int8>:" + std::to_string(serialized_null_value<int8_t, true>()) + ";";
1016  null_values +=
1017  "Array<int16>:" + std::to_string(serialized_null_value<int16_t, true>()) + ";";
1018  null_values +=
1019  "Array<int32>:" + std::to_string(serialized_null_value<int32_t, true>()) + ";";
1020  null_values +=
1021  "Array<int64>:" + std::to_string(serialized_null_value<int64_t, true>()) + ";";
1022  null_values +=
1023  "Array<float32>:" + std::to_string(serialized_null_value<float, true>()) + ";";
1024  null_values +=
1025  "Array<float64>:" + std::to_string(serialized_null_value<double, true>()) + ";";
1026 
1027  result.insert(std::make_pair("null_values", null_values));
1028 
1029  llvm::StringMap<bool> cpu_features;
1030  if (llvm::sys::getHostCPUFeatures(cpu_features)) {
1031  std::string features_str = "";
1032  for (auto it = cpu_features.begin(); it != cpu_features.end(); ++it) {
1033  features_str += (it->getValue() ? " +" : " -");
1034  features_str += it->getKey().str();
1035  }
1036  result.insert(std::make_pair("cpu_features", features_str));
1037  }
1038 
1039  result.insert(std::make_pair("llvm_version",
1040  std::to_string(LLVM_VERSION_MAJOR) + "." +
1041  std::to_string(LLVM_VERSION_MINOR) + "." +
1042  std::to_string(LLVM_VERSION_PATCH)));
1043 
1044 #ifdef HAVE_CUDA
1045  if (!cpu_only) {
1046  int device_count = 0;
1047  checkCudaErrors(cuDeviceGetCount(&device_count));
1048  if (device_count) {
1049  CUdevice device{};
1050  char device_name[256];
1051  int major = 0, minor = 0;
1052  int driver_version;
1053  checkCudaErrors(cuDeviceGet(&device, 0)); // assuming homogeneous multi-GPU system
1054  checkCudaErrors(cuDeviceGetName(device_name, 256, device));
1055  checkCudaErrors(cuDeviceGetAttribute(
1056  &major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, device));
1057  checkCudaErrors(cuDeviceGetAttribute(
1058  &minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, device));
1059  checkCudaErrors(cuDriverGetVersion(&driver_version));
1060 
1061  result.insert(std::make_pair("gpu_name", device_name));
1062  result.insert(std::make_pair("gpu_count", std::to_string(device_count)));
1063  result.insert(std::make_pair("gpu_compute_capability",
1064  std::to_string(major) + "." + std::to_string(minor)));
1065  result.insert(std::make_pair("gpu_triple", get_gpu_target_triple_string()));
1066  result.insert(std::make_pair("gpu_datalayout", get_gpu_data_layout()));
1067  result.insert(std::make_pair("gpu_driver",
1068  "CUDA " + std::to_string(driver_version / 1000) + "." +
1069  std::to_string((driver_version % 1000) / 10)));
1070 
1071  auto rt_libdevice_path = get_cuda_libdevice_dir() + "/libdevice.10.bc";
1072  result.insert(
1073  std::make_pair("gpu_has_libdevice",
1074  std::to_string(boost::filesystem::exists(rt_libdevice_path))));
1075  }
1076  }
1077 #endif
1078 
1079  return result;
1080 }
std::string get_cuda_libdevice_dir(void)
Definition: CudaMgr.cpp:612
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:25
static bool is_allowed_on_dashboard ( const Catalog_Namespace::SessionInfo session_info,
int32_t  dashboard_id,
AccessPrivileges  requestedPermissions 
)
static

Definition at line 4563 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().

4565  {
4566  DBObject object(dashboard_id, DashboardDBObjectType);
4567  auto& catalog = session_info.getCatalog();
4568  auto& user = session_info.get_currentUser();
4569  object.loadKey(catalog);
4570  object.setPrivileges(requestedPermissions);
4571  std::vector<DBObject> privs = {object};
4572  return SysCatalog::instance().checkPrivileges(user, privs);
4573 }
Catalog & getCatalog() const
Definition: SessionInfo.h:75
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:88

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1919 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::objectId, DBObjectKey::permissionType, TablePrivileges::SELECT_FROM_TABLE, ViewPrivileges::SELECT_FROM_VIEW, ServerPrivileges::SERVER_USAGE, 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().

1920  {
1921  TDBObject outObject;
1922  outObject.objectName = inObject.getName();
1923  outObject.grantee = roleName;
1924  outObject.objectId = inObject.getObjectKey().objectId;
1925  const auto ap = inObject.getPrivileges();
1926  switch (inObject.getObjectKey().permissionType) {
1927  case DatabaseDBObjectType:
1928  outObject.privilegeObjectType = TDBObjectType::DatabaseDBObjectType;
1929  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::CREATE_DATABASE));
1930  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::DROP_DATABASE));
1931  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::VIEW_SQL_EDITOR));
1932  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::ACCESS));
1933 
1934  break;
1935  case TableDBObjectType:
1936  outObject.privilegeObjectType = TDBObjectType::TableDBObjectType;
1937  outObject.privs.push_back(ap.hasPermission(TablePrivileges::CREATE_TABLE));
1938  outObject.privs.push_back(ap.hasPermission(TablePrivileges::DROP_TABLE));
1939  outObject.privs.push_back(ap.hasPermission(TablePrivileges::SELECT_FROM_TABLE));
1940  outObject.privs.push_back(ap.hasPermission(TablePrivileges::INSERT_INTO_TABLE));
1941  outObject.privs.push_back(ap.hasPermission(TablePrivileges::UPDATE_IN_TABLE));
1942  outObject.privs.push_back(ap.hasPermission(TablePrivileges::DELETE_FROM_TABLE));
1943  outObject.privs.push_back(ap.hasPermission(TablePrivileges::TRUNCATE_TABLE));
1944  outObject.privs.push_back(ap.hasPermission(TablePrivileges::ALTER_TABLE));
1945 
1946  break;
1947  case DashboardDBObjectType:
1948  outObject.privilegeObjectType = TDBObjectType::DashboardDBObjectType;
1949  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::CREATE_DASHBOARD));
1950  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::DELETE_DASHBOARD));
1951  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::VIEW_DASHBOARD));
1952  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::EDIT_DASHBOARD));
1953 
1954  break;
1955  case ViewDBObjectType:
1956  outObject.privilegeObjectType = TDBObjectType::ViewDBObjectType;
1957  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::CREATE_VIEW));
1958  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::DROP_VIEW));
1959  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::SELECT_FROM_VIEW));
1960  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::INSERT_INTO_VIEW));
1961  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::UPDATE_IN_VIEW));
1962  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::DELETE_FROM_VIEW));
1963 
1964  break;
1965  case ServerDBObjectType:
1966  outObject.privilegeObjectType = TDBObjectType::ServerDBObjectType;
1967  outObject.privs.push_back(ap.hasPermission(ServerPrivileges::CREATE_SERVER));
1968  outObject.privs.push_back(ap.hasPermission(ServerPrivileges::DROP_SERVER));
1969  outObject.privs.push_back(ap.hasPermission(ServerPrivileges::ALTER_SERVER));
1970  outObject.privs.push_back(ap.hasPermission(ServerPrivileges::SERVER_USAGE));
1971 
1972  break;
1973  default:
1974  CHECK(false);
1975  }
1976  const int type_val = static_cast<int>(inObject.getType());
1977  CHECK(type_val >= 0 && type_val < 6);
1978  outObject.objectType = static_cast<TDBObjectType::type>(type_val);
1979  return outObject;
1980 }
static const int32_t SERVER_USAGE
Definition: DBObject.h:129
static const int32_t DROP_VIEW
Definition: DBObject.h:113
static const int32_t ALTER_SERVER
Definition: DBObject.h:128
DBObjectKey getObjectKey() const
Definition: DBObject.h:221
static const int32_t SELECT_FROM_VIEW
Definition: DBObject.h:114
static const int32_t UPDATE_IN_VIEW
Definition: DBObject.h:116
static const int32_t CREATE_VIEW
Definition: DBObject.h:112
int32_t objectId
Definition: DBObject.h:55
static const int32_t ALTER_TABLE
Definition: DBObject.h:93
static const int32_t DROP_DATABASE
Definition: DBObject.h:79
static const int32_t DELETE_FROM_TABLE
Definition: DBObject.h:91
static const int32_t TRUNCATE_TABLE
Definition: DBObject.h:92
std::string getName() const
Definition: DBObject.h:219
static const int32_t EDIT_DASHBOARD
Definition: DBObject.h:104
static const int32_t DELETE_DASHBOARD
Definition: DBObject.h:102
static const int32_t INSERT_INTO_TABLE
Definition: DBObject.h:89
DBObjectType getType() const
Definition: DBObject.h:220
static const int32_t CREATE_SERVER
Definition: DBObject.h:126
const AccessPrivileges & getPrivileges() const
Definition: DBObject.h:226
static const int32_t ACCESS
Definition: DBObject.h:81
static const int32_t CREATE_DATABASE
Definition: DBObject.h:78
static const int32_t VIEW_DASHBOARD
Definition: DBObject.h:103
static const int32_t VIEW_SQL_EDITOR
Definition: DBObject.h:80
static const int32_t DROP_TABLE
Definition: DBObject.h:87
static const int32_t INSERT_INTO_VIEW
Definition: DBObject.h:115
#define CHECK(condition)
Definition: Logger.h:291
static const int32_t DELETE_FROM_VIEW
Definition: DBObject.h:117
static const int32_t CREATE_TABLE
Definition: DBObject.h:86
static const int32_t CREATE_DASHBOARD
Definition: DBObject.h:101
int32_t permissionType
Definition: DBObject.h:53
static const int32_t SELECT_FROM_TABLE
Definition: DBObject.h:88
static const int32_t UPDATE_IN_TABLE
Definition: DBObject.h:90
static const int32_t DROP_SERVER
Definition: DBObject.h:127

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

bool g_allow_system_dashboard_update {false}
bool g_enable_system_tables

Definition at line 64 of file SysCatalog.cpp.

bool g_uniform_request_ids_per_thrift_call {true}

Definition at line 125 of file DBHandler.cpp.

Referenced by CommandLineOptions::fillOptions().