mod, parser and test cases for CREATE [ { TEMPORARY | TEMP } ] SEQUENCE [ IF NOT EXISTS ] (#678)

This commit is contained in:
sam 2022-10-20 02:51:17 +05:30 committed by GitHub
parent b32cbbd855
commit e3c936a6ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 0 deletions

View file

@ -1904,6 +1904,8 @@ impl<'a> Parser<'a> {
self.parse_create_function(temporary)
} else if self.parse_keyword(Keyword::ROLE) {
self.parse_create_role()
} else if self.parse_keyword(Keyword::SEQUENCE) {
self.parse_create_sequence(temporary)
} else {
self.expected("an object type after CREATE", self.peek_token())
}
@ -5414,6 +5416,20 @@ impl<'a> Parser<'a> {
clauses,
})
}
/// https://www.postgresql.org/docs/current/sql-createsequence.html
/// CREATE [ { TEMPORARY | TEMP } ] SEQUENCE [ IF NOT EXISTS ] <sequence_name>
pub fn parse_create_sequence(&mut self, temporary: bool) -> Result<Statement, ParserError> {
//[ IF NOT EXISTS ]
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
//name
let name = self.parse_object_name()?;
Ok(Statement::CreateSequence {
temporary,
if_not_exists,
name,
})
}
}
impl Word {