@@ -1302,7 +1302,10 @@ impl<'a> Parser<'a> {
1302
1302
Keyword::POSITION if self.peek_token_ref().token == Token::LParen => {
1303
1303
Ok(Some(self.parse_position_expr(w.clone().into_ident(w_span))?))
1304
1304
}
1305
- Keyword::SUBSTRING => Ok(Some(self.parse_substring_expr()?)),
1305
+ Keyword::SUBSTR | Keyword::SUBSTRING => {
1306
+ self.prev_token();
1307
+ Ok(Some(self.parse_substring()?))
1308
+ }
1306
1309
Keyword::OVERLAY => Ok(Some(self.parse_overlay_expr()?)),
1307
1310
Keyword::TRIM => Ok(Some(self.parse_trim_expr()?)),
1308
1311
Keyword::INTERVAL => Ok(Some(self.parse_interval()?)),
@@ -2412,8 +2415,16 @@ impl<'a> Parser<'a> {
2412
2415
}
2413
2416
}
2414
2417
2415
- pub fn parse_substring_expr(&mut self) -> Result<Expr, ParserError> {
2416
- // PARSE SUBSTRING (EXPR [FROM 1] [FOR 3])
2418
+ // { SUBSTRING | SUBSTR } (<EXPR> [FROM 1] [FOR 3])
2419
+ pub fn parse_substring(&mut self) -> Result<Expr, ParserError> {
2420
+ let shorthand = match self.expect_one_of_keywords(&[Keyword::SUBSTR, Keyword::SUBSTRING])? {
2421
+ Keyword::SUBSTR => true,
2422
+ Keyword::SUBSTRING => false,
2423
+ _ => {
2424
+ self.prev_token();
2425
+ return self.expected("SUBSTR or SUBSTRING", self.peek_token());
2426
+ }
2427
+ };
2417
2428
self.expect_token(&Token::LParen)?;
2418
2429
let expr = self.parse_expr()?;
2419
2430
let mut from_expr = None;
@@ -2433,6 +2444,7 @@ impl<'a> Parser<'a> {
2433
2444
substring_from: from_expr.map(Box::new),
2434
2445
substring_for: to_expr.map(Box::new),
2435
2446
special,
2447
+ shorthand,
2436
2448
})
2437
2449
}
2438
2450
0 commit comments