Subject Strange behavior, possible bug with aliases in jaybird OR firebird
Author Steffen Heil
Hi

I *wanted* to write the following code:
select a, b, c, d from some_table

And used in java:
a = resultSet.getString( "a" );
b = resultSet.getInt( "b" );
c = resultSet.getString ( "c" );
d = resultSet.getString ( "d" );

This worked fine, as I did not check (or programmatically use) the value of
c at all.
When I started using c I discovered that c was usually "0", which was never
written to the database at all.

Trying to build a testcase, I discovered that my actual query was:
select a, b c, d from some_table
Now, it seems to have handled "c" as some alias for b, even though there was
no "as".

I verified this behavior using direct sql:
select c from ( select a, b c, d from some_table )
Which indeed yielded the value of column 'b'.

Trying the following was rejected by the firebird engine:
select b from ( select a, b c, d from some_table )
The server replied with "unknown column 'b'".

Now my questions:
1. Is "as" optional? Is the code above even sql conformant?
2. Is jaybird correct to allow selecting b in the resultset?
3. Is firebird correct to deny selecting b in the resultset?

Note, that I think that 2. and 3. are mutually exclusive. So there might be
a bug in either firebird or jaybird...

Any comments?

Regards,
Steffen



[Non-text portions of this message have been removed]