1
Fork 0

add basic transction control

This commit is contained in:
Jake Wheat 2015-08-04 22:53:08 +03:00
parent a9d51d1ebb
commit 666d1f877f
4 changed files with 89 additions and 7 deletions

View file

@ -1458,6 +1458,11 @@ TODO: change style
> ,truncateSt > ,truncateSt
> ,insert > ,insert
> ,update > ,update
> ,startTransaction
> ,savepoint
> ,releaseSavepoint
> ,commit
> ,rollback
> ,SelectStatement <$> queryExpr > ,SelectStatement <$> queryExpr
> ] > ]
@ -1752,6 +1757,28 @@ slightly hacky parser for signed integers
> (Restrict <$ keyword_ "restrict" > (Restrict <$ keyword_ "restrict"
> <|> Cascade <$ keyword_ "cascade") > <|> 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 wrapper to parse a series of statements. They must be separated by

View file

@ -562,6 +562,22 @@ which have been changed to try to improve the layout of the output.
== access control == 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 == transactions
== sessions == sessions

View file

@ -465,12 +465,13 @@ I'm not sure if this is valid syntax or not.
> | RevokePrivilege > | RevokePrivilege
> | RevokeRole -} > | RevokeRole -}
> -- transaction management > -- transaction management
> {- | StartTransaction > | StartTransaction
> | SetTransaction > -- | SetTransaction
> | SetContraints > -- | SetContraints
> | SavePoint > | Savepoint Name
> | ReleaseSavePoint > | ReleaseSavepoint Name
> | Rollback -} > | Commit
> | Rollback (Maybe Name)
> -- session > -- session
> {- | SetSessionCharacteristics > {- | SetSessionCharacteristics
> | SetSessionAuthorization > | SetSessionAuthorization

View file

@ -8,9 +8,10 @@ commit, savepoint, etc.), and session management (set).
> module Language.SQL.SimpleSQL.SQL2011Bits (sql2011BitsTests) where > module Language.SQL.SimpleSQL.SQL2011Bits (sql2011BitsTests) where
> import Language.SQL.SimpleSQL.TestTypes > import Language.SQL.SimpleSQL.TestTypes
> import Language.SQL.SimpleSQL.Syntax
> sql2011BitsTests :: TestItem > sql2011BitsTests :: TestItem
> sql2011BitsTests = Group "sql 2011 bits tests" [] > sql2011BitsTests = Group "sql 2011 bits tests" [
17 Transaction management 17 Transaction management
@ -21,6 +22,10 @@ commit, savepoint, etc.), and session management (set).
BEGIN is not in the standard! BEGIN is not in the standard!
> (TestStatement SQL2011
> "start transaction"
> $ StartTransaction)
17.2 <set transaction statement> 17.2 <set transaction statement>
<set transaction statement> ::= <set transaction statement> ::=
@ -72,16 +77,35 @@ BEGIN is not in the standard!
<savepoint specifier> ::= <savepoint specifier> ::=
<savepoint name> <savepoint name>
> ,(TestStatement SQL2011
> "savepoint difficult_bit"
> $ Savepoint $ Name "difficult_bit")
17.6 <release savepoint statement> 17.6 <release savepoint statement>
<release savepoint statement> ::= <release savepoint statement> ::=
RELEASE SAVEPOINT <savepoint specifier> RELEASE SAVEPOINT <savepoint specifier>
> ,(TestStatement SQL2011
> "release savepoint difficult_bit"
> $ ReleaseSavepoint $ Name "difficult_bit")
17.7 <commit statement> 17.7 <commit statement>
<commit statement> ::= <commit statement> ::=
COMMIT [ WORK ] [ AND [ NO ] CHAIN ] COMMIT [ WORK ] [ AND [ NO ] CHAIN ]
> ,(TestStatement SQL2011
> "commit"
> $ Commit)
> ,(TestStatement SQL2011
> "commit work"
> $ Commit)
17.8 <rollback statement> 17.8 <rollback statement>
<rollback statement> ::= <rollback statement> ::=
@ -90,6 +114,18 @@ BEGIN is not in the standard!
<savepoint clause> ::= <savepoint clause> ::=
TO SAVEPOINT <savepoint specifier> 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 19 Session management
@ -179,3 +215,5 @@ BEGIN is not in the standard!
<collation specification> ::= <collation specification> ::=
<value specification> <value specification>
> ]