OmniSciDB  c0231cc57d
 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 "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"
#include "Shared/enable_assign_render_groups.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 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)
 
 super_user_rights_ (false)
 
 idle_session_duration_ (idle_session_duration *60)
 
 max_session_duration_ (max_session_duration *60)
 
 enable_rendering_ (enable_rendering)
 
 renderer_use_ppll_polys_ (renderer_use_ppll_polys)
 
 renderer_prefer_igpu_ (renderer_prefer_igpu)
 
 renderer_vulkan_timeout_ (renderer_vulkan_timeout_ms)
 
 enable_auto_clear_render_mem_ (enable_auto_clear_render_mem)
 
 render_oom_retry_threshold_ (render_oom_retry_threshold)
 
 max_concurrent_render_sessions_ (max_concurrent_render_sessions)
 
 reserved_gpu_mem_ (reserved_gpu_mem)
 
 render_compositor_use_last_gpu_ (render_compositor_use_last_gpu)
 
 render_mem_bytes_ (render_mem_bytes)
 
 num_reader_threads_ (num_reader_threads)
 
 disk_cache_config_ (disk_cache_config)
 
 udf_filename_ (udf_filename)
 
 clang_path_ (clang_path)
 
 clang_options_ (clang_options)
 
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)
 
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 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::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}
 

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:216
#define UNLIKELY(x)
Definition: likely.h:25

Definition at line 3246 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 7070 of file DBHandler.cpp.

Referenced by DBHandler::get_device_parameters().

#define INVALID_SESSION_ID   ""

Definition at line 126 of file DBHandler.cpp.

Referenced by DBHandler::getInvalidSessionId().

#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:128

Definition at line 4990 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:216

Definition at line 128 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::loadTableBinaryColumnarInternal(), DBHandler::populateThriftColumnType(), DBHandler::prepare_loader_generic(), 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::update_custom_expression(), DBHandler::validateDashboardIdsForSharing(), and DBHandler::validateGroups().

Typedef Documentation

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

Definition at line 3244 of file DBHandler.cpp.

Function Documentation

clang_options_ ( clang_options  )

Definition at line 232 of file DBHandler.cpp.

References logger::INFO, LOG, and MAPD_RELEASE.

234 {
235  LOG(INFO) << "HeavyDB Server " << MAPD_RELEASE;
236  initialize(is_new_db);
237 }
#define LOG(tag)
Definition: Logger.h:216
static const std::string MAPD_RELEASE
Definition: release.h:42
clang_path_ ( clang_path  )
disk_cache_config_ ( disk_cache_config  )

Referenced by PersistentStorageMgr::getDiskCacheConfig().

+ Here is the caller graph for this function:

enable_auto_clear_render_mem_ ( enable_auto_clear_render_mem  )
enable_rendering_ ( enable_rendering  )
static std::unique_ptr<RexLiteral> genLiteralStr ( std::string  val)
static
std::map<std::string, std::string> get_device_parameters ( bool  cpu_only)

Definition at line 918 of file NativeCodegen.cpp.

