Add support for OFFSET with the ROWS keyword

MySQL doesn't support the ROWS part of OFFSET. Teach the parser to
remember which variant it saw, including just ROW.
This commit is contained in:
Matt Jibson 2020-04-13 17:59:10 -06:00
parent 05a29212ff
commit c0b0b5924d
4 changed files with 96 additions and 25 deletions

View file

@ -1970,10 +1970,16 @@ impl Parser {
}
/// Parse an OFFSET clause
pub fn parse_offset(&mut self) -> Result<Expr, ParserError> {
pub fn parse_offset(&mut self) -> Result<Offset, ParserError> {
let value = Expr::Value(self.parse_number_value()?);
self.expect_one_of_keywords(&["ROW", "ROWS"])?;
Ok(value)
let rows = if self.parse_keyword("ROW") {
OffsetRows::Row
} else if self.parse_keyword("ROWS") {
OffsetRows::Rows
} else {
OffsetRows::None
};
Ok(Offset { value, rows })
}
/// Parse a FETCH clause