2015-08-01 17:08:54 +02:00
|
|
|
|
2024-01-09 01:07:47 +01:00
|
|
|
{-
|
2015-08-01 19:26:00 +02:00
|
|
|
Sections 17 and 19 in Foundation
|
2015-08-01 17:08:54 +02:00
|
|
|
|
2015-08-01 19:26:00 +02:00
|
|
|
This module covers the tests for transaction management (begin,
|
|
|
|
commit, savepoint, etc.), and session management (set).
|
2024-01-09 01:07:47 +01:00
|
|
|
-}
|
2015-08-01 17:08:54 +02:00
|
|
|
|
|
|
|
|
2024-01-10 08:40:24 +01:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2024-01-09 01:07:47 +01:00
|
|
|
module Language.SQL.SimpleSQL.SQL2011Bits (sql2011BitsTests) where
|
2015-08-01 17:08:54 +02:00
|
|
|
|
2024-01-09 01:07:47 +01:00
|
|
|
import Language.SQL.SimpleSQL.TestTypes
|
|
|
|
import Language.SQL.SimpleSQL.Syntax
|
2024-02-04 17:00:59 +01:00
|
|
|
import Language.SQL.SimpleSQL.TestRunners
|
|
|
|
import Data.Text (Text)
|
2015-08-01 17:08:54 +02:00
|
|
|
|
2024-01-09 01:07:47 +01:00
|
|
|
sql2011BitsTests :: TestItem
|
|
|
|
sql2011BitsTests = Group "sql 2011 bits tests" [
|
2015-08-01 17:08:54 +02:00
|
|
|
|
2024-01-09 01:07:47 +01:00
|
|
|
{-
|
2015-08-01 19:26:00 +02:00
|
|
|
17 Transaction management
|
|
|
|
|
|
|
|
17.1 <start transaction statement>
|
|
|
|
|
|
|
|
<start transaction statement> ::=
|
|
|
|
START TRANSACTION [ <transaction characteristics> ]
|
|
|
|
|
|
|
|
BEGIN is not in the standard!
|
2024-01-09 01:07:47 +01:00
|
|
|
-}
|
2015-08-01 19:26:00 +02:00
|
|
|
|
2024-02-04 17:00:59 +01:00
|
|
|
s "start transaction" StartTransaction
|
|
|
|
|
2024-01-09 01:07:47 +01:00
|
|
|
{-
|
2015-08-01 19:26:00 +02:00
|
|
|
17.2 <set transaction statement>
|
|
|
|
|
|
|
|
<set transaction statement> ::=
|
|
|
|
SET [ LOCAL ] TRANSACTION <transaction characteristics>
|
|
|
|
|
|
|
|
17.3 <transaction characteristics>
|
|
|
|
|
|
|
|
<transaction characteristics> ::=
|
|
|
|
[ <transaction mode> [ { <comma> <transaction mode> }... ] ]
|
|
|
|
|
|
|
|
<transaction mode> ::=
|
|
|
|
<isolation level>
|
|
|
|
| <transaction access mode>
|
|
|
|
| <diagnostics size>
|
|
|
|
|
|
|
|
<transaction access mode> ::=
|
|
|
|
READ ONLY
|
|
|
|
| READ WRITE
|
|
|
|
|
|
|
|
<isolation level> ::=
|
|
|
|
ISOLATION LEVEL <level of isolation>
|
|
|
|
|
|
|
|
<level of isolation> ::=
|
|
|
|
READ UNCOMMITTED
|
|
|
|
| READ COMMITTED
|
|
|
|
| REPEATABLE READ
|
|
|
|
| SERIALIZABLE
|
|
|
|
|
|
|
|
<diagnostics size> ::=
|
|
|
|
DIAGNOSTICS SIZE <number of conditions>
|
|
|
|
|
|
|
|
<number of conditions> ::=
|
|
|
|
<simple value specification>
|
|
|
|
|
|
|
|
17.4 <set constraints mode statement>
|
|
|
|
|
|
|
|
<set constraints mode statement> ::=
|
|
|
|
SET CONSTRAINTS <constraint name list> { DEFERRED | IMMEDIATE }
|
|
|
|
|
|
|
|
<constraint name list> ::=
|
|
|
|
ALL
|
|
|
|
| <constraint name> [ { <comma> <constraint name> }... ]
|
|
|
|
|
|
|
|
17.5 <savepoint statement>
|
|
|
|
|
|
|
|
<savepoint statement> ::=
|
|
|
|
SAVEPOINT <savepoint specifier>
|
|
|
|
|
|
|
|
<savepoint specifier> ::=
|
|
|
|
<savepoint name>
|
2024-01-09 01:07:47 +01:00
|
|
|
-}
|
2015-08-01 19:26:00 +02:00
|
|
|
|
2024-02-04 17:00:59 +01:00
|
|
|
,s "savepoint difficult_bit"
|
|
|
|
$ Savepoint $ Name Nothing "difficult_bit"
|
2015-08-04 21:53:08 +02:00
|
|
|
|
|
|
|
|
2024-01-09 01:07:47 +01:00
|
|
|
{-
|
2015-08-01 19:26:00 +02:00
|
|
|
17.6 <release savepoint statement>
|
|
|
|
|
|
|
|
<release savepoint statement> ::=
|
|
|
|
RELEASE SAVEPOINT <savepoint specifier>
|
2024-01-09 01:07:47 +01:00
|
|
|
-}
|
2015-08-01 19:26:00 +02:00
|
|
|
|
2024-02-04 17:00:59 +01:00
|
|
|
,s "release savepoint difficult_bit"
|
|
|
|
$ ReleaseSavepoint $ Name Nothing "difficult_bit"
|
2015-08-04 21:53:08 +02:00
|
|
|
|
|
|
|
|
2024-01-09 01:07:47 +01:00
|
|
|
{-
|
2015-08-01 19:26:00 +02:00
|
|
|
17.7 <commit statement>
|
|
|
|
|
|
|
|
<commit statement> ::=
|
|
|
|
COMMIT [ WORK ] [ AND [ NO ] CHAIN ]
|
2024-01-09 01:07:47 +01:00
|
|
|
-}
|
2015-08-01 19:26:00 +02:00
|
|
|
|
2024-02-04 17:00:59 +01:00
|
|
|
,s "commit" Commit
|
2015-08-04 21:53:08 +02:00
|
|
|
|
2024-02-04 17:00:59 +01:00
|
|
|
,s "commit work" Commit
|
2015-08-04 21:53:08 +02:00
|
|
|
|
|
|
|
|
2024-01-09 01:07:47 +01:00
|
|
|
{-
|
2015-08-01 19:26:00 +02:00
|
|
|
17.8 <rollback statement>
|
|
|
|
|
|
|
|
<rollback statement> ::=
|
|
|
|
ROLLBACK [ WORK ] [ AND [ NO ] CHAIN ] [ <savepoint clause> ]
|
|
|
|
|
|
|
|
<savepoint clause> ::=
|
|
|
|
TO SAVEPOINT <savepoint specifier>
|
2024-01-09 01:07:47 +01:00
|
|
|
-}
|
2015-08-01 19:26:00 +02:00
|
|
|
|
2024-02-04 17:00:59 +01:00
|
|
|
,s "rollback" $ Rollback Nothing
|
2015-08-04 21:53:08 +02:00
|
|
|
|
2024-02-04 17:00:59 +01:00
|
|
|
,s "rollback work" $ Rollback Nothing
|
2015-08-04 21:53:08 +02:00
|
|
|
|
2024-02-04 17:00:59 +01:00
|
|
|
,s "rollback to savepoint difficult_bit"
|
|
|
|
$ Rollback $ Just $ Name Nothing "difficult_bit"
|
2015-08-04 21:53:08 +02:00
|
|
|
|
2015-08-01 19:26:00 +02:00
|
|
|
|
2024-01-09 01:07:47 +01:00
|
|
|
{-
|
2015-08-01 19:26:00 +02:00
|
|
|
19 Session management
|
|
|
|
|
|
|
|
19.1 <set session characteristics statement>
|
|
|
|
|
|
|
|
<set session characteristics statement> ::=
|
|
|
|
SET SESSION CHARACTERISTICS AS <session characteristic list>
|
|
|
|
|
|
|
|
<session characteristic list> ::=
|
|
|
|
<session characteristic> [ { <comma> <session characteristic> }... ]
|
|
|
|
|
|
|
|
<session characteristic> ::=
|
|
|
|
<session transaction characteristics>
|
|
|
|
|
|
|
|
<session transaction characteristics> ::=
|
|
|
|
TRANSACTION <transaction mode> [ { <comma> <transaction mode> }... ]
|
|
|
|
|
|
|
|
19.2 <set session user identifier statement>
|
|
|
|
|
|
|
|
<set session user identifier statement> ::=
|
|
|
|
SET SESSION AUTHORIZATION <value specification>
|
|
|
|
|
|
|
|
19.3 <set role statement>
|
|
|
|
|
|
|
|
<set role statement> ::=
|
|
|
|
SET ROLE <role specification>
|
|
|
|
|
|
|
|
<role specification> ::=
|
|
|
|
<value specification>
|
|
|
|
| NONE
|
|
|
|
|
|
|
|
19.4 <set local time zone statement>
|
|
|
|
|
|
|
|
<set local time zone statement> ::=
|
|
|
|
SET TIME ZONE <set time zone value>
|
|
|
|
|
|
|
|
<set time zone value> ::=
|
|
|
|
<interval value expression>
|
|
|
|
| LOCAL
|
|
|
|
|
|
|
|
19.5 <set catalog statement>
|
|
|
|
|
|
|
|
<set catalog statement> ::=
|
|
|
|
SET <catalog name characteristic>
|
|
|
|
|
|
|
|
<catalog name characteristic> ::=
|
|
|
|
CATALOG <value specification>
|
|
|
|
|
|
|
|
19.6 <set schema statement>
|
|
|
|
|
|
|
|
<set schema statement> ::=
|
|
|
|
SET <schema name characteristic>
|
|
|
|
|
|
|
|
<schema name characteristic> ::=
|
|
|
|
SCHEMA <value specification>
|
|
|
|
|
|
|
|
19.7 <set names statement>
|
|
|
|
|
|
|
|
<set names statement> ::=
|
|
|
|
SET <character set name characteristic>
|
|
|
|
|
|
|
|
<character set name characteristic> ::=
|
|
|
|
NAMES <value specification>
|
|
|
|
|
|
|
|
19.8 <set path statement>
|
|
|
|
|
|
|
|
<set path statement> ::=
|
|
|
|
SET <SQL-path characteristic>
|
|
|
|
|
|
|
|
<SQL-path characteristic> ::=
|
|
|
|
PATH <value specification>
|
|
|
|
|
|
|
|
19.9 <set transform group statement>
|
|
|
|
|
|
|
|
<set transform group statement> ::=
|
|
|
|
SET <transform group characteristic>
|
|
|
|
|
|
|
|
<transform group characteristic> ::=
|
|
|
|
DEFAULT TRANSFORM GROUP <value specification>
|
|
|
|
| TRANSFORM GROUP FOR TYPE <path-resolved user-defined type name> <value specification>
|
|
|
|
|
|
|
|
19.10 <set session collation statement>
|
|
|
|
|
|
|
|
<set session collation statement> ::=
|
|
|
|
SET COLLATION <collation specification> [ FOR <character set specification list> ]
|
|
|
|
| SET NO COLLATION [ FOR <character set specification list> ]
|
|
|
|
|
|
|
|
<collation specification> ::=
|
|
|
|
<value specification>
|
2024-01-09 01:07:47 +01:00
|
|
|
-}
|
2015-08-04 21:53:08 +02:00
|
|
|
|
2024-01-09 01:07:47 +01:00
|
|
|
]
|
2024-02-04 17:00:59 +01:00
|
|
|
|
|
|
|
s :: HasCallStack => Text -> Statement -> TestItem
|
|
|
|
s src ast = testStatement ansi2011 src ast
|