From d500614fcc6b6e9ddd724a121431e260d7d8a185 Mon Sep 17 00:00:00 2001 From: Tpt Date: Sat, 27 May 2023 15:59:12 +0200 Subject: [PATCH] Fuzzer: do not consider OFFSET and LIMIT for now Result order is not kept by the optimizer. We can't assume it is unchanged. --- Cargo.lock | 2 +- lib/sparql-smith/Cargo.toml | 4 +++- lib/sparql-smith/src/lib.rs | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2ee4cb2..191f9136 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1657,7 +1657,7 @@ dependencies = [ [[package]] name = "sparql-smith" -version = "0.1.0-alpha.3" +version = "0.1.0-alpha.4-dev" dependencies = [ "arbitrary", ] diff --git a/lib/sparql-smith/Cargo.toml b/lib/sparql-smith/Cargo.toml index 64bd375b..2755b225 100644 --- a/lib/sparql-smith/Cargo.toml +++ b/lib/sparql-smith/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sparql-smith" -version = "0.1.0-alpha.3" +version = "0.1.0-alpha.4-dev" authors = ["Tpt "] license = "MIT OR Apache-2.0" readme = "README.md" @@ -14,6 +14,8 @@ edition = "2021" [features] default = [] +limit-offset = ["order"] +order = [] sep-0006 = [] [dependencies] diff --git a/lib/sparql-smith/src/lib.rs b/lib/sparql-smith/src/lib.rs index 6005d827..01ca45e5 100644 --- a/lib/sparql-smith/src/lib.rs +++ b/lib/sparql-smith/src/lib.rs @@ -190,7 +190,9 @@ struct SolutionModifier { // [18] SolutionModifier ::= GroupClause? HavingClause? OrderClause? LimitOffsetClauses? group: Option, having: Option, + #[cfg(feature = "order")] order: Option, + #[cfg(feature = "limit-offset")] limit_offset: Option, } @@ -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, } +#[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), } +#[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)