@@ -248,6 +248,7 @@ data TutorialDOperator where
248 ShowRelation :: RelationalExpr -> TutorialDOperator
248 ShowRelation :: RelationalExpr -> TutorialDOperator
249 ShowRelationType :: RelationalExpr -> TutorialDOperator
249 ShowRelationType :: RelationalExpr -> TutorialDOperator
250 ShowConstraint :: String -> TutorialDOperator
250 ShowConstraint :: String -> TutorialDOperator
251+ ShowPlan :: DatabaseExpr -> TutorialDOperator
251 Quit :: TutorialDOperator
252 Quit :: TutorialDOperator
252 deriving (Show)
253 deriving (Show)
@@ -263,6 +264,12 @@ showRelP = do
263 expr <- relExpr
264 expr <- relExpr
264 return $ ShowRelation expr
265 return $ ShowRelation expr
267+showPlanP :: Parser TutorialDOperator
270+ expr <- databaseExpr
271+ return $ ShowPlan expr
266quitP :: Parser TutorialDOperator
273quitP :: Parser TutorialDOperator
267quitP = do
274quitP = do
268 reservedOp ":q"
275 reservedOp ":q"
@@ -278,6 +285,7 @@ interpreterOps :: Parser TutorialDOperator
278interpreterOps = typeP
285interpreterOps = typeP
279 <|> showRelP
286 <|> showRelP
280 <|> showConstraintsP
287 <|> showConstraintsP
281 <|> quitP
289 <|> quitP
283showRelationAttributes :: Relation -> String
291showRelationAttributes :: Relation -> String
@@ -312,6 +320,11 @@ evalTutorialDOp context (ShowConstraint name) = do
312 "" -> deps
320 "" -> deps
313 name -> HS.filter (\(InclusionDependency n _ _) -> n == name) deps
321 name -> HS.filter (\(InclusionDependency n _ _) -> n == name) deps
323+evalTutorialDOp context (ShowPlan dbExpr) = do
324+ DisplayResult $ show plan
326+ plan = evalState (applyStaticDatabaseOptimization dbExpr) context
315evalTutorialDOp context (Quit) = QuitResult
328evalTutorialDOp context (Quit) = QuitResult
317example1 = "relA {a,b, c}"
330example1 = "relA {a,b, c}"