Skip to content

Commit

Permalink
[regression-test](suites) use master ip to do server side prepared (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
eldenmoon committed Oct 21, 2024
1 parent 60636c8 commit 4138eb1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4138eb1

Please sign in to comment.