OmniSciDB  72c90bc290
 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 200 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 1588 of file DdlCommandExecutor.cpp.

1591  : 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 1593 of file DdlCommandExecutor.cpp.

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

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

1593  {
1594  auto execute_read_lock = legacylockmgr::getExecuteReadLock();
1595 
1596  // Get all table names in the same way as OmniSql \t command
1597 
1598  // valid in read_only_mode
1599 
1600  // label_infos -> column labels
1601  std::vector<std::string> labels{"table_name"};
1602  std::vector<TargetMetaInfo> label_infos;
1603  for (const auto& label : labels) {
1604  label_infos.emplace_back(label, SQLTypeInfo(kTEXT, true));
1605  }
1606 
1607  // Get all table names
1608  auto cat_ptr = session_ptr_->get_catalog_ptr();
1609  auto cur_user = session_ptr_->get_currentUser();
1610  auto table_names = cat_ptr->getTableNamesForUser(cur_user, GET_PHYSICAL_TABLES);
1611 
1612  // logical_values -> table data
1613  std::vector<RelLogicalValues::RowValues> logical_values;
1614  for (auto table_name : table_names) {
1615  logical_values.emplace_back(RelLogicalValues::RowValues{});
1616  logical_values.back().emplace_back(genLiteralStr(table_name));
1617  }
1618 
1619  // Create ResultSet
1620  std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1621  ResultSetLogicalValuesBuilder::create(label_infos, logical_values));
1622 
1623  return ExecutionResult(rSet, label_infos);
1624 }
auto getExecuteReadLock()
static ResultSet * create(std::vector< TargetMetaInfo > &label_infos, std::vector< RelLogicalValues::RowValues > &logical_values)
Definition: sqltypes.h:79
static std::unique_ptr< RexLiteral > genLiteralStr(std::string val)
Definition: DBHandler.cpp:7752
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
std::vector< std::unique_ptr< const RexScalar >> RowValues
Definition: RelAlgDag.h:2656

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