MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_fetch

Method parse_fetch

src/sql-parser/src/parser.rs:9492–9516  ·  view source on GitHub ↗

Parse a `FETCH` statement, assuming that the `FETCH` token has already been consumed.

(&mut self)

Source from the content-addressed store, hash-verified

9490 /// Parse a `FETCH` statement, assuming that the `FETCH` token
9491 /// has already been consumed.
9492 fn parse_fetch(&mut self) -> Result<Statement<Raw>, ParserError> {
9493 let _ = self.parse_keyword(FORWARD);
9494 let count = if let Some(count) = self.maybe_parse(Parser::parse_literal_uint) {
9495 Some(FetchDirection::ForwardCount(count))
9496 } else if self.parse_keyword(ALL) {
9497 Some(FetchDirection::ForwardAll)
9498 } else {
9499 None
9500 };
9501 let _ = self.parse_keyword(FROM);
9502 let name = self.parse_identifier()?;
9503 let options = if self.parse_keyword(WITH) {
9504 self.expect_token(&Token::LParen)?;
9505 let options = self.parse_comma_separated(Self::parse_fetch_option)?;
9506 self.expect_token(&Token::RParen)?;
9507 options
9508 } else {
9509 vec![]
9510 };
9511 Ok(Statement::Fetch(FetchStatement {
9512 name,
9513 count,
9514 options,
9515 }))
9516 }
9517
9518 fn parse_fetch_option(&mut self) -> Result<FetchOption<Raw>, ParserError> {
9519 self.expect_keyword(TIMEOUT)?;

Callers 1

parse_statement_innerMethod · 0.80

Calls 5

parse_keywordMethod · 0.80
maybe_parseMethod · 0.80
parse_identifierMethod · 0.80
expect_tokenMethod · 0.80
parse_comma_separatedMethod · 0.80

Tested by

no test coverage detected