@@ -426,20 +426,15 @@ checkConstraints context = case failures of
426426 where
427427 failures = M.elems $ M.mapMaybeWithKey checkIncDep deps
428428 deps = inclusionDependencies context
429− eval expr = runState (evalRelationalExpr expr) (RelationalExprStateElems context)
430− checkIncDep depName (InclusionDependency subsetExpr supersetExpr) = case evaldSub of
431− (Left err, _) -> Just err
432− (Right relSub, _) -> case evaldSuper of
433− (Left err, _) -> Just err
434− (Right relSuper, _) -> case union relSub relSuper of -- maybe this should be rewritten as a RelationalExpr in order to take advantage of optimizations (union, ==)
435− Left err -> Just err
436− Right resultRel -> if resultRel == relSuper then
437− Nothing
438− else do
439− Just $ InclusionDependencyCheckError depName
440− where
441− evaldSub = eval subsetExpr
442− evaldSuper = eval supersetExpr
429+ eval expr = evalState (evalRelationalExpr expr) (RelationalExprStateElems context)
430+ checkIncDep depName (InclusionDependency subsetExpr supersetExpr) = do
431+ let checkExpr = Equals supersetExpr (Union subsetExpr supersetExpr)
432+ case eval checkExpr of
433+ Left err -> Just err
434+ Right resultRel -> if resultRel == relationTrue then
435+ Nothing
436+ else
437+ Just $ InclusionDependencyCheckError depName
443438
444439-- the type of a relational expression is equal to the relation attribute set returned from executing the relational expression; therefore, the type can be cheaply derived by evaluating a relational expression and ignoring and tuple processing
445440-- furthermore, the type of a relational expression is the resultant header of the evaluated empty-tupled relation