From 4138eb18275ce304595383347bf37e17b6232029 Mon Sep 17 00:00:00 2001 From: lihangyu <15605149486@163.com> Date: Fri, 18 Oct 2024 00:00:40 +0800 Subject: [PATCH] [regression-test](suites) use master ip to do server side prepared (#41981) --- .../org/apache/doris/qe/StmtExecutor.java | 6 ++++-- .../doris/regression/suite/Suite.groovy | 20 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java index 5a36875140f6cb..5d8699d6b942b6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java @@ -711,7 +711,8 @@ private void executeByNereids(TUniqueId queryId) throws Exception { if (logicalPlan instanceof InsertIntoTableCommand) { profileType = ProfileType.LOAD; } - if (context.getCommand() == MysqlCommand.COM_STMT_PREPARE) { + if (context.getCommand() == MysqlCommand.COM_STMT_PREPARE + || context.getCommand() == MysqlCommand.COM_STMT_EXECUTE) { throw new UserException("Forward master command is not supported for prepare statement"); } if (isProxy) { @@ -987,7 +988,8 @@ public void executeByLegacy(TUniqueId queryId) throws Exception { profileType = ProfileType.LOAD; } } - if (context.getCommand() == MysqlCommand.COM_STMT_PREPARE) { + if (context.getCommand() == MysqlCommand.COM_STMT_PREPARE + || context.getCommand() == MysqlCommand.COM_STMT_EXECUTE) { throw new UserException("Forward master command is not supported for prepare statement"); } if (isProxy) { diff --git a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy index ba053aec1dd322..e9e8fc258d8a73 100644 --- a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy +++ b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy @@ -472,6 +472,24 @@ class Suite implements GroovyInterceptable { return res; } + String getMasterIp(Connection conn) { + def result = sql_return_maparray_impl("select Host, QueryPort, IsMaster from frontends();", conn) + logger.info("get master fe: ${result}") + + def masterHost = "" + for (def row : result) { + if (row.IsMaster == "true") { + masterHost = row.Host + break + } + } + + if (masterHost == "") { + throw new Exception("can not find master fe") + } + return masterHost; + } + def jdbc_sql_return_maparray(String sqlStr) { return sql_return_maparray_impl(sqlStr, context.getConnection()) } @@ -1292,7 +1310,7 @@ class Suite implements GroovyInterceptable { String getServerPrepareJdbcUrl(String jdbcUrl, String database) { String urlWithoutSchema = jdbcUrl.substring(jdbcUrl.indexOf("://") + 3) - def sql_ip = urlWithoutSchema.substring(0, urlWithoutSchema.indexOf(":")) + def sql_ip = getMasterIp() def sql_port if (urlWithoutSchema.indexOf("/") >= 0) { // e.g: jdbc:mysql://locahost:8080/?a=b