on master help sign in
fix mistaken join static optimization

the intention was to catch A join A -> A but, instead I was only comparing attributes

commitce6d74f9221449f3698bbdc38f326d4957a2b314 authorAgentM <agentm@themactionfaction.com> dateSun 7 Jun 2015, 22:53 (11 years ago) parent64571d6
1 file changed+8−15
ProjectM36/StaticOptimizer.hs+8−15
ProjectM36/StaticOptimizer.hs+8−15
@@ -45,23 +45,16 @@ applyStaticRelationalOptimization (Union exprA exprB) = do
4545 return $ Right $ Union optExprAx optExprBx
4646
4747applyStaticRelationalOptimization (Join exprA exprB) = do
48− typeA <- typeForRelationalExpr exprA
49− typeB <- typeForRelationalExpr exprB
50− case typeA of
48+ optExprA <- applyStaticRelationalOptimization exprA
49+ optExprB <- applyStaticRelationalOptimization exprB
50+ case optExprA of
5151 Left err -> return $ Left err
52− Right typeA2 -> case typeB of
52+ Right optExprA2 -> case optExprB of
5353 Left err -> return $ Left err
54− Right typeB2 -> if typeA2 == typeB2 then --no new attributes to add
55− return $ Right exprA
56− else do
57− optExprA <- applyStaticRelationalOptimization exprA
58− optExprB <- applyStaticRelationalOptimization exprB
59−
60− case optExprA of
61− Left err -> return $ Left err
62− Right optExprA2 -> case optExprB of
63− Left err -> return $ Left err
64− Right optExprB2 -> return $ Right (Join optExprA2 optExprB2)
54+ Right optExprB2 -> if optExprA == optExprB then --A join A == A
55+ return optExprA
56+ else
57+ return $ Right (Join optExprA2 optExprB2)
6558
6659applyStaticRelationalOptimization e@(Rename _ _ _) = return $ Right e
6760