Parses the column section of a CREATE SOURCE statement which can be empty or a comma-separated list of column identifiers and a single key constraint, e.g. (col_0, col_i, ..., col_n, key_constraint)
(&mut self)
| 3264 | /// |
| 3265 | /// (col_0, col_i, ..., col_n, key_constraint) |
| 3266 | fn parse_source_columns(&mut self) -> Result<(Vec<Ident>, Option<KeyConstraint>), ParserError> { |
| 3267 | if self.consume_token(&Token::LParen) { |
| 3268 | let mut columns = vec![]; |
| 3269 | let mut key_constraints = vec![]; |
| 3270 | loop { |
| 3271 | let pos = self.peek_pos(); |
| 3272 | if let Some(key_constraint) = self.parse_key_constraint()? { |
| 3273 | if !key_constraints.is_empty() { |
| 3274 | return parser_err!(self, pos, "Multiple key constraints not allowed"); |
| 3275 | } |
| 3276 | key_constraints.push(key_constraint); |
| 3277 | } else { |
| 3278 | columns.push(self.parse_identifier()?); |
| 3279 | } |
| 3280 | if !self.consume_token(&Token::Comma) { |
| 3281 | break; |
| 3282 | } |
| 3283 | } |
| 3284 | self.expect_token(&Token::RParen)?; |
| 3285 | Ok((columns, key_constraints.into_iter().next())) |
| 3286 | } else { |
| 3287 | Ok((vec![], None)) |
| 3288 | } |
| 3289 | } |
| 3290 | |
| 3291 | /// Parses a key constraint. |
| 3292 | fn parse_key_constraint(&mut self) -> Result<Option<KeyConstraint>, ParserError> { |
no test coverage detected