It is never a good idea to rely on automatically assigned column names. If you 
want reproducible, predictable, release independant column names then please 
assign them with the AS clause.

-----Ursprüngliche Nachricht-----
Von: Marcus Bergner [mailto:marcusberg...@gmail.com]
Gesendet: Sonntag, 25. Jänner 2015 14:16
An: sqlite-users@sqlite.org
Betreff: [sqlite] Invalid column prefix returned in SELECT with joined subquery

Hi,
Using the latest amalgamation build sqlite-autoconf-3080801 I'm seeing the 
following inconsistent behaviour:

$ ./sqlite3
sqlite> .headers on
sqlite> pragma short_column_names;
1
sqlite> pragma full_column_names;
0
sqlite> create table tbl1 (id1 integer, s1 text); create table tbl2 (id2
sqlite> integer, s2 text); insert into tbl1 values (1, 'v1'); insert
sqlite> into tbl2 values (1, 'v2'); select x.id1, x.s1, y.s2 from tbl1 x
sqlite> inner join tbl2 y on
x.id1=y.id2;
id1|s1|s2
1|v1|v2

So far so good, everything as expected. If I rewrite the above select statement 
to do a join with a subquery instead the resulting output changes in an 
unexpected way.

sqlite> select x.id1, x.s1, subq.s2 from tbl1 x inner join (select *
sqlite> from
tbl2 y where y.id2=1) subq on x.id1=subq.id2;
x.id1|x.s1|subq.s2
1|v1|v2

Here we get unexpected column prefixes on all fetched columns. If I rewrite the 
query again to a subq.* query the behaviour is different again where only the 
first two columns have prefixes.

sqlite> select x.id1, x.s1, subq.* from tbl1 x inner join (select * from
tbl2 y where y.id2=1) subq on x.id1=subq.id2;
x.id1|x.s1|id2|s2
1|v1|1|v2

Expected behaviour: returned columns should not contain prefixes in any of the 
above scenarios.

Kind regards,

Marcus Bergner
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This communication (including any attachments) is intended for the use of the 
intended recipient(s) only and may contain information that is confidential, 
privileged or legally protected. Any unauthorized use or dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the sender by return e-mail message and 
delete all copies of the original communication. Thank you for your cooperation.


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to