{"record":{"id":"cf69f57be5abc66c","repo":"risingwavelabs/risingwave","slug":"precision-must-be-in-range-0","errorCode":null,"errorMessage":"precision must be in range {0}","messagePattern":"precision must be in range (.+?)","errorType":"validation","errorClass":"OutOfRange","httpStatus":null,"severity":"error","filePath":"src/sqlparser/src/parser_v2/number.rs","lineNumber":82,"sourceCode":"    S: TokenStream,\n{\n    token_number\n        .try_map(|s| s.parse::<i64>())\n        .context(StrContext::Label(\"i64\"))\n        .parse_next(input)\n}\n\n/// Consume a precision definition in some types, e.g. `FLOAT(32)`.\n///\n/// The precision must be in the given range.\npub fn precision_in_range<S>(\n    range: impl RangeBounds<u64> + std::fmt::Debug,\n) -> impl ModalParser<S, u64, ContextError>\nwhere\n    S: TokenStream,\n{\n    #[derive(Debug, thiserror::Error)]\n    #[error(\"precision must be in range {0}\")]\n    struct OutOfRange(String);\n\n    delimited(\n        Token::LParen,\n        cut_err(literal_u64.try_map(move |v| {\n            if range.contains(&v) {\n                Ok(v)\n            } else {\n                Err(OutOfRange(format!(\"{:?}\", range)))\n            }\n        })),\n        cut_err(Token::RParen),\n    )\n}\n","sourceCodeStart":64,"sourceCodeEnd":97,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/sqlparser/src/parser_v2/number.rs#L64-L97","documentation":"Produced by the `precision_in_range` helper when a numeric literal inside parentheses after a type name falls outside the allowed range, e.g. `DECIMAL(100)` or `TIME(20)`. The helper wraps `literal_u64` with a range check and converts out-of-range values into this `OutOfRange` error, which is then surfaced to `non_keyword_datatype`.","triggerScenarios":"Parsing type declarations like `DECIMAL(p)`, `TIME(p)`, `TIMESTAMP(p)`, `VARCHAR(p)` where `p` (or precision/scale pair) exceeds the range bound passed by the caller, e.g. `DECIMAL(45)` when max is 38.","commonSituations":"Porting DDL from other engines with larger precision limits (Oracle NUMBER, MySQL DECIMAL(65)); typo'd precision like an extra digit; generated schemas with invalid defaults.","solutions":["Lower the precision to within the supported range (e.g. DECIMAL precision must be <= 38 in RisingWave).","Check the allowed bounds in the error's range debug output and adjust your schema.","If you maintain the parser, ensure the range passed by `non_keyword_datatype` matches the documented limits and the message includes the concrete bounds."],"exampleFix":"// before\nCREATE TABLE t (x DECIMAL(45));\n// after\nCREATE TABLE t (x DECIMAL(38));","handlingStrategy":"validation","validationCode":"fn check_decimal_precision(p: u64) -> Result<(), String> {\n    if (1..=38).contains(&p) { Ok(()) } else { Err(format!(\"precision {p} out of 1..=38\")) }\n}","typeGuard":null,"tryCatchPattern":"// Parse errors surface as ModalResult; match the OutOfRange message\nmatch data_type_result {\n    Err(e) if e.to_string().starts_with(\"precision must be in range\") => {\n        // clamp/fix precision and re-parse\n    }\n    other => other,\n}","preventionTips":["Clamp declared precisions to the target engine's documented limits when porting DDL.","Validate generated schema DDL against engine limits before applying.","Keep a mapping table for cross-engine type/precision translation (Oracle NUMBER -> DECIMAL(38))."],"tags":["sql-parser","precision","out-of-range","data-type"],"backgroundTag":"value-out-of-range","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}