OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RefreshForeignTablesCommand Class Reference

#include <DdlCommandExecutor.h>

+ Inheritance diagram for RefreshForeignTablesCommand:
+ Collaboration diagram for RefreshForeignTablesCommand:

Public Member Functions

 RefreshForeignTablesCommand (const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 
ExecutionResult execute () override
 
- Public Member Functions inherited from DdlCommand
 DdlCommand (const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 

Additional Inherited Members

- Protected Member Functions inherited from DdlCommand
bool isDefaultServer (const std::string &server_name)
 
- Protected Attributes inherited from DdlCommand
const DdlCommandDataddl_data_
 
std::shared_ptr
< Catalog_Namespace::SessionInfo
const
session_ptr_
 

Detailed Description

Definition at line 193 of file DdlCommandExecutor.h.

Constructor & Destructor Documentation

RefreshForeignTablesCommand::RefreshForeignTablesCommand ( const DdlCommandData ddl_data,
std::shared_ptr< Catalog_Namespace::SessionInfo const session_ptr 
)

Definition at line 1410 of file DdlCommandExecutor.cpp.

References CHECK, DdlCommand::ddl_data_, and anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload().

1413  : DdlCommand(ddl_data, session_ptr) {
1414  auto& ddl_payload = extractPayload(ddl_data_);
1415  CHECK(ddl_payload.HasMember("tableNames"));
1416  CHECK(ddl_payload["tableNames"].IsArray());
1417  for (auto const& tablename_def : ddl_payload["tableNames"].GetArray()) {
1418  CHECK(tablename_def.IsString());
1419  }
1420 }
const DdlCommandData & ddl_data_
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
DdlCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
#define CHECK(condition)
Definition: Logger.h:211

+ Here is the call graph for this function:

Member Function Documentation

ExecutionResult RefreshForeignTablesCommand::execute ( )
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 1422 of file DdlCommandExecutor.cpp.

References cat(), CHECK, DdlCommand::ddl_data_, anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload(), Catalog_Namespace::SysCatalog::instance(), CacheInvalidator< CACHE_HOLDING_TYPES >::invalidateCaches(), foreign_storage::OptionsContainer::options, foreign_storage::OptionsContainer::populateOptionsMap(), foreign_storage::refresh_foreign_table(), DdlCommand::session_ptr_, and TableDBObjectType.

Referenced by omnisci.cursor.Cursor::executemany().

1422  {
1423  bool evict_cached_entries{false};
1425  auto& ddl_payload = extractPayload(ddl_data_);
1426  if (ddl_payload.HasMember("options") && !ddl_payload["options"].IsNull()) {
1427  opt.populateOptionsMap(ddl_payload["options"]);
1428  for (const auto& entry : opt.options) {
1429  if (entry.first != "EVICT") {
1430  throw std::runtime_error{
1431  "Invalid option \"" + entry.first +
1432  "\" provided for refresh command. Only \"EVICT\" option is supported."};
1433  }
1434  }
1435  CHECK(opt.options.find("EVICT") != opt.options.end());
1436 
1437  if (boost::iequals(opt.options["EVICT"], "true") ||
1438  boost::iequals(opt.options["EVICT"], "false")) {
1439  if (boost::iequals(opt.options["EVICT"], "true")) {
1440  evict_cached_entries = true;
1441  }
1442  } else {
1443  throw std::runtime_error{
1444  "Invalid value \"" + opt.options["EVICT"] +
1445  "\" provided for EVICT option. Value must be either \"true\" or \"false\"."};
1446  }
1447  }
1448 
1449  auto& cat = session_ptr_->getCatalog();
1450  const auto& current_user = session_ptr_->get_currentUser();
1451  /* verify object ownership if not suser */
1452  if (!current_user.isSuper) {
1453  for (const auto& table_name_json : ddl_payload["tableNames"].GetArray()) {
1454  std::string table_name = table_name_json.GetString();
1455  if (!Catalog_Namespace::SysCatalog::instance().verifyDBObjectOwnership(
1456  current_user, DBObject(table_name, TableDBObjectType), cat)) {
1457  throw std::runtime_error(
1458  std::string("REFRESH FOREIGN TABLES failed on table \"") + table_name +
1459  "\". It can only be executed by super user or "
1460  "owner of the "
1461  "object.");
1462  }
1463  }
1464  }
1465 
1466  for (const auto& table_name_json : ddl_payload["tableNames"].GetArray()) {
1467  std::string table_name = table_name_json.GetString();
1468  foreign_storage::refresh_foreign_table(cat, table_name, evict_cached_entries);
1469  }
1470 
1472 
1473  return ExecutionResult();
1474 }
std::string cat(Ts &&...args)
void refresh_foreign_table(Catalog_Namespace::Catalog &catalog, const std::string &table_name, const bool evict_cached_entries)
static void invalidateCaches()
const DdlCommandData & ddl_data_
static SysCatalog & instance()
Definition: SysCatalog.h:326
void populateOptionsMap(OptionsMap &&options_map, bool clear=false)
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
#define CHECK(condition)
Definition: Logger.h:211
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: