@@ -1302,7 +1302,10 @@ impl<'a> Parser<'a> {
13021302 Keyword::POSITION if self.peek_token_ref().token == Token::LParen => {
13031303 Ok(Some(self.parse_position_expr(w.clone().into_ident(w_span))?))
13041304 }
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+ }
13061309 Keyword::OVERLAY => Ok(Some(self.parse_overlay_expr()?)),
13071310 Keyword::TRIM => Ok(Some(self.parse_trim_expr()?)),
13081311 Keyword::INTERVAL => Ok(Some(self.parse_interval()?)),
@@ -2412,8 +2415,16 @@ impl<'a> Parser<'a> {
24122415 }
24132416 }
24142417
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+ };
24172428 self.expect_token(&Token::LParen)?;
24182429 let expr = self.parse_expr()?;
24192430 let mut from_expr = None;
@@ -2433,6 +2444,7 @@ impl<'a> Parser<'a> {
24332444 substring_from: from_expr.map(Box::new),
24342445 substring_for: to_expr.map(Box::new),
24352446 special,
2447+ shorthand,
24362448 })
24372449 }
24382450
0 commit comments