Commit eac39b34 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2005-06-09 17:49:06 by beppe] Empty log message

Original author: beppe
Date: 2005-06-09 17:49:06+00:00
parent 9ae40325
...@@ -830,14 +830,29 @@ select %%e%% from ...@@ -830,14 +830,29 @@ select %%e%% from
%%p2%% in %%e2%%, %%p2%% in %%e2%%,
: :
%%pn%% in %%en%% %%pn%% in %%en%%
where %%c1%% and ... and %%cn%% where %%c%%
]]></sample> ]]></sample>
<p> <p>
where <code>%%e%%</code> is an expression, the <code>%%ci%%</code> where <code>%%e%%</code> is an expression, <code>%%c%%</code>
are boolean expressions, the <code>%%pi%%</code>'s are patterns, and the a boolean expression, the <code>%%pi%%</code>'s are patterns, and the
<code>%%ei%%</code>'s are sequence expressions. <code>%%ei%%</code>'s are sequence expressions.
</p> </p>
<p> <p>
It works exactly as a standard SQL select expression, with the difference that relations (that is sequences of tuples) after the <code>in</code> keyword can here be generic sequences, and before the <code>in</code> generic patterns instead of just capture variables can be used. So the result is the sequence of all values obtained by calculating <code>%%e%%</code> in the sequence of environments in which the free variables of <code>%%e%%</code> are bounded by iteratively matching each pattern <code>%%pi%%</code> with every element of the sequence <code>%%ei%%</code>, provided that the condition <code>%%c%%</code> is satisfied.
In other words, the first element of the result is obtained by calculating <code>%%e%%</code> in the environment obtained by matching <code>%%p1%%</code> against the first element of <code>%%e1%%</code>, <code>%%p2%%</code> against the first element of <code>%%e2%%</code>, ...; the second element of the result is obtained by calculating <code>%%e%%</code> in the environment obtained by matching <code>%%p1%%</code> against the <i>second</i> element of <code>%%e1%%</code>, <code>%%p2%%</code> against the <i>first</i> element of <code>%%e2%%</code>,...; and so on.
</p>
<p>
Formally, the semantics of the select expression above is defined as:
</p>
<sample><![CDATA[
transform %%e1%% with %%p1%% ->
transform %%e2%% with %%p2%% ->
...
transform %%en%% with %%pn%% ->
if %%e%% then [%%e%%] else []
]]>
</sample>
<p>
A <code>select</code> expression works like a set of nested A <code>select</code> expression works like a set of nested
<code>transform</code> expressions. The advantage of using select rather than <code>transform</code> expressions. The advantage of using select rather than
transform is that queries are automatically optimized by applying classical transform is that queries are automatically optimized by applying classical
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment