Skip to content

Commit 498708c

Browse files
Error on dangling NO in CREATE SEQUENCE options (#1104)
1 parent 3a6d3ec commit 498708c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/parser/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -8700,13 +8700,12 @@ impl<'a> Parser<'a> {
87008700
)));
87018701
}
87028702
// [ [ NO ] CYCLE ]
8703-
if self.parse_keywords(&[Keyword::NO]) {
8704-
if self.parse_keywords(&[Keyword::CYCLE]) {
8705-
sequence_options.push(SequenceOptions::Cycle(true));
8706-
}
8703+
if self.parse_keywords(&[Keyword::NO, Keyword::CYCLE]) {
8704+
sequence_options.push(SequenceOptions::Cycle(true));
87078705
} else if self.parse_keywords(&[Keyword::CYCLE]) {
87088706
sequence_options.push(SequenceOptions::Cycle(false));
87098707
}
8708+
87108709
Ok(sequence_options)
87118710
}
87128711

tests/sqlparser_postgres.rs

+5
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ fn parse_create_sequence() {
276276
sql6,
277277
"CREATE TEMPORARY SEQUENCE IF NOT EXISTS name3 INCREMENT 1 NO MINVALUE MAXVALUE 20 OWNED BY NONE",
278278
);
279+
280+
assert!(matches!(
281+
pg().parse_sql_statements("CREATE SEQUENCE foo INCREMENT 1 NO MINVALUE NO"),
282+
Err(ParserError::ParserError(_))
283+
));
279284
}
280285

281286
#[test]

0 commit comments

Comments
 (0)