Hi List,

I made a copy-paste mistake, resulting in something that looked to me as 
invalid syntax for column names, but sqlite accepted it.
The invalid column names are shown by the following example:



.header on
-- pragma is deprecated, but shows what happens
pragma full_column_names=1;

CREATE TABLE aaa(col1 INTEGER, col2 INTEGER);
CREATE TABLE bbb(col1 INTEGER, col2 INTEGER);


INSERT INTO aaa VALUES (1,2);
INSERT INTO bbb VALUES (1,3);

SELECT a.col2,
       b.col2,
       a.b.col2,        -- invalid column name
       b.a.col2,        -- invalid column name
       a.a.col2,        -- invalid column name
       b.b.col2,        -- invalid column name
       anything.a.col2  -- invalid column name
FROM aaa a,
     bbb b ON a.col1 = b.col1;



output:
aaa.col2    bbb.col2    bbb.col2    aaa.col2    aaa.col2    bbb.col2    aaa.col2
----------  ----------  ----------  ----------  ----------  ----------  
----------
2           3           3           2           2           3           2

From the headers in the output it is clear that sqlite ignores the first part 
of the column name, which indeed is meaningless when using table aliases.
According to the syntax diagrams these invalid colum names are expressions of 
the form <database-name>.<table-name>.<column-name> and hence syntactically 
correct.
But it is interpreted as <ignore>.<table-alias>.<column-name>. It is confusing 
that part of the column name is ignored, but the column name is still accepted.

Could sqlite be adapted to reject such invalid names and report an error, 
instead of silently ignore the first part of the column name? Or did I miss 
something?


Regards,
Rob Golsteijn

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

Reply via email to