Skip to content

Commit

Permalink
Use QUERY_EXCEEDED_COMPILER_LIMIT error code
Browse files Browse the repository at this point in the history
  • Loading branch information
mduggan-starburst authored and wendigo committed Dec 19, 2024
1 parent c1b608c commit d7aba15
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/trino-main/src/main/java/io/trino/util/CompilerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import io.airlift.bytecode.DynamicClassLoader;
import io.airlift.bytecode.ParameterizedType;
import io.airlift.log.Logger;
import io.trino.spi.TrinoException;
import org.objectweb.asm.MethodTooLargeException;

import java.lang.invoke.MethodHandle;
import java.time.Instant;
Expand All @@ -28,6 +30,7 @@
import static io.airlift.bytecode.BytecodeUtils.toJavaIdentifierString;
import static io.airlift.bytecode.ClassGenerator.classGenerator;
import static io.airlift.bytecode.ParameterizedType.typeFromJavaClassName;
import static io.trino.spi.StandardErrorCode.QUERY_EXCEEDED_COMPILER_LIMIT;
import static java.time.ZoneOffset.UTC;

public final class CompilerUtils
Expand Down Expand Up @@ -78,6 +81,11 @@ public static <T> Class<? extends T> defineClass(ClassDefinition classDefinition
public static <T> Class<? extends T> defineClass(ClassDefinition classDefinition, Class<T> superType, DynamicClassLoader classLoader)
{
log.debug("Defining class: %s", classDefinition.getName());
return classGenerator(classLoader).defineClass(classDefinition, superType);
try {
return classGenerator(classLoader).defineClass(classDefinition, superType);
}
catch (MethodTooLargeException e) {
throw new TrinoException(QUERY_EXCEEDED_COMPILER_LIMIT, "Query exceeded maximum method size.", e);
}
}
}

0 comments on commit d7aba15

Please sign in to comment.