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

#include <DdlCommandExecutor.h>

+ Inheritance diagram for ShowDatabasesCommand:
+ Collaboration diagram for ShowDatabasesCommand:

Public Member Functions

 ShowDatabasesCommand (const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 
ExecutionResult execute (bool read_only_mode) 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 Attributes inherited from DdlCommand
const DdlCommandDataddl_data_
 
std::shared_ptr
< Catalog_Namespace::SessionInfo
const > 
session_ptr_
 

Detailed Description

Definition at line 229 of file DdlCommandExecutor.h.

Constructor & Destructor Documentation

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

Definition at line 1795 of file DdlCommandExecutor.cpp.

1798  : DdlCommand(ddl_data, session_ptr) {}
DdlCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)

Member Function Documentation

ExecutionResult ShowDatabasesCommand::execute ( bool  read_only_mode)
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 1800 of file DdlCommandExecutor.cpp.

References ResultSetLogicalValuesBuilder::create(), genLiteralStr(), Catalog_Namespace::SysCatalog::getDatabaseListForUser(), legacylockmgr::getExecuteReadLock(), Catalog_Namespace::SysCatalog::instance(), kTEXT, run_benchmark_import::label, and DdlCommand::session_ptr_.

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

1800  {
1801  auto execute_read_lock = legacylockmgr::getExecuteReadLock();
1802 
1803  // valid in read_only_mode
1804 
1805  // label_infos -> column labels
1806  std::vector<std::string> labels{"Database", "Owner"};
1807  std::vector<TargetMetaInfo> label_infos;
1808  for (const auto& label : labels) {
1809  label_infos.emplace_back(label, SQLTypeInfo(kTEXT, true));
1810  }
1811 
1812  // Get all table names
1813  auto cur_user = session_ptr_->get_currentUser();
1814  const Catalog_Namespace::DBSummaryList db_summaries =
1816 
1817  // logical_values -> table data
1818  std::vector<RelLogicalValues::RowValues> logical_values;
1819  for (const auto& db_summary : db_summaries) {
1820  logical_values.emplace_back(RelLogicalValues::RowValues{});
1821  logical_values.back().emplace_back(genLiteralStr(db_summary.dbName));
1822  logical_values.back().emplace_back(genLiteralStr(db_summary.dbOwnerName));
1823  }
1824 
1825  // Create ResultSet
1826  std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1827  ResultSetLogicalValuesBuilder::create(label_infos, logical_values));
1828 
1829  return ExecutionResult(rSet, label_infos);
1830 }
auto getExecuteReadLock()
static SysCatalog & instance()
Definition: SysCatalog.h:343
DBSummaryList getDatabaseListForUser(const UserMetadata &user)
static ResultSet * create(std::vector< TargetMetaInfo > &label_infos, std::vector< RelLogicalValues::RowValues > &logical_values)
Definition: sqltypes.h:79
static std::unique_ptr< RexLiteral > genLiteralStr(std::string val)
Definition: DBHandler.cpp:7770
std::list< DBSummary > DBSummaryList
Definition: SysCatalog.h:145
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
std::vector< std::unique_ptr< const RexScalar >> RowValues
Definition: RelAlgDag.h:2656

+ 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: