From 279d9d3cfb4d2ef71f745362e821abad228cdec0 Mon Sep 17 00:00:00 2001 From: James Petty Date: Fri, 17 May 2024 11:57:23 -0400 Subject: [PATCH] Reuse SqlRoutine interruption variables --- .../main/java/io/trino/sql/routine/SqlRoutineCompiler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/trino-main/src/main/java/io/trino/sql/routine/SqlRoutineCompiler.java b/core/trino-main/src/main/java/io/trino/sql/routine/SqlRoutineCompiler.java index 4fb2756d3991..af7b3d14e4e6 100644 --- a/core/trino-main/src/main/java/io/trino/sql/routine/SqlRoutineCompiler.java +++ b/core/trino-main/src/main/java/io/trino/sql/routine/SqlRoutineCompiler.java @@ -424,7 +424,7 @@ private BytecodeNode compileLoop(Scope scope, Optional label, Function< { BytecodeBlock block = new BytecodeBlock(); - Variable interruption = scope.createTempVariable(int.class); + Variable interruption = scope.getOrCreateTempVariable(int.class); block.putVariable(interruption, 0); BytecodeBlock interruptionBlock = new BytecodeBlock() @@ -450,6 +450,8 @@ private BytecodeNode compileLoop(Scope scope, Optional label, Function< block.visitLabel(breakLabel); } + scope.releaseTempVariableForReuse(interruption); + return block; }