Add keyword to queries for PARALLEL execution

This commit is contained in:
Tobie Morgan Hitchcock 2022-02-26 16:53:38 +00:00
parent cd545c2edd
commit ec698e85de
7 changed files with 42 additions and 0 deletions

View file

@ -57,6 +57,7 @@ impl<'a> From<&'a SelectStatement> for Iterator<'a> {
order: v.order.as_ref(), order: v.order.as_ref(),
limit: v.limit.as_ref(), limit: v.limit.as_ref(),
start: v.start.as_ref(), start: v.start.as_ref(),
parallel: v.parallel,
..Iterator::default() ..Iterator::default()
} }
} }
@ -66,6 +67,7 @@ impl<'a> From<&'a CreateStatement> for Iterator<'a> {
fn from(v: &'a CreateStatement) -> Self { fn from(v: &'a CreateStatement) -> Self {
Iterator { Iterator {
stmt: Statement::from(v), stmt: Statement::from(v),
parallel: v.parallel,
..Iterator::default() ..Iterator::default()
} }
} }
@ -75,6 +77,7 @@ impl<'a> From<&'a UpdateStatement> for Iterator<'a> {
fn from(v: &'a UpdateStatement) -> Self { fn from(v: &'a UpdateStatement) -> Self {
Iterator { Iterator {
stmt: Statement::from(v), stmt: Statement::from(v),
parallel: v.parallel,
..Iterator::default() ..Iterator::default()
} }
} }
@ -84,6 +87,7 @@ impl<'a> From<&'a RelateStatement> for Iterator<'a> {
fn from(v: &'a RelateStatement) -> Self { fn from(v: &'a RelateStatement) -> Self {
Iterator { Iterator {
stmt: Statement::from(v), stmt: Statement::from(v),
parallel: v.parallel,
..Iterator::default() ..Iterator::default()
} }
} }
@ -93,6 +97,7 @@ impl<'a> From<&'a DeleteStatement> for Iterator<'a> {
fn from(v: &'a DeleteStatement) -> Self { fn from(v: &'a DeleteStatement) -> Self {
Iterator { Iterator {
stmt: Statement::from(v), stmt: Statement::from(v),
parallel: v.parallel,
..Iterator::default() ..Iterator::default()
} }
} }
@ -102,6 +107,7 @@ impl<'a> From<&'a InsertStatement> for Iterator<'a> {
fn from(v: &'a InsertStatement) -> Self { fn from(v: &'a InsertStatement) -> Self {
Iterator { Iterator {
stmt: Statement::from(v), stmt: Statement::from(v),
parallel: v.parallel,
..Iterator::default() ..Iterator::default()
} }
} }

View file

@ -23,6 +23,7 @@ pub struct CreateStatement {
pub data: Option<Data>, pub data: Option<Data>,
pub output: Option<Output>, pub output: Option<Output>,
pub timeout: Option<Timeout>, pub timeout: Option<Timeout>,
pub parallel: bool,
} }
impl CreateStatement { impl CreateStatement {
@ -71,6 +72,9 @@ impl fmt::Display for CreateStatement {
if let Some(ref v) = self.timeout { if let Some(ref v) = self.timeout {
write!(f, " {}", v)? write!(f, " {}", v)?
} }
if self.parallel {
write!(f, " PARALLEL")?
}
Ok(()) Ok(())
} }
} }
@ -82,6 +86,7 @@ pub fn create(i: &str) -> IResult<&str, CreateStatement> {
let (i, data) = opt(preceded(shouldbespace, data))(i)?; let (i, data) = opt(preceded(shouldbespace, data))(i)?;
let (i, output) = opt(preceded(shouldbespace, output))(i)?; let (i, output) = opt(preceded(shouldbespace, output))(i)?;
let (i, timeout) = opt(preceded(shouldbespace, timeout))(i)?; let (i, timeout) = opt(preceded(shouldbespace, timeout))(i)?;
let (i, parallel) = opt(preceded(shouldbespace, tag_no_case("PARALLEL")))(i)?;
Ok(( Ok((
i, i,
CreateStatement { CreateStatement {
@ -89,6 +94,7 @@ pub fn create(i: &str) -> IResult<&str, CreateStatement> {
data, data,
output, output,
timeout, timeout,
parallel: parallel.is_some(),
}, },
)) ))
} }

