Hello,

On 2017-02-10 20:34, Alek Storm wrote:
CREATE TABLE t1 (col1 INT);
CREATE TABLE t2 AS SELECT `col1` FROM t1 GROUP BY col1;
.schema t2
CREATE TABLE t2("`col1`" INT);

I expected: CREATE TABLE t2(col1 INT);

This comes from the fact that all TK_COLUMN expressions in SELECT ... GROUP BY command are transformed into TK_AGG_COLUMN ones and as such their names are taken from ``zSpan'' (i.e. original text of an expression). Because the original text contains back quotes, it is further enclosed in double quotes. The following patch would help, however I'm not sure if an additional checking/validation is not required:

File ``select.c'', foo ``sqlite3ColumnsFromExprList(...)'', change the following line:

      if( pColExpr->op==TK_COLUMN && ALWAYS(pColExpr->pTab!=0) ){

into

if( (pColExpr->op==TK_COLUMN || pColExpr->op==TK_AGG_COLUMN) && ALWAYS(pColExpr->pTab!=0) ){


-- best regards

Cezary H. Noweta
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to