| 32 | } |
| 33 | |
| 34 | BlockIO InterpreterShowStatementsQuery::execute() |
| 35 | { |
| 36 | if (!isQueryInInteractiveSession(getContext(), query_ptr)) |
| 37 | { |
| 38 | throw Exception("SHOW STATEMENTS are supported only in interactive sessions", ErrorCodes::LOGICAL_ERROR); |
| 39 | } |
| 40 | auto * explicit_txn = getContext()->getSessionContext()->getCurrentTransaction()->as<CnchExplicitTransaction>(); |
| 41 | const auto & statements = explicit_txn->getStatements(); |
| 42 | const auto & txns = explicit_txn->getSecondaryTransactions(); |
| 43 | assert(statements.size() == txns.size()); |
| 44 | Block block; |
| 45 | auto block_structures = getBlockStructure(); |
| 46 | for (auto & [name, type] : block_structures) |
| 47 | { |
| 48 | block.insert({type->createColumn(), type, name}); |
| 49 | } |
| 50 | MutableColumns res_columns = block.cloneEmptyColumns(); |
| 51 | for (size_t i = 0; i < statements.size(); ++i) |
| 52 | { |
| 53 | res_columns[0]->insert(txns[i]->getTransactionID().toUInt64()); |
| 54 | res_columns[1]->insert(statements[i]); |
| 55 | res_columns[2]->insert(txnStatusToString(txns[i]->getStatus())); |
| 56 | } |
| 57 | BlockIO res; |
| 58 | res.in = std::make_shared<OneBlockInputStream>(block.cloneWithColumns(std::move(res_columns))); |
| 59 | return res; |
| 60 | } |
| 61 | } |
nothing calls this directly
no test coverage detected