You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/11/30 06:34:26 UTC

[shardingsphere] branch master updated: Decouple ShowTablesBackendHandler and QueryResponse.getQueryHeaders() (#8421)

This is an automated email from the ASF dual-hosted git repository.

zhangyonglun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new ed64496  Decouple ShowTablesBackendHandler and QueryResponse.getQueryHeaders() (#8421)
ed64496 is described below

commit ed644967c52156e2cd8057cf0377249bb1ea6ee6
Author: Liang Zhang <te...@163.com>
AuthorDate: Mon Nov 30 14:34:04 2020 +0800

    Decouple ShowTablesBackendHandler and QueryResponse.getQueryHeaders() (#8421)
---
 .../proxy/backend/text/admin/ShowTablesBackendHandler.java    | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandler.java
index 21419b0..1aa0001 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandler.java
@@ -46,7 +46,7 @@ public final class ShowTablesBackendHandler implements TextProtocolBackendHandle
     
     private final BackendConnection backendConnection;
     
-    private QueryResponse queryResponse;
+    private QueryResult queryResult;
     
     @Override
     public BackendResponse execute() {
@@ -58,9 +58,8 @@ public final class ShowTablesBackendHandler implements TextProtocolBackendHandle
                 null, result.getQueryHeaders().get(0).getColumnName(), result.getQueryHeaders().get(0).getColumnLabel(), Types.VARCHAR, "VARCHAR", 255, 0, false, false, false)));
         Collection<String> allTableNames = ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName()).getSchema().getAllTableNames();
         List<MemoryQueryResultDataRow> rows = allTableNames.stream().map(each -> new MemoryQueryResultDataRow(Collections.singletonList(each))).collect(Collectors.toList());
-        QueryResult queryResult = new RawMemoryQueryResult(metaData, rows);
+        queryResult = new RawMemoryQueryResult(metaData, rows);
         result.getQueryResults().add(queryResult);
-        queryResponse = result;
         return result;
     }
     
@@ -71,14 +70,14 @@ public final class ShowTablesBackendHandler implements TextProtocolBackendHandle
     
     @Override
     public boolean next() throws SQLException {
-        return null != queryResponse && queryResponse.getQueryResults().get(0).next();
+        return null != queryResult && queryResult.next();
     }
     
     @Override
     public Collection<Object> getRowData() throws SQLException {
         Collection<Object> result = new LinkedList<>();
-        for (int columnIndex = 1; columnIndex <= queryResponse.getQueryHeaders().size(); columnIndex++) {
-            result.add(queryResponse.getQueryResults().get(0).getValue(columnIndex, Object.class));
+        for (int columnIndex = 1; columnIndex <= queryResult.getMetaData().getColumnCount(); columnIndex++) {
+            result.add(queryResult.getValue(columnIndex, Object.class));
         }
         return result;
     }