OmniSciDB  d2f719934e
 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 () 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 156 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 1309 of file DdlCommandExecutor.cpp.

1312  : 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 ( )
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 1314 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 omnisci.cursor.Cursor::executemany().

1314  {
1315  // label_infos -> column labels
1316  std::vector<std::string> labels{"Database", "Owner"};
1317  std::vector<TargetMetaInfo> label_infos;
1318  for (const auto& label : labels) {
1319  label_infos.emplace_back(label, SQLTypeInfo(kTEXT, true));
1320  }
1321 
1322  // Get all table names
1323  auto cur_user = session_ptr_->get_currentUser();
1324  const Catalog_Namespace::DBSummaryList db_summaries =
1326 
1327  // logical_values -> table data
1328  std::vector<RelLogicalValues::RowValues> logical_values;
1329  for (const auto& db_summary : db_summaries) {
1330  logical_values.emplace_back(RelLogicalValues::RowValues{});
1331  logical_values.back().emplace_back(genLiteralStr(db_summary.dbName));
1332  logical_values.back().emplace_back(genLiteralStr(db_summary.dbOwnerName));
1333  }
1334 
1335  // Create ResultSet
1336  std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1337  ResultSetLogicalValuesBuilder::create(label_infos, logical_values));
1338 
1339  return ExecutionResult(rSet, label_infos);
1340 }
static SysCatalog & instance()
Definition: SysCatalog.h:326
DBSummaryList getDatabaseListForUser(const UserMetadata &user)
static ResultSet * create(std::vector< TargetMetaInfo > &label_infos, std::vector< RelLogicalValues::RowValues > &logical_values)
Definition: sqltypes.h:52
static std::unique_ptr< RexLiteral > genLiteralStr(std::string val)
Definition: DBHandler.cpp:7369
std::list< DBSummary > DBSummaryList
Definition: SysCatalog.h:151
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
std::vector< std::unique_ptr< const RexScalar >> RowValues

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