add basic transction control
This commit is contained in:
parent
a9d51d1ebb
commit
666d1f877f
|
@ -1458,6 +1458,11 @@ TODO: change style
|
|||
> ,truncateSt
|
||||
> ,insert
|
||||
> ,update
|
||||
> ,startTransaction
|
||||
> ,savepoint
|
||||
> ,releaseSavepoint
|
||||
> ,commit
|
||||
> ,rollback
|
||||
> ,SelectStatement <$> queryExpr
|
||||
> ]
|
||||
|
||||
|
@ -1752,6 +1757,28 @@ slightly hacky parser for signed integers
|
|||
> (Restrict <$ keyword_ "restrict"
|
||||
> <|> Cascade <$ keyword_ "cascade")
|
||||
|
||||
-----------------------------
|
||||
|
||||
= access control
|
||||
|
||||
> startTransaction :: Parser Statement
|
||||
> startTransaction = StartTransaction <$ keywords_ ["start","transaction"]
|
||||
|
||||
> savepoint :: Parser Statement
|
||||
> savepoint = keyword_ "savepoint" >>
|
||||
> Savepoint <$> name
|
||||
|
||||
> releaseSavepoint :: Parser Statement
|
||||
> releaseSavepoint = keywords_ ["release","savepoint"] >>
|
||||
> ReleaseSavepoint <$> name
|
||||
|
||||
> commit :: Parser Statement
|
||||
> commit = Commit <$ keyword_ "commit" <* optional (keyword_ "work")
|
||||
|
||||
> rollback :: Parser Statement
|
||||
> rollback = keyword_ "rollback" >> optional (keyword_ "work") >>
|
||||
> Rollback <$> optionMaybe (keywords_ ["to", "savepoint"] *> name)
|
||||
|
||||
----------------------------
|
||||
|
||||
wrapper to parse a series of statements. They must be separated by
|
||||
|
|
|
@ -562,6 +562,22 @@ which have been changed to try to improve the layout of the output.
|
|||
|
||||
== access control
|
||||
|
||||
> statement _ StartTransaction =
|
||||
> texts ["start", "transaction"]
|
||||
|
||||
> statement _ (Savepoint nm) =
|
||||
> text "savepoint" <+> name nm
|
||||
|
||||
> statement _ (ReleaseSavepoint nm) =
|
||||
> texts ["release", "savepoint"] <+> name nm
|
||||
|
||||
> statement _ Commit =
|
||||
> text "commit"
|
||||
|
||||
> statement _ (Rollback mn) =
|
||||
> text "rollback"
|
||||
> <+> maybe empty (\n -> texts ["to","savepoint"] <+> name n) mn
|
||||
|
||||
== transactions
|
||||
|
||||
== sessions
|
||||
|
|
|
@ -465,12 +465,13 @@ I'm not sure if this is valid syntax or not.
|
|||
> | RevokePrivilege
|
||||
> | RevokeRole -}
|
||||
> -- transaction management
|
||||
> {- | StartTransaction
|
||||
> | SetTransaction
|
||||
> | SetContraints
|
||||
> | SavePoint
|
||||
> | ReleaseSavePoint
|
||||
> | Rollback -}
|
||||
> | StartTransaction
|
||||
> -- | SetTransaction
|
||||
> -- | SetContraints
|
||||
> | Savepoint Name
|
||||
> | ReleaseSavepoint Name
|
||||
> | Commit
|
||||
> | Rollback (Maybe Name)
|
||||
> -- session
|
||||
> {- | SetSessionCharacteristics
|
||||
> | SetSessionAuthorization
|
||||
|
|
|
@ -8,9 +8,10 @@ commit, savepoint, etc.), and session management (set).
|
|||
> module Language.SQL.SimpleSQL.SQL2011Bits (sql2011BitsTests) where
|
||||
|
||||
> import Language.SQL.SimpleSQL.TestTypes
|
||||
> import Language.SQL.SimpleSQL.Syntax
|
||||
|
||||
> sql2011BitsTests :: TestItem
|
||||
> sql2011BitsTests = Group "sql 2011 bits tests" []
|
||||
> sql2011BitsTests = Group "sql 2011 bits tests" [
|
||||
|
||||
17 Transaction management
|
||||
|
||||
|
@ -21,6 +22,10 @@ commit, savepoint, etc.), and session management (set).
|
|||
|
||||
BEGIN is not in the standard!
|
||||
|
||||
> (TestStatement SQL2011
|
||||
> "start transaction"
|
||||
> $ StartTransaction)
|
||||
|
||||
17.2 <set transaction statement>
|
||||
|
||||
<set transaction statement> ::=
|
||||
|
@ -72,16 +77,35 @@ BEGIN is not in the standard!
|
|||
<savepoint specifier> ::=
|
||||
<savepoint name>
|
||||
|
||||
> ,(TestStatement SQL2011
|
||||
> "savepoint difficult_bit"
|
||||
> $ Savepoint $ Name "difficult_bit")
|
||||
|
||||
|
||||
17.6 <release savepoint statement>
|
||||
|
||||
<release savepoint statement> ::=
|
||||
RELEASE SAVEPOINT <savepoint specifier>
|
||||
|
||||
> ,(TestStatement SQL2011
|
||||
> "release savepoint difficult_bit"
|
||||
> $ ReleaseSavepoint $ Name "difficult_bit")
|
||||
|
||||
|
||||
17.7 <commit statement>
|
||||
|
||||
<commit statement> ::=
|
||||
COMMIT [ WORK ] [ AND [ NO ] CHAIN ]
|
||||
|
||||
> ,(TestStatement SQL2011
|
||||
> "commit"
|
||||
> $ Commit)
|
||||
|
||||
> ,(TestStatement SQL2011
|
||||
> "commit work"
|
||||
> $ Commit)
|
||||
|
||||
|
||||
17.8 <rollback statement>
|
||||
|
||||
<rollback statement> ::=
|
||||
|
@ -90,6 +114,18 @@ BEGIN is not in the standard!
|
|||
<savepoint clause> ::=
|
||||
TO SAVEPOINT <savepoint specifier>
|
||||
|
||||
> ,(TestStatement SQL2011
|
||||
> "rollback"
|
||||
> $ Rollback Nothing)
|
||||
|
||||
> ,(TestStatement SQL2011
|
||||
> "rollback work"
|
||||
> $ Rollback Nothing)
|
||||
|
||||
> ,(TestStatement SQL2011
|
||||
> "rollback to savepoint difficult_bit"
|
||||
> $ Rollback $ Just $ Name "difficult_bit")
|
||||
|
||||
|
||||
19 Session management
|
||||
|
||||
|
@ -179,3 +215,5 @@ BEGIN is not in the standard!
|
|||
|
||||
<collation specification> ::=
|
||||
<value specification>
|
||||
|
||||
> ]
|
||||
|
|
Loading…
Reference in a new issue