View file

@ -24,6 +24,7 @@ pub struct DeleteStatement {
pub cond: Option<Cond>, pub cond: Option<Cond>,
pub output: Option<Output>, pub output: Option<Output>,
pub timeout: Option<Timeout>, pub timeout: Option<Timeout>,
pub parallel: bool,
} }
impl DeleteStatement { impl DeleteStatement {
@ -72,6 +73,9 @@ impl fmt::Display for DeleteStatement {
if let Some(ref v) = self.timeout { if let Some(ref v) = self.timeout {
write!(f, " {}", v)? write!(f, " {}", v)?
} }
if self.parallel {
write!(f, " PARALLEL")?
}
Ok(()) Ok(())
} }
} }
@ -84,6 +88,7 @@ pub fn delete(i: &str) -> IResult<&str, DeleteStatement> {
let (i, cond) = opt(preceded(shouldbespace, cond))(i)?; let (i, cond) = opt(preceded(shouldbespace, cond))(i)?;
let (i, output) = opt(preceded(shouldbespace, output))(i)?; let (i, output) = opt(preceded(shouldbespace, output))(i)?;
let (i, timeout) = opt(preceded(shouldbespace, timeout))(i)?; let (i, timeout) = opt(preceded(shouldbespace, timeout))(i)?;
let (i, parallel) = opt(preceded(shouldbespace, tag_no_case("PARALLEL")))(i)?;
Ok(( Ok((
i, i,
DeleteStatement { DeleteStatement {
@ -91,6 +96,7 @@ pub fn delete(i: &str) -> IResult<&str, DeleteStatement> {
cond, cond,
output, output,
timeout, timeout,
parallel: parallel.is_some(),
}, },
)) ))
} }

View file

@ -27,6 +27,7 @@ pub struct InsertStatement {
pub update: Option<Data>, pub update: Option<Data>,
pub output: Option<Output>, pub output: Option<Output>,
pub timeout: Option<Timeout>, pub timeout: Option<Timeout>,
pub parallel: bool,
} }
impl InsertStatement { impl InsertStatement {
@ -80,6 +81,9 @@ impl fmt::Display for InsertStatement {
if let Some(ref v) = self.timeout { if let Some(ref v) = self.timeout {
write!(f, " {}", v)? write!(f, " {}", v)?
} }
if self.parallel {
write!(f, " PARALLEL")?
}
Ok(()) Ok(())
} }
} }
@ -93,6 +97,7 @@ pub fn insert(i: &str) -> IResult<&str, InsertStatement> {
let (i, update) = opt(preceded(shouldbespace, update))(i)?; let (i, update) = opt(preceded(shouldbespace, update))(i)?;
let (i, output) = opt(preceded(shouldbespace, output))(i)?; let (i, output) = opt(preceded(shouldbespace, output))(i)?;
let (i, timeout) = opt(preceded(shouldbespace, timeout))(i)?; let (i, timeout) = opt(preceded(shouldbespace, timeout))(i)?;
let (i, parallel) = opt(preceded(shouldbespace, tag_no_case("PARALLEL")))(i)?;
Ok(( Ok((
i, i,
InsertStatement { InsertStatement {
@ -102,6 +107,7 @@ pub fn insert(i: &str) -> IResult<&str, InsertStatement> {
update, update,
output, output,
timeout, timeout,
parallel: parallel.is_some(),
}, },
)) ))
} }

View file

