Skip to content

Commit 0de2e4d

Browse files
committed
PAUSE MIRROR parsing, will add tests later
1 parent d03b760 commit 0de2e4d

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/ast/mod.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ pub enum Statement {
21462146
if_not_exists: bool,
21472147
create_mirror: CreateMirror,
21482148
},
2149-
/// DROP MIRROR [IF EXISTS] mirror_name
2149+
// DROP MIRROR [IF EXISTS] mirror_name
21502150
DropMirror {
21512151
#[cfg_attr(feature = "derive-visitor", drive(skip))]
21522152
if_exists: bool,
@@ -2162,6 +2162,12 @@ pub enum Statement {
21622162
mirror_name: ObjectName,
21632163
with_options: Vec<SqlOption>,
21642164
},
2165+
// DROP MIRROR [IF EXISTS] mirror_name
2166+
PauseMirror {
2167+
#[cfg_attr(feature = "derive-visitor", drive(skip))]
2168+
if_exists: bool,
2169+
mirror_name: ObjectName,
2170+
}
21652171
}
21662172

21672173
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
@@ -3655,6 +3661,17 @@ impl fmt::Display for Statement {
36553661
Statement::ExecuteMirror { mirror_name } => {
36563662
write!(f, "EXECUTE MIRROR {mirror_name}", mirror_name = mirror_name)?;
36573663
Ok(())
3664+
},
3665+
Statement::PauseMirror {
3666+
if_exists,
3667+
mirror_name,
3668+
} => {
3669+
write!(
3670+
f,
3671+
"PAUSE MIRROR {if_exists}{mirror_name}",
3672+
if_exists = if *if_exists { "IF EXISTS " } else { "" },
3673+
)?;
3674+
Ok(())
36583675
}
36593676
Statement::ResyncMirror {
36603677
if_exists,

src/keywords.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ define_keywords!(
471471
PARTITIONS,
472472
PASSWORD,
473473
PATTERN,
474+
PAUSE,
474475
PEER,
475476
PERCENT,
476477
PERCENTILE_CONT,

src/parser/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ impl<'a> Parser<'a> {
522522
// `PRAGMA` is sqlite specific https://www.sqlite.org/pragma.html
523523
Keyword::PRAGMA => Ok(self.parse_pragma()?),
524524
Keyword::RESYNC => Ok(self.parse_resync()?),
525+
Keyword::PAUSE => Ok(self.parse_pause_mirror()?),
525526
_ => self.expected("an SQL statement", next_token),
526527
},
527528
Token::LParen => {
@@ -8104,6 +8105,16 @@ impl<'a> Parser<'a> {
81048105
})
81058106
}
81068107

8108+
pub fn parse_pause_mirror(&mut self) -> Result<Statement, ParserError> {
8109+
self.expect_keyword(Keyword::MIRROR)?;
8110+
let if_exists = self.parse_keywords(&[Keyword::IF, Keyword::EXISTS]);
8111+
let mirror_name = self.parse_object_name()?;
8112+
return Ok(Statement::PauseMirror {
8113+
if_exists,
8114+
mirror_name,
8115+
});
8116+
}
8117+
81078118
/// The index of the first unprocessed token.
81088119
pub fn index(&self) -> usize {
81098120
self.index

0 commit comments

Comments
 (0)