OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 1177 of file DdlCommandExecutor.cpp.

1180  : 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 1182 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().

1182  {
1183  // label_infos -> column labels
1184  std::vector<std::string> labels{"Database", "Owner"};
1185  std::vector<TargetMetaInfo> label_infos;
1186  for (const auto& label : labels) {
1187  label_infos.emplace_back(label, SQLTypeInfo(kTEXT, true));
1188  }
1189 
1190  // Get all table names
1191  auto cur_user = session_ptr_->get_currentUser();
1192  const Catalog_Namespace::DBSummaryList db_summaries =
1194 
1195  // logical_values -> table data
1196  std::vector<RelLogicalValues::RowValues> logical_values;
1197  for (const auto& db_summary : db_summaries) {
1198  logical_values.emplace_back(RelLogicalValues::RowValues{});
1199  logical_values.back().emplace_back(genLiteralStr(db_summary.dbName));
1200  logical_values.back().emplace_back(genLiteralStr(db_summary.dbOwnerName));
1201  }
1202 
1203  // Create ResultSet
1204  std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1205  ResultSetLogicalValuesBuilder::create(label_infos, logical_values));
1206 
1207  return ExecutionResult(rSet, label_infos);
1208 }
static SysCatalog & instance()
Definition: SysCatalog.h:292
DBSummaryList getDatabaseListForUser(const UserMetadata &user)
static ResultSet * create(std::vector< TargetMetaInfo > &label_infos, std::vector< RelLogicalValues::RowValues > &logical_values)
Definition: sqltypes.h:51
static std::unique_ptr< RexLiteral > genLiteralStr(std::string val)
Definition: DBHandler.cpp:6909
std::list< DBSummary > DBSummaryList
Definition: SysCatalog.h:129
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: