Skip to content

Commit

Permalink
fix(db):miss quote of pl name which contains @ causes pl edit failed #…
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiacj authored Jan 2, 2025
1 parent 76d11f4 commit a168699
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.oceanbase.odc.service.session.model.SqlAsyncExecuteResp;
import com.oceanbase.odc.service.session.model.SqlExecuteResult;
import com.oceanbase.tools.dbbrowser.model.DBObjectType;
import com.oceanbase.tools.dbbrowser.util.MySQLSqlBuilder;

import lombok.NonNull;

Expand Down Expand Up @@ -103,22 +104,21 @@ private EditPLResp executeWrappedEditPL(String sessionId, EditPLReq editPLReq,
String escapeRegexPlName = StringUtils.escapeRegex(plName)
.orElseThrow(() -> new IllegalStateException(String.format("%s name cannot be null", plType)));
String tempPLSql = editPLSql.replaceFirst(escapeRegexPlName, tempPlName);
StringBuilder wrappedSqlBuilder = new StringBuilder();
MySQLSqlBuilder wrappedSqlBuilder = new MySQLSqlBuilder();
ConnectionSession connectionSession = sessionService.nullSafeGet(sessionId, true);
SqlCommentProcessor processor = ConnectionSessionUtil.getSqlCommentProcessor(connectionSession);
String delimiter = processor.getDelimiter();
wrappedSqlBuilder.append("DELIMITER $$\n")
.append(tempPLSql).append(" $$\n")
.append("drop ").append(plType).append(" if exists ").append(tempPlName).append(" $$\n")
.append("drop ").append(plType).append(" if exists ").append(plName).append(" $$\n")
.append("drop ").append(plType).append(" if exists ").identifier(tempPlName).append(" $$\n")
.append("drop ").append(plType).append(" if exists ").identifier(plName).append(" $$\n")
.append(editPLSql).append(" $$\n")
.append("DELIMITER " + delimiter);
String wrappedSql = wrappedSqlBuilder.toString();
SqlAsyncExecuteReq sqlAsyncExecuteReq = new SqlAsyncExecuteReq();
sqlAsyncExecuteReq.setSql(wrappedSql);
sqlAsyncExecuteReq.setSplit(true);
sqlAsyncExecuteReq.setContinueExecutionOnError(false);

Lock editPLLock = obtainEditPLLock(connectionSession, plType);
if (!editPLLock.tryLock(LOCK_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
throw new ConflictException(ErrorCodes.ResourceModifying, "Can not acquire jdbc lock");
Expand Down

0 comments on commit a168699

Please sign in to comment.