1
Fork 0

add create and drop assertion

This commit is contained in:
Jake Wheat 2015-08-16 20:03:02 +03:00
parent 3c0788af6e
commit c102528d5f
4 changed files with 45 additions and 5 deletions

View file

@ -1460,7 +1460,8 @@ TODO: change style
> ,createView > ,createView
> ,createDomain > ,createDomain
> ,createSequence > ,createSequence
> ,createRole] > ,createRole
> ,createAssertion]
> ,keyword_ "alter" *> choice [alterTable > ,keyword_ "alter" *> choice [alterTable
> ,alterDomain > ,alterDomain
> ,alterSequence] > ,alterSequence]
@ -1469,7 +1470,8 @@ TODO: change style
> ,dropView > ,dropView
> ,dropDomain > ,dropDomain
> ,dropSequence > ,dropSequence
> ,dropRole] > ,dropRole
> ,dropAssertion]
> ,delete > ,delete
> ,truncateSt > ,truncateSt
> ,insert > ,insert
@ -1726,6 +1728,17 @@ slightly hacky parser for signed integers
> dropSequence = keyword_ "sequence" >> > dropSequence = keyword_ "sequence" >>
> DropSequence <$> names <*> dropBehaviour > DropSequence <$> names <*> dropBehaviour
> createAssertion :: Parser Statement
> createAssertion = keyword_ "assertion" >>
> CreateAssertion
> <$> names
> <*> (keyword_ "check" *> parens valueExpr)
> dropAssertion :: Parser Statement
> dropAssertion = keyword_ "assertion" >>
> DropAssertion <$> names <*> dropBehaviour
----------------- -----------------
= dml = dml

View file

@ -508,6 +508,14 @@ which have been changed to try to improve the layout of the output.
> statement _ (DropSequence nm db) = > statement _ (DropSequence nm db) =
> text "drop" <+> text "sequence" <+> names nm <+> dropBehav db > text "drop" <+> text "sequence" <+> names nm <+> dropBehav db
> statement d (CreateAssertion nm ex) =
> texts ["create","assertion"] <+> names nm
> <+> text "check" <+> parens (valueExpr d ex)
> statement _ (DropAssertion nm db) =
> text "drop" <+> text "assertion" <+> names nm <+> dropBehav db
== dml == dml
> statement d (SelectStatement q) = queryExpr d q > statement d (SelectStatement q) = queryExpr d q

View file

@ -431,9 +431,9 @@ I'm not sure if this is valid syntax or not.
> | DropCollation > | DropCollation
> | CreateTranslation > | CreateTranslation
> | DropTranslation -} > | DropTranslation -}
> {- | CreateAssertion > | CreateAssertion [Name] ValueExpr
> | DropAssertion > | DropAssertion [Name] DropBehaviour
> | CreateTrigger > {- | CreateTrigger
> | DropTrigger > | DropTrigger
> | CreateType > | CreateType
> | AlterType > | AlterType

View file

@ -1332,11 +1332,30 @@ defintely skip
CHECK <left paren> <search condition> <right paren> CHECK <left paren> <search condition> <right paren>
[ <constraint characteristics> ] [ <constraint characteristics> ]
> ,(TestStatement SQL2011
> "create assertion t1_not_empty CHECK ((select count(*) from t1) > 0);"
> $ CreateAssertion [Name "t1_not_empty"]
> $ BinOp (SubQueryExpr SqSq $
> makeSelect
> {qeSelectList = [(App [Name "count"] [Star],Nothing)]
> ,qeFrom = [TRSimple [Name "t1"]]
> })
> [Name ">"] (NumLit "0"))
11.48 <drop assertion statement> 11.48 <drop assertion statement>
<drop assertion statement> ::= <drop assertion statement> ::=
DROP ASSERTION <constraint name> [ <drop behavior> ] DROP ASSERTION <constraint name> [ <drop behavior> ]
> ,(TestStatement SQL2011
> "drop assertion t1_not_empty;"
> $ DropAssertion [Name "t1_not_empty"] DefaultDropBehaviour)
> ,(TestStatement SQL2011
> "drop assertion t1_not_empty cascade;"
> $ DropAssertion [Name "t1_not_empty"] Cascade)
11.49 <trigger definition> 11.49 <trigger definition>
<trigger definition> ::= <trigger definition> ::=