HHH-16198 - Fix splitting of SqlAstCreationState
This commit is contained in:
parent
1cc5ccfcb7
commit
bcf1df9b65
|
@ -154,7 +154,8 @@ public class MultiTableSqmMutationConverter extends BaseSqmToSqlAstConverter<Sta
|
||||||
SqmParameterResolutionConsumer parameterResolutionConsumer) {
|
SqmParameterResolutionConsumer parameterResolutionConsumer) {
|
||||||
this.parameterResolutionConsumer = parameterResolutionConsumer;
|
this.parameterResolutionConsumer = parameterResolutionConsumer;
|
||||||
|
|
||||||
for ( Assignment assignment : super.visitSetClause( setClause ) ) {
|
final List<Assignment> assignments = super.visitSetClause( setClause );
|
||||||
|
for ( Assignment assignment : assignments ) {
|
||||||
assignmentConsumer.accept( assignment );
|
assignmentConsumer.accept( assignment );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -926,29 +926,15 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
|
|
||||||
for ( SqmAssignment<?> sqmAssignment : setClause.getAssignments() ) {
|
for ( SqmAssignment<?> sqmAssignment : setClause.getAssignments() ) {
|
||||||
targetColumnReferences.clear();
|
targetColumnReferences.clear();
|
||||||
pushProcessingState(
|
|
||||||
new SqlAstProcessingStateImpl(
|
|
||||||
getCurrentProcessingState(),
|
|
||||||
this,
|
|
||||||
getCurrentClauseStack()::getCurrent) {
|
|
||||||
@Override
|
|
||||||
public Expression resolveSqlExpression(
|
|
||||||
ColumnReferenceKey key,
|
|
||||||
Function<SqlAstProcessingState, Expression> creator) {
|
|
||||||
final Expression expression = getParentState()
|
|
||||||
.getSqlExpressionResolver()
|
|
||||||
.resolveSqlExpression( key, creator );
|
|
||||||
assert expression instanceof ColumnReference;
|
|
||||||
targetColumnReferences.add( (ColumnReference) expression );
|
|
||||||
return expression;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getFromClauseIndex()
|
|
||||||
);
|
|
||||||
|
|
||||||
currentClauseStack.push( Clause.SET );
|
|
||||||
final SqmPathInterpretation<?> assignedPathInterpretation;
|
final SqmPathInterpretation<?> assignedPathInterpretation;
|
||||||
try {
|
try {
|
||||||
|
pushProcessingState(
|
||||||
|
createAssignmentProcessingState( targetColumnReferences ),
|
||||||
|
getFromClauseIndex()
|
||||||
|
);
|
||||||
|
currentClauseStack.push( Clause.SET );
|
||||||
|
|
||||||
assignedPathInterpretation = (SqmPathInterpretation<?>) sqmAssignment.getTargetPath().accept( this );
|
assignedPathInterpretation = (SqmPathInterpretation<?>) sqmAssignment.getTargetPath().accept( this );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -956,32 +942,10 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
popProcessingStateStack();
|
popProcessingStateStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
inferrableTypeAccessStack.push( assignedPathInterpretation::getExpressionType );
|
inferrableTypeAccessStack.push( assignedPathInterpretation::getExpressionType );
|
||||||
|
|
||||||
// final List<ColumnReference> valueColumnReferences = new ArrayList<>();
|
|
||||||
// todo: check if we can remove this
|
|
||||||
pushProcessingState(
|
|
||||||
new SqlAstProcessingStateImpl(
|
|
||||||
getCurrentProcessingState(),
|
|
||||||
this,
|
|
||||||
getCurrentClauseStack()::getCurrent) {
|
|
||||||
@Override
|
|
||||||
public Expression resolveSqlExpression(
|
|
||||||
ColumnReferenceKey key,
|
|
||||||
Function<SqlAstProcessingState, Expression> creator) {
|
|
||||||
final Expression expression = getParentState()
|
|
||||||
.getSqlExpressionResolver()
|
|
||||||
.resolveSqlExpression( key, creator );
|
|
||||||
assert expression instanceof ColumnReference;
|
|
||||||
// valueColumnReferences.add( (ColumnReference) expression );
|
|
||||||
return expression;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getFromClauseIndex()
|
|
||||||
);
|
|
||||||
currentClauseStack.push( Clause.SET_EXPRESSION );
|
currentClauseStack.push( Clause.SET_EXPRESSION );
|
||||||
|
|
||||||
try {
|
|
||||||
final SqmExpression<?> assignmentValue = sqmAssignment.getValue();
|
final SqmExpression<?> assignmentValue = sqmAssignment.getValue();
|
||||||
final SqmParameter<?> assignmentValueParameter = getSqmParameter( assignmentValue );
|
final SqmParameter<?> assignmentValueParameter = getSqmParameter( assignmentValue );
|
||||||
if ( assignmentValueParameter != null ) {
|
if ( assignmentValueParameter != null ) {
|
||||||
|
@ -1036,13 +1000,13 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentClauseStack.pop();
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
popProcessingStateStack();
|
currentClauseStack.pop();
|
||||||
inferrableTypeAccessStack.pop();
|
inferrableTypeAccessStack.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( aggregateColumnAssignmentHandler != null ) {
|
if ( aggregateColumnAssignmentHandler != null ) {
|
||||||
aggregateColumnAssignmentHandler.aggregateAssignments( assignments );
|
aggregateColumnAssignmentHandler.aggregateAssignments( assignments );
|
||||||
}
|
}
|
||||||
|
@ -1050,6 +1014,22 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
return assignments;
|
return assignments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SqlAstProcessingStateImpl createAssignmentProcessingState(ArrayList<ColumnReference> targetColumnReferences) {
|
||||||
|
return new SqlAstProcessingStateImpl( getCurrentProcessingState(), this, getCurrentClauseStack()::getCurrent ) {
|
||||||
|
@Override
|
||||||
|
public Expression resolveSqlExpression(
|
||||||
|
ColumnReferenceKey key,
|
||||||
|
Function<SqlAstProcessingState, Expression> creator) {
|
||||||
|
final Expression expression = getParentState()
|
||||||
|
.getSqlExpressionResolver()
|
||||||
|
.resolveSqlExpression( key, creator );
|
||||||
|
assert expression instanceof ColumnReference;
|
||||||
|
targetColumnReferences.add( (ColumnReference) expression );
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void addAssignment(
|
private void addAssignment(
|
||||||
List<Assignment> assignments,
|
List<Assignment> assignments,
|
||||||
AggregateColumnAssignmentHandler aggregateColumnAssignmentHandler,
|
AggregateColumnAssignmentHandler aggregateColumnAssignmentHandler,
|
||||||
|
|
Loading…
Reference in New Issue