2014-04-19 21:24:10 +02:00
|
|
|
|
2015-08-02 18:27:39 +02:00
|
|
|
This file goes through the grammar for SQL 2011 queries (using the
|
|
|
|
draft standard).
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2015-08-02 18:27:39 +02:00
|
|
|
There are other files which cover some of the other sections from SQL
|
|
|
|
2011 (ddl, non-query dml, etc).
|
|
|
|
|
|
|
|
Possible sections not in the todo which could
|
|
|
|
be covered:
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2015-08-01 17:08:54 +02:00
|
|
|
13 modules
|
|
|
|
16 control statements
|
2015-08-02 18:27:39 +02:00
|
|
|
18 connection management
|
2015-08-01 17:08:54 +02:00
|
|
|
20 dynamic
|
|
|
|
22 direct
|
|
|
|
23 diagnostics
|
|
|
|
|
2015-08-02 18:27:39 +02:00
|
|
|
procedural sql
|
|
|
|
|
|
|
|
some of the main areas being left for now:
|
|
|
|
temporal and versioning stuff
|
|
|
|
modules
|
|
|
|
ref stuff
|
|
|
|
todo: finish this list
|
|
|
|
|
2015-08-01 17:08:54 +02:00
|
|
|
|
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
The goal is to create some example tests for each bit of grammar, with
|
|
|
|
some areas getting more comprehensive coverage tests, and also to note
|
|
|
|
which parts aren't currently supported.
|
|
|
|
|
2015-08-01 17:08:54 +02:00
|
|
|
> module Language.SQL.SimpleSQL.SQL2011Queries (sql2011QueryTests) where
|
2014-04-19 21:24:10 +02:00
|
|
|
> import Language.SQL.SimpleSQL.TestTypes
|
|
|
|
> import Language.SQL.SimpleSQL.Syntax
|
|
|
|
|
2015-08-01 17:08:54 +02:00
|
|
|
> sql2011QueryTests :: TestItem
|
|
|
|
> sql2011QueryTests = Group "sql 2011 query tests"
|
2014-04-19 21:24:10 +02:00
|
|
|
> [literals
|
2014-04-20 15:13:14 +02:00
|
|
|
> ,identifiers
|
2014-04-20 16:03:32 +02:00
|
|
|
> ,typeNameTests
|
2014-04-20 18:24:03 +02:00
|
|
|
> ,fieldDefinition
|
2014-04-20 15:13:14 +02:00
|
|
|
> ,valueExpressions
|
|
|
|
> ,queryExpressions
|
|
|
|
> ,scalarSubquery
|
|
|
|
> ,predicates
|
|
|
|
> ,intervalQualifier
|
2014-04-19 21:24:10 +02:00
|
|
|
> ,collateClause
|
2014-04-20 15:13:14 +02:00
|
|
|
> ,aggregateFunction
|
2014-04-19 21:24:10 +02:00
|
|
|
> ,sortSpecificationList
|
|
|
|
> ]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
= 5 Lexical elements
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
The tests don't make direct use of these definitions.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 5.1 <SQL terminal character>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Define the terminal symbols of the SQL language and the elements of
|
|
|
|
strings.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL terminal character> ::= <SQL language character>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL language character> ::=
|
|
|
|
<simple Latin letter>
|
|
|
|
| <digit>
|
|
|
|
| <SQL special character>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<simple Latin letter> ::=
|
|
|
|
<simple Latin upper case letter>
|
|
|
|
| <simple Latin lower case letter>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<simple Latin upper case letter> ::=
|
|
|
|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O
|
|
|
|
| P | Q | R | S | T | U | V | W | X | Y | Z
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<simple Latin lower case letter> ::=
|
|
|
|
a | b | c | d | e | f | g | h | i | j | k | l | m | n | o
|
|
|
|
| p | q | r | s | t | u | v | w | x | y | z
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL special character> ::=
|
|
|
|
<space>
|
|
|
|
| <double quote>
|
|
|
|
| <percent>
|
|
|
|
| <ampersand>
|
|
|
|
| <quote>
|
|
|
|
| <left paren>
|
|
|
|
| <right paren>
|
|
|
|
| <asterisk>
|
|
|
|
| <plus sign>
|
|
|
|
| <comma>
|
|
|
|
| <minus sign>
|
|
|
|
| <period>
|
|
|
|
| <solidus>
|
|
|
|
| <colon>
|
|
|
|
| <semicolon>
|
|
|
|
| <less than operator>
|
|
|
|
| <equals operator>
|
|
|
|
| <greater than operator>
|
|
|
|
| <question mark>
|
|
|
|
| <left bracket>
|
|
|
|
| <right bracket>
|
|
|
|
| <circumflex>
|
|
|
|
| <underscore>
|
|
|
|
| <vertical bar>
|
|
|
|
| <left brace>
|
|
|
|
| <right brace>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<space> ::= !! See the Syntax Rules.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<double quote> ::= "
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<percent> ::= %
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<ampersand> ::= &
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<quote> ::= '
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<left paren> ::= (
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<right paren> ::= )
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<asterisk> ::= *
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<plus sign> ::= +
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<comma> ::= ,
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<minus sign> ::= -
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period> ::= .
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<solidus> ::= /
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<reverse solidus> ::= \
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<colon> ::= :
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<semicolon> ::= ;
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<less than operator> ::= <
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<equals operator> ::= =
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<greater than operator> ::= >
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<question mark> ::= ?
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<left bracket or trigraph> ::= <left bracket> | <left bracket trigraph>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<right bracket or trigraph> ::= <right bracket> | <right bracket trigraph>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<left bracket> ::= [
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<left bracket trigraph> ::= ??(
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<right bracket> ::= ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<right bracket trigraph> ::= ??)
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<circumflex> ::= ^
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<underscore> ::= _
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<vertical bar> ::= |
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<left brace> ::= {
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<right brace> ::= }
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 5.2 <token> and <separator>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Specify lexical units (tokens and separators) that participate in SQL
|
|
|
|
language.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<token> ::= <nondelimiter token> | <delimiter token>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
<nondelimiter token> ::=
|
|
|
|
<regular identifier>
|
|
|
|
| <key word>
|
|
|
|
| <unsigned numeric literal>
|
|
|
|
| <national character string literal>
|
|
|
|
| <binary string literal>
|
|
|
|
| <large object length token>
|
|
|
|
| <Unicode delimited identifier>
|
|
|
|
| <Unicode character string literal>
|
|
|
|
| <SQL language identifier>
|
|
|
|
|
|
|
|
<regular identifier> ::= <identifier body>
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
<identifier body> ::= <identifier start> [ <identifier part>... ]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<identifier part> ::= <identifier start> | <identifier extend>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
<identifier start> ::= !! See the Syntax Rules.
|
|
|
|
|
|
|
|
<identifier extend> ::= !! See the Syntax Rules.
|
|
|
|
|
|
|
|
<large object length token> ::= <digit>... <multiplier>
|
|
|
|
|
|
|
|
<multiplier> ::= K | M | G | T | P
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<delimited identifier> ::=
|
|
|
|
<double quote> <delimited identifier body> <double quote>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<delimited identifier body> ::= <delimited identifier part>...
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<delimited identifier part> ::=
|
|
|
|
<nondoublequote character>
|
|
|
|
| <doublequote symbol>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<Unicode delimited identifier> ::=
|
|
|
|
U <ampersand> <double quote> <Unicode delimiter body> <double quote>
|
|
|
|
<Unicode escape specifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<Unicode escape specifier> ::=
|
|
|
|
[ UESCAPE <quote> <Unicode escape character> <quote> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<Unicode delimiter body> ::= <Unicode identifier part>...
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<Unicode identifier part> ::=
|
|
|
|
<delimited identifier part>
|
|
|
|
| <Unicode escape value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<Unicode escape value> ::=
|
|
|
|
<Unicode 4 digit escape value>
|
|
|
|
| <Unicode 6 digit escape value>
|
|
|
|
| <Unicode character escape value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<Unicode 4 digit escape value> ::=
|
|
|
|
<Unicode escape character> <hexit> <hexit> <hexit> <hexit>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<Unicode 6 digit escape value> ::=
|
|
|
|
<Unicode escape character> <plus sign>
|
|
|
|
<hexit> <hexit> <hexit> <hexit> <hexit> <hexit>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<Unicode character escape value> ::=
|
|
|
|
<Unicode escape character> <Unicode escape character>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<Unicode escape character> ::= !! See the Syntax Rules.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<nondoublequote character> ::= !! See the Syntax Rules.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<doublequote symbol> ::= ""!! two consecutive double quote characters
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
<delimiter token> ::=
|
|
|
|
<character string literal>
|
|
|
|
| <date string>
|
|
|
|
| <time string>
|
|
|
|
| <timestamp string>
|
|
|
|
| <interval string>
|
|
|
|
| <delimited identifier>
|
|
|
|
| <SQL special character>
|
|
|
|
| <not equals operator>
|
|
|
|
| <greater than or equals operator>
|
|
|
|
| <less than or equals operator>
|
|
|
|
| <concatenation operator>
|
|
|
|
| <right arrow>
|
|
|
|
| <left bracket trigraph>
|
|
|
|
| <right bracket trigraph>
|
|
|
|
| <double colon>
|
|
|
|
| <double period>
|
|
|
|
| <named argument assignment token>
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<not equals operator> ::= <>
|
|
|
|
|
|
|
|
<greater than or equals operator> ::= >=
|
|
|
|
|
|
|
|
<less than or equals operator> ::= <=
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<concatenation operator> ::= ||
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<right arrow> ::= ->
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<double colon> ::= ::
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<double period> ::= ..
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<named argument assignment token> ::= =>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<separator> ::= { <comment> | <white space> }...
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<white space> ::= !! See the Syntax Rules.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<comment> ::= <simple comment> | <bracketed comment>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<simple comment> ::=
|
|
|
|
<simple comment introducer> [ <comment character>... ] <newline>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<simple comment introducer> ::= <minus sign> <minus sign>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<bracketed comment> ::=
|
|
|
|
<bracketed comment introducer>
|
|
|
|
<bracketed comment contents>
|
|
|
|
<bracketed comment terminator>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<bracketed comment introducer> ::= /*
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<bracketed comment terminator> ::= */
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<bracketed comment contents> ::=
|
|
|
|
[ { <comment character> | <separator> }... ]!! See the Syntax Rules.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<comment character> ::= <nonquote character> | <quote>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<newline> ::= !! See the Syntax Rules.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<key word> ::= <reserved word> | <non-reserved word>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
<non-reserved word> ::=
|
|
|
|
A | ABSOLUTE | ACTION | ADA | ADD | ADMIN | AFTER | ALWAYS | ASC
|
|
|
|
| ASSERTION | ASSIGNMENT | ATTRIBUTE | ATTRIBUTES
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| BEFORE | BERNOULLI | BREADTH
|
2014-04-20 15:13:14 +02:00
|
|
|
|
|
|
|
| C | CASCADE | CATALOG | CATALOG_NAME | CHAIN | CHARACTER_SET_CATALOG
|
|
|
|
| CHARACTER_SET_NAME | CHARACTER_SET_SCHEMA | CHARACTERISTICS | CHARACTERS
|
|
|
|
| CLASS_ORIGIN | COBOL | COLLATION | COLLATION_CATALOG | COLLATION_NAME | COLLATION_SCHEMA
|
|
|
|
| COLUMN_NAME | COMMAND_FUNCTION | COMMAND_FUNCTION_CODE | COMMITTED
|
|
|
|
| CONDITION_NUMBER | CONNECTION | CONNECTION_NAME | CONSTRAINT_CATALOG | CONSTRAINT_NAME
|
|
|
|
| CONSTRAINT_SCHEMA | CONSTRAINTS | CONSTRUCTOR | CONTINUE | CURSOR_NAME
|
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| DATA | DATETIME_INTERVAL_CODE | DATETIME_INTERVAL_PRECISION | DEFAULTS | DEFERRABLE
|
|
|
|
| DEFERRED | DEFINED | DEFINER | DEGREE | DEPTH | DERIVED | DESC | DESCRIPTOR
|
|
|
|
| DIAGNOSTICS | DISPATCH | DOMAIN | DYNAMIC_FUNCTION | DYNAMIC_FUNCTION_CODE
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| ENFORCED | EXCLUDE | EXCLUDING | EXPRESSION
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| FINAL | FIRST | FLAG | FOLLOWING | FORTRAN | FOUND
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| G | GENERAL | GENERATED | GO | GOTO | GRANTED
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| HIERARCHY
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| IGNORE | IMMEDIATE | IMMEDIATELY | IMPLEMENTATION | INCLUDING | INCREMENT | INITIALLY
|
|
|
|
| INPUT | INSTANCE | INSTANTIABLE | INSTEAD | INVOKER | ISOLATION
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| K | KEY | KEY_MEMBER | KEY_TYPE
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| LAST | LENGTH | LEVEL | LOCATOR
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| M | MAP | MATCHED | MAXVALUE | MESSAGE_LENGTH | MESSAGE_OCTET_LENGTH
|
|
|
|
| MESSAGE_TEXT | MINVALUE | MORE | MUMPS
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| NAME | NAMES | NESTING | NEXT | NFC | NFD | NFKC | NFKD
|
|
|
|
| NORMALIZED | NULLABLE | NULLS | NUMBER
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| OBJECT | OCTETS | OPTION | OPTIONS | ORDERING | ORDINALITY | OTHERS
|
|
|
|
| OUTPUT | OVERRIDING
|
2014-04-20 15:13:14 +02:00
|
|
|
|
|
|
|
| P | PAD | PARAMETER_MODE | PARAMETER_NAME | PARAMETER_ORDINAL_POSITION
|
|
|
|
| PARAMETER_SPECIFIC_CATALOG | PARAMETER_SPECIFIC_NAME | PARAMETER_SPECIFIC_SCHEMA
|
|
|
|
| PARTIAL | PASCAL | PATH | PLACING | PLI | PRECEDING | PRESERVE | PRIOR
|
|
|
|
| PRIVILEGES | PUBLIC
|
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| READ | RELATIVE | REPEATABLE | RESPECT | RESTART | RESTRICT | RETURNED_CARDINALITY
|
|
|
|
| RETURNED_LENGTH | RETURNED_OCTET_LENGTH | RETURNED_SQLSTATE | ROLE
|
|
|
|
| ROUTINE | ROUTINE_CATALOG | ROUTINE_NAME | ROUTINE_SCHEMA | ROW_COUNT
|
2014-04-20 15:13:14 +02:00
|
|
|
|
|
|
|
| SCALE | SCHEMA | SCHEMA_NAME | SCOPE_CATALOG | SCOPE_NAME | SCOPE_SCHEMA
|
|
|
|
| SECTION | SECURITY | SELF | SEQUENCE | SERIALIZABLE | SERVER_NAME | SESSION
|
|
|
|
| SETS | SIMPLE | SIZE | SOURCE | SPACE | SPECIFIC_NAME | STATE | STATEMENT
|
|
|
|
| STRUCTURE | STYLE | SUBCLASS_ORIGIN
|
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| T | TABLE_NAME | TEMPORARY | TIES | TOP_LEVEL_COUNT | TRANSACTION
|
|
|
|
| TRANSACTION_ACTIVE | TRANSACTIONS_COMMITTED | TRANSACTIONS_ROLLED_BACK
|
|
|
|
| TRANSFORM | TRANSFORMS | TRIGGER_CATALOG | TRIGGER_NAME | TRIGGER_SCHEMA | TYPE
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| UNBOUNDED | UNCOMMITTED | UNDER | UNNAMED | USAGE | USER_DEFINED_TYPE_CATALOG
|
|
|
|
| USER_DEFINED_TYPE_CODE | USER_DEFINED_TYPE_NAME | USER_DEFINED_TYPE_SCHEMA
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| VIEW
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| WORK | WRITE
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| ZONE
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
<reserved word> ::=
|
|
|
|
ABS | ALL | ALLOCATE | ALTER | AND | ANY | ARE | ARRAY | ARRAY_AGG
|
|
|
|
| ARRAY_MAX_CARDINALITY | AS | ASENSITIVE | ASYMMETRIC | AT | ATOMIC | AUTHORIZATION
|
|
|
|
| AVG
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| BEGIN | BEGIN_FRAME | BEGIN_PARTITION | BETWEEN | BIGINT | BINARY
|
|
|
|
| BLOB | BOOLEAN | BOTH | BY
|
2014-04-20 15:13:14 +02:00
|
|
|
|
|
|
|
| CALL | CALLED | CARDINALITY | CASCADED | CASE | CAST | CEIL | CEILING
|
|
|
|
| CHAR | CHAR_LENGTH | CHARACTER | CHARACTER_LENGTH | CHECK | CLOB | CLOSE
|
|
|
|
| COALESCE | COLLATE | COLLECT | COLUMN | COMMIT | CONDITION | CONNECT
|
|
|
|
| CONSTRAINT | CONTAINS | CONVERT | CORR | CORRESPONDING | COUNT | COVAR_POP
|
|
|
|
| COVAR_SAMP | CREATE | CROSS | CUBE | CUME_DIST | CURRENT | CURRENT_CATALOG
|
|
|
|
| CURRENT_DATE | CURRENT_DEFAULT_TRANSFORM_GROUP | CURRENT_PATH | CURRENT_ROLE
|
|
|
|
| CURRENT_ROW | CURRENT_SCHEMA | CURRENT_TIME | CURRENT_TIMESTAMP
|
|
|
|
| CURRENT_TRANSFORM_GROUP_FOR_TYPE | CURRENT_USER | CURSOR | CYCLE
|
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| DATE | DAY | DEALLOCATE | DEC | DECIMAL | DECLARE | DEFAULT | DELETE
|
|
|
|
| DENSE_RANK | DEREF | DESCRIBE | DETERMINISTIC | DISCONNECT | DISTINCT
|
|
|
|
| DOUBLE | DROP | DYNAMIC
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| EACH | ELEMENT | ELSE | END | END_FRAME | END_PARTITION | END-EXEC
|
|
|
|
| EQUALS | ESCAPE | EVERY | EXCEPT | EXEC | EXECUTE | EXISTS | EXP
|
|
|
|
| EXTERNAL | EXTRACT
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| FALSE | FETCH | FILTER | FIRST_VALUE | FLOAT | FLOOR | FOR | FOREIGN
|
|
|
|
| FRAME_ROW | FREE | FROM | FULL | FUNCTION | FUSION
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| GET | GLOBAL | GRANT | GROUP | GROUPING | GROUPS
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| HAVING | HOLD | HOUR
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| IDENTITY | IN | INDICATOR | INNER | INOUT | INSENSITIVE | INSERT
|
|
|
|
| INT | INTEGER | INTERSECT | INTERSECTION | INTERVAL | INTO | IS
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| JOIN
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| LAG | LANGUAGE | LARGE | LAST_VALUE | LATERAL | LEAD | LEADING | LEFT
|
|
|
|
| LIKE | LIKE_REGEX | LN | LOCAL | LOCALTIME | LOCALTIMESTAMP | LOWER
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| MATCH | MAX | MEMBER | MERGE | METHOD | MIN | MINUTE
|
|
|
|
| MOD | MODIFIES | MODULE | MONTH | MULTISET
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| NATIONAL | NATURAL | NCHAR | NCLOB | NEW | NO | NONE | NORMALIZE | NOT
|
|
|
|
| NTH_VALUE | NTILE | NULL | NULLIF | NUMERIC
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| OCTET_LENGTH | OCCURRENCES_REGEX | OF | OFFSET | OLD | ON | ONLY | OPEN
|
|
|
|
| OR | ORDER | OUT | OUTER | OVER | OVERLAPS | OVERLAY
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| PARAMETER | PARTITION | PERCENT | PERCENT_RANK | PERCENTILE_CONT
|
|
|
|
| PERCENTILE_DISC | PERIOD | PORTION | POSITION | POSITION_REGEX | POWER | PRECEDES
|
|
|
|
| PRECISION | PREPARE | PRIMARY | PROCEDURE
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| RANGE | RANK | READS | REAL | RECURSIVE | REF | REFERENCES | REFERENCING
|
|
|
|
| REGR_AVGX | REGR_AVGY | REGR_COUNT | REGR_INTERCEPT | REGR_R2 | REGR_SLOPE
|
|
|
|
| REGR_SXX | REGR_SXY | REGR_SYY | RELEASE | RESULT | RETURN | RETURNS
|
|
|
|
| REVOKE | RIGHT | ROLLBACK | ROLLUP | ROW | ROW_NUMBER | ROWS
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| SAVEPOINT | SCOPE | SCROLL | SEARCH | SECOND | SELECT
|
|
|
|
| SENSITIVE | SESSION_USER | SET | SIMILAR | SMALLINT | SOME | SPECIFIC
|
|
|
|
| SPECIFICTYPE | SQL | SQLEXCEPTION | SQLSTATE | SQLWARNING | SQRT | START
|
|
|
|
| STATIC | STDDEV_POP | STDDEV_SAMP | SUBMULTISET | SUBSTRING | SUBSTRING_REGEX
|
|
|
|
| SUCCEEDS | SUM | SYMMETRIC | SYSTEM | SYSTEM_TIME | SYSTEM_USER
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| TABLE | TABLESAMPLE | THEN | TIME | TIMESTAMP | TIMEZONE_HOUR | TIMEZONE_MINUTE
|
|
|
|
| TO | TRAILING | TRANSLATE | TRANSLATE_REGEX | TRANSLATION | TREAT
|
|
|
|
| TRIGGER | TRUNCATE | TRIM | TRIM_ARRAY | TRUE
|
2014-04-20 15:13:14 +02:00
|
|
|
|
|
|
|
| UESCAPE | UNION | UNIQUE | UNKNOWN | UNNEST | UPDATE | UPPER | USER | USING
|
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| VALUE | VALUES | VALUE_OF | VAR_POP | VAR_SAMP | VARBINARY
|
|
|
|
| VARCHAR | VARYING | VERSIONING
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| WHEN | WHENEVER | WHERE | WIDTH_BUCKET | WINDOW | WITH | WITHIN | WITHOUT
|
2014-04-20 15:13:14 +02:00
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
| YEAR
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 5.3 <literal>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a non-null value.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> literals :: TestItem
|
|
|
|
> literals = Group "literals"
|
|
|
|
> [numericLiterals,generalLiterals]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<literal> ::= <signed numeric literal> | <general literal>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<unsigned literal> ::= <unsigned numeric literal> | <general literal>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<general literal> ::=
|
|
|
|
<character string literal>
|
|
|
|
| <national character string literal>
|
|
|
|
| <Unicode character string literal>
|
|
|
|
| <binary string literal>
|
|
|
|
| <datetime literal>
|
|
|
|
| <interval literal>
|
|
|
|
| <boolean literal>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> generalLiterals :: TestItem
|
|
|
|
> generalLiterals = Group "general literals"
|
|
|
|
> [characterStringLiterals
|
2014-04-19 21:24:10 +02:00
|
|
|
> ,nationalCharacterStringLiterals
|
2014-04-20 15:13:14 +02:00
|
|
|
> ,unicodeCharacterStringLiterals
|
2014-04-19 21:24:10 +02:00
|
|
|
> ,binaryStringLiterals
|
2014-04-20 15:13:14 +02:00
|
|
|
> ,dateTimeLiterals
|
2014-04-19 21:24:10 +02:00
|
|
|
> ,intervalLiterals
|
|
|
|
> ,booleanLiterals]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character string literal> ::=
|
|
|
|
[ <introducer> <character set specification> ]
|
|
|
|
<quote> [ <character representation>... ] <quote>
|
|
|
|
[ { <separator> <quote> [ <character representation>... ] <quote> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<introducer> ::= <underscore>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character representation> ::= <nonquote character> | <quote symbol>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<nonquote character> ::= !! See the Syntax Rules.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<quote symbol> ::= <quote> <quote>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> characterStringLiterals :: TestItem
|
|
|
|
> characterStringLiterals = Group "character string literals"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("'a regular string literal'"
|
|
|
|
> ,StringLit "a regular string literal")
|
|
|
|
> ,("'something' ' some more' 'and more'"
|
|
|
|
> ,StringLit "something some moreand more")
|
|
|
|
> ,("'something' \n ' some more' \t 'and more'"
|
|
|
|
> ,StringLit "something some moreand more")
|
|
|
|
> ,("'something' -- a comment\n ' some more' /*another comment*/ 'and more'"
|
|
|
|
> ,StringLit "something some moreand more")
|
|
|
|
> ,("'a quote: '', stuff'"
|
|
|
|
> ,StringLit "a quote: ', stuff")
|
|
|
|
> ,("''"
|
|
|
|
> ,StringLit "")
|
2014-04-20 18:24:03 +02:00
|
|
|
|
|
|
|
I'm not sure how this should work. Maybe the parser should reject non
|
|
|
|
ascii characters in strings and identifiers unless the current SQL
|
|
|
|
character set allows them.
|
|
|
|
|
2014-04-20 16:03:32 +02:00
|
|
|
> ,("_francais 'français'"
|
|
|
|
> ,TypedLit (TypeName [Name "_francais"]) "français")
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<national character string literal> ::=
|
|
|
|
N <quote> [ <character representation>... ]
|
|
|
|
<quote> [ { <separator> <quote> [ <character representation>... ] <quote> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> nationalCharacterStringLiterals :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> nationalCharacterStringLiterals = Group "national character string literals"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("N'something'", CSStringLit "N" "something")
|
|
|
|
> ,("n'something'", CSStringLit "n" "something")
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<Unicode character string literal> ::=
|
|
|
|
[ <introducer> <character set specification> ]
|
|
|
|
U <ampersand> <quote> [ <Unicode representation>... ] <quote>
|
|
|
|
[ { <separator> <quote> [ <Unicode representation>... ] <quote> }... ]
|
|
|
|
<Unicode escape specifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<Unicode representation> ::=
|
|
|
|
<character representation>
|
|
|
|
| <Unicode escape value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> unicodeCharacterStringLiterals :: TestItem
|
|
|
|
> unicodeCharacterStringLiterals = Group "unicode character string literals"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("U&'something'", CSStringLit "U&" "something")
|
|
|
|
> ,("u&'something' escape ="
|
|
|
|
> ,Escape (CSStringLit "u&" "something") '=')
|
|
|
|
> ,("u&'something' uescape ="
|
|
|
|
> ,UEscape (CSStringLit "u&" "something") '=')
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 16:03:32 +02:00
|
|
|
TODO: unicode escape
|
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
<binary string literal> ::=
|
2014-04-20 15:13:14 +02:00
|
|
|
X <quote> [ <space>... ] [ { <hexit> [ <space>... ] <hexit> [ <space>... ] }... ] <quote>
|
|
|
|
[ { <separator> <quote> [ <space>... ] [ { <hexit> [ <space>... ]
|
|
|
|
<hexit> [ <space>... ] }... ] <quote> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<hexit> ::= <digit> | A | B | C | D | E | F | a | b | c | d | e | f
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> binaryStringLiterals :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> binaryStringLiterals = Group "binary string literals"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [--("B'101010'", CSStringLit "B" "101010")
|
|
|
|
> ("X'7f7f7f'", CSStringLit "X" "7f7f7f")
|
|
|
|
> ,("X'7f7f7f' escape z", Escape (CSStringLit "X" "7f7f7f") 'z')
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<signed numeric literal> ::= [ <sign> ] <unsigned numeric literal>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<unsigned numeric literal> ::=
|
|
|
|
<exact numeric literal>
|
|
|
|
| <approximate numeric literal>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<exact numeric literal> ::=
|
|
|
|
<unsigned integer> [ <period> [ <unsigned integer> ] ]
|
|
|
|
| <period> <unsigned integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<sign> ::= <plus sign> | <minus sign>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<approximate numeric literal> ::= <mantissa> E <exponent>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<mantissa> ::= <exact numeric literal>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<exponent> ::= <signed integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<signed integer> ::= [ <sign> ] <unsigned integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<unsigned integer> ::= <digit>...
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> numericLiterals :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> numericLiterals = Group "numeric literals"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("11", NumLit "11")
|
|
|
|
> ,("11.11", NumLit "11.11")
|
|
|
|
|
|
|
|
> ,("11E23", NumLit "11E23")
|
|
|
|
> ,("11E+23", NumLit "11E+23")
|
|
|
|
> ,("11E-23", NumLit "11E-23")
|
|
|
|
|
|
|
|
> ,("11.11E23", NumLit "11.11E23")
|
|
|
|
> ,("11.11E+23", NumLit "11.11E+23")
|
|
|
|
> ,("11.11E-23", NumLit "11.11E-23")
|
|
|
|
|
|
|
|
> ,("+11E23", PrefixOp [Name "+"] $ NumLit "11E23")
|
|
|
|
> ,("+11E+23", PrefixOp [Name "+"] $ NumLit "11E+23")
|
|
|
|
> ,("+11E-23", PrefixOp [Name "+"] $ NumLit "11E-23")
|
|
|
|
> ,("+11.11E23", PrefixOp [Name "+"] $ NumLit "11.11E23")
|
|
|
|
> ,("+11.11E+23", PrefixOp [Name "+"] $ NumLit "11.11E+23")
|
|
|
|
> ,("+11.11E-23", PrefixOp [Name "+"] $ NumLit "11.11E-23")
|
|
|
|
|
|
|
|
> ,("-11E23", PrefixOp [Name "-"] $ NumLit "11E23")
|
|
|
|
> ,("-11E+23", PrefixOp [Name "-"] $ NumLit "11E+23")
|
|
|
|
> ,("-11E-23", PrefixOp [Name "-"] $ NumLit "11E-23")
|
|
|
|
> ,("-11.11E23", PrefixOp [Name "-"] $ NumLit "11.11E23")
|
|
|
|
> ,("-11.11E+23", PrefixOp [Name "-"] $ NumLit "11.11E+23")
|
|
|
|
> ,("-11.11E-23", PrefixOp [Name "-"] $ NumLit "11.11E-23")
|
|
|
|
|
|
|
|
> ,("11.11e23", NumLit "11.11e23")
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<datetime literal> ::= <date literal> | <time literal> | <timestamp literal>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<date literal> ::= DATE <date string>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<time literal> ::= TIME <time string>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<timestamp literal> ::= TIMESTAMP <timestamp string>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<date string> ::= <quote> <unquoted date string> <quote>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<time string> ::= <quote> <unquoted time string> <quote>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<timestamp string> ::= <quote> <unquoted timestamp string> <quote>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<time zone interval> ::= <sign> <hours value> <colon> <minutes value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<date value> ::=
|
|
|
|
<years value> <minus sign> <months value> <minus sign> <days value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<time value> ::= <hours value> <colon> <minutes value> <colon> <seconds value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> dateTimeLiterals :: TestItem
|
|
|
|
> dateTimeLiterals = Group "datetime literals"
|
|
|
|
> [-- TODO: datetime literals
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval literal> ::=
|
|
|
|
INTERVAL [ <sign> ] <interval string> <interval qualifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval string> ::= <quote> <unquoted interval string> <quote>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<unquoted date string> ::= <date value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<unquoted time string> ::= <time value> [ <time zone interval> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<unquoted timestamp string> ::=
|
|
|
|
<unquoted date string> <space> <unquoted time string>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<unquoted interval string> ::=
|
|
|
|
[ <sign> ] { <year-month literal> | <day-time literal> }
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<year-month literal> ::=
|
|
|
|
<years value> [ <minus sign> <months value> ]
|
|
|
|
| <months value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<day-time literal> ::= <day-time interval> | <time interval>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<day-time interval> ::=
|
|
|
|
<days value> [ <space> <hours value> [ <colon> <minutes value>
|
|
|
|
[ <colon> <seconds value> ] ] ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<time interval> ::=
|
|
|
|
<hours value> [ <colon> <minutes value> [ <colon> <seconds value> ] ]
|
|
|
|
| <minutes value> [ <colon> <seconds value> ]
|
|
|
|
| <seconds value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<years value> ::= <datetime value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<months value> ::= <datetime value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<days value> ::= <datetime value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<hours value> ::= <datetime value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<minutes value> ::= <datetime value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<seconds value> ::= <seconds integer value> [ <period> [ <seconds fraction> ] ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<seconds integer value> ::= <unsigned integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<seconds fraction> ::= <unsigned integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<datetime value> ::= <unsigned integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> intervalLiterals :: TestItem
|
2014-04-20 16:03:32 +02:00
|
|
|
> intervalLiterals = Group "intervalLiterals literals"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("interval '1'", TypedLit (TypeName [Name "interval"]) "1")
|
|
|
|
> ,("interval '1' day"
|
|
|
|
> ,IntervalLit Nothing "1" (Itf "day" Nothing) Nothing)
|
|
|
|
> ,("interval '1' day(3)"
|
|
|
|
> ,IntervalLit Nothing "1" (Itf "day" $ Just (3,Nothing)) Nothing)
|
|
|
|
> ,("interval + '1' day(3)"
|
|
|
|
> ,IntervalLit (Just True) "1" (Itf "day" $ Just (3,Nothing)) Nothing)
|
|
|
|
> ,("interval - '1' second(2,2)"
|
|
|
|
> ,IntervalLit (Just False) "1" (Itf "second" $ Just (2,Just 2)) Nothing)
|
|
|
|
> ,("interval '1' year to month"
|
|
|
|
> ,IntervalLit Nothing "1" (Itf "year" Nothing)
|
|
|
|
> (Just $ Itf "month" Nothing))
|
|
|
|
|
|
|
|
> ,("interval '1' year(4) to second(2,3) "
|
|
|
|
> ,IntervalLit Nothing "1" (Itf "year" $ Just (4,Nothing))
|
|
|
|
> (Just $ Itf "second" $ Just (2, Just 3)))
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<boolean literal> ::= TRUE | FALSE | UNKNOWN
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> booleanLiterals :: TestItem
|
|
|
|
> booleanLiterals = Group "boolean literals"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("true", Iden [Name "true"])
|
|
|
|
> ,("false", Iden [Name "false"])
|
|
|
|
> ,("unknown", Iden [Name "unknown"])
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 5.4 Names and identifiers
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify names.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<identifier> ::= <actual identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<actual identifier> ::=
|
|
|
|
<regular identifier>
|
|
|
|
| <delimited identifier>
|
|
|
|
| <Unicode delimited identifier>
|
|
|
|
|
|
|
|
> identifiers :: TestItem
|
|
|
|
> identifiers = Group "identifiers"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("test",Iden [Name "test"])
|
|
|
|
> ,("_test",Iden [Name "_test"])
|
|
|
|
> ,("t1",Iden [Name "t1"])
|
|
|
|
> ,("a.b",Iden [Name "a", Name "b"])
|
|
|
|
> ,("a.b.c",Iden [Name "a", Name "b", Name "c"])
|
|
|
|
> ,("\"quoted iden\"", Iden [QName "quoted iden"])
|
|
|
|
> ,("\"quoted \"\" iden\"", Iden [QName "quoted \" iden"])
|
|
|
|
> ,("U&\"quoted iden\"", Iden [UQName "quoted iden"])
|
|
|
|
> ,("U&\"quoted \"\" iden\"", Iden [UQName "quoted \" iden"])
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
|
|
|
|
2014-04-20 16:03:32 +02:00
|
|
|
TODO: more identifiers, e.g. unicode escapes?, mixed quoted/unquoted
|
|
|
|
chains
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
TODO: review below stuff for exact rules
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL language identifier> ::=
|
|
|
|
<SQL language identifier start> [ <SQL language identifier part>... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL language identifier start> ::= <simple Latin letter>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL language identifier part> ::=
|
|
|
|
<simple Latin letter>
|
|
|
|
| <digit>
|
|
|
|
| <underscore>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<authorization identifier> ::= <role name> | <user identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<table name> ::= <local or schema qualified name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<domain name> ::= <schema qualified name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<schema name> ::= [ <catalog name> <period> ] <unqualified schema name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<unqualified schema name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<catalog name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<schema qualified name> ::= [ <schema name> <period> ] <qualified identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<local or schema qualified name> ::=
|
|
|
|
[ <local or schema qualifier> <period> ] <qualified identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<local or schema qualifier> ::= <schema name> | <local qualifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<qualified identifier> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<column name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<correlation name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<query name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL-client module name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<procedure name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<schema qualified routine name> ::= <schema qualified name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<method name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<specific name> ::= <schema qualified name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<cursor name> ::= <local qualified name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<local qualified name> ::=
|
|
|
|
[ <local qualifier> <period> ] <qualified identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<local qualifier> ::= MODULE
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<host parameter name> ::= <colon> <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL parameter name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<constraint name> ::= <schema qualified name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<external routine name> ::= <identifier> | <character string literal>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<trigger name> ::= <schema qualified name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<collation name> ::= <schema qualified name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character set name> ::= [ <schema name> <period> ] <SQL language identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<transliteration name> ::= <schema qualified name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<transcoding name> ::= <schema qualified name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<schema-resolved user-defined type name> ::= <user-defined type name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<user-defined type name> ::= [ <schema name> <period> ] <qualified identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<attribute name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<field name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<savepoint name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<sequence generator name> ::= <schema qualified name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<role name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<user identifier> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<connection name> ::= <simple value specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL-server name> ::= <simple value specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<connection user name> ::= <simple value specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL statement name> ::= <statement name> | <extended statement name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<statement name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<extended statement name> ::= [ <scope option> ] <simple value specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<dynamic cursor name> ::= <cursor name> | <extended cursor name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<extended cursor name> ::= [ <scope option> ] <simple value specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<descriptor name> ::=
|
|
|
|
<non-extended descriptor name>
|
|
|
|
| <extended descriptor name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<non-extended descriptor name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<extended descriptor name> ::= [ <scope option> ] <simple value specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<scope option> ::= GLOBAL | LOCAL
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window name> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
= 6 Scalar expressions
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.1 <data type>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a data type.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<data type> ::=
|
|
|
|
<predefined type>
|
|
|
|
| <row type>
|
|
|
|
| <path-resolved user-defined type name>
|
|
|
|
| <reference type>
|
|
|
|
| <collection type>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<predefined type> ::=
|
|
|
|
<character string type> [ CHARACTER SET <character set specification> ]
|
|
|
|
[ <collate clause> ]
|
|
|
|
| <national character string type> [ <collate clause> ]
|
|
|
|
| <binary string type>
|
|
|
|
| <numeric type>
|
|
|
|
| <boolean type>
|
|
|
|
| <datetime type>
|
|
|
|
| <interval type>
|
|
|
|
|
|
|
|
<character string type> ::=
|
|
|
|
CHARACTER [ <left paren> <character length> <right paren> ]
|
|
|
|
| CHAR [ <left paren> <character length> <right paren> ]
|
|
|
|
| CHARACTER VARYING <left paren> <character length> <right paren>
|
|
|
|
| CHAR VARYING <left paren> <character length> <right paren>
|
|
|
|
| VARCHAR <left paren> <character length> <right paren>
|
|
|
|
| <character large object type>
|
|
|
|
|
|
|
|
<character large object type> ::=
|
|
|
|
CHARACTER LARGE OBJECT [ <left paren> <character large object length> <right paren> ]
|
|
|
|
| CHAR LARGE OBJECT [ <left paren> <character large object length> <right paren> ]
|
|
|
|
| CLOB [ <left paren> <character large object length> <right paren> ]
|
|
|
|
|
|
|
|
<national character string type> ::=
|
|
|
|
NATIONAL CHARACTER [ <left paren> <character length> <right paren> ]
|
|
|
|
| NATIONAL CHAR [ <left paren> <character length> <right paren> ]
|
|
|
|
| NCHAR [ <left paren> <character length> <right paren> ]
|
|
|
|
| NATIONAL CHARACTER VARYING <left paren> <character length> <right paren>
|
|
|
|
| NATIONAL CHAR VARYING <left paren> <character length> <right paren>
|
|
|
|
| NCHAR VARYING <left paren> <character length> <right paren>
|
|
|
|
| <national character large object type>
|
|
|
|
|
|
|
|
<national character large object type> ::=
|
|
|
|
NATIONAL CHARACTER LARGE OBJECT [ <left paren> <character large object length> <right
|
|
|
|
paren> ]
|
|
|
|
| NCHAR LARGE OBJECT [ <left paren> <character large object length> <right paren> ]
|
|
|
|
| NCLOB [ <left paren> <character large object length> <right paren> ]
|
|
|
|
|
|
|
|
<binary string type> ::=
|
|
|
|
BINARY [ <left paren> <length> <right paren> ]
|
|
|
|
| BINARY VARYING <left paren> <length> <right paren>
|
|
|
|
| VARBINARY <left paren> <length> <right paren>
|
|
|
|
| <binary large object string type>
|
|
|
|
|
|
|
|
<binary large object string type> ::=
|
|
|
|
BINARY LARGE OBJECT [ <left paren> <large object length> <right paren> ]
|
|
|
|
| BLOB [ <left paren> <large object length> <right paren> ]
|
|
|
|
|
|
|
|
<numeric type> ::= <exact numeric type> | <approximate numeric type>
|
|
|
|
|
|
|
|
<exact numeric type> ::=
|
|
|
|
NUMERIC [ <left paren> <precision> [ <comma> <scale> ] <right paren> ]
|
|
|
|
| DECIMAL [ <left paren> <precision> [ <comma> <scale> ] <right paren> ]
|
|
|
|
| DEC [ <left paren> <precision> [ <comma> <scale> ] <right paren> ]
|
|
|
|
| SMALLINT
|
|
|
|
| INTEGER
|
|
|
|
| INT
|
|
|
|
| BIGINT
|
|
|
|
|
|
|
|
<approximate numeric type> ::=
|
|
|
|
FLOAT [ <left paren> <precision> <right paren> ]
|
|
|
|
| REAL
|
|
|
|
| DOUBLE PRECISION
|
|
|
|
|
|
|
|
<length> ::= <unsigned integer>
|
|
|
|
|
|
|
|
<character length> ::= <length> [ <char length units> ]
|
|
|
|
|
|
|
|
<large object length> ::=
|
|
|
|
<length> [ <multiplier> ]
|
|
|
|
| <large object length token>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character large object length> ::=
|
|
|
|
<large object length> [ <char length units> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<char length units> ::= CHARACTERS | OCTETS
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<precision> ::= <unsigned integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<scale> ::= <unsigned integer>
|
|
|
|
|
|
|
|
<boolean type> ::= BOOLEAN
|
|
|
|
|
|
|
|
<datetime type> ::=
|
|
|
|
DATE
|
|
|
|
| TIME [ <left paren> <time precision> <right paren> ] [ <with or without time zone> ]
|
|
|
|
| TIMESTAMP [ <left paren> <timestamp precision> <right paren> ]
|
|
|
|
[ <with or without time zone> ]
|
|
|
|
|
|
|
|
<with or without time zone> ::= WITH TIME ZONE | WITHOUT TIME ZONE
|
|
|
|
|
|
|
|
<time precision> ::= <time fractional seconds precision>
|
|
|
|
|
|
|
|
<timestamp precision> ::= <time fractional seconds precision>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<time fractional seconds precision> ::= <unsigned integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval type> ::= INTERVAL <interval qualifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row type> ::= ROW <row type body>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row type body> ::=
|
|
|
|
<left paren> <field definition> [ { <comma> <field definition> }... ] <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<reference type> ::=
|
|
|
|
REF <left paren> <referenced type> <right paren> [ <scope clause> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<scope clause> ::= SCOPE <table name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<referenced type> ::= <path-resolved user-defined type name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<path-resolved user-defined type name> ::= <user-defined type name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<collection type> ::= <array type> | <multiset type>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<array type> ::=
|
|
|
|
<data type> ARRAY
|
|
|
|
[ <left bracket or trigraph> <maximum cardinality> <right bracket or trigraph> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<maximum cardinality> ::= <unsigned integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<multiset type> ::= <data type> MULTISET
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 16:03:32 +02:00
|
|
|
TODO: below, add new stuff:
|
|
|
|
review the length syntaxes
|
|
|
|
binary, binary varying/varbinary
|
|
|
|
new multipliers
|
|
|
|
|
|
|
|
create a list of type name variations:
|
|
|
|
|
2015-08-15 18:04:29 +02:00
|
|
|
> typeNames :: ([(String,TypeName)],[(String,TypeName)])
|
2014-04-20 16:03:32 +02:00
|
|
|
> typeNames =
|
2015-08-15 18:04:29 +02:00
|
|
|
> (basicTypes, concatMap makeArray basicTypes
|
|
|
|
> ++ map makeMultiset basicTypes)
|
2014-04-20 16:03:32 +02:00
|
|
|
> where
|
|
|
|
> makeArray (s,t) = [(s ++ " array", ArrayTypeName t Nothing)
|
|
|
|
> ,(s ++ " array[5]", ArrayTypeName t (Just 5))]
|
|
|
|
> makeMultiset (s,t) = (s ++ " multiset", MultisetTypeName t)
|
|
|
|
> basicTypes =
|
|
|
|
> -- example of every standard type name
|
|
|
|
> map (\t -> (t,TypeName [Name t]))
|
2014-04-20 22:14:55 +02:00
|
|
|
> ["binary"
|
|
|
|
> ,"binary varying"
|
|
|
|
> ,"character"
|
2014-04-20 16:03:32 +02:00
|
|
|
> ,"char"
|
|
|
|
> ,"character varying"
|
|
|
|
> ,"char varying"
|
2014-04-20 22:14:55 +02:00
|
|
|
> ,"varbinary"
|
2014-04-20 16:03:32 +02:00
|
|
|
> ,"varchar"
|
|
|
|
> ,"character large object"
|
|
|
|
> ,"char large object"
|
|
|
|
> ,"clob"
|
|
|
|
> ,"national character"
|
|
|
|
> ,"national char"
|
|
|
|
> ,"nchar"
|
|
|
|
> ,"national character varying"
|
|
|
|
> ,"national char varying"
|
|
|
|
> ,"nchar varying"
|
|
|
|
> ,"national character large object"
|
|
|
|
> ,"nchar large object"
|
|
|
|
> ,"nclob"
|
|
|
|
> ,"binary large object"
|
|
|
|
> ,"blob"
|
|
|
|
> ,"numeric"
|
|
|
|
> ,"decimal"
|
|
|
|
> ,"dec"
|
|
|
|
> ,"smallint"
|
|
|
|
> ,"integer"
|
|
|
|
> ,"int"
|
|
|
|
> ,"bigint"
|
|
|
|
> ,"float"
|
|
|
|
> ,"real"
|
|
|
|
> ,"double precision"
|
|
|
|
> ,"boolean"
|
|
|
|
> ,"date"
|
|
|
|
> ,"time"
|
|
|
|
> ,"timestamp"]
|
|
|
|
> --interval -- not allowed without interval qualifier
|
|
|
|
> --row -- not allowed without row type body
|
|
|
|
> -- array -- not allowed on own
|
|
|
|
> -- multiset -- not allowed on own
|
|
|
|
|
|
|
|
> ++
|
|
|
|
> [-- 1 single prec + 1 with multiname
|
|
|
|
> ("char(5)", PrecTypeName [Name "char"] 5)
|
|
|
|
> ,("char varying(5)", PrecTypeName [Name "char varying"] 5)
|
|
|
|
> -- 1 scale
|
|
|
|
> ,("decimal(15,2)", PrecScaleTypeName [Name "decimal"] 15 2)
|
2014-04-21 13:16:45 +02:00
|
|
|
> ,("char(3 octets)"
|
|
|
|
> ,PrecLengthTypeName [Name "char"] 3 Nothing (Just PrecOctets))
|
|
|
|
> ,("varchar(50 characters)"
|
|
|
|
> ,PrecLengthTypeName [Name "varchar"] 50 Nothing (Just PrecCharacters))
|
2014-04-20 16:03:32 +02:00
|
|
|
> -- lob prec + with multiname
|
2014-04-20 22:14:55 +02:00
|
|
|
> ,("blob(3M)", PrecLengthTypeName [Name "blob"] 3 (Just PrecM) Nothing)
|
|
|
|
> ,("blob(3T)", PrecLengthTypeName [Name "blob"] 3 (Just PrecT) Nothing)
|
|
|
|
> ,("blob(3P)", PrecLengthTypeName [Name "blob"] 3 (Just PrecP) Nothing)
|
2014-04-20 16:03:32 +02:00
|
|
|
> ,("blob(4M characters) "
|
2014-04-20 22:14:55 +02:00
|
|
|
> ,PrecLengthTypeName [Name "blob"] 4 (Just PrecM) (Just PrecCharacters))
|
2014-04-20 16:03:32 +02:00
|
|
|
> ,("blob(6G octets) "
|
2014-04-20 22:14:55 +02:00
|
|
|
> ,PrecLengthTypeName [Name "blob"] 6 (Just PrecG) (Just PrecOctets))
|
2014-04-20 16:03:32 +02:00
|
|
|
> ,("national character large object(7K) "
|
2014-04-21 13:16:45 +02:00
|
|
|
> ,PrecLengthTypeName [Name "national character large object"]
|
|
|
|
> 7 (Just PrecK) Nothing)
|
2014-04-20 16:03:32 +02:00
|
|
|
> -- 1 with and without tz
|
|
|
|
> ,("time with time zone"
|
|
|
|
> ,TimeTypeName [Name "time"] Nothing True)
|
2016-02-12 10:57:09 +01:00
|
|
|
> ,("timestamp(3) without time zone"
|
|
|
|
> ,TimeTypeName [Name "timestamp"] (Just 3) False)
|
2014-04-20 16:03:32 +02:00
|
|
|
> -- chars: (single/multiname) x prec x charset x collate
|
|
|
|
> -- 1111
|
|
|
|
> ,("char varying(5) character set something collate something_insensitive"
|
|
|
|
> ,CharTypeName [Name "char varying"] (Just 5)
|
|
|
|
> [Name "something"] [Name "something_insensitive"])
|
|
|
|
> -- 0111
|
|
|
|
> ,("char(5) character set something collate something_insensitive"
|
|
|
|
> ,CharTypeName [Name "char"] (Just 5)
|
|
|
|
> [Name "something"] [Name "something_insensitive"])
|
|
|
|
|
|
|
|
> -- 1011
|
|
|
|
> ,("char varying character set something collate something_insensitive"
|
|
|
|
> ,CharTypeName [Name "char varying"] Nothing
|
|
|
|
> [Name "something"] [Name "something_insensitive"])
|
|
|
|
> -- 0011
|
|
|
|
> ,("char character set something collate something_insensitive"
|
|
|
|
> ,CharTypeName [Name "char"] Nothing
|
|
|
|
> [Name "something"] [Name "something_insensitive"])
|
|
|
|
|
|
|
|
> -- 1101
|
|
|
|
> ,("char varying(5) collate something_insensitive"
|
|
|
|
> ,CharTypeName [Name "char varying"] (Just 5)
|
|
|
|
> [] [Name "something_insensitive"])
|
|
|
|
> -- 0101
|
|
|
|
> ,("char(5) collate something_insensitive"
|
|
|
|
> ,CharTypeName [Name "char"] (Just 5)
|
|
|
|
> [] [Name "something_insensitive"])
|
|
|
|
> -- 1001
|
|
|
|
> ,("char varying collate something_insensitive"
|
|
|
|
> ,CharTypeName [Name "char varying"] Nothing
|
|
|
|
> [] [Name "something_insensitive"])
|
|
|
|
> -- 0001
|
|
|
|
> ,("char collate something_insensitive"
|
|
|
|
> ,CharTypeName [Name "char"] Nothing
|
|
|
|
> [] [Name "something_insensitive"])
|
|
|
|
|
|
|
|
> -- 1110
|
|
|
|
> ,("char varying(5) character set something"
|
|
|
|
> ,CharTypeName [Name "char varying"] (Just 5)
|
|
|
|
> [Name "something"] [])
|
|
|
|
> -- 0110
|
|
|
|
> ,("char(5) character set something"
|
|
|
|
> ,CharTypeName [Name "char"] (Just 5)
|
|
|
|
> [Name "something"] [])
|
|
|
|
> -- 1010
|
|
|
|
> ,("char varying character set something"
|
|
|
|
> ,CharTypeName [Name "char varying"] Nothing
|
|
|
|
> [Name "something"] [])
|
|
|
|
> -- 0010
|
|
|
|
> ,("char character set something"
|
|
|
|
> ,CharTypeName [Name "char"] Nothing
|
|
|
|
> [Name "something"] [])
|
|
|
|
> -- 1100
|
|
|
|
> ,("char varying character set something"
|
|
|
|
> ,CharTypeName [Name "char varying"] Nothing
|
|
|
|
> [Name "something"] [])
|
|
|
|
|
|
|
|
> -- single row field, two row field
|
|
|
|
> ,("row(a int)", RowTypeName [(Name "a", TypeName [Name "int"])])
|
|
|
|
> ,("row(a int,b char)"
|
|
|
|
> ,RowTypeName [(Name "a", TypeName [Name "int"])
|
|
|
|
> ,(Name "b", TypeName [Name "char"])])
|
|
|
|
> -- interval each type raw
|
|
|
|
> ,("interval year"
|
|
|
|
> ,IntervalTypeName (Itf "year" Nothing) Nothing)
|
|
|
|
> -- one type with single suffix
|
|
|
|
> -- one type with double suffix
|
|
|
|
> ,("interval year(2)"
|
|
|
|
> ,IntervalTypeName (Itf "year" $ Just (2,Nothing)) Nothing)
|
|
|
|
> ,("interval second(2,5)"
|
|
|
|
> ,IntervalTypeName (Itf "second" $ Just (2,Just 5)) Nothing)
|
|
|
|
> -- a to b with raw
|
|
|
|
> -- a to b with single suffix
|
|
|
|
> ,("interval year to month"
|
|
|
|
> ,IntervalTypeName (Itf "year" Nothing)
|
|
|
|
> (Just $ Itf "month" Nothing))
|
|
|
|
> ,("interval year(4) to second(2,3)"
|
|
|
|
> ,IntervalTypeName (Itf "year" $ Just (4,Nothing))
|
|
|
|
> (Just $ Itf "second" $ Just (2, Just 3)))
|
|
|
|
> ]
|
|
|
|
|
|
|
|
Now test each variation in both cast expression and typed literal
|
|
|
|
expression
|
|
|
|
|
|
|
|
> typeNameTests :: TestItem
|
2015-08-15 18:04:29 +02:00
|
|
|
> typeNameTests = Group "type names"
|
|
|
|
> [Group "type names" $ map (uncurry (TestValueExpr SQL2011))
|
|
|
|
> $ concatMap makeSimpleTests $ fst typeNames
|
|
|
|
> ,Group "generated casts" $ map (uncurry (TestValueExpr SQL2011))
|
|
|
|
> $ concatMap makeCastTests $ fst typeNames
|
|
|
|
> ,Group "generated typename" $ map (uncurry (TestValueExpr SQL2011))
|
|
|
|
> $ concatMap makeTests $ snd typeNames]
|
2014-04-20 16:03:32 +02:00
|
|
|
> where
|
2015-08-15 18:04:29 +02:00
|
|
|
> makeSimpleTests (ctn, stn) =
|
|
|
|
> [(ctn ++ " 'test'", TypedLit stn "test")
|
|
|
|
> ]
|
|
|
|
> makeCastTests (ctn, stn) =
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("cast('test' as " ++ ctn ++ ")", Cast (StringLit "test") stn)
|
|
|
|
> ]
|
2015-08-15 18:04:29 +02:00
|
|
|
> makeTests a = makeSimpleTests a ++ makeCastTests a
|
2014-04-20 16:03:32 +02:00
|
|
|
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.2 <field definition>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Define a field of a row type.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<field definition> ::= <field name> <data type>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 18:24:03 +02:00
|
|
|
> fieldDefinition :: TestItem
|
|
|
|
> fieldDefinition = Group "field definition"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 18:24:03 +02:00
|
|
|
> [("cast('(1,2)' as row(a int,b char))"
|
|
|
|
> ,Cast (StringLit "(1,2)")
|
|
|
|
> $ RowTypeName [(Name "a", TypeName [Name "int"])
|
|
|
|
> ,(Name "b", TypeName [Name "char"])])]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.3 <value expression primary>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a value that is syntactically self-delimited.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<value expression primary> ::=
|
|
|
|
<parenthesized value expression>
|
|
|
|
| <nonparenthesized value expression primary>
|
|
|
|
|
|
|
|
<parenthesized value expression> ::=
|
|
|
|
<left paren> <value expression> <right paren>
|
|
|
|
|
|
|
|
<nonparenthesized value expression primary> ::=
|
|
|
|
<unsigned value specification>
|
|
|
|
| <column reference>
|
|
|
|
| <set function specification>
|
|
|
|
| <window function>
|
|
|
|
| <nested window function>
|
|
|
|
| <scalar subquery>
|
|
|
|
| <case expression>
|
|
|
|
| <cast specification>
|
|
|
|
| <field reference>
|
|
|
|
| <subtype treatment>
|
|
|
|
| <method invocation>
|
|
|
|
| <static method invocation>
|
|
|
|
| <new specification>
|
|
|
|
| <attribute or method reference>
|
|
|
|
| <reference resolution>
|
|
|
|
| <collection value constructor>
|
|
|
|
| <array element reference>
|
|
|
|
| <multiset element reference>
|
|
|
|
| <next value expression>
|
|
|
|
| <routine invocation>
|
|
|
|
|
|
|
|
<collection value constructor> ::=
|
|
|
|
<array value constructor>
|
|
|
|
| <multiset value constructor>
|
|
|
|
|
|
|
|
> valueExpressions :: TestItem
|
|
|
|
> valueExpressions = Group "value expressions"
|
|
|
|
> [generalValueSpecification
|
|
|
|
> ,parameterSpecification
|
|
|
|
> ,contextuallyTypedValueSpecification
|
2014-04-20 18:24:03 +02:00
|
|
|
> ,identifierChain
|
|
|
|
> ,columnReference
|
2014-04-20 15:13:14 +02:00
|
|
|
> ,setFunctionSpecification
|
|
|
|
> ,windowFunction
|
|
|
|
> ,nestedWindowFunction
|
|
|
|
> ,caseExpression
|
|
|
|
> ,castSpecification
|
|
|
|
> ,nextValueExpression
|
|
|
|
> ,fieldReference
|
|
|
|
> ,arrayElementReference
|
|
|
|
> ,multisetElementReference
|
|
|
|
> ,numericValueExpression
|
|
|
|
> ,numericValueFunction
|
|
|
|
> ,stringValueExpression
|
|
|
|
> ,stringValueFunction
|
|
|
|
> ,datetimeValueExpression
|
|
|
|
> ,datetimeValueFunction
|
|
|
|
> ,intervalValueExpression
|
|
|
|
> ,intervalValueFunction
|
|
|
|
> ,booleanValueExpression
|
|
|
|
> ,arrayValueExpression
|
|
|
|
> ,arrayValueFunction
|
|
|
|
> ,arrayValueConstructor
|
|
|
|
> ,multisetValueExpression
|
|
|
|
> ,multisetValueFunction
|
|
|
|
> ,multisetValueConstructor
|
2014-04-20 16:03:32 +02:00
|
|
|
> ,parenthesizedValueExpression
|
|
|
|
> ]
|
|
|
|
|
|
|
|
> parenthesizedValueExpression :: TestItem
|
2014-04-21 13:16:45 +02:00
|
|
|
> parenthesizedValueExpression = Group "parenthesized value expression"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("(3)", Parens (NumLit "3"))
|
|
|
|
> ,("((3))", Parens $ Parens (NumLit "3"))
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
|
|
|
|
|
|
|
== 6.4 <value specification> and <target specification>
|
|
|
|
|
|
|
|
Function
|
|
|
|
Specify one or more values, host parameters, SQL parameters, dynamic parameters, or host variables.
|
|
|
|
|
|
|
|
<value specification> ::= <literal> | <general value specification>
|
|
|
|
|
|
|
|
<unsigned value specification> ::=
|
|
|
|
<unsigned literal>
|
|
|
|
| <general value specification>
|
|
|
|
|
|
|
|
<general value specification> ::=
|
|
|
|
<host parameter specification>
|
|
|
|
| <SQL parameter reference>
|
|
|
|
| <dynamic parameter specification>
|
|
|
|
| <embedded variable specification>
|
|
|
|
| <current collation specification>
|
|
|
|
| CURRENT_CATALOG
|
|
|
|
| CURRENT_DEFAULT_TRANSFORM_GROUP
|
|
|
|
| CURRENT_PATH
|
|
|
|
| CURRENT_ROLE
|
|
|
|
| CURRENT_SCHEMA
|
|
|
|
| CURRENT_TRANSFORM_GROUP_FOR_TYPE <path-resolved user-defined type name>
|
|
|
|
| CURRENT_USER
|
|
|
|
| SESSION_USER
|
|
|
|
| SYSTEM_USER
|
|
|
|
| USER
|
|
|
|
| VALUE
|
|
|
|
|
|
|
|
> generalValueSpecification :: TestItem
|
|
|
|
> generalValueSpecification = Group "general value specification"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011)) $
|
2014-04-20 16:03:32 +02:00
|
|
|
> map mkIden ["CURRENT_DEFAULT_TRANSFORM_GROUP"
|
|
|
|
> ,"CURRENT_PATH"
|
|
|
|
> ,"CURRENT_ROLE"
|
|
|
|
> ,"CURRENT_USER"
|
|
|
|
> ,"SESSION_USER"
|
|
|
|
> ,"SYSTEM_USER"
|
|
|
|
> ,"USER"
|
|
|
|
> ,"VALUE"]
|
|
|
|
> where
|
|
|
|
> mkIden nm = (nm,Iden [Name nm])
|
|
|
|
|
|
|
|
TODO: add the missing bits
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<simple value specification> ::=
|
|
|
|
<literal>
|
|
|
|
| <host parameter name>
|
|
|
|
| <SQL parameter reference>
|
|
|
|
| <embedded variable name>
|
|
|
|
|
|
|
|
<target specification> ::=
|
|
|
|
<host parameter specification>
|
|
|
|
| <SQL parameter reference>
|
|
|
|
| <column reference>
|
|
|
|
| <target array element specification>
|
|
|
|
| <dynamic parameter specification>
|
|
|
|
| <embedded variable specification>
|
|
|
|
|
|
|
|
<simple target specification> ::=
|
|
|
|
<host parameter name>
|
|
|
|
| <SQL parameter reference>
|
|
|
|
| <column reference>
|
|
|
|
| <embedded variable name>
|
|
|
|
|
|
|
|
<host parameter specification> ::=
|
|
|
|
<host parameter name> [ <indicator parameter> ]
|
|
|
|
|
|
|
|
<dynamic parameter specification> ::= <question mark>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<embedded variable specification> ::=
|
|
|
|
<embedded variable name> [ <indicator variable> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<indicator variable> ::= [ INDICATOR ] <embedded variable name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<indicator parameter> ::= [ INDICATOR ] <host parameter name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<target array element specification> ::=
|
|
|
|
<target array reference>
|
|
|
|
<left bracket or trigraph> <simple value specification> <right bracket or trigraph>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<target array reference> ::= <SQL parameter reference> | <column reference>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> parameterSpecification :: TestItem
|
|
|
|
> parameterSpecification = Group "parameter specification"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [(":hostparam", HostParameter "hostparam" Nothing)
|
|
|
|
> ,(":hostparam indicator :another_host_param"
|
|
|
|
> ,HostParameter "hostparam" $ Just "another_host_param")
|
|
|
|
> ,("?", Parameter)
|
|
|
|
> ,(":h[3]", Array (HostParameter "h" Nothing) [NumLit "3"])
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
|
|
|
|
|
|
|
<current collation specification> ::=
|
|
|
|
COLLATION FOR <left paren> <string value expression> <right paren>
|
|
|
|
|
2014-04-20 16:03:32 +02:00
|
|
|
TODO: review the modules stuff
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.5 <contextually typed value specification>
|
|
|
|
|
|
|
|
Function
|
|
|
|
Specify a value whose data type is to be inferred from its context.
|
|
|
|
|
|
|
|
<contextually typed value specification> ::=
|
|
|
|
<implicitly typed value specification>
|
|
|
|
| <default specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<implicitly typed value specification> ::=
|
|
|
|
<null specification>
|
|
|
|
| <empty specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<null specification> ::= NULL
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<empty specification> ::=
|
|
|
|
ARRAY <left bracket or trigraph> <right bracket or trigraph>
|
|
|
|
| MULTISET <left bracket or trigraph> <right bracket or trigraph>
|
|
|
|
|
|
|
|
<default specification> ::= DEFAULT
|
|
|
|
|
|
|
|
> contextuallyTypedValueSpecification :: TestItem
|
2014-04-21 13:16:45 +02:00
|
|
|
> contextuallyTypedValueSpecification =
|
|
|
|
> Group "contextually typed value specification"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("null", Iden [Name "null"])
|
|
|
|
> ,("array[]", Array (Iden [Name "array"]) [])
|
|
|
|
> ,("multiset[]", MultisetCtor [])
|
|
|
|
> ,("default", Iden [Name "default"])
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.6 <identifier chain>
|
|
|
|
|
|
|
|
Function
|
|
|
|
Disambiguate a <period>-separated chain of identifiers.
|
|
|
|
|
|
|
|
<identifier chain> ::= <identifier> [ { <period> <identifier> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<basic identifier chain> ::= <identifier chain>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 18:24:03 +02:00
|
|
|
> identifierChain :: TestItem
|
|
|
|
> identifierChain = Group "identifier chain"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 18:24:03 +02:00
|
|
|
> [("a.b", Iden [Name "a",Name "b"])]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.7 <column reference>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Reference a column.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<column reference> ::=
|
|
|
|
<basic identifier chain>
|
|
|
|
| MODULE <period> <qualified identifier> <period> <column name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 18:24:03 +02:00
|
|
|
> columnReference :: TestItem
|
|
|
|
> columnReference = Group "column reference"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 18:24:03 +02:00
|
|
|
> [("module.a.b", Iden [Name "module",Name "a",Name "b"])]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.8 <SQL parameter reference>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Reference an SQL parameter.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL parameter reference> ::= <basic identifier chain>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.9 <set function specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a value derived by the application of a function to an argument.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<set function specification> ::= <aggregate function> | <grouping operation>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<grouping operation> ::=
|
|
|
|
GROUPING <left paren> <column reference>
|
|
|
|
[ { <comma> <column reference> }... ] <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> setFunctionSpecification :: TestItem
|
|
|
|
> setFunctionSpecification = Group "set function specification"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("SELECT SalesQuota, SUM(SalesYTD) TotalSalesYTD,\n\
|
|
|
|
> \ GROUPING(SalesQuota) AS Grouping\n\
|
|
|
|
> \FROM Sales.SalesPerson\n\
|
|
|
|
> \GROUP BY ROLLUP(SalesQuota);"
|
|
|
|
> ,makeSelect
|
|
|
|
> {qeSelectList = [(Iden [Name "SalesQuota"],Nothing)
|
2014-04-21 13:16:45 +02:00
|
|
|
> ,(App [Name "SUM"] [Iden [Name "SalesYTD"]]
|
|
|
|
> ,Just (Name "TotalSalesYTD"))
|
|
|
|
> ,(App [Name "GROUPING"] [Iden [Name "SalesQuota"]]
|
|
|
|
> ,Just (Name "Grouping"))]
|
2014-04-20 16:03:32 +02:00
|
|
|
> ,qeFrom = [TRSimple [Name "Sales",Name "SalesPerson"]]
|
|
|
|
> ,qeGroupBy = [Rollup [SimpleGroup (Iden [Name "SalesQuota"])]]})
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
|
|
|
|
|
|
|
== 6.10 <window function>
|
|
|
|
|
|
|
|
Function
|
|
|
|
Specify a window function.
|
|
|
|
|
|
|
|
<window function> ::=
|
|
|
|
<window function type> OVER <window name or specification>
|
|
|
|
|
|
|
|
<window function type> ::=
|
|
|
|
<rank function type> <left paren> <right paren>
|
|
|
|
| ROW_NUMBER <left paren> <right paren>
|
|
|
|
| <aggregate function>
|
|
|
|
| <ntile function>
|
|
|
|
| <lead or lag function>
|
|
|
|
| <first or last value function>
|
|
|
|
| <nth value function>
|
|
|
|
|
|
|
|
<rank function type> ::= RANK | DENSE_RANK | PERCENT_RANK | CUME_DIST
|
|
|
|
|
|
|
|
<ntile function> ::= NTILE <left paren> <number of tiles> <right paren>
|
|
|
|
|
|
|
|
<number of tiles> ::=
|
|
|
|
<simple value specification>
|
|
|
|
| <dynamic parameter specification>
|
|
|
|
|
|
|
|
<lead or lag function> ::=
|
|
|
|
<lead or lag> <left paren> <lead or lag extent>
|
|
|
|
[ <comma> <offset> [ <comma> <default expression> ] ] <right paren>
|
|
|
|
[ <null treatment> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<lead or lag> ::= LEAD | LAG
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<lead or lag extent> ::= <value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<offset> ::= <exact numeric literal>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<default expression> ::= <value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<null treatment> ::= RESPECT NULLS | IGNORE NULLS
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<first or last value function> ::=
|
|
|
|
<first or last value> <left paren> <value expression> <right paren> [ <null treatment>
|
|
|
|
]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<first or last value> ::= FIRST_VALUE | LAST_VALUE
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<nth value function> ::=
|
|
|
|
NTH_VALUE <left paren> <value expression> <comma> <nth row> <right paren>
|
|
|
|
[ <from first or last> ] [ <null treatment> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<nth row> ::= <simple value specification> | <dynamic parameter specification>
|
|
|
|
|
|
|
|
<from first or last> ::= FROM FIRST | FROM LAST
|
|
|
|
|
|
|
|
<window name or specification> ::=
|
|
|
|
<window name>
|
|
|
|
| <in-line window specification>
|
|
|
|
|
|
|
|
<in-line window specification> ::= <window specification>
|
|
|
|
|
|
|
|
> windowFunction :: TestItem
|
|
|
|
> windowFunction = Group "window function"
|
|
|
|
> [-- todo: window function
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.11 <nested window function>
|
|
|
|
|
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Specify a function nested in an aggregated argument of an
|
|
|
|
<aggregate function> simply contained in a <window function>.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<nested window function> ::=
|
|
|
|
<nested row number function>
|
|
|
|
| <value_of expression at row>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<nested row number function> ::=
|
|
|
|
ROW_NUMBER <left paren> <row marker> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<value_of expression at row> ::=
|
|
|
|
VALUE_OF <left paren> <value expression> AT <row marker expression>
|
|
|
|
[ <comma> <value_of default value> ] <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row marker> ::=
|
|
|
|
BEGIN_PARTITION
|
|
|
|
| BEGIN_FRAME
|
|
|
|
| CURRENT_ROW
|
|
|
|
| FRAME_ROW
|
|
|
|
| END_FRAME
|
|
|
|
| END_PARTITION
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row marker expression> ::= <row marker> [ <row marker delta> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row marker delta> ::=
|
|
|
|
<plus sign> <row marker offset>
|
|
|
|
| <minus sign> <row marker offset>
|
|
|
|
|
|
|
|
<row marker offset> ::=
|
|
|
|
<simple value specification>
|
|
|
|
| <dynamic parameter specification>
|
|
|
|
|
|
|
|
<value_of default value> ::= <value expression>
|
|
|
|
|
|
|
|
> nestedWindowFunction :: TestItem
|
|
|
|
> nestedWindowFunction = Group "nested window function"
|
|
|
|
> [-- todo: nested window function
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
|
|
|
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.12 <case expression>
|
|
|
|
|
|
|
|
Function
|
|
|
|
Specify a conditional value.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<case expression> ::= <case abbreviation> | <case specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<case abbreviation> ::=
|
|
|
|
NULLIF <left paren> <value expression> <comma> <value expression> <right paren>
|
|
|
|
| COALESCE <left paren> <value expression>
|
|
|
|
{ <comma> <value expression> }... <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<case specification> ::= <simple case> | <searched case>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<simple case> ::=
|
|
|
|
CASE <case operand> <simple when clause>... [ <else clause> ] END
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<searched case> ::= CASE <searched when clause>... [ <else clause> ] END
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<simple when clause> ::= WHEN <when operand list> THEN <result>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<searched when clause> ::= WHEN <search condition> THEN <result>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<else clause> ::= ELSE <result>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<case operand> ::= <row value predicand> | <overlaps predicate part 1>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<when operand list> ::= <when operand> [ { <comma> <when operand> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<when operand> ::=
|
|
|
|
<row value predicand>
|
|
|
|
| <comparison predicate part 2>
|
|
|
|
| <between predicate part 2>
|
|
|
|
| <in predicate part 2>
|
|
|
|
| <character like predicate part 2>
|
|
|
|
| <octet like predicate part 2>
|
|
|
|
| <similar predicate part 2>
|
|
|
|
| <regex like predicate part 2>
|
|
|
|
| <null predicate part 2>
|
|
|
|
| <quantified comparison predicate part 2>
|
|
|
|
| <normalized predicate part 2>
|
|
|
|
| <match predicate part 2>
|
|
|
|
| <overlaps predicate part 2>
|
|
|
|
| <distinct predicate part 2>
|
|
|
|
| <member predicate part 2>
|
|
|
|
| <submultiset predicate part 2>
|
|
|
|
| <set predicate part 2>
|
|
|
|
| <type predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 18:24:03 +02:00
|
|
|
I haven't seen these part 2 style when operands in the wild. It
|
|
|
|
doesn't even allow all the binary operators here. We will allow them
|
|
|
|
all, and parser and represent these expressions by considering all the
|
|
|
|
binary ops as unary prefix ops.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<result> ::= <result expression> | NULL
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<result expression> ::= <value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> caseExpression :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> caseExpression = Group "case expression"
|
|
|
|
> [-- todo: case expression
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.13 <cast specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a data conversion.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<cast specification> ::=
|
|
|
|
CAST <left paren> <cast operand> AS <cast target> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<cast operand> ::= <value expression> | <implicitly typed value specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<cast target> ::= <domain name> | <data type>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> castSpecification :: TestItem
|
|
|
|
> castSpecification = Group "cast specification"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("cast(a as int)"
|
|
|
|
> ,Cast (Iden [Name "a"]) (TypeName [Name "int"]))
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.14 <next value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Return the next value of a sequence generator.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<next value expression> ::= NEXT VALUE FOR <sequence generator name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> nextValueExpression :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> nextValueExpression = Group "next value expression"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("next value for a.b", NextValueFor [Name "a", Name "b"])
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.15 <field reference>
|
|
|
|
|
|
|
|
Function
|
|
|
|
Reference a field of a row value.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<field reference> ::= <value expression primary> <period> <field name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> fieldReference :: TestItem
|
|
|
|
> fieldReference = Group "field reference"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("f(something).a"
|
|
|
|
> ,BinOp (App [Name "f"] [Iden [Name "something"]])
|
|
|
|
> [Name "."]
|
|
|
|
> (Iden [Name "a"]))
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 16:03:32 +02:00
|
|
|
TODO: try all possible value expression syntax variations followed by
|
|
|
|
field reference
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.16 <subtype treatment>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Modify the declared type of an expression.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<subtype treatment> ::=
|
|
|
|
TREAT <left paren> <subtype operand> AS <target subtype> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<subtype operand> ::= <value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<target subtype> ::= <path-resolved user-defined type name> | <reference type>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
todo: subtype treatment
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.17 <method invocation>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Reference an SQL-invoked method of a user-defined type value.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<method invocation> ::= <direct invocation> | <generalized invocation>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<direct invocation> ::=
|
|
|
|
<value expression primary> <period> <method name> [ <SQL argument list> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<generalized invocation> ::=
|
|
|
|
<left paren> <value expression primary> AS <data type> <right paren>
|
|
|
|
<period> <method name> [ <SQL argument list> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<method selection> ::= <routine invocation>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<constructor method selection> ::= <routine invocation>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
todo: method invocation
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.18 <static method invocation>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Invoke a static method.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<static method invocation> ::=
|
|
|
|
<path-resolved user-defined type name> <double colon> <method name>
|
|
|
|
[ <SQL argument list> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<static method selection> ::= <routine invocation>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
todo: static method invocation
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.19 <new specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Invoke a method on a newly-constructed value of a structured type.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<new specification> ::=
|
|
|
|
NEW <path-resolved user-defined type name> <SQL argument list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<new invocation> ::= <method invocation> | <routine invocation>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
todo: new specification
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.20 <attribute or method reference>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Return a value acquired by accessing a column of the row identified by
|
|
|
|
a value of a reference type or by invoking an SQL-invoked method.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<attribute or method reference> ::=
|
|
|
|
<value expression primary> <dereference operator> <qualified identifier>
|
|
|
|
[ <SQL argument list> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<dereference operator> ::= <right arrow>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
todo: attribute of method reference
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.21 <dereference operation>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Access a column of the row identified by a value of a reference type.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<dereference operation> ::=
|
|
|
|
<reference value expression> <dereference operator> <attribute name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
todo: deference operation
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.22 <method reference>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Return a value acquired from invoking an SQL-invoked routine that is a method.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<method reference> ::=
|
|
|
|
<value expression primary> <dereference operator> <method name> <SQL argument list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
todo: method reference
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.23 <reference resolution>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Obtain the value referenced by a reference value.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<reference resolution> ::=
|
|
|
|
DEREF <left paren> <reference value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
todo: reference resolution
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.24 <array element reference>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Return an element of an array.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<array element reference> ::=
|
|
|
|
<array value expression>
|
|
|
|
<left bracket or trigraph> <numeric value expression> <right bracket or trigraph>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> arrayElementReference :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> arrayElementReference = Group "array element reference"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("something[3]"
|
|
|
|
> ,Array (Iden [Name "something"]) [NumLit "3"])
|
|
|
|
> ,("(something(a))[x]"
|
|
|
|
> ,Array (Parens (App [Name "something"] [Iden [Name "a"]]))
|
|
|
|
> [Iden [Name "x"]])
|
|
|
|
> ,("(something(a))[x][y] "
|
|
|
|
> ,Array (
|
|
|
|
> Array (Parens (App [Name "something"] [Iden [Name "a"]]))
|
|
|
|
> [Iden [Name "x"]])
|
|
|
|
> [Iden [Name "y"]])
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.25 <multiset element reference>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Return the sole element of a multiset of one element.
|
|
|
|
|
|
|
|
<multiset element reference> ::=
|
|
|
|
ELEMENT <left paren> <multiset value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> multisetElementReference :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> multisetElementReference = Group "multisetElementReference"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("element(something)"
|
|
|
|
> ,App [Name "element"] [Iden [Name "something"]])
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.26 <value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a value.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<value expression> ::=
|
|
|
|
<common value expression>
|
|
|
|
| <boolean value expression>
|
|
|
|
| <row value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<common value expression> ::=
|
|
|
|
<numeric value expression>
|
|
|
|
| <string value expression>
|
|
|
|
| <datetime value expression>
|
|
|
|
| <interval value expression>
|
|
|
|
| <user-defined type value expression>
|
|
|
|
| <reference value expression>
|
|
|
|
| <collection value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<user-defined type value expression> ::= <value expression primary>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<reference value expression> ::= <value expression primary>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<collection value expression> ::=
|
|
|
|
<array value expression>
|
|
|
|
| <multiset value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.27 <numeric value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a numeric value.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<numeric value expression> ::=
|
|
|
|
<term>
|
|
|
|
| <numeric value expression> <plus sign> <term>
|
|
|
|
| <numeric value expression> <minus sign> <term>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<term> ::= <factor> | <term> <asterisk> <factor> | <term> <solidus> <factor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<factor> ::= [ <sign> ] <numeric primary>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<numeric primary> ::= <value expression primary> | <numeric value function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> numericValueExpression :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> numericValueExpression = Group "numeric value expression"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("a + b", binOp "+")
|
|
|
|
> ,("a - b", binOp "-")
|
|
|
|
> ,("a * b", binOp "*")
|
|
|
|
> ,("a / b", binOp "/")
|
|
|
|
> ,("+a", prefOp "+")
|
|
|
|
> ,("-a", prefOp "-")
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
2014-04-20 16:03:32 +02:00
|
|
|
> where
|
|
|
|
> binOp o = BinOp (Iden [Name "a"]) [Name o] (Iden [Name "b"])
|
|
|
|
> prefOp o = PrefixOp [Name o] (Iden [Name "a"])
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 16:03:32 +02:00
|
|
|
TODO: precedence and associativity tests (need to review all operators
|
|
|
|
for what precendence and associativity tests to write)
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.28 <numeric value function>
|
|
|
|
|
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a function yielding a value of type numeric.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<numeric value function> ::=
|
|
|
|
<position expression>
|
|
|
|
| <regex occurrences function>
|
|
|
|
| <regex position expression>
|
|
|
|
| <extract expression>
|
|
|
|
| <length expression>
|
|
|
|
| <cardinality expression>
|
|
|
|
| <max cardinality expression>
|
|
|
|
| <absolute value expression>
|
|
|
|
| <modulus expression>
|
|
|
|
| <natural logarithm>
|
|
|
|
| <exponential function>
|
|
|
|
| <power function>
|
|
|
|
| <square root>
|
|
|
|
| <floor function>
|
|
|
|
| <ceiling function>
|
|
|
|
| <width bucket function>
|
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> numericValueFunction :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> numericValueFunction = Group "numeric value function"
|
|
|
|
> [-- todo: numeric value function
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<position expression> ::=
|
|
|
|
<character position expression>
|
|
|
|
| <binary position expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regex occurrences function> ::=
|
|
|
|
OCCURRENCES_REGEX <left paren>
|
|
|
|
<XQuery pattern> [ FLAG <XQuery option flag> ]
|
|
|
|
IN <regex subject string>
|
|
|
|
[ FROM <start position> ]
|
|
|
|
[ USING <char length units> ]
|
|
|
|
<right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<XQuery pattern> ::= <character value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<XQuery option flag> ::= <character value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regex subject string> ::= <character value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regex position expression> ::=
|
|
|
|
POSITION_REGEX <left paren>
|
|
|
|
[ <regex position start or after> ]
|
|
|
|
<XQuery pattern> [ FLAG <XQuery option flag> ]
|
|
|
|
IN <regex subject string>
|
|
|
|
[ FROM <start position> ]
|
|
|
|
[ USING <char length units> ]
|
|
|
|
[ OCCURRENCE <regex occurrence> ]
|
|
|
|
[ GROUP <regex capture group> ]
|
|
|
|
<right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regex position start or after> ::= START | AFTER
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regex occurrence> ::= <numeric value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regex capture group> ::= <numeric value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character position expression> ::=
|
|
|
|
POSITION <left paren> <character value expression 1> IN <character value expression 2>
|
|
|
|
[ USING <char length units> ] <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character value expression 1> ::= <character value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character value expression 2> ::= <character value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<binary position expression> ::=
|
|
|
|
POSITION <left paren> <binary value expression> IN <binary value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<length expression> ::= <char length expression> | <octet length expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<char length expression> ::=
|
|
|
|
{ CHAR_LENGTH | CHARACTER_LENGTH } <left paren> <character value expression>
|
|
|
|
[ USING <char length units> ] <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<octet length expression> ::=
|
|
|
|
OCTET_LENGTH <left paren> <string value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<extract expression> ::=
|
|
|
|
EXTRACT <left paren> <extract field> FROM <extract source> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<extract field> ::= <primary datetime field> | <time zone field>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<time zone field> ::= TIMEZONE_HOUR | TIMEZONE_MINUTE
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<extract source> ::= <datetime value expression> | <interval value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<cardinality expression> ::=
|
|
|
|
CARDINALITY <left paren> <collection value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<max cardinality expression> ::=
|
|
|
|
ARRAY_MAX_CARDINALITY <left paren> <array value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<absolute value expression> ::=
|
|
|
|
ABS <left paren> <numeric value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<modulus expression> ::=
|
|
|
|
MOD <left paren> <numeric value expression dividend> <comma>
|
|
|
|
<numeric value expression divisor> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<numeric value expression dividend> ::= <numeric value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<numeric value expression divisor> ::= <numeric value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<natural logarithm> ::=
|
|
|
|
LN <left paren> <numeric value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<exponential function> ::=
|
|
|
|
EXP <left paren> <numeric value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<power function> ::=
|
|
|
|
POWER <left paren> <numeric value expression base> <comma>
|
|
|
|
<numeric value expression exponent> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<numeric value expression base> ::= <numeric value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<numeric value expression exponent> ::= <numeric value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<square root> ::= SQRT <left paren> <numeric value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<floor function> ::=
|
|
|
|
FLOOR <left paren> <numeric value expression> <right paren>
|
|
|
|
|
|
|
|
<ceiling function> ::=
|
|
|
|
{ CEIL | CEILING } <left paren> <numeric value expression> <right paren>
|
|
|
|
|
|
|
|
<width bucket function> ::=
|
|
|
|
WIDTH_BUCKET <left paren> <width bucket operand> <comma> <width bucket bound 1> <comma>
|
|
|
|
<width bucket bound 2> <comma> <width bucket count> <right paren>
|
|
|
|
|
|
|
|
<width bucket operand> ::= <numeric value expression>
|
|
|
|
|
|
|
|
<width bucket bound 1> ::= <numeric value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<width bucket bound 2> ::= <numeric value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<width bucket count> ::= <numeric value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.29 <string value expression>
|
|
|
|
|
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a character string value or a binary string value.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<string value expression> ::=
|
|
|
|
<character value expression>
|
|
|
|
| <binary value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character value expression> ::= <concatenation> | <character factor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<concatenation> ::=
|
|
|
|
<character value expression> <concatenation operator> <character factor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character factor> ::= <character primary> [ <collate clause> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character primary> ::= <value expression primary> | <string value function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<binary value expression> ::= <binary concatenation> | <binary factor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<binary factor> ::= <binary primary>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<binary primary> ::= <value expression primary> | <string value function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<binary concatenation> ::=
|
|
|
|
<binary value expression> <concatenation operator> <binary factor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> stringValueExpression :: TestItem
|
|
|
|
> stringValueExpression = Group "string value expression"
|
|
|
|
> [-- todo: string value expression
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.30 <string value function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a function yielding a value of type character string or binary string.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<string value function> ::=
|
|
|
|
<character value function>
|
|
|
|
| <binary value function>
|
|
|
|
|
|
|
|
<character value function> ::=
|
|
|
|
<character substring function>
|
|
|
|
| <regular expression substring function>
|
|
|
|
| <regex substring function>
|
|
|
|
| <fold>
|
|
|
|
| <transcoding>
|
|
|
|
| <character transliteration>
|
|
|
|
| <regex transliteration>
|
|
|
|
| <trim function>
|
|
|
|
| <character overlay function>
|
|
|
|
| <normalize function>
|
|
|
|
| <specific type method>
|
|
|
|
|
|
|
|
> stringValueFunction :: TestItem
|
|
|
|
> stringValueFunction = Group "string value function"
|
|
|
|
> [-- todo: string value function
|
|
|
|
> ]
|
|
|
|
|
|
|
|
<character substring function> ::=
|
|
|
|
SUBSTRING <left paren> <character value expression> FROM <start position>
|
|
|
|
[ FOR <string length> ] [ USING <char length units> ] <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regular expression substring function> ::=
|
|
|
|
SUBSTRING <left paren> <character value expression> SIMILAR <character value expression>
|
|
|
|
ESCAPE <escape character> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regex substring function> ::=
|
|
|
|
SUBSTRING_REGEX <left paren>
|
|
|
|
<XQuery pattern> [ FLAG <XQuery option flag> ]
|
|
|
|
IN <regex subject string>
|
|
|
|
[ FROM <start position> ]
|
|
|
|
[ USING <char length units> ]
|
|
|
|
[ OCCURRENCE <regex occurrence> ]
|
|
|
|
[ GROUP <regex capture group> ]
|
|
|
|
<right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<fold> ::=
|
|
|
|
{ UPPER | LOWER } <left paren> <character value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<transcoding> ::=
|
|
|
|
CONVERT <left paren> <character value expression>
|
|
|
|
USING <transcoding name> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character transliteration> ::=
|
|
|
|
TRANSLATE <left paren> <character value expression>
|
|
|
|
USING <transliteration name> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regex transliteration> ::=
|
|
|
|
TRANSLATE_REGEX <left paren>
|
|
|
|
<XQuery pattern> [ FLAG <XQuery option flag> ]
|
|
|
|
IN <regex subject string>
|
|
|
|
[ WITH <XQuery replacement string> ]
|
|
|
|
[ FROM <start position> ]
|
|
|
|
[ USING <char length units> ]
|
|
|
|
[ OCCURRENCE <regex transliteration occurrence> ]
|
|
|
|
<right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<XQuery replacement string> ::= <character value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regex transliteration occurrence> ::= <regex occurrence> | ALL
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<trim function> ::= TRIM <left paren> <trim operands> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<trim operands> ::=
|
|
|
|
[ [ <trim specification> ] [ <trim character> ] FROM ] <trim source>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<trim source> ::= <character value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<trim specification> ::= LEADING | TRAILING | BOTH
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<trim character> ::= <character value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character overlay function> ::=
|
|
|
|
OVERLAY <left paren> <character value expression> PLACING <character value expression>
|
|
|
|
FROM <start position> [ FOR <string length> ]
|
|
|
|
[ USING <char length units> ] <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<normalize function> ::=
|
|
|
|
NORMALIZE <left paren> <character value expression>
|
|
|
|
[ <comma> <normal form> [ <comma> <normalize function result length> ] ] <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<normal form> ::= NFC | NFD | NFKC | NFKD
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<normalize function result length> ::=
|
|
|
|
<character length>
|
|
|
|
| <character large object length>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<specific type method> ::=
|
|
|
|
<user-defined type value expression> <period> SPECIFICTYPE
|
|
|
|
[ <left paren> <right paren> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<binary value function> ::=
|
|
|
|
<binary substring function>
|
|
|
|
| <binary trim function>
|
|
|
|
| <binary overlay function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<binary substring function> ::=
|
|
|
|
SUBSTRING <left paren> <binary value expression> FROM <start position>
|
|
|
|
[ FOR <string length> ] <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<binary trim function> ::=
|
|
|
|
TRIM <left paren> <binary trim operands> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<binary trim operands> ::=
|
|
|
|
[ [ <trim specification> ] [ <trim octet> ] FROM ] <binary trim source>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<binary trim source> ::= <binary value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<trim octet> ::= <binary value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<binary overlay function> ::=
|
|
|
|
OVERLAY <left paren> <binary value expression> PLACING <binary value expression>
|
|
|
|
FROM <start position> [ FOR <string length> ] <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<start position> ::= <numeric value expression>
|
|
|
|
|
|
|
|
<string length> ::= <numeric value expression>
|
|
|
|
|
|
|
|
== 6.31 <datetime value expression>
|
|
|
|
|
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a datetime value.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<datetime value expression> ::=
|
|
|
|
<datetime term>
|
|
|
|
| <interval value expression> <plus sign> <datetime term>
|
|
|
|
| <datetime value expression> <plus sign> <interval term>
|
|
|
|
| <datetime value expression> <minus sign> <interval term>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> datetimeValueExpression :: TestItem
|
|
|
|
> datetimeValueExpression = Group "datetime value expression"
|
|
|
|
> [-- todo: datetime value expression
|
|
|
|
> datetimeValueFunction
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<datetime term> ::= <datetime factor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<datetime factor> ::= <datetime primary> [ <time zone> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<datetime primary> ::= <value expression primary> | <datetime value function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<time zone> ::= AT <time zone specifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<time zone specifier> ::= LOCAL | TIME ZONE <interval primary>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.32 <datetime value function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a function yielding a value of type datetime.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<datetime value function> ::=
|
|
|
|
<current date value function>
|
|
|
|
| <current time value function>
|
|
|
|
| <current timestamp value function>
|
|
|
|
| <current local time value function>
|
|
|
|
| <current local timestamp value function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> datetimeValueFunction :: TestItem
|
|
|
|
> datetimeValueFunction = Group "datetime value function"
|
|
|
|
> [-- todo: datetime value function
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<current date value function> ::= CURRENT_DATE
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<current time value function> ::=
|
|
|
|
CURRENT_TIME [ <left paren> <time precision> <right paren> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<current local time value function> ::=
|
|
|
|
LOCALTIME [ <left paren> <time precision> <right paren> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<current timestamp value function> ::=
|
|
|
|
CURRENT_TIMESTAMP [ <left paren> <timestamp precision> <right paren> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<current local timestamp value function> ::=
|
|
|
|
LOCALTIMESTAMP [ <left paren> <timestamp precision> <right paren> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.33 <interval value expression>
|
|
|
|
|
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify an interval value.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval value expression> ::=
|
|
|
|
<interval term>
|
|
|
|
| <interval value expression 1> <plus sign> <interval term 1>
|
|
|
|
| <interval value expression 1> <minus sign> <interval term 1>
|
|
|
|
| <left paren> <datetime value expression> <minus sign> <datetime term> <right paren>
|
|
|
|
<interval qualifier>
|
|
|
|
|
|
|
|
> intervalValueExpression :: TestItem
|
|
|
|
> intervalValueExpression = Group "interval value expression"
|
|
|
|
> [-- todo: interval value expression
|
|
|
|
> ]
|
|
|
|
|
|
|
|
|
|
|
|
<interval term> ::=
|
|
|
|
<interval factor>
|
|
|
|
| <interval term 2> <asterisk> <factor>
|
|
|
|
| <interval term 2> <solidus> <factor>
|
|
|
|
| <term> <asterisk> <interval factor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval factor> ::= [ <sign> ] <interval primary>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval primary> ::=
|
|
|
|
<value expression primary> [ <interval qualifier> ]
|
|
|
|
| <interval value function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval value expression 1> ::= <interval value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval term 1> ::= <interval term>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval term 2> ::= <interval term>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.34 <interval value function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a function yielding a value of type interval.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval value function> ::= <interval absolute value function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval absolute value function> ::=
|
|
|
|
ABS <left paren> <interval value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> intervalValueFunction :: TestItem
|
|
|
|
> intervalValueFunction = Group "interval value function"
|
|
|
|
> [-- todo: interval value function
|
|
|
|
> ]
|
|
|
|
|
|
|
|
|
|
|
|
== 6.35 <boolean value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a boolean value.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<boolean value expression> ::=
|
|
|
|
<boolean term>
|
|
|
|
| <boolean value expression> OR <boolean term>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<boolean term> ::= <boolean factor> | <boolean term> AND <boolean factor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<boolean factor> ::= [ NOT ] <boolean test>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<boolean test> ::= <boolean primary> [ IS [ NOT ] <truth value> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<truth value> ::= TRUE | FALSE | UNKNOWN
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<boolean primary> ::= <predicate> | <boolean predicand>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<boolean predicand> ::=
|
|
|
|
<parenthesized boolean value expression>
|
|
|
|
| <nonparenthesized value expression primary>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<parenthesized boolean value expression> ::=
|
|
|
|
<left paren> <boolean value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
> booleanValueExpression :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> booleanValueExpression = Group "booleab value expression"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("a or b", BinOp a [Name "or"] b)
|
|
|
|
> ,("a and b", BinOp a [Name "and"] b)
|
|
|
|
> ,("not a", PrefixOp [Name "not"] a)
|
|
|
|
> ,("a is true", postfixOp "is true")
|
|
|
|
> ,("a is false", postfixOp "is false")
|
|
|
|
> ,("a is unknown", postfixOp "is unknown")
|
|
|
|
> ,("a is not true", postfixOp "is not true")
|
|
|
|
> ,("a is not false", postfixOp "is not false")
|
|
|
|
> ,("a is not unknown", postfixOp "is not unknown")
|
|
|
|
> ,("(a or b)", Parens $ BinOp a [Name "or"] b)
|
|
|
|
> ]
|
|
|
|
> where
|
|
|
|
> a = Iden [Name "a"]
|
|
|
|
> b = Iden [Name "b"]
|
|
|
|
> postfixOp nm = PostfixOp [Name nm] a
|
|
|
|
|
|
|
|
TODO: review if more tests are needed. Should at least have
|
|
|
|
precendence tests for mixed and, or and not without parens.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.36 <array value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify an array value.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<array value expression> ::= <array concatenation> | <array primary>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<array concatenation> ::=
|
|
|
|
<array value expression 1> <concatenation operator> <array primary>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<array value expression 1> ::= <array value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<array primary> ::= <array value function> | <value expression primary>
|
|
|
|
|
|
|
|
> arrayValueExpression :: TestItem
|
|
|
|
> arrayValueExpression = Group "array value expression"
|
|
|
|
> [-- todo: array value expression
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.37 <array value function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a function yielding a value of an array type.
|
|
|
|
|
|
|
|
<array value function> ::= <trim array function>
|
|
|
|
|
|
|
|
<trim array function> ::=
|
|
|
|
TRIM_ARRAY <left paren> <array value expression> <comma> <numeric value expression>
|
|
|
|
<right paren>
|
|
|
|
|
|
|
|
> arrayValueFunction :: TestItem
|
|
|
|
> arrayValueFunction = Group "array value function"
|
|
|
|
> [-- todo: array value function
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.38 <array value constructor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify construction of an array.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<array value constructor> ::=
|
|
|
|
<array value constructor by enumeration>
|
|
|
|
| <array value constructor by query>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<array value constructor by enumeration> ::=
|
|
|
|
ARRAY <left bracket or trigraph> <array element list> <right bracket or trigraph>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<array element list> ::= <array element> [ { <comma> <array element> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<array element> ::= <value expression>
|
|
|
|
|
|
|
|
<array value constructor by query> ::= ARRAY <table subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> arrayValueConstructor :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> arrayValueConstructor = Group "array value constructor"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("array[1,2,3]"
|
|
|
|
> ,Array (Iden [Name "array"])
|
|
|
|
> [NumLit "1", NumLit "2", NumLit "3"])
|
|
|
|
> ,("array[a,b,c]"
|
|
|
|
> ,Array (Iden [Name "array"])
|
|
|
|
> [Iden [Name "a"], Iden [Name "b"], Iden [Name "c"]])
|
|
|
|
> ,("array(select * from t)"
|
|
|
|
> ,ArrayCtor (makeSelect
|
|
|
|
> {qeSelectList = [(Star,Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]}))
|
|
|
|
> ,("array(select * from t order by a)"
|
|
|
|
> ,ArrayCtor (makeSelect
|
|
|
|
> {qeSelectList = [(Star,Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]
|
2014-04-21 13:16:45 +02:00
|
|
|
> ,qeOrderBy = [SortSpec (Iden [Name "a"])
|
|
|
|
> DirDefault NullsOrderDefault]}))
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
|
|
|
|
2014-04-20 16:03:32 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.39 <multiset value expression>
|
|
|
|
|
|
|
|
Function
|
|
|
|
Specify a multiset value.
|
|
|
|
|
|
|
|
<multiset value expression> ::=
|
|
|
|
<multiset term>
|
|
|
|
| <multiset value expression> MULTISET UNION [ ALL | DISTINCT ] <multiset term>
|
|
|
|
| <multiset value expression> MULTISET EXCEPT [ ALL | DISTINCT ] <multiset term>
|
|
|
|
|
|
|
|
<multiset term> ::=
|
|
|
|
<multiset primary>
|
|
|
|
| <multiset term> MULTISET INTERSECT [ ALL | DISTINCT ] <multiset primary>
|
|
|
|
|
|
|
|
<multiset primary> ::= <multiset value function> | <value expression primary>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> multisetValueExpression :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> multisetValueExpression = Group "multiset value expression"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("a multiset union b"
|
|
|
|
> ,MultisetBinOp (Iden [Name "a"]) Union SQDefault (Iden [Name "b"]))
|
|
|
|
> ,("a multiset union all b"
|
|
|
|
> ,MultisetBinOp (Iden [Name "a"]) Union All (Iden [Name "b"]))
|
|
|
|
> ,("a multiset union distinct b"
|
|
|
|
> ,MultisetBinOp (Iden [Name "a"]) Union Distinct (Iden [Name "b"]))
|
|
|
|
> ,("a multiset except b"
|
|
|
|
> ,MultisetBinOp (Iden [Name "a"]) Except SQDefault (Iden [Name "b"]))
|
|
|
|
> ,("a multiset intersect b"
|
|
|
|
> ,MultisetBinOp (Iden [Name "a"]) Intersect SQDefault (Iden [Name "b"]))
|
|
|
|
> ]
|
|
|
|
|
|
|
|
TODO: check precedence and associativity
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.40 <multiset value function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a function yielding a value of a multiset type.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<multiset value function> ::= <multiset set function>
|
|
|
|
|
|
|
|
<multiset set function> ::=
|
|
|
|
SET <left paren> <multiset value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2015-08-01 19:26:00 +02:00
|
|
|
TODO: set is now a reserved keyword. Fix the set parsing with a
|
|
|
|
special case term.
|
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
> multisetValueFunction :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> multisetValueFunction = Group "multiset value function"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("set(a)", App [Name "set"] [Iden [Name "a"]])
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 6.41 <multiset value constructor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify construction of a multiset.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<multiset value constructor> ::=
|
|
|
|
<multiset value constructor by enumeration>
|
|
|
|
| <multiset value constructor by query>
|
|
|
|
| <table value constructor by query>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<multiset value constructor by enumeration> ::=
|
|
|
|
MULTISET <left bracket or trigraph> <multiset element list> <right bracket or trigraph>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<multiset element list> ::=
|
|
|
|
<multiset element> [ { <comma> <multiset element> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<multiset element> ::= <value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<multiset value constructor by query> ::= MULTISET <table subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<table value constructor by query> ::= TABLE <table subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> multisetValueConstructor :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> multisetValueConstructor = Group "multiset value constructor"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-21 13:16:45 +02:00
|
|
|
> [("multiset[a,b,c]", MultisetCtor[Iden [Name "a"]
|
|
|
|
> ,Iden [Name "b"], Iden [Name "c"]])
|
2014-04-20 16:03:32 +02:00
|
|
|
> ,("multiset(select * from t)", MultisetQueryCtor qe)
|
|
|
|
> ,("table(select * from t)", MultisetQueryCtor qe)
|
|
|
|
> ]
|
|
|
|
> where
|
|
|
|
> qe = makeSelect {qeSelectList = [(Star,Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]}
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
= 7 Query expressions
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> queryExpressions :: TestItem
|
|
|
|
> queryExpressions = Group "query expressions"
|
|
|
|
> [rowValueConstructor
|
|
|
|
> ,tableValueConstructor
|
2014-04-20 21:10:55 +02:00
|
|
|
> ,fromClause
|
2014-04-20 15:13:14 +02:00
|
|
|
> ,tableReference
|
|
|
|
> ,joinedTable
|
|
|
|
> ,whereClause
|
|
|
|
> ,groupByClause
|
2014-04-20 21:10:55 +02:00
|
|
|
> ,havingClause
|
2014-04-20 15:13:14 +02:00
|
|
|
> ,windowClause
|
|
|
|
> ,querySpecification
|
|
|
|
> ,withQueryExpression
|
|
|
|
> ,setOpQueryExpression
|
|
|
|
> ,explicitTableQueryExpression
|
|
|
|
> ,orderOffsetFetchQueryExpression
|
|
|
|
> ,searchOrCycleClause
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.1 <row value constructor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a value or list of values to be constructed into a row.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row value constructor> ::=
|
|
|
|
<common value expression>
|
|
|
|
| <boolean value expression>
|
|
|
|
| <explicit row value constructor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<explicit row value constructor> ::=
|
|
|
|
<left paren> <row value constructor element> <comma>
|
|
|
|
<row value constructor element list> <right paren>
|
|
|
|
| ROW <left paren> <row value constructor element list> <right paren>
|
|
|
|
| <row subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row value constructor element list> ::=
|
|
|
|
<row value constructor element> [ { <comma> <row value constructor element> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row value constructor element> ::= <value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<contextually typed row value constructor> ::=
|
|
|
|
<common value expression>
|
|
|
|
| <boolean value expression>
|
|
|
|
| <contextually typed value specification>
|
|
|
|
| <left paren> <contextually typed value specification> <right paren>
|
|
|
|
| <left paren> <contextually typed row value constructor element> <comma>
|
|
|
|
<contextually typed row value constructor element list> <right paren>
|
|
|
|
| ROW <left paren> <contextually typed row value constructor element list> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<contextually typed row value constructor element list> ::=
|
|
|
|
<contextually typed row value constructor element>
|
|
|
|
[ { <comma> <contextually typed row value constructor element> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<contextually typed row value constructor element> ::=
|
|
|
|
<value expression>
|
|
|
|
| <contextually typed value specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row value constructor predicand> ::=
|
|
|
|
<common value expression>
|
|
|
|
| <boolean predicand>
|
|
|
|
| <explicit row value constructor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> rowValueConstructor :: TestItem
|
|
|
|
> rowValueConstructor = Group "row value constructor"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 22:14:55 +02:00
|
|
|
> [("(a,b)"
|
|
|
|
> ,SpecialOp [Name "rowctor"] [Iden [Name "a"], Iden [Name "b"]])
|
|
|
|
> ,("row(1)",App [Name "row"] [NumLit "1"])
|
|
|
|
> ,("row(1,2)",App [Name "row"] [NumLit "1",NumLit "2"])
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
|
|
|
|
|
|
|
== 7.2 <row value expression>
|
|
|
|
|
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a row value.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row value expression> ::=
|
|
|
|
<row value special case>
|
|
|
|
| <explicit row value constructor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<table row value expression> ::=
|
|
|
|
<row value special case>
|
|
|
|
| <row value constructor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<contextually typed row value expression> ::=
|
|
|
|
<row value special case>
|
|
|
|
| <contextually typed row value constructor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row value predicand> ::=
|
|
|
|
<row value special case>
|
|
|
|
| <row value constructor predicand>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row value special case> ::= <nonparenthesized value expression primary>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 22:14:55 +02:00
|
|
|
There is nothing new here.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.3 <table value constructor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a set of <row value expression>s to be constructed into a table.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<table value constructor> ::= VALUES <row value expression list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row value expression list> ::=
|
|
|
|
<table row value expression> [ { <comma> <table row value expression> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<contextually typed table value constructor> ::=
|
|
|
|
VALUES <contextually typed row value expression list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<contextually typed row value expression list> ::=
|
|
|
|
<contextually typed row value expression>
|
|
|
|
[ { <comma> <contextually typed row value expression> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> tableValueConstructor :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> tableValueConstructor = Group "table value constructor"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 22:14:55 +02:00
|
|
|
> [("values (1,2), (a+b,(select count(*) from t));"
|
|
|
|
> ,Values [[NumLit "1", NumLit "2"]
|
|
|
|
> ,[BinOp (Iden [Name "a"]) [Name "+"]
|
|
|
|
> (Iden [Name "b"])
|
|
|
|
> ,SubQueryExpr SqSq
|
|
|
|
> (makeSelect
|
|
|
|
> {qeSelectList = [(App [Name "count"] [Star],Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]})]])
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.4 <table expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a table or a grouped table.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<table expression> ::=
|
|
|
|
<from clause>
|
|
|
|
[ <where clause> ]
|
|
|
|
[ <group by clause> ]
|
|
|
|
[ <having clause> ]
|
|
|
|
[ <window clause> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.5 <from clause>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a table derived from one or more tables.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<from clause> ::= FROM <table reference list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<table reference list> ::=
|
|
|
|
<table reference> [ { <comma> <table reference> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 21:10:55 +02:00
|
|
|
> fromClause :: TestItem
|
|
|
|
> fromClause = Group "fromClause"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 21:10:55 +02:00
|
|
|
> [("select * from tbl1,tbl2"
|
|
|
|
> ,makeSelect
|
|
|
|
> {qeSelectList = [(Star, Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "tbl1"], TRSimple [Name "tbl2"]]
|
|
|
|
> })]
|
|
|
|
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.6 <table reference>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Reference a table.
|
|
|
|
|
2014-04-20 21:10:55 +02:00
|
|
|
> tableReference :: TestItem
|
|
|
|
> tableReference = Group "table reference"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 21:10:55 +02:00
|
|
|
> [("select * from t", sel)
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<table reference> ::= <table factor> | <joined table>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<table factor> ::= <table primary> [ <sample clause> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<sample clause> ::=
|
|
|
|
TABLESAMPLE <sample method> <left paren> <sample percentage> <right paren>
|
|
|
|
[ <repeatable clause> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<sample method> ::= BERNOULLI | SYSTEM
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<repeatable clause> ::= REPEATABLE <left paren> <repeat argument> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<sample percentage> ::= <numeric value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<repeat argument> ::= <numeric value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<table primary> ::=
|
2014-04-20 21:10:55 +02:00
|
|
|
<table or query name> [ <query system time period specification> ]
|
2014-04-20 15:13:14 +02:00
|
|
|
[ [ AS ] <correlation name>
|
|
|
|
[ <left paren> <derived column list> <right paren> ] ]
|
|
|
|
| <derived table> [ AS ] <correlation name>
|
|
|
|
[ <left paren> <derived column list> <right paren> ]
|
|
|
|
| <lateral derived table> [ AS ] <correlation name>
|
|
|
|
[ <left paren> <derived column list> <right paren> ]
|
|
|
|
| <collection derived table> [ AS ] <correlation name>
|
|
|
|
[ <left paren> <derived column list> <right paren> ]
|
|
|
|
| <table function derived table> [ AS ] <correlation name>
|
|
|
|
[ <left paren> <derived column list> <right paren> ]
|
|
|
|
| <only spec> [ [ AS ] <correlation name>
|
|
|
|
[ <left paren> <derived column list> <right paren> ] ]
|
|
|
|
| <data change delta table> [ [ AS ] <correlation name>
|
|
|
|
[ <left paren> <derived column list> <right paren> ] ]
|
|
|
|
| <parenthesized joined table>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<query system time period specification> ::=
|
|
|
|
FOR SYSTEM_TIME AS OF <point in time 1>
|
|
|
|
| FOR SYSTEM_TIME BETWEEN [ ASYMMETRIC | SYMMETRIC ]
|
|
|
|
<point in time 1> AND <point in time 2>
|
|
|
|
| FOR SYSTEM_TIME FROM <point in time 1> TO <point in time 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 21:10:55 +02:00
|
|
|
TODO: query system time period spec
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<point in time 1> ::= <point in time>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<point in time 2> ::= <point in time>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<point in time> ::= <datetime value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<only spec> ::= ONLY <left paren> <table or query name> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 21:10:55 +02:00
|
|
|
TODO: only
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<lateral derived table> ::= LATERAL <table subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<collection derived table> ::=
|
|
|
|
UNNEST <left paren> <collection value expression>
|
|
|
|
[ { <comma> <collection value expression> }... ] <right paren>
|
|
|
|
[ WITH ORDINALITY ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<table function derived table> ::=
|
|
|
|
TABLE <left paren> <collection value expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<derived table> ::= <table subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<table or query name> ::= <table name> | <transition table name> | <query name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<derived column list> ::= <column name list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<column name list> ::= <column name> [ { <comma> <column name> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<data change delta table> ::=
|
|
|
|
<result option> TABLE <left paren> <data change statement> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<data change statement> ::=
|
|
|
|
<delete statement: searched>
|
|
|
|
| <insert statement>
|
|
|
|
| <merge statement>
|
|
|
|
| <update statement: searched>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<result option> ::= FINAL | NEW | OLD
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<parenthesized joined table> ::=
|
|
|
|
<left paren> <parenthesized joined table> <right paren>
|
|
|
|
| <left paren> <joined table> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 21:10:55 +02:00
|
|
|
|
|
|
|
> -- table or query name
|
|
|
|
> ,("select * from t u", a sel)
|
|
|
|
> ,("select * from t as u", a sel)
|
|
|
|
> ,("select * from t u(a,b)", sel1 )
|
|
|
|
> ,("select * from t as u(a,b)", sel1)
|
|
|
|
> -- derived table TODO: realistic example
|
|
|
|
> ,("select * from (select * from t) u"
|
|
|
|
> ,a $ sel {qeFrom = [TRQueryExpr sel]})
|
|
|
|
> -- lateral TODO: realistic example
|
|
|
|
> ,("select * from lateral t"
|
|
|
|
> ,af TRLateral sel)
|
|
|
|
> -- TODO: bug, lateral should bind more tightly than the alias
|
|
|
|
> --,("select * from lateral t u"
|
|
|
|
> -- ,a $ af sel TRLateral)
|
|
|
|
> -- collection TODO: realistic example
|
|
|
|
> -- TODO: make it work
|
|
|
|
> --,("select * from unnest(a)", undefined)
|
|
|
|
> --,("select * from unnest(a,b)", undefined)
|
|
|
|
> --,("select * from unnest(a,b) with ordinality", undefined)
|
|
|
|
> --,("select * from unnest(a,b) with ordinality u", undefined)
|
|
|
|
> --,("select * from unnest(a,b) with ordinality as u", undefined)
|
|
|
|
> -- table fn TODO: realistic example
|
|
|
|
> -- TODO: make it work
|
|
|
|
> --,("select * from table(a)", undefined)
|
|
|
|
> -- parens
|
|
|
|
> ,("select * from (a join b)", jsel)
|
|
|
|
> ,("select * from (a join b) u", a jsel)
|
|
|
|
> ,("select * from ((a join b)) u", a $ af TRParens jsel)
|
|
|
|
> ,("select * from ((a join b) u) u", a $ af TRParens $ a jsel)
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-20 21:10:55 +02:00
|
|
|
> where
|
|
|
|
> sel = makeSelect
|
|
|
|
> {qeSelectList = [(Star, Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]}
|
|
|
|
> af f s = s {qeFrom = map f (qeFrom s)}
|
|
|
|
> a s = af (\x -> TRAlias x $ Alias (Name "u") Nothing) s
|
|
|
|
> sel1 = makeSelect
|
|
|
|
> {qeSelectList = [(Star, Nothing)]
|
|
|
|
> ,qeFrom = [TRAlias (TRSimple [Name "t"])
|
|
|
|
> $ Alias (Name "u") $ Just [Name "a", Name "b"]]}
|
|
|
|
> jsel = sel {qeFrom =
|
|
|
|
> [TRParens $ TRJoin (TRSimple [Name "a"])
|
|
|
|
> False
|
|
|
|
> JInner
|
|
|
|
> (TRSimple [Name "b"])
|
|
|
|
> Nothing]}
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.7 <joined table>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a table derived from a Cartesian product, inner join, or outer join.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<joined table> ::= <cross join> | <qualified join> | <natural join>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<cross join> ::= <table reference> CROSS JOIN <table factor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<qualified join> ::=
|
|
|
|
{ <table reference> | <partitioned join table> }
|
|
|
|
[ <join type> ] JOIN
|
|
|
|
{ <table reference> | <partitioned join table> }
|
|
|
|
<join specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<partitioned join table> ::=
|
|
|
|
<table factor> PARTITION BY
|
|
|
|
<partitioned join column reference list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<partitioned join column reference list> ::=
|
|
|
|
<left paren> <partitioned join column reference>
|
|
|
|
[ { <comma> <partitioned join column reference> }... ]
|
|
|
|
<right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<partitioned join column reference> ::= <column reference>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<natural join> ::=
|
|
|
|
{ <table reference> | <partitioned join table> }
|
|
|
|
NATURAL [ <join type> ] JOIN
|
|
|
|
{ <table factor> | <partitioned join table> }
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<join specification> ::= <join condition> | <named columns join>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<join condition> ::= ON <search condition>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<named columns join> ::= USING <left paren> <join column list> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<join type> ::= INNER | <outer join type> [ OUTER ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<outer join type> ::= LEFT | RIGHT | FULL
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<join column list> ::= <column name list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> joinedTable :: TestItem
|
|
|
|
> joinedTable = Group "joined table"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 21:10:55 +02:00
|
|
|
> [("select * from a cross join b"
|
|
|
|
> ,sel $ TRJoin a False JCross b Nothing)
|
|
|
|
> ,("select * from a join b on true"
|
|
|
|
> ,sel $ TRJoin a False JInner b
|
|
|
|
> (Just $ JoinOn $ Iden [Name "true"]))
|
|
|
|
> ,("select * from a join b using (c)"
|
|
|
|
> ,sel $ TRJoin a False JInner b
|
|
|
|
> (Just $ JoinUsing [Name "c"]))
|
|
|
|
> ,("select * from a inner join b on true"
|
|
|
|
> ,sel $ TRJoin a False JInner b
|
|
|
|
> (Just $ JoinOn $ Iden [Name "true"]))
|
|
|
|
> ,("select * from a left join b on true"
|
|
|
|
> ,sel $ TRJoin a False JLeft b
|
|
|
|
> (Just $ JoinOn $ Iden [Name "true"]))
|
|
|
|
> ,("select * from a left outer join b on true"
|
|
|
|
> ,sel $ TRJoin a False JLeft b
|
|
|
|
> (Just $ JoinOn $ Iden [Name "true"]))
|
|
|
|
> ,("select * from a right join b on true"
|
|
|
|
> ,sel $ TRJoin a False JRight b
|
|
|
|
> (Just $ JoinOn $ Iden [Name "true"]))
|
|
|
|
> ,("select * from a full join b on true"
|
|
|
|
> ,sel $ TRJoin a False JFull b
|
|
|
|
> (Just $ JoinOn $ Iden [Name "true"]))
|
|
|
|
> ,("select * from a natural join b"
|
|
|
|
> ,sel $ TRJoin a True JInner b Nothing)
|
|
|
|
> ,("select * from a natural inner join b"
|
|
|
|
> ,sel $ TRJoin a True JInner b Nothing)
|
|
|
|
> ,("select * from a natural left join b"
|
|
|
|
> ,sel $ TRJoin a True JLeft b Nothing)
|
|
|
|
> ,("select * from a natural left outer join b"
|
|
|
|
> ,sel $ TRJoin a True JLeft b Nothing)
|
|
|
|
> ,("select * from a natural right join b"
|
|
|
|
> ,sel $ TRJoin a True JRight b Nothing)
|
|
|
|
> ,("select * from a natural full join b"
|
|
|
|
> ,sel $ TRJoin a True JFull b Nothing)
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-20 21:10:55 +02:00
|
|
|
> where
|
|
|
|
> sel t = makeSelect
|
|
|
|
> {qeSelectList = [(Star, Nothing)]
|
|
|
|
> ,qeFrom = [t]}
|
|
|
|
> a = TRSimple [Name "a"]
|
|
|
|
> b = TRSimple [Name "b"]
|
|
|
|
|
|
|
|
TODO: partitioned joins
|
2014-04-20 15:13:14 +02:00
|
|
|
|
|
|
|
== 7.8 <where clause>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Specify a table derived by the application of a <search condition> to
|
|
|
|
the result of the preceding <from clause>.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<where clause> ::= WHERE <search condition>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> whereClause :: TestItem
|
|
|
|
> whereClause = Group "where clause"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("select * from t where a = 5"
|
|
|
|
> ,makeSelect
|
|
|
|
> {qeSelectList = [(Star,Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]
|
|
|
|
> ,qeWhere = Just $ BinOp (Iden [Name "a"]) [Name "="] (NumLit "5")})]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.9 <group by clause>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Specify a grouped table derived by the application of the <group by
|
|
|
|
clause> to the result of the previously specified clause.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<group by clause> ::= GROUP BY [ <set quantifier> ] <grouping element list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<grouping element list> ::=
|
|
|
|
<grouping element> [ { <comma> <grouping element> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<grouping element> ::=
|
|
|
|
<ordinary grouping set>
|
|
|
|
| <rollup list>
|
|
|
|
| <cube list>
|
|
|
|
| <grouping sets specification>
|
|
|
|
| <empty grouping set>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<ordinary grouping set> ::=
|
|
|
|
<grouping column reference>
|
|
|
|
| <left paren> <grouping column reference list> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<grouping column reference> ::= <column reference> [ <collate clause> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<grouping column reference list> ::=
|
|
|
|
<grouping column reference> [ { <comma> <grouping column reference> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<rollup list> ::=
|
|
|
|
ROLLUP <left paren> <ordinary grouping set list> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<ordinary grouping set list> ::=
|
|
|
|
<ordinary grouping set> [ { <comma> <ordinary grouping set> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<cube list> ::= CUBE <left paren> <ordinary grouping set list> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<grouping sets specification> ::=
|
|
|
|
GROUPING SETS <left paren> <grouping set list> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<grouping set list> ::= <grouping set> [ { <comma> <grouping set> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<grouping set> ::=
|
|
|
|
<ordinary grouping set>
|
|
|
|
| <rollup list>
|
|
|
|
| <cube list>
|
|
|
|
| <grouping sets specification>
|
|
|
|
| <empty grouping set>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<empty grouping set> ::= <left paren> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 21:10:55 +02:00
|
|
|
|
|
|
|
> groupByClause :: TestItem
|
|
|
|
> groupByClause = Group "group by clause"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 21:10:55 +02:00
|
|
|
> [("select a,sum(x) from t group by a"
|
|
|
|
> ,qe [SimpleGroup $ Iden [Name "a"]])
|
|
|
|
> ,("select a,sum(x) from t group by a collate c"
|
|
|
|
> ,qe [SimpleGroup $ Collate (Iden [Name "a"]) [Name "c"]])
|
|
|
|
> ,("select a,b,sum(x) from t group by a,b"
|
|
|
|
> ,qex [SimpleGroup $ Iden [Name "a"]
|
|
|
|
> ,SimpleGroup $ Iden [Name "b"]])
|
|
|
|
> -- todo: group by set quantifier
|
|
|
|
> --,("select a,sum(x) from t group by distinct a"
|
|
|
|
> --,undefined)
|
|
|
|
> --,("select a,sum(x) from t group by all a"
|
|
|
|
> -- ,undefined)
|
|
|
|
> ,("select a,b,sum(x) from t group by rollup(a,b)"
|
|
|
|
> ,qex [Rollup [SimpleGroup $ Iden [Name "a"]
|
|
|
|
> ,SimpleGroup $ Iden [Name "b"]]])
|
|
|
|
> ,("select a,b,sum(x) from t group by cube(a,b)"
|
|
|
|
> ,qex [Cube [SimpleGroup $ Iden [Name "a"]
|
|
|
|
> ,SimpleGroup $ Iden [Name "b"]]])
|
|
|
|
> ,("select a,b,sum(x) from t group by grouping sets((),(a,b))"
|
|
|
|
> ,qex [GroupingSets [GroupingParens []
|
|
|
|
> ,GroupingParens [SimpleGroup $ Iden [Name "a"]
|
|
|
|
> ,SimpleGroup $ Iden [Name "b"]]]])
|
|
|
|
> ,("select sum(x) from t group by ()"
|
|
|
|
> ,let x = qe [GroupingParens []]
|
|
|
|
> in x {qeSelectList = tail $ qeSelectList x})
|
|
|
|
> ]
|
|
|
|
> where
|
|
|
|
> qe g = makeSelect
|
|
|
|
> {qeSelectList = [(Iden [Name "a"], Nothing)
|
|
|
|
> ,(App [Name "sum"] [Iden [Name "x"]], Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]
|
|
|
|
> ,qeGroupBy = g}
|
|
|
|
> qex g = let x = qe g
|
|
|
|
> in x {qeSelectList = let [a,b] = qeSelectList x
|
|
|
|
> in [a,(Iden [Name "b"],Nothing),b]}
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.10 <having clause>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Specify a grouped table derived by the elimination of groups that do
|
|
|
|
not satisfy a <search condition>.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<having clause> ::= HAVING <search condition>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 21:10:55 +02:00
|
|
|
> havingClause :: TestItem
|
|
|
|
> havingClause = Group "having clause"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 21:10:55 +02:00
|
|
|
> [("select a,sum(x) from t group by a having sum(x) > 1000"
|
|
|
|
> ,makeSelect
|
|
|
|
> {qeSelectList = [(Iden [Name "a"], Nothing)
|
|
|
|
> ,(App [Name "sum"] [Iden [Name "x"]], Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]
|
|
|
|
> ,qeGroupBy = [SimpleGroup $ Iden [Name "a"]]
|
|
|
|
> ,qeHaving = Just $ BinOp (App [Name "sum"] [Iden [Name "x"]])
|
|
|
|
> [Name ">"]
|
|
|
|
> (NumLit "1000")})
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.11 <window clause>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify one or more window definitions.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window clause> ::= WINDOW <window definition list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window definition list> ::=
|
|
|
|
<window definition> [ { <comma> <window definition> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window definition> ::= <new window name> AS <window specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<new window name> ::= <window name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window specification> ::=
|
|
|
|
<left paren> <window specification details> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window specification details> ::=
|
|
|
|
[ <existing window name> ]
|
|
|
|
[ <window partition clause> ]
|
|
|
|
[ <window order clause> ]
|
|
|
|
[ <window frame clause> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<existing window name> ::= <window name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window partition clause> ::=
|
|
|
|
PARTITION BY <window partition column reference list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window partition column reference list> ::=
|
|
|
|
<window partition column reference>
|
|
|
|
[ { <comma> <window partition column reference> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window partition column reference> ::= <column reference> [ <collate clause> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window order clause> ::= ORDER BY <sort specification list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window frame clause> ::=
|
|
|
|
<window frame units> <window frame extent>
|
|
|
|
[ <window frame exclusion> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window frame units> ::= ROWS | RANGE | GROUPS
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window frame extent> ::= <window frame start> | <window frame between>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window frame start> ::=
|
|
|
|
UNBOUNDED PRECEDING
|
|
|
|
| <window frame preceding>
|
|
|
|
| CURRENT ROW
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window frame preceding> ::= <unsigned value specification> PRECEDING
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window frame between> ::=
|
|
|
|
BETWEEN <window frame bound 1> AND <window frame bound 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window frame bound 1> ::= <window frame bound>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window frame bound 2> ::= <window frame bound>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window frame bound> ::=
|
|
|
|
<window frame start>
|
|
|
|
| UNBOUNDED FOLLOWING
|
|
|
|
| <window frame following>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window frame following> ::= <unsigned value specification> FOLLOWING
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<window frame exclusion> ::=
|
|
|
|
EXCLUDE CURRENT ROW
|
|
|
|
| EXCLUDE GROUP
|
|
|
|
| EXCLUDE TIES
|
|
|
|
| EXCLUDE NO OTHERS
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> windowClause :: TestItem
|
|
|
|
> windowClause = Group "window clause"
|
|
|
|
> [-- todo: window clause
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.12 <query specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a table derived from the result of a <table expression>.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<query specification> ::=
|
|
|
|
SELECT [ <set quantifier> ] <select list> <table expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<select list> ::=
|
|
|
|
<asterisk>
|
|
|
|
| <select sublist> [ { <comma> <select sublist> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<select sublist> ::= <derived column> | <qualified asterisk>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<qualified asterisk> ::=
|
|
|
|
<asterisked identifier chain> <period> <asterisk>
|
|
|
|
| <all fields reference>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<asterisked identifier chain> ::=
|
|
|
|
<asterisked identifier> [ { <period> <asterisked identifier> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<asterisked identifier> ::= <identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<derived column> ::= <value expression> [ <as clause> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<as clause> ::= [ AS ] <column name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<all fields reference> ::=
|
|
|
|
<value expression primary> <period> <asterisk>
|
|
|
|
[ AS <left paren> <all fields column name list> <right paren> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<all fields column name list> ::= <column name list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> querySpecification :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> querySpecification = Group "query specification"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 22:14:55 +02:00
|
|
|
> [("select a from t",qe)
|
|
|
|
> ,("select all a from t",qe {qeSetQuantifier = All})
|
|
|
|
> ,("select distinct a from t",qe {qeSetQuantifier = Distinct})
|
|
|
|
> ,("select * from t", qe {qeSelectList = [(Star,Nothing)]})
|
|
|
|
> ,("select a.* from t"
|
|
|
|
> ,qe {qeSelectList = [(BinOp (Iden [Name "a"]) [Name "."] Star
|
|
|
|
> ,Nothing)]})
|
|
|
|
> ,("select a b from t"
|
|
|
|
> ,qe {qeSelectList = [(Iden [Name "a"], Just $ Name "b")]})
|
|
|
|
> ,("select a as b from t"
|
|
|
|
> ,qe {qeSelectList = [(Iden [Name "a"], Just $ Name "b")]})
|
|
|
|
> ,("select a,b from t"
|
|
|
|
> ,qe {qeSelectList = [(Iden [Name "a"], Nothing)
|
|
|
|
> ,(Iden [Name "b"], Nothing)]})
|
|
|
|
> -- todo: all field reference alias
|
|
|
|
> --,("select * as (a,b) from t",undefined)
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-20 22:14:55 +02:00
|
|
|
> where
|
|
|
|
> qe = makeSelect
|
|
|
|
> {qeSelectList = [(Iden [Name "a"], Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]
|
|
|
|
> }
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.13 <query expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a table.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<query expression> ::=
|
|
|
|
[ <with clause> ] <query expression body>
|
|
|
|
[ <order by clause> ] [ <result offset clause> ] [ <fetch first clause> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<with clause> ::= WITH [ RECURSIVE ] <with list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<with list> ::= <with list element> [ { <comma> <with list element> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<with list element> ::=
|
|
|
|
<query name> [ <left paren> <with column list> <right paren> ]
|
|
|
|
AS <table subquery> [ <search or cycle clause> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<with column list> ::= <column name list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> withQueryExpression :: TestItem
|
|
|
|
> withQueryExpression= Group "with query expression"
|
|
|
|
> [-- todo: with query expression
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<query expression body> ::=
|
|
|
|
<query term>
|
|
|
|
| <query expression body> UNION [ ALL | DISTINCT ]
|
|
|
|
[ <corresponding spec> ] <query term>
|
|
|
|
| <query expression body> EXCEPT [ ALL | DISTINCT ]
|
|
|
|
[ <corresponding spec> ] <query term>
|
|
|
|
|
|
|
|
<query term> ::=
|
|
|
|
<query primary>
|
|
|
|
| <query term> INTERSECT [ ALL | DISTINCT ]
|
|
|
|
[ <corresponding spec> ] <query primary>
|
|
|
|
|
|
|
|
<query primary> ::=
|
|
|
|
<simple table>
|
|
|
|
| <left paren> <query expression body>
|
|
|
|
[ <order by clause> ] [ <result offset clause> ] [ <fetch first clause> ]
|
|
|
|
<right paren>
|
|
|
|
|
|
|
|
> setOpQueryExpression :: TestItem
|
|
|
|
> setOpQueryExpression= Group "set operation query expression"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 22:14:55 +02:00
|
|
|
> -- todo: complete setop query expression tests
|
|
|
|
> [{-("select * from t union select * from t"
|
|
|
|
> ,undefined)
|
|
|
|
> ,("select * from t union all select * from t"
|
|
|
|
> ,undefined)
|
|
|
|
> ,("select * from t union distinct select * from t"
|
|
|
|
> ,undefined)
|
|
|
|
> ,("select * from t union corresponding select * from t"
|
|
|
|
> ,undefined)
|
|
|
|
> ,("select * from t union corresponding by (a,b) select * from t"
|
|
|
|
> ,undefined)
|
|
|
|
> ,("select * from t except select * from t"
|
|
|
|
> ,undefined)
|
|
|
|
> ,("select * from t in intersect select * from t"
|
|
|
|
> ,undefined)-}
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 22:14:55 +02:00
|
|
|
TODO: tests for the associativity and precendence
|
|
|
|
|
|
|
|
TODO: not sure exactly where parens are allowed, we will allow them
|
|
|
|
everywhere
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<simple table> ::=
|
|
|
|
<query specification>
|
|
|
|
| <table value constructor>
|
|
|
|
| <explicit table>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<explicit table> ::= TABLE <table or query name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<corresponding spec> ::=
|
|
|
|
CORRESPONDING [ BY <left paren> <corresponding column list> <right paren> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<corresponding column list> ::= <column name list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> explicitTableQueryExpression :: TestItem
|
|
|
|
> explicitTableQueryExpression= Group "explicit table query expression"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 22:14:55 +02:00
|
|
|
> [("table t", Table [Name "t"])
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<order by clause> ::= ORDER BY <sort specification list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<result offset clause> ::= OFFSET <offset row count> { ROW | ROWS }
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<fetch first clause> ::=
|
|
|
|
FETCH { FIRST | NEXT } [ <fetch first quantity> ] { ROW | ROWS } { ONLY | WITH TIES }
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<fetch first quantity> ::= <fetch first row count> | <fetch first percentage>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<offset row count> ::= <simple value specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<fetch first row count> ::= <simple value specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<fetch first percentage> ::= <simple value specification> PERCENT
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> orderOffsetFetchQueryExpression :: TestItem
|
|
|
|
> orderOffsetFetchQueryExpression = Group "order, offset, fetch query expression"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 22:14:55 +02:00
|
|
|
> [-- todo: finish tests for order offset and fetch
|
2014-04-21 13:16:45 +02:00
|
|
|
> ("select a from t order by a"
|
|
|
|
> ,qe {qeOrderBy = [SortSpec (Iden [Name "a"])
|
|
|
|
> DirDefault NullsOrderDefault]})
|
|
|
|
> ,("select a from t offset 5 row"
|
|
|
|
> ,qe {qeOffset = Just $ NumLit "5"})
|
|
|
|
> ,("select a from t offset 5 rows"
|
|
|
|
> ,qe {qeOffset = Just $ NumLit "5"})
|
|
|
|
> ,("select a from t fetch first 5 row only"
|
|
|
|
> ,qe {qeFetchFirst = Just $ NumLit "5"})
|
|
|
|
> -- todo: support with ties and percent in fetch
|
|
|
|
> --,("select a from t fetch next 5 rows with ties"
|
|
|
|
> --,("select a from t fetch first 5 percent rows only"
|
2014-04-19 21:24:10 +02:00
|
|
|
> ]
|
2014-04-21 13:16:45 +02:00
|
|
|
> where
|
|
|
|
> qe = makeSelect
|
|
|
|
> {qeSelectList = [(Iden [Name "a"], Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]
|
|
|
|
> }
|
|
|
|
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.14 <search or cycle clause>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Specify the generation of ordering and cycle detection information in
|
|
|
|
the result of recursive query expressions.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<search or cycle clause> ::=
|
|
|
|
<search clause>
|
|
|
|
| <cycle clause>
|
|
|
|
| <search clause> <cycle clause>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<search clause> ::= SEARCH <recursive search order> SET <sequence column>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<recursive search order> ::=
|
|
|
|
DEPTH FIRST BY <column name list>
|
|
|
|
| BREADTH FIRST BY <column name list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<sequence column> ::= <column name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<cycle clause> ::=
|
|
|
|
CYCLE <cycle column list> SET <cycle mark column> TO <cycle mark value>
|
|
|
|
DEFAULT <non-cycle mark value> USING <path column>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<cycle column list> ::= <cycle column> [ { <comma> <cycle column> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<cycle column> ::= <column name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<cycle mark column> ::= <column name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<path column> ::= <column name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<cycle mark value> ::= <value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<non-cycle mark value> ::= <value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> searchOrCycleClause :: TestItem
|
|
|
|
> searchOrCycleClause = Group "search or cycle clause"
|
|
|
|
> [-- todo: search or cycle clause
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 7.15 <subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-20 18:24:03 +02:00
|
|
|
|
|
|
|
Specify a scalar value, a row, or a table derived from a <query
|
|
|
|
expression>.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<scalar subquery> ::= <subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row subquery> ::= <subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<table subquery> ::= <subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<subquery> ::= <left paren> <query expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> scalarSubquery :: TestItem
|
|
|
|
> scalarSubquery = Group "scalar subquery"
|
|
|
|
> [-- todo: scalar subquery
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
= 8 Predicates
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.1 <predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a condition that can be evaluated to give a boolean value.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<predicate> ::=
|
|
|
|
<comparison predicate>
|
|
|
|
| <between predicate>
|
|
|
|
| <in predicate>
|
|
|
|
| <like predicate>
|
|
|
|
| <similar predicate>
|
|
|
|
| <regex like predicate>
|
|
|
|
| <null predicate>
|
|
|
|
| <quantified comparison predicate>
|
|
|
|
| <exists predicate>
|
|
|
|
| <unique predicate>
|
|
|
|
| <normalized predicate>
|
|
|
|
| <match predicate>
|
|
|
|
| <overlaps predicate>
|
|
|
|
| <distinct predicate>
|
|
|
|
| <member predicate>
|
|
|
|
| <submultiset predicate>
|
|
|
|
| <set predicate>
|
|
|
|
| <type predicate>
|
|
|
|
| <period predicate>
|
|
|
|
|
|
|
|
> predicates :: TestItem
|
|
|
|
> predicates = Group "predicates"
|
|
|
|
> [comparisonPredicates
|
|
|
|
> ,betweenPredicate
|
|
|
|
> ,inPredicate
|
|
|
|
> ,likePredicate
|
|
|
|
> ,similarPredicate
|
|
|
|
> ,regexLikePredicate
|
|
|
|
> ,nullPredicate
|
|
|
|
> ,quantifiedComparisonPredicate
|
|
|
|
> ,existsPredicate
|
|
|
|
> ,uniquePredicate
|
|
|
|
> ,normalizedPredicate
|
|
|
|
> ,matchPredicate
|
|
|
|
> ,overlapsPredicate
|
|
|
|
> ,distinctPredicate
|
|
|
|
> ,memberPredicate
|
|
|
|
> ,submultisetPredicate
|
|
|
|
> ,setPredicate
|
|
|
|
> ,periodPredicate
|
|
|
|
> ]
|
|
|
|
|
|
|
|
|
|
|
|
== 8.1 <predicate>
|
|
|
|
|
|
|
|
No grammar
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.2 <comparison predicate>
|
|
|
|
|
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a comparison of two row values.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<comparison predicate> ::= <row value predicand> <comparison predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<comparison predicate part 2> ::= <comp op> <row value predicand>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<comp op> ::=
|
|
|
|
<equals operator>
|
|
|
|
| <not equals operator>
|
|
|
|
| <less than operator>
|
|
|
|
| <greater than operator>
|
|
|
|
| <less than or equals operator>
|
|
|
|
| <greater than or equals operator>
|
|
|
|
|
|
|
|
> comparisonPredicates :: TestItem
|
|
|
|
> comparisonPredicates = Group "comparison predicates"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 18:24:03 +02:00
|
|
|
> $ map mkOp ["=", "<>", "<", ">", "<=", ">="]
|
|
|
|
> ++ [("ROW(a) = ROW(b)"
|
|
|
|
> ,BinOp (App [Name "ROW"] [a])
|
|
|
|
> [Name "="]
|
|
|
|
> (App [Name "ROW"] [b]))
|
|
|
|
> ,("(a,b) = (c,d)"
|
|
|
|
> ,BinOp (SpecialOp [Name "rowctor"] [a,b])
|
|
|
|
> [Name "="]
|
|
|
|
> (SpecialOp [Name "rowctor"] [Iden [Name "c"], Iden [Name "d"]]))
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-20 18:24:03 +02:00
|
|
|
> where
|
|
|
|
> mkOp nm = ("a " ++ nm ++ " b"
|
|
|
|
> ,BinOp a [Name nm] b)
|
|
|
|
> a = Iden [Name "a"]
|
|
|
|
> b = Iden [Name "b"]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 18:24:03 +02:00
|
|
|
TODO: what other tests, more complex expressions with comparisons?
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.3 <between predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a range comparison.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<between predicate> ::= <row value predicand> <between predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<between predicate part 2> ::=
|
|
|
|
[ NOT ] BETWEEN [ ASYMMETRIC | SYMMETRIC ]
|
|
|
|
<row value predicand> AND <row value predicand>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> betweenPredicate :: TestItem
|
|
|
|
> betweenPredicate = Group "between predicate"
|
|
|
|
> [-- todo: between predicate
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.4 <in predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a quantified comparison.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<in predicate> ::= <row value predicand> <in predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<in predicate part 2> ::= [ NOT ] IN <in predicate value>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<in predicate value> ::=
|
|
|
|
<table subquery>
|
|
|
|
| <left paren> <in value list> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<in value list> ::=
|
|
|
|
<row value expression> [ { <comma> <row value expression> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> inPredicate :: TestItem
|
|
|
|
> inPredicate = Group "in predicate"
|
|
|
|
> [-- todo: in predicate
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.5 <like predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a pattern-match comparison.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<like predicate> ::= <character like predicate> | <octet like predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character like predicate> ::=
|
|
|
|
<row value predicand> <character like predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character like predicate part 2> ::=
|
|
|
|
[ NOT ] LIKE <character pattern> [ ESCAPE <escape character> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character pattern> ::= <character value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<escape character> ::= <character value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<octet like predicate> ::= <row value predicand> <octet like predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<octet like predicate part 2> ::=
|
|
|
|
[ NOT ] LIKE <octet pattern> [ ESCAPE <escape octet> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<octet pattern> ::= <binary value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<escape octet> ::= <binary value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> likePredicate :: TestItem
|
|
|
|
> likePredicate = Group "like predicate"
|
|
|
|
> [-- todo: like predicate
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.6 <similar predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a character string similarity by means of a regular expression.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<similar predicate> ::= <row value predicand> <similar predicate part 2>
|
|
|
|
|
|
|
|
<similar predicate part 2> ::=
|
|
|
|
[ NOT ] SIMILAR TO <similar pattern> [ ESCAPE <escape character> ]
|
|
|
|
|
|
|
|
<similar pattern> ::= <character value expression>
|
|
|
|
|
|
|
|
<regular expression> ::=
|
|
|
|
<regular term>
|
|
|
|
| <regular expression> <vertical bar> <regular term>
|
|
|
|
|
|
|
|
<regular term> ::= <regular factor> | <regular term> <regular factor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regular factor> ::=
|
|
|
|
<regular primary>
|
|
|
|
| <regular primary> <asterisk>
|
|
|
|
| <regular primary> <plus sign>
|
|
|
|
| <regular primary> <question mark>
|
|
|
|
| <regular primary> <repeat factor>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<repeat factor> ::= <left brace> <low value> [ <upper limit> ] <right brace>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<upper limit> ::= <comma> [ <high value> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<low value> ::= <unsigned integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<high value> ::= <unsigned integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regular primary> ::=
|
|
|
|
<character specifier>
|
|
|
|
| <percent>
|
|
|
|
| <regular character set>
|
|
|
|
| <left paren> <regular expression> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character specifier> ::= <non-escaped character> | <escaped character>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<non-escaped character> ::= !! See the Syntax Rules.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<escaped character> ::= !! See the Syntax Rules.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regular character set> ::=
|
|
|
|
<underscore>
|
|
|
|
| <left bracket> <character enumeration>... <right bracket>
|
|
|
|
| <left bracket> <circumflex> <character enumeration>... <right bracket>
|
|
|
|
| <left bracket> <character enumeration include>...
|
|
|
|
<circumflex> <character enumeration exclude>... <right bracket>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character enumeration include> ::= <character enumeration>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character enumeration exclude> ::= <character enumeration>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character enumeration> ::=
|
|
|
|
<character specifier>
|
|
|
|
| <character specifier> <minus sign> <character specifier>
|
|
|
|
| <left bracket> <colon> <regular character set identifier> <colon> <right bracket>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regular character set identifier> ::= <identifier>
|
|
|
|
|
|
|
|
> similarPredicate :: TestItem
|
|
|
|
> similarPredicate = Group "similar predicate"
|
|
|
|
> [-- todo: similar predicate
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.7 <regex like predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a pattern-match comparison using an XQuery regular expression.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regex like predicate> ::= <row value predicand> <regex like predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<regex like predicate part 2> ::=
|
|
|
|
[ NOT ] LIKE_REGEX <XQuery pattern> [ FLAG <XQuery option flag> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> regexLikePredicate :: TestItem
|
|
|
|
> regexLikePredicate = Group "regex like predicate"
|
|
|
|
> [-- todo: regex like predicate
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.8 <null predicate>
|
|
|
|
|
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a test for a null value.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<null predicate> ::= <row value predicand> <null predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<null predicate part 2> ::= IS [ NOT ] NULL
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> nullPredicate :: TestItem
|
|
|
|
> nullPredicate = Group "null predicate"
|
|
|
|
> [-- todo: null predicate
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.9 <quantified comparison predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a quantified comparison.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<quantified comparison predicate> ::=
|
|
|
|
<row value predicand> <quantified comparison predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<quantified comparison predicate part 2> ::=
|
|
|
|
<comp op> <quantifier> <table subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<quantifier> ::= <all> | <some>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<all> ::= ALL
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<some> ::= SOME | ANY
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> quantifiedComparisonPredicate :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> quantifiedComparisonPredicate = Group "quantified comparison predicate"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
|
|
|
|
> [("a = any (select * from t)"
|
|
|
|
> ,QuantifiedComparison (Iden [Name "a"]) [Name "="] CPAny qe)
|
|
|
|
> ,("a <= some (select * from t)"
|
|
|
|
> ,QuantifiedComparison (Iden [Name "a"]) [Name "<="] CPSome qe)
|
|
|
|
> ,("a > all (select * from t)"
|
|
|
|
> ,QuantifiedComparison (Iden [Name "a"]) [Name ">"] CPAll qe)
|
|
|
|
> ,("(a,b) <> all (select * from t)"
|
|
|
|
> ,QuantifiedComparison
|
2014-04-21 13:16:45 +02:00
|
|
|
> (SpecialOp [Name "rowctor"] [Iden [Name "a"]
|
|
|
|
> ,Iden [Name "b"]]) [Name "<>"] CPAll qe)
|
2014-04-20 16:03:32 +02:00
|
|
|
> ]
|
|
|
|
> where
|
|
|
|
> qe = makeSelect
|
|
|
|
> {qeSelectList = [(Star,Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]}
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.10 <exists predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a test for a non-empty set.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<exists predicate> ::= EXISTS <table subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> existsPredicate :: TestItem
|
|
|
|
> existsPredicate = Group "exists predicate"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("exists(select * from t where a = 4)"
|
|
|
|
> ,SubQueryExpr SqExists
|
|
|
|
> $ makeSelect
|
|
|
|
> {qeSelectList = [(Star,Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]
|
|
|
|
> ,qeWhere = Just (BinOp (Iden [Name "a"]) [Name "="] (NumLit "4"))
|
|
|
|
> }
|
|
|
|
> )]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.11 <unique predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a test for the absence of duplicate rows.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<unique predicate> ::= UNIQUE <table subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> uniquePredicate :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> uniquePredicate = Group "unique predicate"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("unique(select * from t where a = 4)"
|
|
|
|
> ,SubQueryExpr SqUnique
|
|
|
|
> $ makeSelect
|
|
|
|
> {qeSelectList = [(Star,Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]
|
|
|
|
> ,qeWhere = Just (BinOp (Iden [Name "a"]) [Name "="] (NumLit "4"))
|
|
|
|
> }
|
|
|
|
> )]
|
2014-04-20 15:13:14 +02:00
|
|
|
|
|
|
|
== 8.12 <normalized predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Determine whether a character string value is normalized.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<normalized predicate> ::= <row value predicand> <normalized predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<normalized predicate part 2> ::= IS [ NOT ] [ <normal form> ] NORMALIZED
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> normalizedPredicate :: TestItem
|
|
|
|
> normalizedPredicate = Group "normalized predicate"
|
|
|
|
> [-- todo: normalized predicate
|
|
|
|
> ]
|
|
|
|
|
|
|
|
== 8.13 <match predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a test for matching rows.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<match predicate> ::= <row value predicand> <match predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<match predicate part 2> ::=
|
|
|
|
MATCH [ UNIQUE ] [ SIMPLE | PARTIAL | FULL ] <table subquery>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> matchPredicate :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> matchPredicate = Group "match predicate"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("a match (select a from t)"
|
|
|
|
> ,Match (Iden [Name "a"]) False qe)
|
|
|
|
> ,("(a,b) match (select a,b from t)"
|
2014-04-21 13:16:45 +02:00
|
|
|
> ,Match (SpecialOp [Name "rowctor"]
|
|
|
|
> [Iden [Name "a"], Iden [Name "b"]]) False qea)
|
2014-04-20 16:03:32 +02:00
|
|
|
> ,("(a,b) match unique (select a,b from t)"
|
2014-04-21 13:16:45 +02:00
|
|
|
> ,Match (SpecialOp [Name "rowctor"]
|
|
|
|
> [Iden [Name "a"], Iden [Name "b"]]) True qea)
|
2014-04-20 16:03:32 +02:00
|
|
|
> ]
|
|
|
|
> where
|
|
|
|
> qe = makeSelect
|
|
|
|
> {qeSelectList = [(Iden [Name "a"],Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]}
|
2014-04-21 13:16:45 +02:00
|
|
|
> qea = qe {qeSelectList = qeSelectList qe
|
|
|
|
> ++ [(Iden [Name "b"],Nothing)]}
|
2014-04-20 16:03:32 +02:00
|
|
|
|
|
|
|
TODO: simple, partial and full
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.14 <overlaps predicate>
|
|
|
|
|
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a test for an overlap between two datetime periods.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<overlaps predicate> ::=
|
|
|
|
<overlaps predicate part 1> <overlaps predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<overlaps predicate part 1> ::= <row value predicand 1>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<overlaps predicate part 2> ::= OVERLAPS <row value predicand 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row value predicand 1> ::= <row value predicand>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row value predicand 2> ::= <row value predicand>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> overlapsPredicate :: TestItem
|
|
|
|
> overlapsPredicate = Group "overlaps predicate"
|
|
|
|
> [-- todo: overlaps predicate
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.15 <distinct predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a test of whether two row values are distinct
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<distinct predicate> ::= <row value predicand 3> <distinct predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<distinct predicate part 2> ::=
|
|
|
|
IS [ NOT ] DISTINCT FROM <row value predicand 4>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row value predicand 3> ::= <row value predicand>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<row value predicand 4> ::= <row value predicand>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> distinctPredicate :: TestItem
|
|
|
|
> distinctPredicate = Group "distinct predicate"
|
|
|
|
> [-- todo: distinct predicate
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.16 <member predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a test of whether a value is a member of a multiset.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<member predicate> ::= <row value predicand> <member predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<member predicate part 2> ::= [ NOT ] MEMBER [ OF ] <multiset value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> memberPredicate :: TestItem
|
|
|
|
> memberPredicate = Group "member predicate"
|
|
|
|
> [-- todo: member predicate
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.17 <submultiset predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a test of whether a multiset is a submultiset of another multiset.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<submultiset predicate> ::=
|
|
|
|
<row value predicand> <submultiset predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<submultiset predicate part 2> ::=
|
|
|
|
[ NOT ] SUBMULTISET [ OF ] <multiset value expression>
|
|
|
|
|
|
|
|
> submultisetPredicate :: TestItem
|
|
|
|
> submultisetPredicate = Group "submultiset predicate"
|
|
|
|
> [-- todo: submultiset predicate
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.18 <set predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Specify a test of whether a multiset is a set (that is, does not
|
|
|
|
contain any duplicates).
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<set predicate> ::= <row value predicand> <set predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<set predicate part 2> ::= IS [ NOT ] A SET
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> setPredicate :: TestItem
|
|
|
|
> setPredicate = Group "set predicate"
|
|
|
|
> [-- todo: set predicate
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.19 <type predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
Specify a type test.
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<type predicate> ::= <row value predicand> <type predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<type predicate part 2> ::=
|
|
|
|
IS [ NOT ] OF <left paren> <type list> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<type list> ::=
|
|
|
|
<user-defined type specification>
|
|
|
|
[ { <comma> <user-defined type specification> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<user-defined type specification> ::=
|
|
|
|
<inclusive user-defined type specification>
|
|
|
|
| <exclusive user-defined type specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<inclusive user-defined type specification> ::=
|
|
|
|
<path-resolved user-defined type name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<exclusive user-defined type specification> ::=
|
|
|
|
ONLY <path-resolved user-defined type name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
TODO: type predicate
|
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.20 <period predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a test to determine the relationship between periods.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period predicate> ::=
|
|
|
|
<period overlaps predicate>
|
|
|
|
| <period equals predicate>
|
|
|
|
| <period contains predicate>
|
|
|
|
| <period precedes predicate>
|
|
|
|
| <period succeeds predicate>
|
|
|
|
| <period immediately precedes predicate>
|
|
|
|
| <period immediately succeeds predicate>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period overlaps predicate> ::=
|
|
|
|
<period predicand 1> <period overlaps predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period overlaps predicate part 2> ::= OVERLAPS <period predicand 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period predicand 1> ::= <period predicand>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period predicand 2> ::= <period predicand>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period predicand> ::=
|
|
|
|
<period reference>
|
|
|
|
| PERIOD <left paren> <period start value> <comma> <period end value> <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period reference> ::= <basic identifier chain>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period start value> ::= <datetime value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period end value> ::= <datetime value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period equals predicate> ::=
|
|
|
|
<period predicand 1> <period equals predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period equals predicate part 2> ::= EQUALS <period predicand 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period contains predicate> ::=
|
|
|
|
<period predicand 1> <period contains predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period contains predicate part 2> ::=
|
|
|
|
CONTAINS <period or point-in-time predicand>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period or point-in-time predicand> ::=
|
|
|
|
<period predicand>
|
|
|
|
| <datetime value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period precedes predicate> ::=
|
|
|
|
<period predicand 1> <period precedes predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period precedes predicate part 2> ::= PRECEDES <period predicand 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period succeeds predicate> ::=
|
|
|
|
<period predicand 1> <period succeeds predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period succeeds predicate part 2> ::= SUCCEEDS <period predicand 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period immediately precedes predicate> ::=
|
|
|
|
<period predicand 1> <period immediately precedes predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period immediately precedes predicate part 2> ::=
|
|
|
|
IMMEDIATELY PRECEDES <period predicand 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period immediately succeeds predicate> ::=
|
|
|
|
<period predicand 1> <period immediately succeeds predicate part 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<period immediately succeeds predicate part 2> ::=
|
|
|
|
IMMEDIATELY SUCCEEDS <period predicand 2>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> periodPredicate :: TestItem
|
|
|
|
> periodPredicate = Group "period predicate"
|
|
|
|
> [-- todo: period predicate
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 8.21 <search condition>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Specify a condition that is True, False, or Unknown, depending on the
|
|
|
|
value of a <boolean value expression>.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<search condition> ::= <boolean value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
= 10 Additional common elements
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 10.1 <interval qualifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify the precision of an interval data type.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval qualifier> ::= <start field> TO <end field> | <single datetime field>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<start field> ::=
|
|
|
|
<non-second primary datetime field>
|
|
|
|
[ <left paren> <interval leading field precision> <right paren> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<end field> ::=
|
|
|
|
<non-second primary datetime field>
|
|
|
|
| SECOND [ <left paren> <interval fractional seconds precision> <right paren> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<single datetime field> ::=
|
|
|
|
<non-second primary datetime field>
|
|
|
|
[ <left paren> <interval leading field precision> <right paren> ]
|
|
|
|
| SECOND [ <left paren> <interval leading field precision>
|
|
|
|
[ <comma> <interval fractional seconds precision> ] <right paren> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<primary datetime field> ::= <non-second primary datetime field> | SECOND
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<non-second primary datetime field> ::= YEAR | MONTH | DAY | HOUR | MINUTE
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval fractional seconds precision> ::= <unsigned integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<interval leading field precision> ::= <unsigned integer>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> intervalQualifier :: TestItem
|
|
|
|
> intervalQualifier = Group "interval qualifier"
|
|
|
|
> [-- todo: interval qualifier
|
|
|
|
> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
todo: also test all of these in the typenames and in the interval
|
|
|
|
literal tests
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 10.2 <language clause>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a programming language.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<language clause> ::= LANGUAGE <language name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<language name> ::= ADA | C | COBOL | FORTRAN | M | MUMPS | PASCAL | PLI | SQL
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 10.3 <path specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify an order for searching for an SQL-invoked routine.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<path specification> ::= PATH <schema name list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<schema name list> ::= <schema name> [ { <comma> <schema name> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 10.4 <routine invocation>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Invoke an SQL-invoked routine.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<routine invocation> ::= <routine name> <SQL argument list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<routine name> ::= [ <schema name> <period> ] <qualified identifier>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL argument list> ::=
|
|
|
|
<left paren> [ <SQL argument> [ { <comma> <SQL argument> }... ] ] <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<SQL argument> ::=
|
|
|
|
<value expression>
|
|
|
|
| <generalized expression>
|
|
|
|
| <target specification>
|
|
|
|
| <contextually typed value specification>
|
|
|
|
| <named argument specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<generalized expression> ::=
|
|
|
|
<value expression> AS <path-resolved user-defined type name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<named argument specification> ::=
|
|
|
|
<SQL parameter name> <named argument assignment token>
|
|
|
|
<named argument SQL argument>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<named argument SQL argument> ::=
|
|
|
|
<value expression>
|
|
|
|
| <target specification>
|
|
|
|
| <contextually typed value specification>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 10.5 <character set specification>
|
|
|
|
|
|
|
|
Function
|
|
|
|
Identify a character set.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<character set specification> ::=
|
|
|
|
<standard character set name>
|
|
|
|
| <implementation-defined character set name>
|
|
|
|
| <user-defined character set name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<standard character set name> ::= <character set name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<implementation-defined character set name> ::= <character set name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<user-defined character set name> ::= <character set name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
tested in the type names
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 10.6 <specific routine designator>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify an SQL-invoked routine.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<specific routine designator> ::=
|
|
|
|
SPECIFIC <routine type> <specific name>
|
|
|
|
| <routine type> <member name> [ FOR <schema-resolved user-defined type name> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<routine type> ::=
|
|
|
|
ROUTINE
|
|
|
|
| FUNCTION
|
|
|
|
| PROCEDURE
|
|
|
|
| [ INSTANCE | STATIC | CONSTRUCTOR ] METHOD
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<member name> ::= <member name alternatives> [ <data type list> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<member name alternatives> ::= <schema qualified routine name> | <method name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<data type list> ::=
|
|
|
|
<left paren> [ <data type> [ { <comma> <data type> }... ] ] <right paren>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 10.7 <collate clause>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a default collation.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<collate clause> ::= COLLATE <collation name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
> collateClause :: TestItem
|
|
|
|
> collateClause = Group "collate clause"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011))
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("a collate my_collation"
|
|
|
|
> ,Collate (Iden [Name "a"]) [Name "my_collation"])]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 10.8 <constraint name definition> and <constraint characteristics>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify the name of a constraint and its characteristics.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<constraint name definition> ::= CONSTRAINT <constraint name>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<constraint characteristics> ::=
|
|
|
|
<constraint check time> [ [ NOT ] DEFERRABLE ] [ <constraint enforcement> ]
|
|
|
|
| [ NOT ] DEFERRABLE [ <constraint check time> ] [ <constraint enforcement> ]
|
|
|
|
| <constraint enforcement>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<constraint check time> ::= INITIALLY DEFERRED | INITIALLY IMMEDIATE
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<constraint enforcement> ::= [ NOT ] ENFORCED
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 10.9 <aggregate function>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a value computed from a collection of rows.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<aggregate function> ::=
|
|
|
|
COUNT <left paren> <asterisk> <right paren> [ <filter clause> ]
|
|
|
|
| <general set function> [ <filter clause> ]
|
|
|
|
| <binary set function> [ <filter clause> ]
|
|
|
|
| <ordered set function> [ <filter clause> ]
|
|
|
|
| <array aggregate function> [ <filter clause> ]
|
|
|
|
|
|
|
|
<general set function> ::=
|
|
|
|
<set function type> <left paren> [ <set quantifier> ]
|
|
|
|
<value expression> <right paren>
|
|
|
|
|
|
|
|
<set function type> ::= <computational operation>
|
|
|
|
|
|
|
|
<computational operation> ::=
|
|
|
|
AVG
|
|
|
|
| MAX
|
|
|
|
| MIN
|
|
|
|
| SUM
|
|
|
|
| EVERY
|
|
|
|
| ANY
|
|
|
|
| SOME
|
|
|
|
| COUNT
|
|
|
|
| STDDEV_POP
|
|
|
|
| STDDEV_SAMP
|
|
|
|
| VAR_SAMP
|
|
|
|
| VAR_POP
|
|
|
|
| COLLECT
|
|
|
|
| FUSION
|
|
|
|
| INTERSECTION
|
|
|
|
|
|
|
|
<set quantifier> ::= DISTINCT | ALL
|
|
|
|
|
|
|
|
<filter clause> ::= FILTER <left paren> WHERE <search condition> <right paren>
|
|
|
|
|
|
|
|
<binary set function> ::=
|
|
|
|
<binary set function type> <left paren> <dependent variable expression> <comma>
|
|
|
|
<independent variable expression> <right paren>
|
|
|
|
|
|
|
|
<binary set function type> ::=
|
|
|
|
COVAR_POP
|
|
|
|
| COVAR_SAMP
|
|
|
|
| CORR
|
|
|
|
| REGR_SLOPE
|
|
|
|
| REGR_INTERCEPT
|
|
|
|
| REGR_COUNT
|
|
|
|
| REGR_R2
|
|
|
|
| REGR_AVGX
|
|
|
|
| REGR_AVGY
|
|
|
|
| REGR_SXX
|
|
|
|
| REGR_SYY
|
|
|
|
| REGR_SXY
|
|
|
|
|
|
|
|
<dependent variable expression> ::= <numeric value expression>
|
|
|
|
|
|
|
|
<independent variable expression> ::= <numeric value expression>
|
|
|
|
|
|
|
|
<ordered set function> ::=
|
|
|
|
<hypothetical set function>
|
|
|
|
| <inverse distribution function>
|
|
|
|
|
|
|
|
<hypothetical set function> ::=
|
|
|
|
<rank function type> <left paren>
|
|
|
|
<hypothetical set function value expression list> <right paren>
|
|
|
|
<within group specification>
|
|
|
|
|
|
|
|
<within group specification> ::=
|
|
|
|
WITHIN GROUP <left paren> ORDER BY <sort specification list> <right paren>
|
|
|
|
|
|
|
|
<hypothetical set function value expression list> ::=
|
|
|
|
<value expression> [ { <comma> <value expression> }... ]
|
|
|
|
|
|
|
|
<inverse distribution function> ::=
|
|
|
|
<inverse distribution function type> <left paren>
|
|
|
|
<inverse distribution function argument> <right paren>
|
|
|
|
<within group specification>
|
|
|
|
|
|
|
|
<inverse distribution function argument> ::= <numeric value expression>
|
|
|
|
|
|
|
|
<inverse distribution function type> ::= PERCENTILE_CONT | PERCENTILE_DISC
|
|
|
|
|
|
|
|
<array aggregate function> ::=
|
|
|
|
ARRAY_AGG
|
|
|
|
<left paren> <value expression> [ ORDER BY <sort specification list> ] <right paren>
|
|
|
|
|
|
|
|
> aggregateFunction :: TestItem
|
|
|
|
> aggregateFunction = Group "aggregate function"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestValueExpr SQL2011)) $
|
2014-04-20 16:03:32 +02:00
|
|
|
> [("count(*)",App [Name "count"] [Star])
|
|
|
|
> ,("count(*) filter (where something > 5)"
|
|
|
|
> ,AggregateApp [Name "count"] SQDefault [Star] [] fil)
|
|
|
|
|
|
|
|
gsf
|
|
|
|
|
|
|
|
> ,("count(a)",App [Name "count"] [Iden [Name "a"]])
|
|
|
|
> ,("count(distinct a)"
|
|
|
|
> ,AggregateApp [Name "count"]
|
|
|
|
> Distinct
|
|
|
|
> [Iden [Name "a"]] [] Nothing)
|
|
|
|
> ,("count(all a)"
|
|
|
|
> ,AggregateApp [Name "count"]
|
|
|
|
> All
|
|
|
|
> [Iden [Name "a"]] [] Nothing)
|
|
|
|
> ,("count(all a) filter (where something > 5)"
|
|
|
|
> ,AggregateApp [Name "count"]
|
|
|
|
> All
|
|
|
|
> [Iden [Name "a"]] [] fil)
|
|
|
|
> ] ++ concatMap mkSimpleAgg
|
|
|
|
> ["avg","max","min","sum"
|
|
|
|
> ,"every", "any", "some"
|
|
|
|
> ,"stddev_pop","stddev_samp","var_samp","var_pop"
|
|
|
|
> ,"collect","fusion","intersection"]
|
|
|
|
|
|
|
|
bsf
|
|
|
|
|
|
|
|
> ++ concatMap mkBsf
|
|
|
|
> ["COVAR_POP","COVAR_SAMP","CORR","REGR_SLOPE"
|
|
|
|
> ,"REGR_INTERCEPT","REGR_COUNT","REGR_R2"
|
|
|
|
> ,"REGR_AVGX","REGR_AVGY"
|
|
|
|
> ,"REGR_SXX","REGR_SYY","REGR_SXY"]
|
|
|
|
|
|
|
|
osf
|
|
|
|
|
|
|
|
> ++
|
|
|
|
> [("rank(a,c) within group (order by b)"
|
|
|
|
> ,AggregateAppGroup [Name "rank"]
|
|
|
|
> [Iden [Name "a"], Iden [Name "c"]]
|
|
|
|
> ob)]
|
|
|
|
> ++ map mkGp ["dense_rank","percent_rank"
|
|
|
|
> ,"cume_dist", "percentile_cont"
|
|
|
|
> ,"percentile_disc"]
|
|
|
|
> ++ [("array_agg(a)", App [Name "array_agg"] [Iden [Name "a"]])
|
|
|
|
> ,("array_agg(a order by z)"
|
|
|
|
> ,AggregateApp [Name "array_agg"]
|
|
|
|
> SQDefault
|
|
|
|
> [Iden [Name "a"]]
|
2014-04-21 13:16:45 +02:00
|
|
|
> [SortSpec (Iden [Name "z"])
|
|
|
|
> DirDefault NullsOrderDefault]
|
2014-04-20 16:03:32 +02:00
|
|
|
> Nothing)]
|
|
|
|
|
|
|
|
> where
|
|
|
|
> fil = Just $ BinOp (Iden [Name "something"]) [Name ">"] (NumLit "5")
|
|
|
|
> ob = [SortSpec (Iden [Name "b"]) DirDefault NullsOrderDefault]
|
|
|
|
> mkGp nm = (nm ++ "(a) within group (order by b)"
|
|
|
|
> ,AggregateAppGroup [Name nm]
|
|
|
|
> [Iden [Name "a"]]
|
|
|
|
> ob)
|
|
|
|
|
|
|
|
> mkSimpleAgg nm =
|
|
|
|
> [(nm ++ "(a)",App [Name nm] [Iden [Name "a"]])
|
|
|
|
> ,(nm ++ "(distinct a)"
|
|
|
|
> ,AggregateApp [Name nm]
|
|
|
|
> Distinct
|
|
|
|
> [Iden [Name "a"]] [] Nothing)]
|
|
|
|
> mkBsf nm =
|
|
|
|
> [(nm ++ "(a,b)",App [Name nm] [Iden [Name "a"],Iden [Name "b"]])
|
|
|
|
> ,(nm ++"(a,b) filter (where something > 5)"
|
|
|
|
> ,AggregateApp [Name nm]
|
|
|
|
> SQDefault
|
|
|
|
> [Iden [Name "a"],Iden [Name "b"]] [] fil)]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
== 10.10 <sort specification list>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
Function
|
|
|
|
Specify a sort order.
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<sort specification list> ::=
|
|
|
|
<sort specification> [ { <comma> <sort specification> }... ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<sort specification> ::=
|
|
|
|
<sort key> [ <ordering specification> ] [ <null ordering> ]
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<sort key> ::= <value expression>
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<ordering specification> ::= ASC | DESC
|
2014-04-19 21:24:10 +02:00
|
|
|
|
2014-04-20 15:13:14 +02:00
|
|
|
<null ordering> ::=
|
|
|
|
| NULLS LAST
|
|
|
|
NULLS FIRST
|
2014-04-19 21:24:10 +02:00
|
|
|
|
|
|
|
> sortSpecificationList :: TestItem
|
2014-04-20 15:13:14 +02:00
|
|
|
> sortSpecificationList = Group "sort specification list"
|
2014-06-27 11:19:15 +02:00
|
|
|
> $ map (uncurry (TestQueryExpr SQL2011))
|
2014-04-20 22:29:22 +02:00
|
|
|
> [("select * from t order by a"
|
2014-04-21 13:16:45 +02:00
|
|
|
> ,qe {qeOrderBy = [SortSpec (Iden [Name "a"])
|
|
|
|
> DirDefault NullsOrderDefault]})
|
2014-04-20 22:29:22 +02:00
|
|
|
> ,("select * from t order by a,b"
|
2014-04-21 13:16:45 +02:00
|
|
|
> ,qe {qeOrderBy = [SortSpec (Iden [Name "a"])
|
|
|
|
> DirDefault NullsOrderDefault
|
|
|
|
> ,SortSpec (Iden [Name "b"])
|
|
|
|
> DirDefault NullsOrderDefault]})
|
2014-04-20 22:29:22 +02:00
|
|
|
> ,("select * from t order by a asc,b"
|
2014-04-21 13:16:45 +02:00
|
|
|
> ,qe {qeOrderBy = [SortSpec (Iden [Name "a"])
|
|
|
|
> Asc NullsOrderDefault
|
|
|
|
> ,SortSpec (Iden [Name "b"])
|
|
|
|
> DirDefault NullsOrderDefault]})
|
2014-04-20 22:29:22 +02:00
|
|
|
> ,("select * from t order by a desc,b"
|
2014-04-21 13:16:45 +02:00
|
|
|
> ,qe {qeOrderBy = [SortSpec (Iden [Name "a"])
|
|
|
|
> Desc NullsOrderDefault
|
|
|
|
> ,SortSpec (Iden [Name "b"])
|
|
|
|
> DirDefault NullsOrderDefault]})
|
2014-04-20 22:29:22 +02:00
|
|
|
> ,("select * from t order by a collate x desc,b"
|
2014-04-21 13:16:45 +02:00
|
|
|
> ,qe {qeOrderBy = [SortSpec
|
|
|
|
> (Collate (Iden [Name "a"]) [Name "x"])
|
|
|
|
> Desc NullsOrderDefault
|
|
|
|
> ,SortSpec (Iden [Name "b"])
|
|
|
|
> DirDefault NullsOrderDefault]})
|
2014-04-20 22:29:22 +02:00
|
|
|
> ,("select * from t order by 1,2"
|
2014-04-21 13:16:45 +02:00
|
|
|
> ,qe {qeOrderBy = [SortSpec (NumLit "1")
|
|
|
|
> DirDefault NullsOrderDefault
|
|
|
|
> ,SortSpec (NumLit "2")
|
|
|
|
> DirDefault NullsOrderDefault]})
|
2014-04-20 15:13:14 +02:00
|
|
|
> ]
|
2014-04-20 22:29:22 +02:00
|
|
|
> where
|
|
|
|
> qe = makeSelect
|
|
|
|
> {qeSelectList = [(Star,Nothing)]
|
|
|
|
> ,qeFrom = [TRSimple [Name "t"]]}
|