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

#include <DdlCommandExecutor.h>

+ Inheritance diagram for ShowTablesCommand:
+ Collaboration diagram for ShowTablesCommand:

Public Member Functions

 ShowTablesCommand (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 136 of file DdlCommandExecutor.h.

Constructor & Destructor Documentation

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

Definition at line 1173 of file DdlCommandExecutor.cpp.

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

Member Function Documentation

ExecutionResult ShowTablesCommand::execute ( )
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 1178 of file DdlCommandExecutor.cpp.

References ResultSetLogicalValuesBuilder::create(), genLiteralStr(), GET_PHYSICAL_TABLES, kTEXT, run_benchmark_import::label, and DdlCommand::session_ptr_.

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

1178  {
1179  // Get all table names in the same way as OmniSql \t command
1180 
1181  // label_infos -> column labels
1182  std::vector<std::string> labels{"table_name"};
1183  std::vector<TargetMetaInfo> label_infos;
1184  for (const auto& label : labels) {
1185  label_infos.emplace_back(label, SQLTypeInfo(kTEXT, true));
1186  }
1187 
1188  // Get all table names
1189  auto cat_ptr = session_ptr_->get_catalog_ptr();
1190  auto cur_user = session_ptr_->get_currentUser();
1191  auto table_names = cat_ptr->getTableNamesForUser(cur_user, GET_PHYSICAL_TABLES);
1192 
1193  // logical_values -> table data
1194  std::vector<RelLogicalValues::RowValues> logical_values;
1195  for (auto table_name : table_names) {
1196  logical_values.emplace_back(RelLogicalValues::RowValues{});
1197  logical_values.back().emplace_back(genLiteralStr(table_name));
1198  }
1199 
1200  // Create ResultSet
1201  std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1202  ResultSetLogicalValuesBuilder::create(label_infos, logical_values));
1203 
1204  return ExecutionResult(rSet, label_infos);
1205 }
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::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: