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]]
name = "sparql-smith"
version = "0.1.0-alpha.3"
version = "0.1.0-alpha.4-dev"
dependencies = [
"arbitrary",
]

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

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

Loading…
Cancel
Save