@@ -6467,12 +6467,6 @@ impl<'a> Parser<'a> {
64676467 ///
64686468 /// [PostgreSQL Documentation](https://www.postgresql.org/docs/current/sql-createoperator.html)
64696469 pub fn parse_create_operator(&mut self) -> Result<Statement, ParserError> {
6470- macro_rules! dup_err {
6471- ($name:expr) => {
6472- ParserError::ParserError(format!("Duplicate {} clause in CREATE OPERATOR", $name))
6473- };
6474- }
6475-
64766470 let name = self.parse_operator_name()?;
64776471 self.expect_token(&Token::LParen)?;
64786472
@@ -6502,44 +6496,26 @@ impl<'a> Parser<'a> {
65026496 ])?;
65036497
65046498 match keyword {
6505- Keyword::HASHES => {
6506- if hashes {
6507- return Err(dup_err!("HASHES"));
6508- }
6499+ Keyword::HASHES if !hashes => {
65096500 hashes = true;
65106501 }
6511- Keyword::MERGES => {
6512- if merges {
6513- return Err(dup_err!("MERGES"));
6514- }
6502+ Keyword::MERGES if !merges => {
65156503 merges = true;
65166504 }
6517- Keyword::FUNCTION | Keyword::PROCEDURE => {
6518- if function.is_some() {
6519- return Err(dup_err!("FUNCTION/PROCEDURE"));
6520- }
6505+ Keyword::FUNCTION | Keyword::PROCEDURE if function.is_none() => {
65216506 self.expect_token(&Token::Eq)?;
65226507 function = Some(self.parse_object_name(false)?);
65236508 is_procedure = keyword == Keyword::PROCEDURE;
65246509 }
6525- Keyword::LEFTARG => {
6526- if left_arg.is_some() {
6527- return Err(dup_err!("LEFTARG"));
6528- }
6510+ Keyword::LEFTARG if left_arg.is_none() => {
65296511 self.expect_token(&Token::Eq)?;
65306512 left_arg = Some(self.parse_data_type()?);
65316513 }
6532- Keyword::RIGHTARG => {
6533- if right_arg.is_some() {
6534- return Err(dup_err!("RIGHTARG"));
6535- }
6514+ Keyword::RIGHTARG if right_arg.is_none() => {
65366515 self.expect_token(&Token::Eq)?;
65376516 right_arg = Some(self.parse_data_type()?);
65386517 }
6539- Keyword::COMMUTATOR => {
6540- if commutator.is_some() {
6541- return Err(dup_err!("COMMUTATOR"));
6542- }
6518+ Keyword::COMMUTATOR if commutator.is_none() => {
65436519 self.expect_token(&Token::Eq)?;
65446520 if self.parse_keyword(Keyword::OPERATOR) {
65456521 self.expect_token(&Token::LParen)?;
@@ -6549,10 +6525,7 @@ impl<'a> Parser<'a> {
65496525 commutator = Some(self.parse_operator_name()?);
65506526 }
65516527 }
6552- Keyword::NEGATOR => {
6553- if negator.is_some() {
6554- return Err(dup_err!("NEGATOR"));
6555- }
6528+ Keyword::NEGATOR if negator.is_none() => {
65566529 self.expect_token(&Token::Eq)?;
65576530 if self.parse_keyword(Keyword::OPERATOR) {
65586531 self.expect_token(&Token::LParen)?;
@@ -6562,23 +6535,17 @@ impl<'a> Parser<'a> {
65626535 negator = Some(self.parse_operator_name()?);
65636536 }
65646537 }
6565- Keyword::RESTRICT => {
6566- if restrict.is_some() {
6567- return Err(dup_err!("RESTRICT"));
6568- }
6538+ Keyword::RESTRICT if restrict.is_none() => {
65696539 self.expect_token(&Token::Eq)?;
65706540 restrict = Some(self.parse_object_name(false)?);
65716541 }
6572- Keyword::JOIN => {
6573- if join.is_some() {
6574- return Err(dup_err!("JOIN"));
6575- }
6542+ Keyword::JOIN if join.is_none() => {
65766543 self.expect_token(&Token::Eq)?;
65776544 join = Some(self.parse_object_name(false)?);
65786545 }
65796546 _ => {
65806547 return Err(ParserError::ParserError(format!(
6581- "Unexpected keyword {:?} in CREATE OPERATOR",
6548+ "Duplicate or unexpected keyword {:?} in CREATE OPERATOR",
65826549 keyword
65836550 )))
65846551 }
0 commit comments