OmniSciDB  c0231cc57d
 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 (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 147 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 1366 of file DdlCommandExecutor.cpp.

1369  : 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 ( 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 1371 of file DdlCommandExecutor.cpp.

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

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

1371  {
1372  // Get all table names in the same way as OmniSql \t command
1373 
1374  // valid in read_only_mode
1375 
1376  // label_infos -> column labels
1377  std::vector<std::string> labels{"table_name"};
1378  std::vector<TargetMetaInfo> label_infos;
1379  for (const auto& label : labels) {
1380  label_infos.emplace_back(label, SQLTypeInfo(kTEXT, true));
1381  }
1382 
1383  // Get all table names
1384  auto cat_ptr = session_ptr_->get_catalog_ptr();
1385  auto cur_user = session_ptr_->get_currentUser();
1386  auto table_names = cat_ptr->getTableNamesForUser(cur_user, GET_PHYSICAL_TABLES);
1387 
1388  // logical_values -> table data
1389  std::vector<RelLogicalValues::RowValues> logical_values;
1390  for (auto table_name : table_names) {
1391  logical_values.emplace_back(RelLogicalValues::RowValues{});
1392  logical_values.back().emplace_back(genLiteralStr(table_name));
1393  }
1394 
1395  // Create ResultSet
1396  std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1397  ResultSetLogicalValuesBuilder::create(label_infos, logical_values));
1398 
1399  return ExecutionResult(rSet, label_infos);
1400 }
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::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: