The Pyrrho Database Management System

Malcolm Crowe, University of the West of Scotland

 

Pyrrho SQL syntax

Value

Value = Literal
| Value BinaryOp Value
| '-' Value
| '(' Value ')'
| Value Collate
| Value '[' Value ']'
| ColumnRef
| VariableRef
| (SYSTEM_TIME|Period_id|(PERIOD'('Value','Value')'))
| VALUE
| ROW
| Value '.' Member_id
| MethodCall
| NEW MethodCall
| FunctionCall
| VALUES '(' Value { ',' Value } ')' { ',' '(' Value { ',' Value } ')' }
| QueryExpression
| Subquery
| ROW '(' Value { ',' Value } ')'
| Document
| DocArray
| ( MULTISET | ARRAY ) (('[' Value { ',' Value } ']')|Subquery )
| TREAT '(' Value AS Sub_Type ')'
| CURRENT_USER
| CURRENT_ROLE
| HTTP GET url_Value [AS mime_string ] [ WhereClause].

The VALUE keyword is used in Check Constraints. ROW if not followed by '(' can be used for testing the type of the currently selected row. Subqueries that are mulitset-valued must be part of the MULTISET constructor syntax. Collate if specified applies to an immediately preceding Boolean expression, affecting comparison operands etc. The mime string is used for retrieval of a particuar content type from the server (Json is the default). The AS syntax in Value AS Type is allowed only in parameter lists and methodcalls. The WhereClause in the HTTP GET syntax is provided as an alternative to using an expression for the uri, but depending on the web service being accessed, may be limited to a conjunction of equality conditions.

Document = '{'[keyname':'DocValue{','keyname':'DocValue }]'}'.

In the Document syntax, keynames are case-sensitive and should be enclosed in single or double quotes.

DocArray = '['[DocValue{','DocValue}]']' .

DocValue = Value> | doublequotedstring .

To avoid being parsed as a doublequotedstring, a double-quoted identifier in a DocValue needs to be part of a larger expression such as a dotted identifier chain.

BinaryOp = '+' | '-' | '*' | '/' | '||' | MultisetOp .

|| is used in array and string concatenation.

VariableRef = { scope_id '.' } Variable_id .

ColumnRef = [ tableOrAlias_id '.' ] ColRef
| TableOrAlias_id '.' ( PROVENANCE | CHECK).

The use of the PROVENANCE and CHECK pseudo-columns is a change to SQL2011 behaviour. CHECK is a row versioning cookie derived from a string type.

MultisetOp = MULTISET ( UNION | INTERSECT | EXCEPT ) ( ALL | DISTINCT ) .

Literal = int
| float
| string
| TRUE | FALSE
| 'X' ''' { hexit } '''
| id '^^' (Domain_id | Type_id | [Namespace_id] ':' id | uri)
| DATE date_string
| TIME time_string
| TIMESTAMP timestamp_string
| INTERVAL ['-'] interval_string IntervalQualifier.

Strings are enclosed in single quotes. Two single quotes in a string represent one single quote. Hexits are hexadecimal digits 0-9, A-F, a-f and are used for binary objects.

The syntax with ^^ is special in Pyrrho and is added for RDF/OWL support, e.g. "2.5"^^units:ampere or "2.5"^^<http://ex.com#t> ). In the RDF/OWL syntax, @ in the double quoted part is a special character and introduces a locale. Note however that without the ^^,  "2.5" would be an id and not a string, and the <> do not normally behave like quotes.

Dates, times and intervals use string (quoted) values and are not locale-dependent. For full details see SQL2011: e.g.

IntervalQualifier = StartField TO EndField
| DateTimeField .

StartField = IntervalField ['(' int ')'] .

EndField = IntervalField | SECOND ['(' int ')'] .

DateTimeField = StartField | SECOND ['(' int [',' int]')'] .

The ints here represent precision for the leading field and/or the fractional seconds.

IntervalField = YEAR | MONTH | DAY | HOUR | MINUTE .