918  {
919  std::map<std::string, std::string> result;
920 
921  result.insert(std::make_pair("cpu_name", llvm::sys::getHostCPUName()));
922  result.insert(std::make_pair("cpu_triple", llvm::sys::getProcessTriple()));
923  result.insert(
924  std::make_pair("cpu_cores", std::to_string(llvm::sys::getHostNumPhysicalCores())));
925  result.insert(std::make_pair("cpu_threads", std::to_string(cpu_threads())));
926 
927  // https://en.cppreference.com/w/cpp/language/types
928  std::string sizeof_types;
929  sizeof_types += "bool:" + std::to_string(sizeof(bool)) + ";";
930  sizeof_types += "size_t:" + std::to_string(sizeof(size_t)) + ";";
931  sizeof_types += "ssize_t:" + std::to_string(sizeof(ssize_t)) + ";";
932  sizeof_types += "char:" + std::to_string(sizeof(char)) + ";";
933  sizeof_types += "uchar:" + std::to_string(sizeof(unsigned char)) + ";";
934  sizeof_types += "short:" + std::to_string(sizeof(short)) + ";";
935  sizeof_types += "ushort:" + std::to_string(sizeof(unsigned short int)) + ";";
936  sizeof_types += "int:" + std::to_string(sizeof(int)) + ";";
937  sizeof_types += "uint:" + std::to_string(sizeof(unsigned int)) + ";";
938  sizeof_types += "long:" + std::to_string(sizeof(long int)) + ";";
939  sizeof_types += "ulong:" + std::to_string(sizeof(unsigned long int)) + ";";
940  sizeof_types += "longlong:" + std::to_string(sizeof(long long int)) + ";";
941  sizeof_types += "ulonglong:" + std::to_string(sizeof(unsigned long long int)) + ";";
942  sizeof_types += "float:" + std::to_string(sizeof(float)) + ";";
943  sizeof_types += "double:" + std::to_string(sizeof(double)) + ";";
944  sizeof_types += "longdouble:" + std::to_string(sizeof(long double)) + ";";
945  sizeof_types += "voidptr:" + std::to_string(sizeof(void*)) + ";";
946 
947  result.insert(std::make_pair("type_sizeof", sizeof_types));
948 
949  std::string null_values;
950  null_values += "boolean1:" + std::to_string(serialized_null_value<bool>()) + ";";
951  null_values += "boolean8:" + std::to_string(serialized_null_value<int8_t>()) + ";";
952  null_values += "int8:" + std::to_string(serialized_null_value<int8_t>()) + ";";
953  null_values += "int16:" + std::to_string(serialized_null_value<int16_t>()) + ";";
954  null_values += "int32:" + std::to_string(serialized_null_value<int32_t>()) + ";";
955  null_values += "int64:" + std::to_string(serialized_null_value<int64_t>()) + ";";
956  null_values += "uint8:" + std::to_string(serialized_null_value<uint8_t>()) + ";";
957  null_values += "uint16:" + std::to_string(serialized_null_value<uint16_t>()) + ";";
958  null_values += "uint32:" + std::to_string(serialized_null_value<uint32_t>()) + ";";
959  null_values += "uint64:" + std::to_string(serialized_null_value<uint64_t>()) + ";";
960  null_values += "float32:" + std::to_string(serialized_null_value<float>()) + ";";
961  null_values += "float64:" + std::to_string(serialized_null_value<double>()) + ";";
962  null_values +=
963  "Array<boolean8>:" + std::to_string(serialized_null_value<int8_t, true>()) + ";";
964  null_values +=
965  "Array<int8>:" + std::to_string(serialized_null_value<int8_t, true>()) + ";";
966  null_values +=
967  "Array<int16>:" + std::to_string(serialized_null_value<int16_t, true>()) + ";";
968  null_values +=
969  "Array<int32>:" + std::to_string(serialized_null_value<int32_t, true>()) + ";";
970  null_values +=
971  "Array<int64>:" + std::to_string(serialized_null_value<int64_t, true>()) + ";";
972  null_values +=
973  "Array<float32>:" + std::to_string(serialized_null_value<float, true>()) + ";";
974  null_values +=
975  "Array<float64>:" + std::to_string(serialized_null_value<double, true>()) + ";";
976 
977  result.insert(std::make_pair("null_values", null_values));
978 
979  llvm::StringMap<bool> cpu_features;
980  if (llvm::sys::getHostCPUFeatures(cpu_features)) {
981  std::string features_str = "";
982  for (auto it = cpu_features.begin(); it != cpu_features.end(); ++it) {
983  features_str += (it->getValue() ? " +" : " -");
984  features_str += it->getKey().str();
985  }
986  result.insert(std::make_pair("cpu_features", features_str));
987  }
988 
989  result.insert(std::make_pair("llvm_version",
990  std::to_string(LLVM_VERSION_MAJOR) + "." +
991  std::to_string(LLVM_VERSION_MINOR) + "." +
992  std::to_string(LLVM_VERSION_PATCH)));
993 
994 #ifdef HAVE_CUDA
995  if (!cpu_only) {
996  int device_count = 0;
997  checkCudaErrors(cuDeviceGetCount(&device_count));
998  if (device_count) {
999  CUdevice device{};
1000  char device_name[256];
1001  int major = 0, minor = 0;
1002  int driver_version;
1003  checkCudaErrors(cuDeviceGet(&device, 0)); // assuming homogeneous multi-GPU system
1004  checkCudaErrors(cuDeviceGetName(device_name, 256, device));
1005  checkCudaErrors(cuDeviceGetAttribute(
1006  &major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, device));
1007  checkCudaErrors(cuDeviceGetAttribute(
1008  &minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, device));
1009  checkCudaErrors(cuDriverGetVersion(&driver_version));
1010 
1011  result.insert(std::make_pair("gpu_name", device_name));
1012  result.insert(std::make_pair("gpu_count", std::to_string(device_count)));
1013  result.insert(std::make_pair("gpu_compute_capability",
1014  std::to_string(major) + "." + std::to_string(minor)));
1015  result.insert(std::make_pair("gpu_triple", get_gpu_target_triple_string()));
1016  result.insert(std::make_pair("gpu_datalayout", get_gpu_data_layout()));
1017  result.insert(std::make_pair("gpu_driver",
1018  "CUDA " + std::to_string(driver_version / 1000) + "." +
1019  std::to_string((driver_version % 1000) / 10)));
1020  }
1021  }
1022 #endif
1023 
1024  return result;
1025 }
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
idle_session_duration_ ( idle_session_duration *  60)

Referenced by CachedSessionStore::add(), and CachedSessionStore::get().

+ Here is the caller graph for this function:

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

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

4208  {
4209  DBObject object(dashboard_id, DashboardDBObjectType);
4210  auto& catalog = session_info.getCatalog();
4211  auto& user = session_info.get_currentUser();
4212  object.loadKey(catalog);
4213  object.setPrivileges(requestedPermissions);
4214  std::vector<DBObject> privs = {object};
4215  return SysCatalog::instance().checkPrivileges(user, privs);
4216 }
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:

