|
|
|
|
|
|
Created a unified "alias registry" to make sure we do not have alias collisions between different clauses/contexts. For example, `select a.address as a from Anything as a`.
The spec is not completely explicit. However quotes from a few sections give us some principles that must be followed...
{quote:title=4.4.2 Identification Variables} All identification variables used in the SELECT, WHERE, ORDER BY, GROUP BY, or HAVING clause of a SELECT or DELETE statement must be declared in the FROM clause. The identification variables used in the WHERE clause of an UPDATE statement must be declared in the UPDATE clause. ... An identification variable is scoped to the query (or subquery) in which it is defined and is also visible any subqueries within that query scope that do not define an identification variable of the same name. {quote}
2 main take-aways from here.. # It implies that aliases defined in the FROM clause are different (more on this below) # The last sentence explicitly defines the rules around aliases in terms of parent/sub queries. An alias may in fact be redefined in a subquery in which case it "hides" the same alias from the parent query.
The other piece here is the implicit distinction between aliases defined in the FROM clause and aliases defined in the SELECT clause. The initial design of the alias registry disallowed reuse of an alias between SELECT and FROM clauses. I have not (yet?) seen anywhere that the spec says anything about this.
|
|
|
|
|
|