Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/trino-parser/src/main/java/io/trino/sql/parser/SqlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.antlr.v4.runtime.Recognizer;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.atn.PredictionMode;
import org.antlr.v4.runtime.misc.Interval;
import org.antlr.v4.runtime.misc.Pair;
import org.antlr.v4.runtime.tree.TerminalNode;

Expand All @@ -46,6 +47,7 @@
import java.util.function.BiConsumer;
import java.util.function.Function;

import static com.google.common.base.Verify.verify;
import static java.util.Objects.requireNonNull;

public class SqlParser
Expand Down Expand Up @@ -73,6 +75,15 @@ public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int
.specialToken(SqlBaseLexer.INTEGER_VALUE, "<integer>")
.build();

static {
// TODO: Remove after https://github.com/antlr/antlr4/issues/4901 is fixed
// This is a temporary workaround to prime the internal cache for Interval
// that is not thread safe and can cause concurrency issues.
for (int i = 0; i <= Interval.INTERVAL_POOL_MAX_VALUE; i++) {
verify(Interval.of(i, i).length() == 1, "Expected Interval.of(%s, %s) to have length 1", i, i);
}
}

private final BiConsumer<SqlBaseLexer, SqlBaseParser> initializer;

public SqlParser()
Expand Down
Loading