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
Operations

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:
Relate
 

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);

   or

   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.


Dmitry


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
Dmitry Yemanov made changes - 24/Oct/09 04:36 PM
Field Original Value New Value
Fix Version/s 3.0 Alpha 1 [ 10331 ]
Dmitry Yemanov made changes - 23/Oct/12 08:45 AM
Fix Version/s 3.0 Beta 1 [ 10332 ]
Fix Version/s 3.0 Alpha 1 [ 10331 ]
Dmitry Yemanov made changes - 18/Apr/14 04:22 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Dmitry Yemanov made changes - 30/Sep/14 07:49 AM
Assignee Adriano dos Santos Fernandes [ asfernandes ]
Pavel Zotov made changes - 28/May/15 03:36 PM
Status Resolved [ 5 ] Resolved [ 5 ]
QA Status Done successfully
Pavel Cisar made changes - 28/Sep/15 12:55 PM
Status Resolved [ 5 ] Closed [ 6 ]
Dmitry Yemanov made changes - 09/Nov/15 07:25 PM
Link This issue relate to CORE-5001 [ CORE-5001 ]