Subject Re: [Firebird-Architect] XSQLDA/XSQLVAR issues
Author Arno Brinkman
Hi,

> select
> schema,
> tablename,
> tableid as id
> from
> system.tables
> where
> id=46
>
> in Netfrastructure dutifully gives
>
> SCHEMA TABLENAME ID
> ---------- ---------- --
>
> NETFRASITE MEMBERSHIP 46

> The important questions are:
>
> 1. Is it useful?

Could be useful, but not very much IMO.

> 2. Is it well defined?

Indeed, what should be happen for example with generators, sub-queries,
double alias, same name known as field etc...

SELECT
FX AS FY,
FY AS FX,
GEN_ID(MY_GEN_ID, 1) AS ITEMID,
(SELECT FIELD FROM TABLEX WHERE FX = FY) AS SUBS
FROM
TABLEY
WHERE
ITEMID = 1 and
SUBS = 1 and
FX = 1 and
FY = 1

Should a sub-select be able to use the ALIAS inside etc...

> 3. Does it violate the standard?

I can't find anything about it that column-aliasses should be supported
inside WHERE, GROUP BY, HAVING clauses.

> 4. Is it likely to violate the standard at some future if the SQL
> committee does something borderline plausible but dumb?

The only problem i currently can see is what field would have the precedence
in this query :

SELECT
F1 AS F2
FROM
TableX
WHERE
F2 = 1

Where TableX has F1 and F2 as fields, should it use TableX.F1 or TableX.F2
in the WHERE clause? May be a stupid example, but you can imagine...

> A general implement is very easy.

Shouldn't be that difficult, but the rules must be clear.

> Hang a pointer to a select object off
> the SQL context object. If a single name identifier doesn't resolve to
> a context column name, check it against the select list. The immediate
> complication is that the current guy who resolves an identifier to a
> context returns only a field pointer, not a compiled expression which is
> necessary to support aliases expressions.

Thus your precedence is always first fields from available contextes and
when no one found look in the select-list for aliasses?

> We really should encrypt pass1.cpp so only the most experienced,
> hardened, least impressionable programmers are exposed to such hideous,
> deplorable, disease infested, festering code. It is exactly the sort of
> code that makes me want to to make a special programmers' editor that
> supports block move but not cut and paste. Ugh.

I agree it's ugly and hard to work with. Hopefully the time will come to
make it nice looking code with objects.

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/

Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep :
news://80.126.130.81