@ -30,6 +30,7 @@ pub struct RelateStatement {
pub data: Option<Data>, pub data: Option<Data>,
pub output: Option<Output>, pub output: Option<Output>,
pub timeout: Option<Timeout>, pub timeout: Option<Timeout>,
pub parallel: bool,
} }
impl RelateStatement { impl RelateStatement {
@ -81,6 +82,9 @@ impl fmt::Display for RelateStatement {
if let Some(ref v) = self.timeout { if let Some(ref v) = self.timeout {
write!(f, " {}", v)? write!(f, " {}", v)?
} }
if self.parallel {
write!(f, " PARALLEL")?
}
Ok(()) Ok(())
} }
} }
@ -93,6 +97,7 @@ pub fn relate(i: &str) -> IResult<&str, RelateStatement> {
let (i, data) = opt(preceded(shouldbespace, data))(i)?; let (i, data) = opt(preceded(shouldbespace, data))(i)?;
let (i, output) = opt(preceded(shouldbespace, output))(i)?; let (i, output) = opt(preceded(shouldbespace, output))(i)?;
let (i, timeout) = opt(preceded(shouldbespace, timeout))(i)?; let (i, timeout) = opt(preceded(shouldbespace, timeout))(i)?;
let (i, parallel) = opt(preceded(shouldbespace, tag_no_case("PARALLEL")))(i)?;
Ok(( Ok((
i, i,
RelateStatement { RelateStatement {
@ -103,6 +108,7 @@ pub fn relate(i: &str) -> IResult<&str, RelateStatement> {
data, data,
output, output,
timeout, timeout,
parallel: parallel.is_some(),
}, },
)) ))
} }

View file

@ -37,6 +37,7 @@ pub struct SelectStatement {
pub fetch: Option<Fetchs>, pub fetch: Option<Fetchs>,
pub version: Option<Version>, pub version: Option<Version>,
pub timeout: Option<Timeout>, pub timeout: Option<Timeout>,
pub parallel: bool,
} }
impl SelectStatement { impl SelectStatement {
@ -114,6 +115,9 @@ impl fmt::Display for SelectStatement {
if let Some(ref v) = self.timeout { if let Some(ref v) = self.timeout {
write!(f, " {}", v)? write!(f, " {}", v)?
} }
if self.parallel {
write!(f, " PARALLEL")?
}
Ok(()) Ok(())
} }
} }
@ -135,6 +139,7 @@ pub fn select(i: &str) -> IResult<&str, SelectStatement> {
let (i, fetch) = opt(preceded(shouldbespace, fetch))(i)?; let (i, fetch) = opt(preceded(shouldbespace, fetch))(i)?;
let (i, version) = opt(preceded(shouldbespace, version))(i)?; let (i, version) = opt(preceded(shouldbespace, version))(i)?;
let (i, timeout) = opt(preceded(shouldbespace, timeout))(i)?; let (i, timeout) = opt(preceded(shouldbespace, timeout))(i)?;
let (i, parallel) = opt(preceded(shouldbespace, tag_no_case("PARALLEL")))(i)?;
Ok(( Ok((
i, i,
SelectStatement { SelectStatement {
@ -149,6 +154,7 @@ pub fn select(i: &str) -> IResult<&str, SelectStatement> {
fetch, fetch,
version, version,
timeout, timeout,
parallel: parallel.is_some(),
}, },
)) ))
} }

View file

@ -25,6 +25,7 @@ pub struct UpdateStatement {
pub cond: Option<Cond>, pub cond: Option<Cond>,
pub output: Option<Output>, pub output: Option<Output>,
pub timeout: Option<Timeout>, pub timeout: Option<Timeout>,
pub parallel: bool,
} }
impl UpdateStatement { impl UpdateStatement {
@ -76,6 +77,9 @@ impl fmt::Display for UpdateStatement {
if let Some(ref v) = self.timeout { if let Some(ref v) = self.timeout {
write!(f, " {}", v)? write!(f, " {}", v)?
} }
if self.parallel {
write!(f, " PARALLEL")?
}
Ok(()) Ok(())
} }
} }
@ -88,6 +92,7 @@ pub fn update(i: &str) -> IResult<&str, UpdateStatement> {
let (i, cond) = opt(preceded(shouldbespace, cond))(i)?; let (i, cond) = opt(preceded(shouldbespace, cond))(i)?;
let (i, output) = opt(preceded(shouldbespace, output))(i)?; let (i, output) = opt(preceded(shouldbespace, output))(i)?;
let (i, timeout) = opt(preceded(shouldbespace, timeout))(i)?; let (i, timeout) = opt(preceded(shouldbespace, timeout))(i)?;
let (i, parallel) = opt(preceded(shouldbespace, tag_no_case("PARALLEL")))(i)?;
Ok(( Ok((
i, i,
UpdateStatement { UpdateStatement {
@ -96,6 +101,7 @@ pub fn update(i: &str) -> IResult<&str, UpdateStatement> {
cond, cond,
output, output,
timeout, timeout,
parallel: parallel.is_some(),
}, },
)) ))
} }