Issue Details (XML | Word | Printable)

Key: CORE-2350
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Adriano dos Santos Fernandes
Reporter: Bill Oliver
Votes: 1
Watchers: 2

If you were logged in you would be able to see more operations.
Firebird Core

Too long column name for select alias should be rejected

Created: 03/Mar/09 10:08 PM   Updated: 15/Jun/16 10:06 PM
Component/s: Engine
Affects Version/s: 2.0.0, 1.5.4, 2.0.1, 2.0.2, 2.0.3, 1.5.5, 2.1.0, 2.0.4, 2.5 Alpha 1, 2.1.1, 2.0.5
Fix Version/s: 3.0 Beta 1

Environment: tested on windows xp, portable problem
Issue Links:

QA Status: Done successfully

 Description  « Hide

A co-worker reported this test case. The last query silently truncates the aliased column name. He thinks that an error should be raised in this case. That seems reasonable to me.

The truncated column can still be referenced by the long name. This query returns the "correct" column. This is likely because we always chop to 31 chars.

Dmitry suggested to add a tracker, with this additional information.

I'm not sure it's really truncated, because a reference via a one-char-shorter fails:

   select i2345678901234567890123456789012345 from (select i as
   i23456789012345678901234567890123456 from t1);


   select i23456789012345678901234567890123456 from (select i as
   i2345678901234567890123456789012345 from t1);

Column alias names are not part of ODS, they don't even exist at the BLR level. It's a purely parsing time thing, so I believe the parser has no need to truncate the name and always deals with longer alias names. So, technically speaking, this is not a bug.

 From another side, column alias names can be used to implicitly name the view columns and this fails:

   create view v as
   select rdb$relation_id as i23456789012345678901234567890123456
   from rdb$relations

which looks somewhat inconsistent with the above.

Besides, I suspect that the SQL spec also requires alias names to share the implementation-defined length limits with column names, table names,
etc. If so, maybe it's worth entering a request into the tracker.


create database 'test.fdb';

-- fails, table name too long
create table t23456789012345678901234567890123456 (i integer);

-- fails, column name too long
create table t1 (i23456789012345678901234567890123456 integer);

create table t1 (i integer);
-- passes, and column name is truncated to 31 characters?
select i as i23456789012345678901234567890123456 from t1;

-- this works, too. We can still reference truncated column by long name,
-- which is better than nothing, I guess.
select i23456789012345678901234567890123456 from (select i as
i23456789012345678901234567890123456 from t1);

drop database;

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
There are no subversion log entries for this issue yet.