diff --git a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/common/DbeCommonUtils.java b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/common/DbeCommonUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..3543434012d35e64092d21decf351e65e3d4ce08 --- /dev/null +++ b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/common/DbeCommonUtils.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * openGauss is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +package org.opengauss.mppdbide.common; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.stream.Collectors; + +import org.apache.commons.lang.StringUtils; +import org.opengauss.mppdbide.debuger.service.DbeDebugService; +import org.opengauss.mppdbide.debuger.vo.dbe.InfoCodeVo; +import org.opengauss.mppdbide.utils.IMessagesConstants; +import org.opengauss.mppdbide.utils.loader.MessageConfigLoader; +import org.opengauss.mppdbide.utils.logger.MPPDBIDELoggerUtility; + +/** + * Description: DbeCommonUtils + * + * @since 3.0.0 + */ +public final class DbeCommonUtils { + /** + * list of infoCode + */ + public static volatile List infoCodes; + + /** + * variable begin + */ + public static final String BEGIN = "BEGIN"; + + /** + * variable END + */ + public static final String END = "END"; + + private DbeCommonUtils() { + + } + + /** + * checkCanBreakLines + * + * @param sourceCode code + * @param conn dbConnection + * @param oid oid + * @param selectIndex index + * @throws SQLException exception + */ + public static void checkCanBreakLines(List sourceCodes, IConnection conn, long oid, List indexs) + throws SQLException { + List infos = DbeDebugService.getInfoCodes(conn, Arrays.asList(oid)); + List canBreaks = infos.stream().filter(item -> item.canbreak).collect(Collectors.toList()); + for (int i = 0; i < indexs.size(); i++) { + String selectCode = sourceCodes.get(Integer.parseInt(indexs.get(i))); + long count = canBreaks.stream().filter(item -> item.query.equalsIgnoreCase(selectCode)).count(); + if (count == 0) { + throw new SQLException(MessageConfigLoader.getProperty(IMessagesConstants.NOT_SUPPORT_BREAK)); + } + } + } + + /** + * getBeginToEndLineNo + * + * @param sourceCode code + * @return Map map + */ + public static Map getBeginToEndLineNo(List sourceCodes) { + Map map = new HashMap(); + boolean isBeginFlag = true; + for (int i = 0; i < sourceCodes.size(); i++) { + String code = sourceCodes.get(i); + if (isBeginFlag && checkStrEquals(code, BEGIN)) { + map.put(BEGIN, i); + isBeginFlag = false; + continue; + } + if (checkStrEquals(code, END)) { + map.put(END, i); + } + } + return map; + } + + /** + * checkStrEquals + * + * @param firstCode firstCode + * @param endCode endCode + * @return boolean boolean + */ + public static boolean checkStrEquals(String firstCode, String endCode) { + return firstCode.toUpperCase(Locale.ENGLISH).trim().startsWith(endCode); + } + + /** + * getCanBreakLinesByInfo + * + * @param conn dbConnection + * @param inputsParams params + * @param sourceCode code + * @return List string + */ + public static List getCanBreakLinesByInfo(IConnection conn, List inputsParams, + List sourceCodes) { + List infos = null; + try { + infos = DbeDebugService.getInfoCodes(conn, inputsParams); + } catch (SQLException e) { + MPPDBIDELoggerUtility.error(e.getMessage()); + return Collections.emptyList(); + } + return getBreakLines(infos, sourceCodes); + } + + /** + * getBreakLines + * + * @param infos infoCode + * @param sourceCode code + * @return List string + */ + public static List getBreakLines(List infos, List sourceCodes) { + Map map = getBeginToEndLineNo(sourceCodes); + List linse = new ArrayList(); + for (int i = map.get(BEGIN); i < sourceCodes.size(); i++) { + if (i >= map.get(END)) { + return linse; + } + if (i < infos.size() && infos.get(i).canbreak) { + linse.add(String.valueOf(i)); + } + } + return linse; + } + + /** + * compluteIndex + * + * @param infos infos + * @param sourceCode code + * @return index int + */ + public static int compluteIndex(List infos, List sourceCodes) { + Map map = getBeginToEndLineNo(sourceCodes); + int index = -1; + for (int i = map.get(BEGIN) + 1; i < sourceCodes.size(); i++) { + index = i; + if (index >= map.get(END)) { + return index; + } + if (!StringUtils.isBlank(sourceCodes.get(index)) && infos.size() >= index && infos.get(index).canbreak) { + return i; + } + } + return index; + } +} \ No newline at end of file diff --git a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/common/QueryResVoConvertHelper.java b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/common/QueryResVoConvertHelper.java index d3df0c59c6ea51ee8b392d2a84d4d305bef71ce5..d3c8f32b341037fc2a1185f0e1fdbcedb7140b1f 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/common/QueryResVoConvertHelper.java +++ b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/common/QueryResVoConvertHelper.java @@ -18,6 +18,7 @@ package org.opengauss.mppdbide.common; import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import org.opengauss.mppdbide.debuger.annotation.ParseVo; @@ -43,7 +44,7 @@ public class QueryResVoConvertHelper { * @return return value * @throws SQLException the exception */ - public static T parse(ResultSet rs, Class clazz, IConnection conn) throws SQLException { + public static Optional parse(ResultSet rs, Class clazz, IConnection conn) throws SQLException { VersionVo version = VersionHelper.getDebuggerVersion(conn); return parse(rs, clazz, version); } @@ -58,17 +59,12 @@ public class QueryResVoConvertHelper { * @return the converted value * @throws SQLException the exception */ - public static T parse(ResultSet rs, Class clazz, VersionVo versionVo) throws SQLException { + public static Optional parse(ResultSet rs, Class clazz, VersionVo versionVo) throws SQLException { T obj = null; - // if openGauss2.0 command do not need to convert - if (!getConvert(versionVo.getDebuggerVersion())) { - obj = ParseVo.parse(rs, clazz); - } else { - if (SourceCodeVo.class.equals(clazz)) { - obj = convertToSourceCodeVo(rs); - } + if (SourceCodeVo.class.equals(clazz)) { + obj = convertToSourceCodeVo(rs, clazz); } - return obj; + return Optional.of(obj); } /** @@ -111,12 +107,14 @@ public class QueryResVoConvertHelper { * Convert vo by class * * @param rs the rs + * @param clazz class * @param the Generics * @return the converted value * @throws SQLException the exception */ - public static T convertToSourceCodeVo(ResultSet rs) throws SQLException { + public static T convertToSourceCodeVo(ResultSet rs, Class clazz) throws SQLException { List infos = ParseVo.parseList(rs, InfoCodeVo.class); + DbeCommonUtils.infoCodes = infos; List infoCodeList = infos.stream().filter(item -> item.lineno != null).collect(Collectors.toList()); StringBuffer buffer = new StringBuffer(); infoCodeList.forEach(infoItem -> { diff --git a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DbeDebugService.java b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DbeDebugService.java index 9dda765b60336ffa9ee728f18cd267ee5dd82efd..e3807b6a404984bf6f50464bb93d85b725b46b6c 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DbeDebugService.java +++ b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DbeDebugService.java @@ -21,13 +21,16 @@ import java.sql.SQLException; import java.sql.SQLWarning; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; +import org.opengauss.mppdbide.common.IConnection; import org.opengauss.mppdbide.common.QueryResVoConvertHelper; import org.opengauss.mppdbide.common.VersionHelper; import org.opengauss.mppdbide.debuger.annotation.ParseVo; @@ -39,6 +42,7 @@ import org.opengauss.mppdbide.debuger.vo.PositionVo; import org.opengauss.mppdbide.debuger.vo.StackVo; import org.opengauss.mppdbide.debuger.vo.VariableVo; import org.opengauss.mppdbide.debuger.vo.dbe.AttachVo; +import org.opengauss.mppdbide.debuger.vo.dbe.InfoCodeVo; import org.opengauss.mppdbide.debuger.vo.dbe.TurnOnVo; import org.opengauss.mppdbide.utils.DebuggerStartVariable; import org.opengauss.mppdbide.utils.VariableRunLine; @@ -107,7 +111,17 @@ public class DbeDebugService extends DebugService { }, 2000); try (ResultSet rs = ps.executeQuery()) { if (rs.next()) { - return Optional.ofNullable(rs.getObject(1)); + int totalCount = rs.getMetaData().getColumnCount(); + int initCount = 0; + List resList = new ArrayList(); + while (initCount < totalCount) { + initCount++; + String columnName = rs.getMetaData().getColumnName(initCount); + Object result = rs.getObject(initCount); + String coverRes = String.format(Locale.ENGLISH, columnName+"%s "+result,":"); + resList.add(coverRes); + } + return Optional.ofNullable(String.join("; ", resList)); } return Optional.empty(); } @@ -349,6 +363,27 @@ public class DbeDebugService extends DebugService { return VariableRunLine.isPldebugger; } + /** + * get infoCodes + * + * @param conn the dbConnection + * @param debugOpt debugOpt + * @param params oid + * @return List InfoCodeVo + * @throws SQLException Exception + */ + public static List getInfoCodes(IConnection conn, List params) throws SQLException { + try (PreparedStatement ps = conn.getDebugOptPrepareStatement( + DebugConstants.DebugOpt.DBE_GET_SOURCE_CODE, params)) { + try (ResultSet rs = ps.executeQuery()) { + return ParseVo.parseList(rs, InfoCodeVo.class); + } catch (SQLException e) { + MPPDBIDELoggerUtility.error(e.getMessage()); + } + } + return Collections.emptyList(); + } + private boolean disposeDbeBreakpoint(DebugOpt debugOpt, PositionVo positionVo, Boolean isDelete) throws SQLException { if (positionVo.func == null || positionVo.func.intValue() == 0) { diff --git a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DbeQueryService.java b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DbeQueryService.java new file mode 100644 index 0000000000000000000000000000000000000000..f0a6957f2425e729e8edd2c3369e18c9a9bda372 --- /dev/null +++ b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DbeQueryService.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * openGauss is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +package org.opengauss.mppdbide.debuger.service; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +import org.opengauss.mppdbide.common.QueryResVoConvertHelper; +import org.opengauss.mppdbide.debuger.debug.DebugConstants; +import org.opengauss.mppdbide.debuger.vo.SourceCodeVo; + +/** + * Title: the QueryService class + * + * @since 3.0.0 + */ +public class DbeQueryService extends QueryService { + /** + * get base source code + * + * @param oid function oid + * @return Optional the source code + * @throws SQLException sql exp + */ + @Override + public Optional getSourceCode(Long oid) throws SQLException { + return getTempSourceCode(oid, DebugConstants.DebugOpt.DBE_GET_SOURCE_CODE, SourceCodeVo.class); + } + + private Optional getTempSourceCode(Long oid, DebugConstants.DebugOpt debugOpt, Class clazz) + throws SQLException { + List inputParams = Arrays.asList(oid); + try (PreparedStatement ps = getIConn().getDebugOptPrepareStatement( + debugOpt, inputParams)) { + try (ResultSet rs = ps.executeQuery()) { + return QueryResVoConvertHelper.parse(rs, clazz, getIConn()); + } + } + } +} \ No newline at end of file diff --git a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DbeSourceCodeService.java b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DbeSourceCodeService.java new file mode 100644 index 0000000000000000000000000000000000000000..16a430449df1ac77405d415edb14e76f89275c83 --- /dev/null +++ b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DbeSourceCodeService.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022 Huawei Technologies Co.,Ltd. + * + * openGauss is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +package org.opengauss.mppdbide.debuger.service; + +import java.util.List; + +import org.opengauss.mppdbide.common.DbeCommonUtils; +import org.opengauss.mppdbide.debuger.exception.DebugPositionNotFoundException; + +/** + * Title: the SourceCodeService class + * + * @since 3.0.0 + */ +public class DbeSourceCodeService extends SourceCodeService { + /** + * get begin debug line number + * + * @return int return begin debug line number in code line + * @throws DebugPositionNotFoundException debug position exp + */ + @Override + public int getBeginDebugCodeLine() throws DebugPositionNotFoundException { + List terminalCodes = super.totalCodeDesc.getCodeList(); + return DbeCommonUtils.compluteIndex(DbeCommonUtils.infoCodes, terminalCodes); + } +} diff --git a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DebugService.java b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DebugService.java index 0fa9e4e483d38ea98f7a21d7b0c64758cb23eceb..2857d6f8fe2b171b6775a5726e22cdba70059178 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DebugService.java +++ b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DebugService.java @@ -15,15 +15,27 @@ package org.opengauss.mppdbide.debuger.service; -import org.opengauss.mppdbide.debuger.event.Event; -import org.opengauss.mppdbide.debuger.event.EventHander; -import org.opengauss.mppdbide.debuger.event.Event.EventMessage; -import org.opengauss.mppdbide.debuger.exception.DebugExitException; -import org.opengauss.mppdbide.debuger.service.chain.MsgChainHelper; +import java.lang.Thread.State; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.Optional; + +import org.opengauss.mppdbide.common.IConnection; import org.opengauss.mppdbide.debuger.annotation.ParseVo; import org.opengauss.mppdbide.debuger.debug.DebugConstants; import org.opengauss.mppdbide.debuger.debug.DebugConstants.DebugOpt; import org.opengauss.mppdbide.debuger.debug.DebugState; +import org.opengauss.mppdbide.debuger.event.Event; +import org.opengauss.mppdbide.debuger.event.Event.EventMessage; +import org.opengauss.mppdbide.debuger.event.EventHander; +import org.opengauss.mppdbide.debuger.exception.DebugExitException; +import org.opengauss.mppdbide.debuger.service.chain.MsgChainHelper; import org.opengauss.mppdbide.debuger.thread.DebugServerRunable; import org.opengauss.mppdbide.debuger.thread.DebugServerThreadProxy; import org.opengauss.mppdbide.debuger.thread.EventQueueThread; @@ -33,20 +45,9 @@ import org.opengauss.mppdbide.debuger.vo.SessionVo; import org.opengauss.mppdbide.debuger.vo.StackVo; import org.opengauss.mppdbide.debuger.vo.VariableVo; import org.opengauss.mppdbide.debuger.vo.VersionVo; -import org.opengauss.mppdbide.common.IConnection; import org.opengauss.mppdbide.utils.logger.MPPDBIDELoggerUtility; import org.postgresql.core.NoticeListener; -import java.lang.Thread.State; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - /** * Title: the DebugService class * Description: this is module use to debug openGauss database's pl/sql function. @@ -150,10 +151,7 @@ public class DebugService implements NoticeListener, EventHander, IDebugService ps.setObject(i, args.get(i - 1)); } try (ResultSet rs = ps.executeQuery()) { - if (rs.next()) { - return Optional.ofNullable(rs.getObject(1)); - } - return Optional.empty(); + return this.listResultSet(rs); } } } finally { @@ -793,4 +791,28 @@ public class DebugService implements NoticeListener, EventHander, IDebugService void getServerCallBackBegin() throws SQLException { serverCallBackBegin(); } + + /** + * get all val from ResultSet + * + * @param rs param + * @return Optional<> Object + * @throws SQLException Exception + */ + private Optional listResultSet(ResultSet rs) throws SQLException { + if (rs.next()) { + int totalCount = rs.getMetaData().getColumnCount(); + int initCount = 0; + List resList = new ArrayList(); + while (initCount < totalCount) { + initCount++; + String columnName = rs.getMetaData().getColumnName(initCount); + Object result = rs.getObject(initCount); + String coverRes = String.format(Locale.ENGLISH, columnName+"%s "+result,":"); + resList.add(coverRes); + } + return Optional.ofNullable(String.join("; ", resList)); + } + return Optional.empty(); + } } diff --git a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DebuggerReportService.java b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DebuggerReportService.java index 14a393eac70cf84da96cec4c109b0168b9088d42..fbf1081acfefc5d4d85174f43cb829a82cd583ce 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DebuggerReportService.java +++ b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/DebuggerReportService.java @@ -23,7 +23,9 @@ import java.util.Arrays; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; +import org.opengauss.mppdbide.common.DbeCommonUtils; import org.opengauss.mppdbide.common.IConnection; import org.opengauss.mppdbide.common.IConnectionProvider; import org.opengauss.mppdbide.debuger.annotation.ParseVo; @@ -52,8 +54,9 @@ public class DebuggerReportService { public static final int CODE_BASE_OFFSET = 1; private static final String CREAT_TABLE = "CREATE TABLE IF NOT EXISTS his_coverage( oid BIGINT,"; private static final String TABLE_FIELD_ONE = " cid BIGINT, coverageLines VARCHAR, remarkLines VARCHAR, "; - private static final String TABLE_FIELD_TWO = "endTime BIGINT, sourceCode VARCHAR, params VARCHAR);"; - private static final String INSERT = "insert into his_coverage VALUES(?,?,?,?,?,?,?);"; + private static final String TABLE_FIELD_TWO = "endTime BIGINT, sourceCode VARCHAR, params VARCHAR," + + " canBreakLine VARCHAR);"; + private static final String INSERT = "insert into his_coverage VALUES(?,?,?,?,?,?,?,?);"; /** * default value @@ -62,6 +65,7 @@ public class DebuggerReportService { private IConnection serverConn; private IConnection clientConn; + private IConnection queryConn; private FunctionVo functionVo; private TurnOnVo turnOnVo; private DebuggerStartInfoVo startInfo; @@ -109,12 +113,9 @@ public class DebuggerReportService { } private String getCurLine() { - try { - return String.valueOf(getBeginDebugCodeLine()); - } catch (DebugPositionNotFoundException debugExp) { - MPPDBIDELoggerUtility.error("receive invalid position:" + debugExp.toString()); - } - return "-1"; + List terminalCodes = this.totalCodeDesc.getCodeList(); + int index = DbeCommonUtils.compluteIndex(DbeCommonUtils.infoCodes, terminalCodes); + return String.valueOf(index); } /** @@ -127,6 +128,7 @@ public class DebuggerReportService { try { this.serverConn = connectProvider.getValidFreeConnection(); this.clientConn = connectProvider.getValidFreeConnection(); + this.queryConn = connectProvider.getValidFreeConnection(); this.functionVo = functionVo; } catch (SQLException e) { MPPDBIDELoggerUtility.error(e.getMessage()); @@ -175,6 +177,14 @@ public class DebuggerReportService { } catch (SQLException sqlErr) { MPPDBIDELoggerUtility.warn("reportService clientConn close failed, err=" + sqlErr.toString()); } + try { + if (queryConn != null) { + queryConn.close(); + queryConn = null; + } + } catch (SQLException sqlErr) { + MPPDBIDELoggerUtility.warn("reportService queryConn close failed, err=" + sqlErr.toString()); + } } /** @@ -273,6 +283,11 @@ public class DebuggerReportService { List historyList = DebuggerStartVariable.getHistoryList(functionVo.oid); historyList.add(endInfo); DebuggerStartVariable.setHistoryList(functionVo.oid, historyList); + List toRunLines = DbeCommonUtils.getCanBreakLinesByInfo(queryConn, + Arrays.asList(functionVo.oid), SourceCodeService.CodeDescription.getLines(endInfo.sourceCode)) + .stream().map(item -> String.valueOf(Integer.parseInt(item) + 1)) + .collect(Collectors.toList()); + endInfo.canBreakLine = String.join(",", toRunLines); createTbale(endInfo); } @@ -293,6 +308,7 @@ public class DebuggerReportService { if (endInfo.args != null) { preparedStatement.setObject(7, endInfo.args.toString()); } + preparedStatement.setObject(8, endInfo.canBreakLine); preparedStatement.execute(); } catch (SQLException e) { MPPDBIDELoggerUtility.error(e.getMessage()); diff --git a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/QueryService.java b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/QueryService.java index a77e991df5dc45114be6e4d567e61e401dda20df..6b07081fcf9b80dd5d7c300e51b5381f551bf6ce 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/QueryService.java +++ b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/QueryService.java @@ -15,24 +15,22 @@ package org.opengauss.mppdbide.debuger.service; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -import org.opengauss.mppdbide.common.IConnection; -import org.opengauss.mppdbide.common.QueryResVoConvertHelper; -import org.opengauss.mppdbide.common.VersionHelper; import org.opengauss.mppdbide.debuger.dao.FunctionDao; +import org.opengauss.mppdbide.debuger.annotation.ParseVo; import org.opengauss.mppdbide.debuger.debug.DebugConstants; -import org.opengauss.mppdbide.debuger.debug.DebugConstants.DebugOpt; import org.opengauss.mppdbide.debuger.vo.FunctionVo; import org.opengauss.mppdbide.debuger.vo.SourceCodeVo; import org.opengauss.mppdbide.debuger.vo.TotalSourceCodeVo; +import org.opengauss.mppdbide.common.IConnection; import org.opengauss.mppdbide.utils.logger.MPPDBIDELoggerUtility; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + /** * Title: the QueryService class * @@ -68,10 +66,9 @@ public class QueryService implements IService { * @throws SQLException sql exp */ public Optional getSourceCode(Long oid) throws SQLException { - DebugOpt opt = VersionHelper.getDebugOptByDebuggerVersion(conn, DebugConstants.DebugOpt.GET_SOURCE_CODE); - Optional sourceCodeVo = getTempSourceCode(oid, opt, SourceCodeVo.class); - String sourceCode = sourceCodeVo.get().getSourceCode(); - return sourceCodeVo; + return getTempSourceCode(oid, + DebugConstants.DebugOpt.GET_SOURCE_CODE, + SourceCodeVo.class); } /** @@ -96,7 +93,7 @@ public class QueryService implements IService { debugOpt, inputParams)) { try (ResultSet rs = ps.executeQuery()) { if (rs.next()) { - return Optional.of(QueryResVoConvertHelper.parse(rs, clazz, conn)); + return Optional.of(ParseVo.parse(rs, clazz)); } return Optional.empty(); } @@ -157,4 +154,8 @@ public class QueryService implements IService { MPPDBIDELoggerUtility.warn("close conn with err:" + e.toString()); } } + + IConnection getIConn() { + return conn; + } } diff --git a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/ServiceFactory.java b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/ServiceFactory.java index 2c0f771e9f00d83aa3640421a7b9d78d3dbf13c3..645fa1b9dcca86769b0ae65c751b348d9c699682 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/ServiceFactory.java +++ b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/ServiceFactory.java @@ -21,7 +21,6 @@ import org.opengauss.mppdbide.debuger.debug.DebugConstants; import org.opengauss.mppdbide.debuger.vo.FunctionVo; import org.opengauss.mppdbide.common.IConnection; import org.opengauss.mppdbide.common.IConnectionProvider; -import org.opengauss.mppdbide.common.VersionHelper; import org.opengauss.mppdbide.debuger.vo.VersionVo; import org.opengauss.mppdbide.utils.VariableRunLine; import org.opengauss.mppdbide.utils.logger.MPPDBIDELoggerUtility; @@ -87,7 +86,7 @@ public class ServiceFactory { * @return Optional the version vo * @throws SQLException sql error */ - public Optional getVersion() throws SQLException { + public Optional getVersion() throws SQLException { IConnection conn = provider.getValidFreeConnection(); try (PreparedStatement ps = conn.getDebugOptPrepareStatement( DebugConstants.DebugOpt.DEBUG_VERSION, @@ -113,6 +112,9 @@ public class ServiceFactory { * @return SourceCodeService the code service */ public SourceCodeService getCodeService() { + if (!VariableRunLine.isPldebugger) { + return new DbeSourceCodeService(); + } return new SourceCodeService(); } @@ -128,11 +130,6 @@ public class ServiceFactory { } private static DebugService getDebugService(IConnection conn) { - try { - VariableRunLine.isPldebugger = VersionHelper.getDebuggerVersion(conn).isPldebugger(); - } catch (SQLException e) { - MPPDBIDELoggerUtility.error(e.getMessage()); - } if (!VariableRunLine.isPldebugger) { return new DbeDebugService(); } @@ -140,7 +137,12 @@ public class ServiceFactory { } private static QueryService createQueryService(IConnection conn) { - QueryService queryService = new QueryService(); + QueryService queryService; + if (!VariableRunLine.isPldebugger) { + queryService = new DbeQueryService(); + } else { + queryService = new QueryService(); + } queryService.setFunctionDao(new FunctionDao()); queryService.setConn(conn); return queryService; diff --git a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/SourceCodeService.java b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/SourceCodeService.java index 57a4f516075de5ca36601c1ec653b3aecf7d81f3..7cb74910135050f4bff09451ad1955b118cbf289 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/SourceCodeService.java +++ b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/service/SourceCodeService.java @@ -15,14 +15,13 @@ package org.opengauss.mppdbide.debuger.service; -import org.opengauss.mppdbide.debuger.exception.DebugPositionNotFoundException; - -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.stream.Collectors; +import org.opengauss.mppdbide.debuger.exception.DebugPositionNotFoundException; + /** * Title: the SourceCodeService class * @@ -33,11 +32,9 @@ public class SourceCodeService implements IService { * the offset of show code and base code */ public static final int CODE_BASE_OFFSET = 1; - private static final String BEGIN = "BEGIN"; - private static final String END = "END;"; - private CodeDescription baseCodeDesc = null; - private CodeDescription totalCodeDesc = null; + CodeDescription baseCodeDesc = null; + CodeDescription totalCodeDesc = null; /** * close service @@ -231,68 +228,22 @@ public class SourceCodeService implements IService { } /** - * get code to run lines + * get code list * * @param srcCode the code - * @return the run line num + * @return the line list */ - public static List getRunLines(String srcCode) { - List totalLines = getLines(srcCode); - Boolean isStart = false; - Boolean isEnd = false; - Boolean isBegin = false; - List runLines = new ArrayList(); - for (String line : totalLines) { - if (!isStart) { - isStart = line.toUpperCase(Locale.ENGLISH).contains(BEGIN); - } - isEnd = line.toUpperCase(Locale.ENGLISH).contains(END); - if (isEnd) { - break; - } - if (isStart) { - isBegin = line.toUpperCase(Locale.ENGLISH).contains(BEGIN); - if (!isBegin) { - runLines.add(line); - } - } - } - return runLines; + public List getCodeList() { + return this.codeList; } /** - * get line num by code + * get BeginFromCode * - * @param srcCode the code - * @return the line num + * @param lines line + * @return int linse item */ - public static List getRunLinesNums(String srcCode) { - List totalLines = getLines(srcCode); - Boolean isStart = false; - Boolean isEnd = false; - Boolean isBegin = false; - List runLines = new ArrayList(); - Integer count = 0; - for (String line : totalLines) { - count++; - if (!isStart) { - isStart = line.toUpperCase(Locale.ENGLISH).contains(BEGIN); - } - isEnd = line.toUpperCase(Locale.ENGLISH).contains(END); - if (isEnd) { - break; - } - if (isStart) { - isBegin = line.toUpperCase(Locale.ENGLISH).contains(BEGIN); - if (!isBegin) { - runLines.add(count.toString()); - } - } - } - return runLines; - } - - private int getBeginFromCode(List lines) { + public int getBeginFromCode(List lines) { for (int i = 0; i < lines.size(); i++) { if (lines.get(i).toUpperCase(Locale.ENGLISH).trim().startsWith("BEGIN")) { return i; diff --git a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/vo/dbe/ExportParamVo.java b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/vo/dbe/ExportParamVo.java index 280085f1a2a36e2a8f4e4e90f8d92da6dc6b1502..acaffa94b3ba0a602a1b615b50c59f50836548a1 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/vo/dbe/ExportParamVo.java +++ b/code/datastudio/src/org.opengauss.mppdbide.debuger/src/org/opengauss/mppdbide/debuger/vo/dbe/ExportParamVo.java @@ -59,4 +59,9 @@ public class ExportParamVo { * html of function */ public String html; + + /** + * canBreakLine of function + */ + public String canBreakLine; } diff --git a/code/datastudio/src/org.opengauss.mppdbide.utils/src/messages.properties b/code/datastudio/src/org.opengauss.mppdbide.utils/src/messages.properties index af1785cb3731ce7e81bcd9a34b009eefa444644a..671ff78b4909aa8455130ef40c606aa484d274b7 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.utils/src/messages.properties +++ b/code/datastudio/src/org.opengauss.mppdbide.utils/src/messages.properties @@ -3179,13 +3179,13 @@ CREATE_VIEW_UI_DELETE = Delete CREATE_VIEW_UI_MATERVIEW = Materialized view CREATE_VIEW_UI_VIEW = View CREATE_VIEW_UI_NAME_NOT_EMPTY = View name cann't be empty! -REMARK_SHORTCUT_KEY_BINDING_TOGGLE_LINE_COMMENTS=remark Line /UnRemark Line (coverage) +REMARK_SHORTCUT_KEY_BINDING_TOGGLE_LINE_COMMENTS=Remark/Unremark Line OID=Oid -TOTAL_LINE=Total rows -TOTAL_RUN_LINE_NUM=Total running lines +TOTAL_LINE=Total Rows +TOTAL_RUN_LINE_NUM=Total Running Lines TOTAL_COVERAGE=Total Coverage REMARK_LINE=Mark Row -REMARK_RUM_LINE_NUM=Mark execution line number +REMARK_RUM_LINE_NUM=Mark Execution Line REMARK_COVERAGE=Remark Coverage DELETE_COVERAGE=Select Delete DELETE_COVERAGE_ALL=Delete All @@ -3193,13 +3193,16 @@ EXPORT_REPORT=Export Report SURE_EXPORT_REPORT=Are you sure you want to export coverage reports? COVERAGE_REPORT_NOT_EXIST=Coverage report does not exist COVERAGE_REPORT_TO_SELECT=Please select a record -COVERAGE_HISTORY_TITLE=Coverage_Report - {0} +COVERAGE_HISTORY_TITLE=Historical Coverage - {0} DELETE_COVERAGE_REPORT_TITLE=Delete Stored Procedure DELETE_SELECTED_COVERAGE_HISTORY_ALERT=Are you sure you want to delete the selected stored procedure query history for the {0} connection profile? DELETE_ALL_COVERAGE_HISTORY_ALERT=Are you sure you want to delete the stored procedure query history for the {0} connection profile? -UPDATE_TIME=Update time +UPDATE_TIME=Update Time DEBUG_POSITION_LABEL_PASS=pass DEBUG_POSITION_LABEL_FAIL=fail COVERAGE_HINT=To view the coverage report, please execute Debug! EXPORT_PATH = The report has been downloaded to: {0} -COVERAGE_CHECK = This version does not support this function! \ No newline at end of file +COVERAGE_CHECK = This version does not support this function! +INPUT_PARAMS = Input Params +NOT_SUPPORT_BREAK = There are rows that do not support flags! +VERSION_CHECK_FAIL = Check version failed! \ No newline at end of file diff --git a/code/datastudio/src/org.opengauss.mppdbide.utils/src/messages_zh_CN.properties b/code/datastudio/src/org.opengauss.mppdbide.utils/src/messages_zh_CN.properties index ce94248b592aa06887c267246996156d8decce72..259934b0ae35ba2741cccd912200188e1351b532 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.utils/src/messages_zh_CN.properties +++ b/code/datastudio/src/org.opengauss.mppdbide.utils/src/messages_zh_CN.properties @@ -3158,7 +3158,7 @@ CREATE_VIEW_UI_DELETE = \u5220\u9664 CREATE_VIEW_UI_MATERVIEW = \u7269\u5316\u89C6\u56FE CREATE_VIEW_UI_VIEW = \u89C6\u56FE CREATE_VIEW_UI_NAME_NOT_EMPTY = \u89C6\u56FE\u540D\u4E0D\u80FD\u4E3A\u7A7A -REMARK_SHORTCUT_KEY_BINDING_TOGGLE_LINE_COMMENTS=\u6807\u8BB0\u884C/\u53D6\u6D88\u6807\u8BB0\u884C(\u8986\u76D6\u7387) +REMARK_SHORTCUT_KEY_BINDING_TOGGLE_LINE_COMMENTS=\u6807\u8BB0/\u53D6\u6D88\u6807\u8BB0\u884C OID=Oid TOTAL_LINE=\u603B\u884C\u6570 TOTAL_RUN_LINE_NUM=\u6267\u884C\u884C\u6570 @@ -3172,7 +3172,7 @@ EXPORT_REPORT=\u5BFC\u51FA\u8986\u76D6\u7387\u62A5\u544A SURE_EXPORT_REPORT=\u786E\u5B9A\u5BFC\u51FA\u8986\u76D6\u7387\u62A5\u544A\u5417? COVERAGE_REPORT_NOT_EXIST=\u8986\u76D6\u7387\u62A5\u544A\u4E0D\u5B58\u5728 COVERAGE_REPORT_TO_SELECT=\u8BF7\u9009\u62E9\u4E00\u6761\u8BB0\u5F55 -COVERAGE_HISTORY_TITLE=\u8986\u76D6\u7387\u62A5\u544A - {0} +COVERAGE_HISTORY_TITLE=\u5386\u53F2\u8986\u76D6\u7387 - {0} DELETE_COVERAGE_REPORT_TITLE=\u5220\u9664\u5B58\u50A8\u8FC7\u7A0B DELETE_SELECTED_COVERAGE_HISTORY_ALERT=\u4F60\u786E\u5B9A\u8981\u5220\u9664\u201C{0}\u201D\u8FDE\u63A5\u914D\u7F6E\u6587\u4EF6\u7684\u9009\u5B9A\u7684\u5B58\u50A8\u8FC7\u7A0B\u67E5\u8BE2\u5386\u53F2\uFF1F DELETE_ALL_COVERAGE_HISTORY_ALERT=\u4F60\u786E\u5B9A\u8981\u5220\u9664\u201C{0}\u201D\u8FDE\u63A5\u914D\u7F6E\u6587\u4EF6\u7684\u5B58\u50A8\u8FC7\u7A0B\u67E5\u8BE2\u5386\u53F2\uFF1F @@ -3181,4 +3181,17 @@ DEBUG_POSITION_LABEL_PASS=\u901A\u8FC7 DEBUG_POSITION_LABEL_FAIL=\u672A\u901A\u8FC7 COVERAGE_HINT=\u82E5\u9700\u8981\u67E5\u770B\u8986\u76D6\u7387\u62A5\u544A,\u8BF7\u6267\u884CDebug! EXPORT_PATH = \u62A5\u544A\u5DF2\u4E0B\u8F7D\u5230: {0} -COVERAGE_CHECK = \u8BE5\u7248\u672C\u4E0D\u652F\u6301\u6B64\u529F\u80FD! \ No newline at end of file +COVERAGE_CHECK = \u8BE5\u7248\u672C\u4E0D\u652F\u6301\u6B64\u529F\u80FD! +INPUT_PARAMS = \u5165\u53C2 +NOT_SUPPORT_BREAK = \u5B58\u5728\u4E0D\u652F\u6301\u6807\u8BB0\u7684\u884C! +VERSION_CHECK_FAIL = \u7248\u672C\u6821\u9A8C\u5931\u8D25! +EXP_EXECUTE_STATEMENT = \u6267\u884C\u8BED\u53E5 +EXP_SERIAL_NUMBER = \u5E8F\u53F7 +EXP_TOTAL_ROWS = \u603B\u884C\u6570 +EXP_TOTAL_RUNNING_LINES = \u6267\u884C\u884C\u6570 +EXP_TOTAL_COVERAGE = \u603B\u8986\u76D6\u7387 +EXP_MARK_ROW = \u6807\u8BB0\u884C +EXP_MARK_EXECUTION_LINE = \u6807\u8BB0\u6267\u884C\u884C +EXP_MARKER_COVERAGE = \u6807\u8BB0\u8986\u76D6\u7387 +EXP_INPUT_PARAMS = \u5165\u53C2 +EXP_UPDATE_TIME = \u7ED3\u675F\u65F6\u95F4 \ No newline at end of file diff --git a/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/IMessagesConstants.java b/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/IMessagesConstants.java index 2ed00e54d535b857ca1e7125d8c6d70ab1710028..d387fdfb42de37648ef71d46e84ad867aaeff37e 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/IMessagesConstants.java +++ b/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/IMessagesConstants.java @@ -3120,4 +3120,9 @@ public interface IMessagesConstants extends IMessagesConstantsOne { * The update time */ String UPDATE_TIME = "UPDATE_TIME"; + + /** + * The input params + */ + String INPUT_PARAMS = "INPUT_PARAMS"; } \ No newline at end of file diff --git a/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/IMessagesConstantsOne.java b/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/IMessagesConstantsOne.java index cf0883c9fa44ab231bae6b80d1b26c278b49ff78..35f159f250b46af6526efcba97fe84a92d206f62 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/IMessagesConstantsOne.java +++ b/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/IMessagesConstantsOne.java @@ -1114,4 +1114,64 @@ public interface IMessagesConstantsOne extends IMessagesConstantsTwo { * COVERAGE_CHECK */ String COVERAGE_CHECK = "COVERAGE_CHECK"; + + /** + * BREAK + */ + String NOT_SUPPORT_BREAK = "NOT_SUPPORT_BREAK"; + + /** + * VERSION_CHECK_FAIL + */ + String VERSION_CHECK_FAIL = "VERSION_CHECK_FAIL"; + + /** + * EXP_EXECUTE_STATEMENT + */ + String EXP_EXECUTE_STATEMENT = "EXP_EXECUTE_STATEMENT"; + + /** + * EXP_SERIAL_NUMBER + */ + String EXP_SERIAL_NUMBER = "EXP_SERIAL_NUMBER"; + + /** + * EXP_TOTAL_ROWS + */ + String EXP_TOTAL_ROWS = "EXP_TOTAL_ROWS"; + + /** + * EXP_TOTAL_RUNNING_LINES + */ + String EXP_TOTAL_RUNNING_LINES = "EXP_TOTAL_RUNNING_LINES"; + + /** + * VERSION_CHECK_FAIL + */ + String EXP_TOTAL_COVERAGE = "EXP_TOTAL_COVERAGE"; + + /** + * EXP_MARK_ROW + */ + String EXP_MARK_ROW = "EXP_MARK_ROW"; + + /** + * EXP_MARK_EXECUTION_LINE + */ + String EXP_MARK_EXECUTION_LINE = "EXP_MARK_EXECUTION_LINE"; + + /** + * VERSION_CHECK_FAIL + */ + String EXP_MARKER_COVERAGE = "EXP_MARKER_COVERAGE"; + + /** + * EXP_INPUT_PARAMS + */ + String EXP_INPUT_PARAMS = "EXP_INPUT_PARAMS"; + + /** + * EXP_UPDATE_TIME + */ + String EXP_UPDATE_TIME = "EXP_UPDATE_TIME"; } \ No newline at end of file diff --git a/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/vo/DebuggerStartInfoVo.java b/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/vo/DebuggerStartInfoVo.java index fa38e9c796ca0b034b4c06e2ecdfad35483c2a38..cbf071f0f25cf4c349ee2a098db27997a27bae7a 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/vo/DebuggerStartInfoVo.java +++ b/code/datastudio/src/org.opengauss.mppdbide.utils/src/org/opengauss/mppdbide/utils/vo/DebuggerStartInfoVo.java @@ -55,6 +55,11 @@ public class DebuggerStartInfoVo { */ public boolean isMakeReport = true; + /** + * totalCanBreakLine of function + */ + public String canBreakLine; + /** * get remakr list * diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/Application.e4xmi b/code/datastudio/src/org.opengauss.mppdbide.view/Application.e4xmi index 0d93b5955efaf5f19d2a29cbecb94e4c6e5e76d3..7cff0786622bccbc71b5bd93563cd03ceab1c89f 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/Application.e4xmi +++ b/code/datastudio/src/org.opengauss.mppdbide.view/Application.e4xmi @@ -294,6 +294,7 @@ + @@ -979,6 +980,7 @@ + diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/core/sourceeditor/PLSourceEditorCore.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/core/sourceeditor/PLSourceEditorCore.java index 186b6d93c8e81350eba50c25305c4bedb0af746e..d90cb242c4df7176b6267d71ecc1e6955149e362 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/core/sourceeditor/PLSourceEditorCore.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/core/sourceeditor/PLSourceEditorCore.java @@ -17,6 +17,7 @@ package org.opengauss.mppdbide.view.core.sourceeditor; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -25,6 +26,7 @@ import java.util.stream.Collectors; import javax.annotation.PreDestroy; +import org.apache.commons.lang3.StringUtils; import org.eclipse.core.commands.Command; import org.eclipse.core.commands.ParameterizedCommand; import org.eclipse.e4.core.commands.ECommandService; @@ -86,6 +88,7 @@ import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.GridData; @@ -101,9 +104,11 @@ import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; import org.opengauss.mppdbide.adapter.keywordssyntax.SQLSyntax; import org.opengauss.mppdbide.bl.serverdatacache.Database; +import org.opengauss.mppdbide.common.DbeCommonUtils; import org.opengauss.mppdbide.common.IConnection; import org.opengauss.mppdbide.common.IConnectionProvider; import org.opengauss.mppdbide.common.VersionHelper; +import org.opengauss.mppdbide.debuger.service.SourceCodeService; import org.opengauss.mppdbide.gauss.sqlparser.SQLFoldingConstants; import org.opengauss.mppdbide.utils.DebuggerStartVariable; import org.opengauss.mppdbide.utils.IMessagesConstants; @@ -142,10 +147,6 @@ import org.opengauss.mppdbide.view.workerjob.UIWorkerJob; * @since 3.0.0 */ public final class PLSourceEditorCore extends SelectMenuItem implements IPropertyChangeListener { - private static final String START_LINE = "startLine: "; - - private static final String END_LINE = "endLine: "; - private static final String FORMAT_COMMAND_ID = "org.opengauss.mppdbide.command.id.format"; private ECommandService commandService; @@ -213,6 +214,8 @@ public final class PLSourceEditorCore extends SelectMenuItem implements IPropert private int counterForTxtInEditor = 0; private MenuItem toggleLineComments; + + private MenuItem toggleRemarkComments; private MenuItem toggleBlockComments; @@ -1346,15 +1349,22 @@ public final class PLSourceEditorCore extends SelectMenuItem implements IPropert toggleLineComments.setImage(IconUtility.getIconImage(IiconPath.ICON_TOGGLE_LINE_COMMENTS, this.getClass())); } + /** + * Adds the toggle remark comment menu item. + * + * @param menuItem the menu item + */ private void addRemarkLineCommentMenuItem(Menu menuItem) { - toggleLineComments = new MenuItem(menuItem, SWT.PUSH); - toggleLineComments.setText(MessageConfigLoader + toggleRemarkComments = new MenuItem(menuItem, SWT.PUSH); + toggleRemarkComments.setText(MessageConfigLoader .getProperty(IMessagesConstants.REMARK_SHORTCUT_KEY_BINDING_TOGGLE_LINE_COMMENTS)); - toggleLineComments.addSelectionListener(new SelectionListener() { + toggleRemarkComments.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent event) { - remarkLineCommentHandle(); + Command cmd = commandService.getCommand("org.opengauss.mppdbide.view.command.ToggleRemarkComment"); + ParameterizedCommand parameterizedCmd = new ParameterizedCommand(cmd, null); + handlerService.executeHandler(parameterizedCmd); } @Override @@ -1362,60 +1372,51 @@ public final class PLSourceEditorCore extends SelectMenuItem implements IPropert } }); - toggleLineComments.setImage(IconUtility.getIconImage(IiconPath.ICON_REMARK_COVERAGE, this.getClass())); + toggleRemarkComments.setImage(IconUtility.getIconImage(IiconPath.ICON_REMARK_COVERAGE, this.getClass())); } - private void remarkLineCommentHandle() { + /** + * Remark line comment. + */ + public void remarkLineComment() { PLSourceEditor pl = UIElement.getInstance().getVisibleSourceViewer(); - IConnectionProvider prov = new DBConnectionProvider(pl.getDebugObject().getDatabase()); - Optional conn = prov.getFreeConnection(); - try { - boolean isPldebugger = VersionHelper.getDebuggerVersion(conn.get()).isPldebugger(); - if (isPldebugger) { - MPPDBIDEDialogs.generateOKMessageDialog(MESSAGEDIALOGTYPE.INFORMATION, true, - MessageConfigLoader.getProperty(IMessagesConstants.EXECDIALOG_HINT), - MessageConfigLoader.getProperty(IMessagesConstants.COVERAGE_CHECK)); - return; - } - ISelection res = viewer.getSelection(); - int start = Integer.valueOf(res.toString().split(START_LINE)[1].split(",")[0]); - String[] arr = res.toString().split(END_LINE); - int endLength = 1; - if (arr.length > 1) { - endLength = Integer.parseInt(arr[1].split(",")[0]); - } - List list = new ArrayList(); - for (int i = start; i < (endLength == 1 ? start + 1 : endLength + 1); i++) { - list.add(String.valueOf(i)); - } - long oid = pl.getDebugObject().getOid(); - DebuggerStartInfoVo startInfo = DebuggerStartVariable.getStartInfo(oid); - List remarkLines = startInfo.getRemarkList(); - List cancel = list.stream() - .filter(item -> remarkLines.contains(item)).collect(Collectors.toList()); - cancel.forEach(item -> viewer.getTextWidget() - .setLineBackground(Integer.parseInt(item), 1, - SQLSyntaxColorProvider.BACKGROUND_COLOR)); - List newRemark = list.stream() - .filter(item -> !remarkLines.contains(item)).collect(Collectors.toList()); - newRemark.forEach(item -> viewer.getTextWidget() - .setLineBackground(Integer.parseInt(item), 1, - SQLSyntaxColorProvider.BACKGROUND_COLOR_GREY)); - List oldRemark = remarkLines.stream() - .filter(item -> !list.contains(item)).collect(Collectors.toList()); - newRemark.addAll(oldRemark); - String remarLinesStr = newRemark.stream().map(String::valueOf).collect(Collectors.joining(",")); - startInfo.remarLinesStr = remarLinesStr; - DebuggerStartVariable.setStartInfo(oid, startInfo); - } catch (SQLException e) { - MPPDBIDELoggerUtility.error(e.getMessage()); - } finally { - try { - conn.get().close(); - } catch (SQLException e) { - MPPDBIDELoggerUtility.error(e.getMessage()); - } + long oid = pl.getDebugObject().getOid(); + List list = getList(); + DebuggerStartInfoVo startInfo = DebuggerStartVariable.getStartInfo(oid); + List remarkLines = startInfo.getRemarkList(); + List cancels = getRemarkList(list, remarkLines, true); + setLineBackground(cancels, SQLSyntaxColorProvider.BACKGROUND_COLOR); + List newRemarks = getRemarkList(list, remarkLines, false); + setLineBackground(newRemarks, SQLSyntaxColorProvider.BACKGROUND_COLOR_GREY); + List oldRemarks = getRemarkList(remarkLines, list, false); + newRemarks.addAll(oldRemarks); + String remarLinesStr = newRemarks.stream().map(String::valueOf).collect(Collectors.joining(",")); + startInfo.remarLinesStr = remarLinesStr; + DebuggerStartVariable.setStartInfo(oid, startInfo); + } + + private List getRemarkList(List rangeList, List lines, boolean isEqual) { + return rangeList.stream().filter(item -> { + if (isEqual) { + return lines.contains(item); + } + return !lines.contains(item); + }).collect(Collectors.toList()); + } + + private void setLineBackground(List lines, Color background) { + lines.forEach(item -> viewer.getTextWidget().setLineBackground(Integer.parseInt(item), 1, background)); + } + + private List getList() { + ITextSelection selection = (ITextSelection) viewer.getSelection(); + int start = selection.getStartLine(); + int end = selection.getEndLine(); + List list = new ArrayList(); + for (int i = start; i < (end == 1 ? start + 1 : end + 1); i++) { + list.add(String.valueOf(i)); } + return list; } /** @@ -1933,10 +1934,12 @@ public final class PLSourceEditorCore extends SelectMenuItem implements IPropert ITextSelection selection = (ITextSelection) viewer.getSelection(); int selOffset = selection.getOffset(); int selLength = selection.getLength(); + int startLine = selection.getStartLine(); + int endLine = selection.getEndLine(); + removeRemarkLines(startLine, endLine); String selText = null != selection.getText() ? selection.getText() : ""; int blockCommentOpenLen = MPPDBIDEConstants.ML_COMMENT_START.length(); int blockCommentEndLen = MPPDBIDEConstants.ML_COMMENT_END.length(); - DocumentRewriteSession rewriteSession = null; rewriteSession = getRewriteSession(document); @@ -2144,6 +2147,21 @@ public final class PLSourceEditorCore extends SelectMenuItem implements IPropert public String getText() { return getDocument().get(); } + + private void removeRemarkLines(int start, int end) { + PLSourceEditor pl = UIElement.getInstance().getVisibleSourceViewer(); + long oid = pl.getDebugObject().getOid(); + DebuggerStartInfoVo vo = DebuggerStartVariable.getStartInfo(oid); + List oldList = Arrays.asList(vo.remarLinesStr.split(",")); + List newLine = new ArrayList<>(); + oldList.forEach(item -> { + if (!StringUtils.isBlank(item) && (Integer.valueOf(item) < start || Integer.valueOf(item) > end)) { + newLine.add(item); + } + }); + vo.remarLinesStr = String.join(",", newLine); + DebuggerStartVariable.setStartInfo(oid, vo); + } /** * Toggle line comment. @@ -2157,6 +2175,9 @@ public final class PLSourceEditorCore extends SelectMenuItem implements IPropert boolean firstLineFlag = true; int startLine = textSelection.getStartLine(); int endLine = textSelection.getEndLine(); + + removeRemarkLines(startLine, endLine); + int lineCommentLen = SL_COMMENT.length(); boolean lineComment = false; int selLineNo = 0; @@ -2403,9 +2424,40 @@ public final class PLSourceEditorCore extends SelectMenuItem implements IPropert } toggleLineComments.setEnabled(isEnabled); toggleBlockComments.setEnabled(isEnabled); - + checkVisiable(isEnabled); } + private void checkVisiable(boolean isEnabled) { + PLSourceEditor pl = UIElement.getInstance().getVisibleSourceViewer(); + long oid = pl.getDebugObject().getOid(); + IDocument document = viewer.getDocument(); + List codes = SourceCodeService.CodeDescription.getLines(document.get()); + List list = getList(); + IConnectionProvider prov = new DBConnectionProvider(pl.getDebugObject().getDatabase()); + Optional conn = Optional.empty(); + boolean isVisiable = true; + boolean isPldebugger = false; + try { + conn = prov.getFreeConnection(); + isPldebugger = VersionHelper.getDebuggerVersion(conn.get()).isPldebugger(); + DbeCommonUtils.checkCanBreakLines(codes, conn.get(), oid, list); + } catch (SQLException e1) { + isVisiable = false; + } finally { + try { + conn.get().close(); + } catch (SQLException e) { + MPPDBIDELoggerUtility.error(e.getMessage()); + } + } + if (!isPldebugger && isVisiable) { + toggleRemarkComments.setEnabled(isEnabled); + } else { + toggleRemarkComments.setEnabled(false); + return; + } + } + /** * Property change. * diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/coverage/CoverageService.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/coverage/CoverageService.java index 8204a82ec464692d765e68e817e6848c550fb9d7..bdc1a495422e2562f81f071b53efe891fca2dba5 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/coverage/CoverageService.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/coverage/CoverageService.java @@ -19,6 +19,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; @@ -26,7 +27,6 @@ import java.util.stream.Collectors; import org.opengauss.mppdbide.common.IConnection; import org.opengauss.mppdbide.debuger.annotation.ParseVo; import org.opengauss.mppdbide.debuger.service.IService; -import org.opengauss.mppdbide.debuger.service.SourceCodeService; import org.opengauss.mppdbide.utils.DebuggerStartVariable; import org.opengauss.mppdbide.utils.logger.MPPDBIDELoggerUtility; import org.opengauss.mppdbide.utils.vo.DebuggerEndInfoVo; @@ -82,7 +82,7 @@ public class CoverageService implements IService { List res = this.queryList(sql, CoverageVo.class); res.stream().forEach(cov -> { if (cov.sourceCode != null) { - List toRunLines = SourceCodeService.CodeDescription.getRunLinesNums(cov.sourceCode); + List toRunLines = Arrays.asList(cov.canBreakLine.split(",")); cov.totalLineNum = toRunLines.size(); cov.coverageLineNum = cov.getRunList().size(); cov.coverageLinesArr = cov.getRunList(); @@ -162,7 +162,7 @@ public class CoverageService implements IService { } private List queryList(String sql, Class clazz) throws SQLException { - List list = null; + List list = new ArrayList(); try (PreparedStatement ps = conn.getStatement(sql)) { try (ResultSet rs = ps.executeQuery()) { list = ParseVo.parseList(rs, clazz); diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/DebugServiceHelper.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/DebugServiceHelper.java index a91417a391e60c83c3bb14afcd0f9a1706814c0d..57fb85b646e4e6172ce640a30e32cc408815ed53 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/DebugServiceHelper.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/DebugServiceHelper.java @@ -21,7 +21,9 @@ import java.util.Optional; import org.eclipse.jface.preference.PreferenceStore; import org.opengauss.mppdbide.bl.serverdatacache.IDebugObject; +import org.opengauss.mppdbide.common.IConnection; import org.opengauss.mppdbide.common.IConnectionProvider; +import org.opengauss.mppdbide.common.VersionHelper; import org.opengauss.mppdbide.debuger.event.Event; import org.opengauss.mppdbide.debuger.event.IHandlerManger; import org.opengauss.mppdbide.debuger.event.Event.EventMessage; @@ -34,11 +36,14 @@ import org.opengauss.mppdbide.debuger.service.DebuggerReportService; import org.opengauss.mppdbide.debuger.vo.SourceCodeVo; import org.opengauss.mppdbide.utils.IMessagesConstants; import org.opengauss.mppdbide.utils.MPPDBIDEConstants; +import org.opengauss.mppdbide.utils.VariableRunLine; import org.opengauss.mppdbide.utils.loader.MessageConfigLoader; +import org.opengauss.mppdbide.utils.logger.MPPDBIDELoggerUtility; import org.opengauss.mppdbide.view.core.sourceeditor.BreakpointAnnotation; import org.opengauss.mppdbide.view.coverage.CoverageService; import org.opengauss.mppdbide.view.prefernces.PreferenceWrapper; -import org.opengauss.mppdbide.view.service.CoverageServiceFactory; +import org.opengauss.mppdbide.view.utils.dialog.MPPDBIDEDialogs; +import org.opengauss.mppdbide.view.utils.dialog.MPPDBIDEDialogs.MESSAGEDIALOGTYPE; /** * Title: class @@ -50,7 +55,6 @@ public class DebugServiceHelper { private static DebugServiceHelper debugServiceHelper = new DebugServiceHelper(); private IDebugObject debugObject = null; private ServiceFactory serviceFactory = null; - private CoverageServiceFactory coverageServiceFactory = null; private WrappedDebugService debugService = null; private DebuggerReportService debuggerReportService = null; private FunctionVo functionVo = null; @@ -84,17 +88,18 @@ public class DebugServiceHelper { if (!isCommonDatabase(debugObject)) { IConnectionProvider provider = new DBConnectionProvider(debugObject.getDatabase()); serviceFactory = new ServiceFactory(provider); - coverageServiceFactory = new CoverageServiceFactory(provider); checkSupportDebug(); + checkDebugVersion(provider); queryService = serviceFactory.getQueryService(); functionVo = queryService.queryFunction(debugObject.getName()); - debuggerReportService = DebuggerReportService.getInstance(); - debuggerReportService.setAttr(provider, functionVo); debugService = new WrappedDebugService(serviceFactory.getDebugService(functionVo)); debugService.addHandler(new UiEventHandler()); debugService.addHandler(new DebugEventHandler()); + debuggerReportService = DebuggerReportService.getInstance(); + if (!VariableRunLine.isPldebugger) { + debuggerReportService.setAttr(provider, functionVo); + } codeService = serviceFactory.getCodeService(); - coverageService = coverageServiceFactory.getCoverageService(); Optional sourceCode = queryService.getSourceCode(functionVo.oid); if (sourceCode.isPresent()) { codeService.setBaseCode(sourceCode.get().getSourceCode()); @@ -158,11 +163,15 @@ public class DebugServiceHelper { return queryService; } + /** + * description: get coverage service + * + * @return CoverageService the coverage service + */ public CoverageService getCoverageService() { return coverageService; } - /** * description: get code service * @@ -250,6 +259,24 @@ public class DebugServiceHelper { } } + private void checkDebugVersion(IConnectionProvider provider) throws SQLException { + IConnection conn = null; + try { + conn = provider.getValidFreeConnection(); + VariableRunLine.isPldebugger = VersionHelper.getDebuggerVersion(conn).isPldebugger(); + } catch (SQLException e) { + MPPDBIDEDialogs.generateOKMessageDialog(MESSAGEDIALOGTYPE.INFORMATION, true, + MessageConfigLoader.getProperty(IMessagesConstants.EXECDIALOG_HINT), + MessageConfigLoader.getProperty(IMessagesConstants.VERSION_CHECK_FAIL)); + MPPDBIDELoggerUtility.error(e.getMessage()); + return; + } finally { + if (conn != null) { + conn.close(); + } + } + } + private static boolean getRollbackPreference() { PreferenceStore store = PreferenceWrapper.getInstance().getPreferenceStore(); if (store != null) { @@ -278,4 +305,10 @@ public class DebugServiceHelper { IMessagesConstants.DEBUG_NOT_SUPPORT_WARN); } } + + void closeDbConn() { + queryService.closeService(); + debuggerReportService.close(); + debugService.closeService(); + } } diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/StartDebugHandler.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/StartDebugHandler.java index 4573e93e87256eca7c6896cc8482f7d80c81ae51..dfbef0da4c88f36c07791e1a88146ff1c8e1909d 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/StartDebugHandler.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/StartDebugHandler.java @@ -85,6 +85,7 @@ public class StartDebugHandler { } catch (SQLException sqlExp) { MPPDBIDELoggerUtility.warn("create servicefactory with error:" + sqlExp.getMessage()); showMsg(sqlExp.getLocalizedMessage()); + serviceHelper.closeDbConn(); return; } plSourceEditor.setExecuteInProgress(true); diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/chain/ServerExitChain.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/chain/ServerExitChain.java index 7fd9878197eb53cbee686e84580bdba32cc80e82..dfa647b59e17848bd60fa03cfc92b13f8096c12d 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/chain/ServerExitChain.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/chain/ServerExitChain.java @@ -59,8 +59,10 @@ public class ServerExitChain extends IMsgChain { Display.getDefault().asyncExec(new UpdateDebugPositionTask(-1)); Display.getDefault().asyncExec(new UpdateHighlightLineNumTask()); - if (!VariableRunLine.isPldebugger) { - reportService.makeReport(); + if (VariableRunLine.isPldebugger != null && !VariableRunLine.isPldebugger) { + if (!event.hasException()) { + reportService.makeReport(); + } if (VariableRunLine.isContinue != null && VariableRunLine.isContinue) { Display.getDefault().asyncExec(() -> UpdateDebugPositionTask.continueDebug()); } diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/ui/UpdateDebugPositionTask.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/ui/UpdateDebugPositionTask.java index 1e266c026b3869b19a161952b2f42ee0488ae49b..ee8b306bf3951927b5029af3a4915ecb4d8efb90 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/ui/UpdateDebugPositionTask.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/handler/debug/ui/UpdateDebugPositionTask.java @@ -16,18 +16,17 @@ package org.opengauss.mppdbide.view.handler.debug.ui; import java.util.Arrays; -import java.util.HashSet; import java.util.List; -import java.util.Locale; -import java.util.Set; +import java.util.Map; import org.eclipse.jface.text.BadLocationException; +import org.opengauss.mppdbide.bl.serverdatacache.IDebugObject; +import org.opengauss.mppdbide.common.DbeCommonUtils; import org.opengauss.mppdbide.debuger.service.SourceCodeService; +import org.opengauss.mppdbide.debuger.service.SourceCodeService.CodeDescription; import org.opengauss.mppdbide.debuger.vo.VersionVo; import org.opengauss.mppdbide.utils.DebuggerStartVariable; import org.opengauss.mppdbide.utils.VariableRunLine; -import org.opengauss.mppdbide.utils.exceptions.DatabaseCriticalException; -import org.opengauss.mppdbide.utils.exceptions.DatabaseOperationException; import org.opengauss.mppdbide.utils.exceptions.MPPDBIDEException; import org.opengauss.mppdbide.utils.logger.MPPDBIDELoggerUtility; import org.opengauss.mppdbide.view.core.sourceeditor.SQLSyntaxColorProvider; @@ -41,10 +40,6 @@ import org.opengauss.mppdbide.view.utils.UIElement; * @since 3.0.0 */ public class UpdateDebugPositionTask implements Runnable { - private static final String BEGIN = "BEGIN"; - - private static final String END = "END;"; - private int showLine = -1; /** @@ -54,7 +49,9 @@ public class UpdateDebugPositionTask implements Runnable { */ public UpdateDebugPositionTask(int showLine) { this.showLine = showLine; - VariableRunLine.passLine.add(showLine); + if (showLine != -1) { + VariableRunLine.passLine.add(showLine); + } } @Override @@ -76,7 +73,7 @@ public class UpdateDebugPositionTask implements Runnable { } else { // dbedebugger if (VariableRunLine.isTerminate) { - debDebuggerRemark(plSourceEditor); + dbeDebuggerRemark(plSourceEditor); } } } catch (MPPDBIDEException e) { @@ -120,8 +117,12 @@ public class UpdateDebugPositionTask implements Runnable { MPPDBIDELoggerUtility.error(e.getMessage()); } PLSourceEditor pl = terminateDebug(); - getToatlLineNo(pl).forEach(item -> { + String code = pl.getDebugObject().getSourceCode().getCode(); + List list = DbeCommonUtils.getBreakLines(DbeCommonUtils.infoCodes, + SourceCodeService.CodeDescription.getLines(code)); + list.forEach(core -> { try { + Integer item = Integer.parseInt(core); if (VariableRunLine.runList.contains(String.valueOf(item))) { pl.createPassPosition(item); } else { @@ -149,14 +150,17 @@ public class UpdateDebugPositionTask implements Runnable { } } - private void debDebuggerRemark(PLSourceEditor plSourceEditor) { - plSourceEditor.removeDebugPosition(); + private void dbeDebuggerRemark(PLSourceEditor pl) { + pl.removeDebugPosition(); try { - remarkBack(plSourceEditor); - if (showLine >= 0) { - plSourceEditor.createDebugPosition(showLine); + remarkBack(pl); + IDebugObject iDebugObject = pl.getDebugObject(); + String code = iDebugObject.getSourceCode().getCode(); + Map map = DbeCommonUtils.getBeginToEndLineNo(CodeDescription.getLines(code)); + if (showLine >= map.get(DbeCommonUtils.BEGIN) && map.get(DbeCommonUtils.END) >= showLine) { + pl.createDebugPosition(showLine); } - remark(showLine, plSourceEditor); + remark(showLine, pl); } catch (BadLocationException e) { MPPDBIDELoggerUtility.error("set debugPostion at " + showLine + " failed,err=" + e.getMessage()); } catch (Exception e) { @@ -165,8 +169,11 @@ public class UpdateDebugPositionTask implements Runnable { } private void remark(int line, PLSourceEditor plSourceEditor) { - getToatlLineNo(plSourceEditor).forEach(item -> { + String code = plSourceEditor.getDebugObject().getSourceCode().getCode(); + List list = DbeCommonUtils.getBreakLines(DbeCommonUtils.infoCodes, CodeDescription.getLines(code)); + list.forEach(core -> { try { + Integer item = Integer.parseInt(core); if (showLine != item && VariableRunLine.passLine.contains(item)) { plSourceEditor.createPassPosition(item); } else { @@ -179,47 +186,4 @@ public class UpdateDebugPositionTask implements Runnable { } }); } - - /** - * The get Toatl LineNo - * - * @param plSourceEditor the source editor - * @return the value for function - */ - public static Set getToatlLineNo(PLSourceEditor plSourceEditor) { - Set record = new HashSet<>(); - int begin = -1; - int end = -1; - ; - try { - String sourceCode = plSourceEditor.getDebugObject().getLatestSouceCode().getCode(); - List total = SourceCodeService.CodeDescription.getLines(sourceCode); - - for (int i = 0; i < total.size(); i++) { - String code = total.get(i); - if (code.toUpperCase(Locale.ENGLISH).trim().startsWith(BEGIN)) { - begin = i; - } - if (code.toUpperCase(Locale.ENGLISH).trim().startsWith(END)) { - end = i; - break; - } - } - Boolean isFlag = true; - int beg = begin; - while (isFlag && begin != -1 && end != -1 && begin < end) { - int val = ++beg; - if (val == end) { - break; - } - record.add(val); - if (val + 1 == end) { - isFlag = false; - } - } - } catch (DatabaseOperationException | DatabaseCriticalException e) { - MPPDBIDELoggerUtility.error(e.getMessage()); - } - return record; - } } diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/service/CoverageServiceFactory.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/service/CoverageServiceFactory.java index 8d95796e39fa30c50a799cde0c4d867587ec5e36..9093ee899742392a374920a93c8476cea83442a0 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/service/CoverageServiceFactory.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/service/CoverageServiceFactory.java @@ -16,9 +16,11 @@ package org.opengauss.mppdbide.view.service; import java.sql.SQLException; +import java.util.Optional; import org.opengauss.mppdbide.common.IConnection; import org.opengauss.mppdbide.common.IConnectionProvider; +import org.opengauss.mppdbide.utils.VariableRunLine; import org.opengauss.mppdbide.view.coverage.CoverageService; /** @@ -39,13 +41,16 @@ public class CoverageServiceFactory { * @return the value * @throws SQLException the exception */ - public CoverageService getCoverageService() throws SQLException { + public Optional getCoverageService() throws SQLException { return createCoverageService(provider.getValidFreeConnection()); } - private static CoverageService createCoverageService(IConnection conn) { + private static Optional createCoverageService(IConnection conn) { + if (VariableRunLine.isPldebugger != null && VariableRunLine.isPldebugger) { + return Optional.empty(); + } CoverageService service = new CoverageService(); service.setConn(conn); - return service; + return Optional.of(service); } } diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/ui/CoverageHistory.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/ui/CoverageHistory.java index e5cfbb60f7993c60c21fb239fb74e67f1b6376c8..73cbd5d19a1779d3652773be0632dd40a0cde31b 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/ui/CoverageHistory.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/ui/CoverageHistory.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -75,8 +76,10 @@ public class CoverageHistory extends Dialog { private static final int REMARK_LINE = 4; private static final int REMARK_RUM_LINE_NUM = 5; private static final int REMARK_COVERAGE = 6; - private static final int UPDATE_TIME = 7; + private static final int INPUT_PARAMS = 7; + private static final int UPDATE_TIME = 8; + private String sqlName = null; private Table table = null; private ToolItem saveToolItem = null; private ToolItem deleteToolItem = null; @@ -141,6 +144,9 @@ public class CoverageHistory extends Dialog { TableColumn remarkCoverage = new TableColumn(table, SWT.LEFT); remarkCoverage.setText(org.opengauss.mppdbide.utils.loader.MessageConfigLoader.getProperty( IMessagesConstants.REMARK_COVERAGE)); + TableColumn inputParams = new TableColumn(table, SWT.LEFT); + inputParams.setText(org.opengauss.mppdbide.utils.loader.MessageConfigLoader.getProperty( + IMessagesConstants.INPUT_PARAMS)); TableColumn updateTime = new TableColumn(table, SWT.LEFT); updateTime.setText(org.opengauss.mppdbide.utils.loader.MessageConfigLoader.getProperty( IMessagesConstants.UPDATE_TIME)); @@ -149,9 +155,10 @@ public class CoverageHistory extends Dialog { totalRunLineNum.pack(); totalCoverage.pack(); remarkCoverage.pack(); + inputParams.setWidth(150); updateTime.setWidth(150); - remarkLine.setWidth(200); - remarkRunLineNum.setWidth(200); + remarkLine.setWidth(150); + remarkRunLineNum.setWidth(150); displaySqlHistoryObject(); mainSc.setExpandHorizontal(true); mainSc.setExpandVertical(true); @@ -168,7 +175,7 @@ public class CoverageHistory extends Dialog { protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(MessageConfigLoader.getProperty(IMessagesConstants.COVERAGE_HISTORY_TITLE, profileName)); - shell.setImage(IconUtility.getIconImage(IiconPath.SQL_HISTORY1, this.getClass())); + shell.setImage(IconUtility.getIconImage(IiconPath.ICON_COVERAGE, this.getClass())); shell.setSize(1000, 750); } @@ -178,18 +185,21 @@ public class CoverageHistory extends Dialog { public void displaySqlHistoryObject() { PLSourceEditor pl = UIElement.getInstance().getVisibleSourceViewer(); long oid = pl.getDebugObject().getOid(); + sqlName = pl.getDebugObject().getName(); coverageServiceFactory = new CoverageServiceFactory( new DBConnectionProvider(pl.getDebugObject().getDatabase())); - CoverageService coverageService = null; + Optional coverageService = Optional.empty(); try { coverageService = coverageServiceFactory.getCoverageService(); - List ls = coverageService.getCoverageInfoByOid(oid); - setInput(ls); + if (coverageService.isPresent()) { + List ls = coverageService.get().getCoverageInfoByOid(oid); + setInput(ls); + } } catch (SQLException e) { MPPDBIDELoggerUtility.error(e.getMessage()); } finally { - if (coverageService != null) { - coverageService.closeService(); + if (coverageService.isPresent()) { + coverageService.get().closeService(); } } } @@ -222,6 +232,7 @@ public class CoverageHistory extends Dialog { row.setText(REMARK_LINE, String.valueOf(item.remarkLinesArr)); row.setText(REMARK_RUM_LINE_NUM, String.valueOf(item.remarkCoverageLinesArr)); row.setText(REMARK_COVERAGE, String.valueOf(item.remarkPercent)); + row.setText(INPUT_PARAMS, item.params); row.setText(UPDATE_TIME, item.parseDate()); } @@ -247,7 +258,7 @@ public class CoverageHistory extends Dialog { private void createToolbar(final Composite parent) { final ToolBar bar = new ToolBar(parent, SWT.FLAT | SWT.FOCUSED); - final Image sqlcloseIcon = IconUtility.getIconImage(IiconPath.LOAD_QUERY_SQL, getClass()); + final Image sqlcloseIcon = IconUtility.getIconImage(IiconPath.ICO_EXPORT_CURRENT_PAGE, getClass()); saveToolItem = new ToolItem(bar, SWT.PUSH); saveToolItem.setEnabled(false); saveToolItem.setImage(sqlcloseIcon); @@ -328,20 +339,13 @@ public class CoverageHistory extends Dialog { List list = getData(item); serialNum = String.valueOf(index + 1); list.add(0, serialNum); - Map code = getCode(vo.sourceCode); - ExportParamVo expVo = new ExportParamVo(); - expVo.oid = vo.oid; - expVo.index = serialNum; - expVo.executeSql = code; - expVo.remarkLines = vo.remarkLinesArr.stream().collect(Collectors.toSet()); - expVo.coveragePassLines = vo.coverageLinesArr.stream().collect(Collectors.toSet()); - expVo.list = list; + ExportParamVo expVo = getExportParamVo(vo, list, serialNum); if (isFlag) { - html = ExportUtil.exportReport(expVo); + html = ExportUtil.exportReport(expVo, sqlName); isFlag = false; } else { expVo.html = html; - html = ExportUtil.exportReport(expVo); + html = ExportUtil.exportReport(expVo, sqlName); } } try { @@ -360,6 +364,19 @@ public class CoverageHistory extends Dialog { } } + private ExportParamVo getExportParamVo(CoverageVo vo, List list, String serialNum) { + Map code = getCode(vo.sourceCode); + ExportParamVo expVo = new ExportParamVo(); + expVo.oid = vo.oid; + expVo.index = serialNum; + expVo.executeSql = code; + expVo.remarkLines = vo.remarkLinesArr.stream().collect(Collectors.toSet()); + expVo.coveragePassLines = vo.coverageLinesArr.stream().collect(Collectors.toSet()); + expVo.list = list; + expVo.canBreakLine = vo.canBreakLine; + return expVo; + } + private Map getCode(String sourceCode) { Map code = new HashMap(); List codes = SourceCodeService.CodeDescription.getLines(sourceCode); @@ -414,7 +431,7 @@ public class CoverageHistory extends Dialog { if (counter != 0) { CoverageService[] service = new CoverageService[1]; try { - service[0] = coverageServiceFactory.getCoverageService(); + service[0] = coverageServiceFactory.getCoverageService().get(); historyItems.forEach(item -> { service[0].delCoverageInfoByOid(item.oid, item.cid); }); diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/utils/ExportUtil.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/utils/ExportUtil.java index b1760198b01456bcd3db412d0eab5657eb4beabd..64625203f596136ec0960d52ecc01671a7540874 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/utils/ExportUtil.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/utils/ExportUtil.java @@ -20,7 +20,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.net.URL; -import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.Map; @@ -30,8 +30,11 @@ import org.eclipse.core.runtime.FileLocator; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; +import org.opengauss.mppdbide.common.DbeCommonUtils; import org.opengauss.mppdbide.debuger.vo.dbe.ExportParamVo; +import org.opengauss.mppdbide.utils.IMessagesConstantsOne; import org.opengauss.mppdbide.utils.MPPDBIDEConstants; +import org.opengauss.mppdbide.utils.loader.MessageConfigLoader; import org.opengauss.mppdbide.utils.logger.MPPDBIDELoggerUtility; /** @@ -55,17 +58,19 @@ public final class ExportUtil { * exportReport * * @param vo the vo + * @param sqlName the sqlName * @return the value */ - public static String exportReport(ExportParamVo vo) { + public static String exportReport(ExportParamVo vo, String sqlName) { long oid = vo.oid; Map executeSql = vo.executeSql; List list = vo.list; String html = vo.html; URL url = getUrl("exportTemplate.html"); Document parse = null; - parse = getText(html, url, oid); - List offset = getOffset(executeSql); + parse = getText(html, url, oid, sqlName); + Map offset = DbeCommonUtils.getBeginToEndLineNo( + executeSql.values().stream().collect(Collectors.toList())); Element data = parse.getElementById("data"); Element datatr = data.appendElement("tr"); list.forEach(item -> { @@ -92,10 +97,12 @@ public final class ExportUtil { if (vo.remarkLines.contains(k.toString())) { td2.addClass("bac_remark"); } - if (vo.coveragePassLines.contains((k - 1) + "")) { + boolean isCanBreak = Arrays.asList(vo.canBreakLine.split(",")).contains(String.valueOf(k)); + if (vo.coveragePassLines.contains((k - 1) + "") && isCanBreak) { div.addClass("bac_pass"); } else { - if (k > (offset.get(0) + 1) && k < (offset.get(1) + 1)) { + if (k > (offset.get(DbeCommonUtils.BEGIN) + 1) && k < (offset.get(DbeCommonUtils.END) + 1) + && isCanBreak) { div.addClass("bac_fail"); } } @@ -114,16 +121,18 @@ public final class ExportUtil { return classLoader.getResource(messageFileName); } - private static Document getText(String html, URL url, long oid) { + private static Document getText(String html, URL url, long oid, String sqlName) { Document parse = null; try { if (html == null) { String path = FileLocator.toFileURL(url).getPath().substring(1); file = new File(path); - String workDirectory = System.getProperty("user.dir"); - String fileSeparator = System.getProperty("file.separator"); - outpath = workDirectory + fileSeparator + oid + "_" + System.currentTimeMillis() + ".html"; + String workDir = System.getProperty("user.dir"); + String fileSepa = System.getProperty("file.separator"); + outpath = String.format(Locale.ENGLISH, "%s%s%s_%s_%s.html", + workDir, fileSepa, oid, sqlName, System.currentTimeMillis()); parse = Jsoup.parse(file, "gbk"); + convertZhCn(parse); } else { parse = Jsoup.parse(html); } @@ -133,24 +142,31 @@ public final class ExportUtil { return parse; } - private static List getOffset(Map executeSql) { - int begin = -1; - int end = -1; - List val = executeSql.values().stream().collect(Collectors.toList()); - for (int i = 0; i < val.size(); i++) { - String code = val.get(i); - if (code.toUpperCase(Locale.ENGLISH).trim().startsWith("BEGIN")) { - begin = i; - } - if (code.toUpperCase(Locale.ENGLISH).trim().startsWith("END;")) { - end = i; - break; - } + private static void convertZhCn(Document parse) { + String locale = Locale.getDefault().toString(); + if (!locale.equals(MPPDBIDEConstants.CHINESE_LOCALE)) { + return; } - List list = new ArrayList<>(); - list.add(begin); - list.add(end); - return list; + Element execStatement = parse.getElementById(IMessagesConstantsOne.EXP_EXECUTE_STATEMENT); + execStatement.text(MessageConfigLoader.getProperty(IMessagesConstantsOne.EXP_EXECUTE_STATEMENT)); + Element searialNum = parse.getElementById(IMessagesConstantsOne.EXP_SERIAL_NUMBER); + searialNum.text(MessageConfigLoader.getProperty(IMessagesConstantsOne.EXP_SERIAL_NUMBER)); + Element totalRows = parse.getElementById(IMessagesConstantsOne.EXP_TOTAL_ROWS); + totalRows.text(MessageConfigLoader.getProperty(IMessagesConstantsOne.EXP_TOTAL_ROWS)); + Element runLines = parse.getElementById(IMessagesConstantsOne.EXP_TOTAL_RUNNING_LINES); + runLines.text(MessageConfigLoader.getProperty(IMessagesConstantsOne.EXP_TOTAL_RUNNING_LINES)); + Element totalCoverage = parse.getElementById(IMessagesConstantsOne.EXP_TOTAL_COVERAGE); + totalCoverage.text(MessageConfigLoader.getProperty(IMessagesConstantsOne.EXP_TOTAL_COVERAGE)); + Element markRow = parse.getElementById(IMessagesConstantsOne.EXP_MARK_ROW); + markRow.text(MessageConfigLoader.getProperty(IMessagesConstantsOne.EXP_MARK_ROW)); + Element execLine = parse.getElementById(IMessagesConstantsOne.EXP_MARK_EXECUTION_LINE); + execLine.text(MessageConfigLoader.getProperty(IMessagesConstantsOne.EXP_MARK_EXECUTION_LINE)); + Element markCoverage = parse.getElementById(IMessagesConstantsOne.EXP_MARKER_COVERAGE); + markCoverage.text(MessageConfigLoader.getProperty(IMessagesConstantsOne.EXP_MARKER_COVERAGE)); + Element inputParams = parse.getElementById(IMessagesConstantsOne.EXP_INPUT_PARAMS); + inputParams.text(MessageConfigLoader.getProperty(IMessagesConstantsOne.EXP_INPUT_PARAMS)); + Element updateTime = parse.getElementById(IMessagesConstantsOne.EXP_UPDATE_TIME); + updateTime.text(MessageConfigLoader.getProperty(IMessagesConstantsOne.EXP_UPDATE_TIME)); } /** diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/utils/icon/IiconPath.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/utils/icon/IiconPath.java index beb042185c89d5ec495fca94855535e1dd0e4605..5d130a88d258b39f8127e5ec58aa97124a0bd0b2 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/utils/icon/IiconPath.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/utils/icon/IiconPath.java @@ -994,4 +994,9 @@ public interface IiconPath { * The icon remark coverage */ String ICON_REMARK_COVERAGE = "icon-remarkCoverage.png"; + + /** + * The icon remark coverage + */ + String ICON_COVERAGE = PRE_DEBUG_PATH + "breakpoint_indicate.png"; } diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/vo/CoverageVo.java b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/vo/CoverageVo.java index bcca7798bcd15cf84ca4704eae0e869cbe7dd95c..c1422c272d2b3936c3c852b018b25ac5ebb3038f 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/vo/CoverageVo.java +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/org/opengauss/mppdbide/view/vo/CoverageVo.java @@ -116,6 +116,17 @@ public class CoverageVo { @DumpFiled public String params; + /** + * the name + */ + public String name; + + /** + * the canBreakLine + */ + @DumpFiled + public String canBreakLine; + private final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/resources/exportTemplate.html b/code/datastudio/src/org.opengauss.mppdbide.view/src/resources/exportTemplate.html index 89c325daa94d4111241f9f447c3afacc73a103e3..5b6724875545f7a05b5ce63e1eab479e0aaf9c44 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/resources/exportTemplate.html +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/resources/exportTemplate.html @@ -13,15 +13,15 @@ - - - - + + + + - - + + - + diff --git a/code/datastudio/src/org.opengauss.mppdbide.view/src/resources/exportTemplate_zh_CN.html b/code/datastudio/src/org.opengauss.mppdbide.view/src/resources/exportTemplate_zh_CN.html index 51f5b1fd143a1b0a8a1e276cb75e096f390c6864..ecc5be21d5f2a5e08c8c62bfc408bdea3abc2f76 100644 --- a/code/datastudio/src/org.opengauss.mppdbide.view/src/resources/exportTemplate_zh_CN.html +++ b/code/datastudio/src/org.opengauss.mppdbide.view/src/resources/exportTemplate_zh_CN.html @@ -4,7 +4,7 @@
Serial numberTotal rowsNumber of execution linesTotal coverageSerial NumberTotal RowsTotal Running LinesTotal Coverage Mark RowMark execution lineMarker coverageMark Execution LineMarker Coverage Input ParamsEnd timeUpdate Time
- + @@ -13,15 +13,15 @@
执行语句
- - - - - - - - - + + + + + + + + + diff --git a/code/datastudio/testcode/LLT/org.opengauss.mppdbide.bl.debug.test.fragment/src/org/opengauss/mppdbide/bl/test/debug/DbeDebugerTest.java b/code/datastudio/testcode/LLT/org.opengauss.mppdbide.bl.debug.test.fragment/src/org/opengauss/mppdbide/bl/test/debug/DbeDebugerTest.java index bacebff1f83fe9c6b360c504df4ec33b326b5169..fe8feb5b7f6447125662e10c80b5be36cdd9ff3c 100644 --- a/code/datastudio/testcode/LLT/org.opengauss.mppdbide.bl.debug.test.fragment/src/org/opengauss/mppdbide/bl/test/debug/DbeDebugerTest.java +++ b/code/datastudio/testcode/LLT/org.opengauss.mppdbide.bl.debug.test.fragment/src/org/opengauss/mppdbide/bl/test/debug/DbeDebugerTest.java @@ -32,6 +32,7 @@ import org.junit.Before; import org.junit.Test; import org.opengauss.mppdbide.bl.mock.debug.DebugerJdbcTestCaseBase; import org.opengauss.mppdbide.bl.mock.debug.MockDebugServiceHelper; +import org.opengauss.mppdbide.common.DbeCommonUtils; import org.opengauss.mppdbide.common.IConnectionProvider; import org.opengauss.mppdbide.debuger.debug.DebugConstants.DebugOpt; import org.opengauss.mppdbide.debuger.debug.DebugState; @@ -119,8 +120,8 @@ public class DbeDebugerTest extends DebugerJdbcTestCaseBase { mockHelper.mockDbeInfoCode("select * from DBE_PLDEBUGGER.info_code(?)"); try { Optional sourceCode = queryService.getSourceCode(functionVo.oid); - SourceCodeService.CodeDescription.getRunLines(sourceCode.get().getSourceCode()); - SourceCodeService.CodeDescription.getRunLinesNums(sourceCode.get().getSourceCode()); + DbeCommonUtils.getBeginToEndLineNo( + SourceCodeService.CodeDescription.getLines(sourceCode.get().getSourceCode())); } catch (SQLException e) { fail("get breakpoints failed!"); } diff --git a/information/datastudio/Data Studio User Manual.pdf b/information/datastudio/Data Studio User Manual.pdf index e7cae1b1f8d3b9fb53d28124bbca857b53c45be4..dd01dee80271bee1766c4ea094562a1121f4581b 100644 Binary files a/information/datastudio/Data Studio User Manual.pdf and b/information/datastudio/Data Studio User Manual.pdf differ diff --git "a/information/datastudio/Data Studio \347\224\250\346\210\267\346\211\213\345\206\214.pdf" "b/information/datastudio/Data Studio \347\224\250\346\210\267\346\211\213\345\206\214.pdf" index a027832b1806141db744138a72dab7ad0048894d..ea5abac83a996b8414999f362f5ac932d6bcae5a 100644 Binary files "a/information/datastudio/Data Studio \347\224\250\346\210\267\346\211\213\345\206\214.pdf" and "b/information/datastudio/Data Studio \347\224\250\346\210\267\346\211\213\345\206\214.pdf" differ
序号总行数执行行数总覆盖率标记行标记执行行标记覆盖率入参结束时间