(&mut self)
| 7939 | } |
| 7940 | |
| 7941 | fn parse_set(&mut self) -> Result<Statement<Raw>, ParserStatementError> { |
| 7942 | let modifier = self.parse_one_of_keywords(&[SESSION, LOCAL]); |
| 7943 | let mut variable = self.parse_identifier().map_no_statement_parser_err()?; |
| 7944 | let mut normal = self.consume_token(&Token::Eq) || self.parse_keyword(TO); |
| 7945 | if !normal { |
| 7946 | match variable.as_str().parse() { |
| 7947 | Ok(TIME) => { |
| 7948 | self.expect_keyword(ZONE).map_no_statement_parser_err()?; |
| 7949 | variable = ident!("timezone"); |
| 7950 | normal = true; |
| 7951 | } |
| 7952 | Ok(NAMES) => { |
| 7953 | variable = ident!("client_encoding"); |
| 7954 | normal = true; |
| 7955 | } |
| 7956 | _ => {} |
| 7957 | } |
| 7958 | } |
| 7959 | if variable.as_str().parse() == Ok(SCHEMA) { |
| 7960 | variable = ident!("search_path"); |
| 7961 | let to = self |
| 7962 | .parse_set_schema_to() |
| 7963 | .map_parser_err(StatementKind::SetVariable)?; |
| 7964 | Ok(Statement::SetVariable(SetVariableStatement { |
| 7965 | local: modifier == Some(LOCAL), |
| 7966 | variable, |
| 7967 | to, |
| 7968 | })) |
| 7969 | } else if normal { |
| 7970 | let to = self |
| 7971 | .parse_set_variable_to() |
| 7972 | .map_parser_err(StatementKind::SetVariable)?; |
| 7973 | Ok(Statement::SetVariable(SetVariableStatement { |
| 7974 | local: modifier == Some(LOCAL), |
| 7975 | variable, |
| 7976 | to, |
| 7977 | })) |
| 7978 | } else if variable.as_str().parse() == Ok(TRANSACTION) && modifier.is_none() { |
| 7979 | // SET TRANSACTION transaction_mode |
| 7980 | Ok(Statement::SetTransaction(SetTransactionStatement { |
| 7981 | local: true, |
| 7982 | modes: self |
| 7983 | .parse_transaction_modes(true) |
| 7984 | .map_parser_err(StatementKind::SetTransaction)?, |
| 7985 | })) |
| 7986 | } else if modifier == Some(SESSION) |
| 7987 | && variable.as_str().parse() == Ok(CHARACTERISTICS) |
| 7988 | && self.parse_keywords(&[AS, TRANSACTION]) |
| 7989 | { |
| 7990 | // SET SESSION CHARACTERISTICS AS TRANSACTION transaction_mode |
| 7991 | Ok(Statement::SetTransaction(SetTransactionStatement { |
| 7992 | local: false, |
| 7993 | modes: self |
| 7994 | .parse_transaction_modes(true) |
| 7995 | .map_parser_err(StatementKind::SetTransaction)?, |
| 7996 | })) |
| 7997 | } else { |
| 7998 | self.expected(self.peek_pos(), "equals sign or TO", self.peek_token()) |
no test coverage detected