Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eldenmoon committed Dec 26, 2024
1 parent 20e9098 commit d2ed545
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ public enum TableFrom {

private boolean isDpHyp = false;

// Check if doing prepared statement with nondeterministic functions
private boolean hasNondeterministicInPreparedStatement = false;
private boolean hasNondeterministic = false;

// hasUnknownColStats true if any column stats in the tables used by this sql is unknown
// the algorithm to derive plan when column stats are unknown is implemented in cascading framework, not in dphyper.
Expand Down Expand Up @@ -309,12 +308,12 @@ public void setConnectContext(ConnectContext connectContext) {
this.connectContext = connectContext;
}

public void setHasNondeterministicInPreparedStatement(boolean hasNondeterministic) {
this.hasNondeterministicInPreparedStatement = hasNondeterministic;
public void setHasNondeterministic(boolean hasNondeterministic) {
this.hasNondeterministic = hasNondeterministic;
}

public boolean hasNondeterministicInPreparedStatement() {
return hasNondeterministicInPreparedStatement;
public boolean hasNondeterministic() {
return hasNondeterministic;
}

public ConnectContext getConnectContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,9 @@ public Expression visitUnboundFunction(UnboundFunction unboundFunction, Expressi
buildResult.second.checkOrderExprIsValid();
Optional<SqlCacheContext> sqlCacheContext = Optional.empty();

// If it is prepared statement in EXECUTE phase, record nonDeterministic info
if (ConnectContext.get() != null && ConnectContext.get().getCommand() == MysqlCommand.COM_STMT_EXECUTE
&& !buildResult.second.isDeterministic()) {
if (!buildResult.second.isDeterministic()) {
StatementContext statementContext = context.cascadesContext.getStatementContext();
statementContext.setHasNondeterministicInPreparedStatement(true);
statementContext.setHasNondeterministic(true);
}
if (wantToParseSqlFromSqlCache) {
StatementContext statementContext = context.cascadesContext.getStatementContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void run(ConnectContext ctx, StmtExecutor executor) throws Exception {
&& preparedStmtCtx.shortCircuitQueryContext.get().tbl.getBaseSchemaVersion()
!= preparedStmtCtx.shortCircuitQueryContext.get().schemaVersion;
boolean needAnalyze = !isShortCircuit || schemaVersionMismatch || !hasShortCircuitContext
|| executor.getContext().getStatementContext().hasNondeterministicInPreparedStatement();
|| executor.getContext().getStatementContext().hasNondeterministic();
if (needAnalyze) {
// execute real statement
preparedStmtCtx.shortCircuitQueryContext = Optional.empty();
Expand Down

0 comments on commit d2ed545

Please sign in to comment.