@@ -6434,12 +6434,14 @@ impl<'a> Parser<'a> {
64346434 /// Parse an operator name, which can contain special characters like +, -, <, >, =
64356435 /// that are tokenized as operator tokens rather than identifiers.
64366436 /// This is used for PostgreSQL CREATE OPERATOR statements.
6437- ///
6437+ ///
64386438 /// Examples: `+`, `myschema.+`, `pg_catalog.<=`
64396439 pub fn parse_operator_name(&mut self) -> Result<ObjectName, ParserError> {
64406440 let mut parts = vec![];
64416441 loop {
6442- parts.push(ObjectNamePart::Identifier(Ident::new(self.next_token().to_string())));
6442+ parts.push(ObjectNamePart::Identifier(Ident::new(
6443+ self.next_token().to_string(),
6444+ )));
64436445 if !self.consume_token(&Token::Period) {
64446446 break;
64456447 }
@@ -6473,38 +6475,57 @@ impl<'a> Parser<'a> {
64736475
64746476 loop {
64756477 let keyword = self.expect_one_of_keywords(&[
6476- Keyword::FUNCTION, Keyword::PROCEDURE, Keyword::LEFTARG, Keyword::RIGHTARG,
6477- Keyword::COMMUTATOR, Keyword::NEGATOR, Keyword::RESTRICT, Keyword::JOIN,
6478- Keyword::HASHES, Keyword::MERGES,
6478+ Keyword::FUNCTION,
6479+ Keyword::PROCEDURE,
6480+ Keyword::LEFTARG,
6481+ Keyword::RIGHTARG,
6482+ Keyword::COMMUTATOR,
6483+ Keyword::NEGATOR,
6484+ Keyword::RESTRICT,
6485+ Keyword::JOIN,
6486+ Keyword::HASHES,
6487+ Keyword::MERGES,
64796488 ])?;
64806489
64816490 match keyword {
64826491 Keyword::HASHES => {
6483- if hashes { return Err(dup_err!("HASHES")); }
6492+ if hashes {
6493+ return Err(dup_err!("HASHES"));
6494+ }
64846495 hashes = true;
64856496 }
64866497 Keyword::MERGES => {
6487- if merges { return Err(dup_err!("MERGES")); }
6498+ if merges {
6499+ return Err(dup_err!("MERGES"));
6500+ }
64886501 merges = true;
64896502 }
64906503 Keyword::FUNCTION | Keyword::PROCEDURE => {
6491- if function.is_some() { return Err(dup_err!("FUNCTION/PROCEDURE")); }
6504+ if function.is_some() {
6505+ return Err(dup_err!("FUNCTION/PROCEDURE"));
6506+ }
64926507 self.expect_token(&Token::Eq)?;
64936508 function = Some(self.parse_object_name(false)?);
64946509 is_procedure = keyword == Keyword::PROCEDURE;
64956510 }
64966511 Keyword::LEFTARG => {
6497- if left_arg.is_some() { return Err(dup_err!("LEFTARG")); }
6512+ if left_arg.is_some() {
6513+ return Err(dup_err!("LEFTARG"));
6514+ }
64986515 self.expect_token(&Token::Eq)?;
64996516 left_arg = Some(self.parse_data_type()?);
65006517 }
65016518 Keyword::RIGHTARG => {
6502- if right_arg.is_some() { return Err(dup_err!("RIGHTARG")); }
6519+ if right_arg.is_some() {
6520+ return Err(dup_err!("RIGHTARG"));
6521+ }
65036522 self.expect_token(&Token::Eq)?;
65046523 right_arg = Some(self.parse_data_type()?);
65056524 }
65066525 Keyword::COMMUTATOR => {
6507- if commutator.is_some() { return Err(dup_err!("COMMUTATOR")); }
6526+ if commutator.is_some() {
6527+ return Err(dup_err!("COMMUTATOR"));
6528+ }
65086529 self.expect_token(&Token::Eq)?;
65096530 if self.parse_keyword(Keyword::OPERATOR) {
65106531 self.expect_token(&Token::LParen)?;
@@ -6515,7 +6536,9 @@ impl<'a> Parser<'a> {
65156536 }
65166537 }
65176538 Keyword::NEGATOR => {
6518- if negator.is_some() { return Err(dup_err!("NEGATOR")); }
6539+ if negator.is_some() {
6540+ return Err(dup_err!("NEGATOR"));
6541+ }
65196542 self.expect_token(&Token::Eq)?;
65206543 if self.parse_keyword(Keyword::OPERATOR) {
65216544 self.expect_token(&Token::LParen)?;
@@ -6526,18 +6549,25 @@ impl<'a> Parser<'a> {
65266549 }
65276550 }
65286551 Keyword::RESTRICT => {
6529- if restrict.is_some() { return Err(dup_err!("RESTRICT")); }
6552+ if restrict.is_some() {
6553+ return Err(dup_err!("RESTRICT"));
6554+ }
65306555 self.expect_token(&Token::Eq)?;
65316556 restrict = Some(self.parse_object_name(false)?);
65326557 }
65336558 Keyword::JOIN => {
6534- if join.is_some() { return Err(dup_err!("JOIN")); }
6559+ if join.is_some() {
6560+ return Err(dup_err!("JOIN"));
6561+ }
65356562 self.expect_token(&Token::Eq)?;
65366563 join = Some(self.parse_object_name(false)?);
65376564 }
6538- _ => return Err(ParserError::ParserError(format!(
6539- "Unexpected keyword {:?} in CREATE OPERATOR", keyword
6540- ))),
6565+ _ => {
6566+ return Err(ParserError::ParserError(format!(
6567+ "Unexpected keyword {:?} in CREATE OPERATOR",
6568+ keyword
6569+ )))
6570+ }
65416571 }
65426572
65436573 if !self.consume_token(&Token::Comma) {
0 commit comments