OmniSciDB  c0231cc57d
 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 176 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 1564 of file DdlCommandExecutor.cpp.

1567  : 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 1569 of file DdlCommandExecutor.cpp.

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

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

1569  {
1570  // valid in read_only_mode
1571 
1572  // label_infos -> column labels
1573  std::vector<std::string> labels{"Database", "Owner"};
1574  std::vector<TargetMetaInfo> label_infos;
1575  for (const auto& label : labels) {
1576  label_infos.emplace_back(label, SQLTypeInfo(kTEXT, true));
1577  }
1578 
1579  // Get all table names
1580  auto cur_user = session_ptr_->get_currentUser();
1581  const Catalog_Namespace::DBSummaryList db_summaries =
1583 
1584  // logical_values -> table data
1585  std::vector<RelLogicalValues::RowValues> logical_values;
1586  for (const auto& db_summary : db_summaries) {
1587  logical_values.emplace_back(RelLogicalValues::RowValues{});
1588  logical_values.back().emplace_back(genLiteralStr(db_summary.dbName));
1589  logical_values.back().emplace_back(genLiteralStr(db_summary.dbOwnerName));
1590  }
1591 
1592  // Create ResultSet
1593  std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1594  ResultSetLogicalValuesBuilder::create(label_infos, logical_values));
1595 
1596  return ExecutionResult(rSet, label_infos);
1597 }
static SysCatalog & instance()
Definition: SysCatalog.h:341
DBSummaryList getDatabaseListForUser(const UserMetadata &user)
static ResultSet * create(std::vector< TargetMetaInfo > &label_infos, std::vector< RelLogicalValues::RowValues > &logical_values)
Definition: sqltypes.h:66
static std::unique_ptr< RexLiteral > genLiteralStr(std::string val)
Definition: DBHandler.cpp:7263
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:2226

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