[Pick](PreparedStatement) allow prepare mysql command in Nerids even … (#39960)

…if enableServeSidePreparedStatement is false to avoid fallback to
legacy planner

backport #39465
This commit is contained in:
lihangyu
2024-08-27 14:58:28 +08:00
committed by GitHub
parent b7e0bfa1c2
commit bf7675dc94
3 changed files with 11 additions and 6 deletions

View File

@ -412,6 +412,9 @@ public class ConnectContext {
}
public void addPreparedStatementContext(String stmtName, PreparedStatementContext ctx) throws UserException {
if (!sessionVariable.enableServeSidePreparedStatement) {
throw new UserException("Failed to do prepared command, server side prepared statement is disabled");
}
if (this.preparedStatementContextMap.size() > sessionVariable.maxPreparedStmtCount) {
throw new UserException("Failed to create a server prepared statement"
+ "possibly because there are too many active prepared statements on server already."

View File

@ -227,13 +227,8 @@ public abstract class ConnectProcessor {
Exception nereidsParseException = null;
long parseSqlStartTime = System.currentTimeMillis();
List<StatementBase> cachedStmts = null;
// Currently we add a config to decide whether using PREPARED/EXECUTE command for nereids
// TODO: after implemented full prepared, we could remove this flag
boolean nereidsUseServerPrep = (sessionVariable.enableServeSidePreparedStatement
&& !sessionVariable.isEnableInsertGroupCommit())
|| mysqlCommand == MysqlCommand.COM_QUERY;
CacheKeyType cacheKeyType = null;
if (nereidsUseServerPrep && sessionVariable.isEnableNereidsPlanner()) {
if (!sessionVariable.isEnableInsertGroupCommit() && sessionVariable.isEnableNereidsPlanner()) {
if (wantToParseSqlFromSqlCache) {
cachedStmts = parseFromSqlCache(originStmt);
Optional<SqlCacheContext> sqlCacheContext = ConnectContext.get()