max_concurrent_render_sessions_ ( max_concurrent_render_sessions  )
max_session_duration_ ( max_session_duration *  60)

Referenced by CachedSessionStore::add(), and CachedSessionStore::get().

+ Here is the caller graph for this function:

num_reader_threads_ ( num_reader_threads  )

Referenced by File_Namespace::GlobalFileMgr::getNumReaderThreads(), File_Namespace::FileMgr::getNumReaderThreads(), and File_Namespace::CachingFileMgr::reconstruct().

+ Here is the caller graph for this function:

render_compositor_use_last_gpu_ ( render_compositor_use_last_gpu  )
render_mem_bytes_ ( render_mem_bytes  )
render_oom_retry_threshold_ ( render_oom_retry_threshold  )
renderer_prefer_igpu_ ( renderer_prefer_igpu  )
renderer_use_ppll_polys_ ( renderer_use_ppll_polys  )
renderer_vulkan_timeout_ ( renderer_vulkan_timeout_ms  )
reserved_gpu_mem_ ( reserved_gpu_mem  )
static TDBObject serialize_db_object ( const std::string &  roleName,
const DBObject inObject 
)
static

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

1680  {
1681  TDBObject outObject;
1682  outObject.objectName = inObject.getName();
1683  outObject.grantee = roleName;
1684  outObject.objectId = inObject.getObjectKey().objectId;
1685  const auto ap = inObject.getPrivileges();
1686  switch (inObject.getObjectKey().permissionType) {
1687  case DatabaseDBObjectType:
1688  outObject.privilegeObjectType = TDBObjectType::DatabaseDBObjectType;
1689  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::CREATE_DATABASE));
1690  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::DROP_DATABASE));
1691  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::VIEW_SQL_EDITOR));
1692  outObject.privs.push_back(ap.hasPermission(DatabasePrivileges::ACCESS));
1693 
1694  break;
1695  case TableDBObjectType:
1696  outObject.privilegeObjectType = TDBObjectType::TableDBObjectType;
1697  outObject.privs.push_back(ap.hasPermission(TablePrivileges::CREATE_TABLE));
1698  outObject.privs.push_back(ap.hasPermission(TablePrivileges::DROP_TABLE));
1699  outObject.privs.push_back(ap.hasPermission(TablePrivileges::SELECT_FROM_TABLE));
1700  outObject.privs.push_back(ap.hasPermission(TablePrivileges::INSERT_INTO_TABLE));
1701  outObject.privs.push_back(ap.hasPermission(TablePrivileges::UPDATE_IN_TABLE));
1702  outObject.privs.push_back(ap.hasPermission(TablePrivileges::DELETE_FROM_TABLE));
1703  outObject.privs.push_back(ap.hasPermission(TablePrivileges::TRUNCATE_TABLE));
1704  outObject.privs.push_back(ap.hasPermission(TablePrivileges::ALTER_TABLE));
1705 
1706  break;
1707  case DashboardDBObjectType:
1708  outObject.privilegeObjectType = TDBObjectType::DashboardDBObjectType;
1709  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::CREATE_DASHBOARD));
1710  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::DELETE_DASHBOARD));
1711  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::VIEW_DASHBOARD));
1712  outObject.privs.push_back(ap.hasPermission(DashboardPrivileges::EDIT_DASHBOARD));
1713 
1714  break;
1715  case ViewDBObjectType:
1716  outObject.privilegeObjectType = TDBObjectType::ViewDBObjectType;
1717  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::CREATE_VIEW));
1718  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::DROP_VIEW));
1719  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::SELECT_FROM_VIEW));
1720  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::INSERT_INTO_VIEW));
1721  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::UPDATE_IN_VIEW));
1722  outObject.privs.push_back(ap.hasPermission(ViewPrivileges::DELETE_FROM_VIEW));
1723 
1724  break;
1725  case ServerDBObjectType:
1726  outObject.privilegeObjectType = TDBObjectType::ServerDBObjectType;
1727  outObject.privs.push_back(ap.hasPermission(ServerPrivileges::CREATE_SERVER));
1728  outObject.privs.push_back(ap.hasPermission(ServerPrivileges::DROP_SERVER));
1729  outObject.privs.push_back(ap.hasPermission(ServerPrivileges::ALTER_SERVER));
1730  outObject.privs.push_back(ap.hasPermission(ServerPrivileges::SERVER_USAGE));
1731 
1732  break;
1733  default:
1734  CHECK(false);
1735  }
1736  const int type_val = static_cast<int>(inObject.getType());
1737  CHECK(type_val >= 0 && type_val < 6);
1738  outObject.objectType = static_cast<TDBObjectType::type>(type_val);
1739  return outObject;
1740 }
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:222
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:

super_user_rights_ ( false  )
udf_filename_ ( udf_filename  )

Variable Documentation

bool g_allow_system_dashboard_update {false}
bool g_enable_system_tables

Definition at line 64 of file SysCatalog.cpp.