Ruben Q L created CALCITE-7731:
----------------------------------

             Summary: Bound plain-notation expansion of DECIMAL literals to 
prevent parse-time OutOfMemoryError
                 Key: CALCITE-7731
                 URL: https://issues.apache.org/jira/browse/CALCITE-7731
             Project: Calcite
          Issue Type: Improvement
          Components: core
            Reporter: Ruben Q L
             Fix For: 1.43.0


BigDecimal accepts any int exponent, so a DECIMAL literal such as {{DECIMAL 
'1E2147483647'}} (~30 characters) parses to a BigDecimal whose plain-notation 
form would be one character per digit: a multi-gigabyte allocation (potentially 
an OOM error).

Three places call BigDecimal.toPlainString() on a value derived from 
user-supplied input and would attempt that allocation:
- SqlParserUtil.parseDecimalLiteral
- SqlNumericLiteral.toValue
- RexBuilder.makeLiteral

It would be required to add a check in there to prevent an OOM error.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to