Support drop sequence statement (#673)

* Add ObjectType Sequence

* Drop sequence test cases added.

* Parser and Drop statement Display updated.

* Parser and Drop statement Display updated.

* Fix compile errors

* add new test case
This commit is contained in:
sam 2022-10-15 17:34:19 +05:30 committed by GitHub
parent b42632fa0d
commit b32cbbd855
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 2 deletions

View file

@ -1184,6 +1184,9 @@ pub enum Statement {
/// Whether `CASCADE` was specified. This will be `false` when
/// `RESTRICT` or no drop behavior at all was specified.
cascade: bool,
/// Whether `RESTRICT` was specified. This will be `false` when
/// `CASCADE` or no drop behavior at all was specified.
restrict: bool,
/// Hive allows you specify whether the table's stored data will be
/// deleted along with the dropped table
purge: bool,
@ -2143,14 +2146,16 @@ impl fmt::Display for Statement {
if_exists,
names,
cascade,
restrict,
purge,
} => write!(
f,
"DROP {}{} {}{}{}",
"DROP {}{} {}{}{}{}",
object_type,
if *if_exists { " IF EXISTS" } else { "" },
display_comma_separated(names),
if *cascade { " CASCADE" } else { "" },
if *restrict { " RESTRICT" } else { "" },
if *purge { " PURGE" } else { "" }
),
Statement::Discard { object_type } => {
@ -2910,6 +2915,7 @@ pub enum ObjectType {
Index,
Schema,
Role,
Sequence,
}
impl fmt::Display for ObjectType {
@ -2920,6 +2926,7 @@ impl fmt::Display for ObjectType {
ObjectType::Index => "INDEX",
ObjectType::Schema => "SCHEMA",
ObjectType::Role => "ROLE",
ObjectType::Sequence => "SEQUENCE",
})
}
}

View file

@ -2441,9 +2441,11 @@ impl<'a> Parser<'a> {
ObjectType::Role
} else if self.parse_keyword(Keyword::SCHEMA) {
ObjectType::Schema
} else if self.parse_keyword(Keyword::SEQUENCE) {
ObjectType::Sequence
} else {
return self.expected(
"TABLE, VIEW, INDEX, ROLE, or SCHEMA after DROP",
"TABLE, VIEW, INDEX, ROLE, SCHEMA, or SEQUENCE after DROP",
self.peek_token(),
);
};
@ -2465,6 +2467,7 @@ impl<'a> Parser<'a> {
if_exists,
names,
cascade,
restrict,
purge,
})
}