Fuzzer: do not consider OFFSET and LIMIT for now

Result order is not kept by the optimizer.
We can't assume it is unchanged.
pull/512/head
Tpt 1 year ago committed by Thomas Tanon
parent 2650c5ed13
commit d500614fcc
  1. 2
      Cargo.lock
  2. 4
      lib/sparql-smith/Cargo.toml
  3. 14
      lib/sparql-smith/src/lib.rs

2
Cargo.lock generated

@ -1657,7 +1657,7 @@ dependencies = [
[[package]] [[package]]
name = "sparql-smith" name = "sparql-smith"
version = "0.1.0-alpha.3" version = "0.1.0-alpha.4-dev"
dependencies = [ dependencies = [
"arbitrary", "arbitrary",
] ]

@ -1,6 +1,6 @@
[package] [package]
name = "sparql-smith" name = "sparql-smith"
version = "0.1.0-alpha.3" version = "0.1.0-alpha.4-dev"
authors = ["Tpt <thomas@pellissier-tanon.fr>"] authors = ["Tpt <thomas@pellissier-tanon.fr>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"
@ -14,6 +14,8 @@ edition = "2021"
[features] [features]
default = [] default = []
limit-offset = ["order"]
order = []
sep-0006 = [] sep-0006 = []
[dependencies] [dependencies]

@ -190,7 +190,9 @@ struct SolutionModifier {
// [18] SolutionModifier ::= GroupClause? HavingClause? OrderClause? LimitOffsetClauses? // [18] SolutionModifier ::= GroupClause? HavingClause? OrderClause? LimitOffsetClauses?
group: Option<GroupClause>, group: Option<GroupClause>,
having: Option<HavingClause>, having: Option<HavingClause>,
#[cfg(feature = "order")]
order: Option<OrderClause>, order: Option<OrderClause>,
#[cfg(feature = "limit-offset")]
limit_offset: Option<LimitOffsetClauses>, limit_offset: Option<LimitOffsetClauses>,
} }
@ -202,9 +204,11 @@ impl fmt::Display for SolutionModifier {
if let Some(having) = &self.having { if let Some(having) = &self.having {
write!(f, " {having}")?; write!(f, " {having}")?;
} }
#[cfg(feature = "order")]
if let Some(order) = &self.order { if let Some(order) = &self.order {
write!(f, " {order}")?; write!(f, " {order}")?;
} }
#[cfg(feature = "limit-offset")]
if let Some(limit_offset) = &self.limit_offset { if let Some(limit_offset) = &self.limit_offset {
write!(f, " {limit_offset}")?; write!(f, " {limit_offset}")?;
} }
@ -275,6 +279,7 @@ impl fmt::Display for HavingClause {
// [22] HavingCondition ::= Constraint // [22] HavingCondition ::= Constraint
type HavingCondition = Constraint; type HavingCondition = Constraint;
#[cfg(feature = "order")]
#[derive(Arbitrary)] #[derive(Arbitrary)]
struct OrderClause { struct OrderClause {
// [23] OrderClause ::= 'ORDER' 'BY' OrderCondition+ // [23] OrderClause ::= 'ORDER' 'BY' OrderCondition+
@ -282,6 +287,7 @@ struct OrderClause {
others: Vec<OrderCondition>, others: Vec<OrderCondition>,
} }
#[cfg(feature = "order")]
impl fmt::Display for OrderClause { impl fmt::Display for OrderClause {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "ORDER BY {}", self.start)?; write!(f, "ORDER BY {}", self.start)?;
@ -292,6 +298,7 @@ impl fmt::Display for OrderClause {
} }
} }
#[cfg(feature = "order")]
#[derive(Arbitrary)] #[derive(Arbitrary)]
enum OrderCondition { enum OrderCondition {
// [24] OrderCondition ::= ( ( 'ASC' | 'DESC' ) BrackettedExpression ) | ( Constraint | Var ) // [24] OrderCondition ::= ( ( 'ASC' | 'DESC' ) BrackettedExpression ) | ( Constraint | Var )
@ -303,6 +310,7 @@ enum OrderCondition {
Var(Var), Var(Var),
} }
#[cfg(feature = "order")]
impl fmt::Display for OrderCondition { impl fmt::Display for OrderCondition {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
@ -319,6 +327,7 @@ impl fmt::Display for OrderCondition {
} }
} }
#[cfg(feature = "limit-offset")]
#[derive(Arbitrary)] #[derive(Arbitrary)]
enum LimitOffsetClauses { enum LimitOffsetClauses {
// [25] LimitOffsetClauses ::= LimitClause OffsetClause? | OffsetClause LimitClause? // [25] LimitOffsetClauses ::= LimitClause OffsetClause? | OffsetClause LimitClause?
@ -326,6 +335,7 @@ enum LimitOffsetClauses {
OffsetLimit(OffsetClause, Option<LimitClause>), OffsetLimit(OffsetClause, Option<LimitClause>),
} }
#[cfg(feature = "limit-offset")]
impl fmt::Display for LimitOffsetClauses { impl fmt::Display for LimitOffsetClauses {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
@ -337,24 +347,28 @@ impl fmt::Display for LimitOffsetClauses {
} }
} }
#[cfg(feature = "limit-offset")]
#[derive(Arbitrary)] #[derive(Arbitrary)]
struct LimitClause { struct LimitClause {
// [26] LimitClause ::= 'LIMIT' INTEGER // [26] LimitClause ::= 'LIMIT' INTEGER
value: u8, value: u8,
} }
#[cfg(feature = "limit-offset")]
impl fmt::Display for LimitClause { impl fmt::Display for LimitClause {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "LIMIT {}", self.value) write!(f, "LIMIT {}", self.value)
} }
} }
#[cfg(feature = "limit-offset")]
#[derive(Arbitrary)] #[derive(Arbitrary)]
struct OffsetClause { struct OffsetClause {
// [27] OffsetClause ::= 'OFFSET' INTEGER // [27] OffsetClause ::= 'OFFSET' INTEGER
value: u8, value: u8,
} }
#[cfg(feature = "limit-offset")]
impl fmt::Display for OffsetClause { impl fmt::Display for OffsetClause {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "OFFSET {}", self.value) write!(f, "OFFSET {}", self.value)

Loading…
Cancel
Save