Recognize TK_COLLATE operators that have been transformed into TK_REGISTER.
Skip both TK_COLLATE and TK_AS operators when looking for the top of an
expression.
check-in: f66c1db2 user: drh tags: ticket-71e333e7

pItem->iOrderByCol = (u16)iCol;
continue;
}
if( sqlite3ExprIsInteger(sqlite3ExprSkipCollate(pE), &iCol) ){
/* The ORDER BY term is an integer constant. Again, set the column
** number so that sqlite3ResolveOrderGroupBy() will convert the
** order-by term to a copy of the result-set expression */
if( (iCol & ~0xffff)!=0 ){
resolveOutOfRangeError(pParse, zType, i+1, nResult);
return 1;
}
pItem->iOrderByCol = (u16)iCol;
continue;
}

|

952
953
954
955
956
957
958
959
960
961
962
963
964
965
966

pItem->iOrderByCol = (u16)iCol;
continue;
}
if( sqlite3ExprIsInteger(sqlite3ExprSkipCollate(pE), &iCol) ){
/* The ORDER BY term is an integer constant. Again, set the column
** number so that sqlite3ResolveOrderGroupBy() will convert the
** order-by term to a copy of the result-set expression */
if( iCol<1 || iCol>0xffff ){
resolveOutOfRangeError(pParse, zType, i+1, nResult);
return 1;
}
pItem->iOrderByCol = (u16)iCol;
continue;
}

Changes to test/tkt2822.test.

269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285

CREATE TABLE t7(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,
a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25);
}
catchsql {
SELECT * FROM t7 ORDER BY 0;
}
} {1 {1st ORDER BY term out of range - should be between 1 and 25}}
do_test tkt2822-7.2 {
catchsql {
SELECT * FROM t7 ORDER BY 1, 0;
}
} {1 {2nd ORDER BY term out of range - should be between 1 and 25}}
do_test tkt2822-7.3 {
catchsql {
SELECT * FROM t7 ORDER BY 1, 2, 0;
}
} {1 {3rd ORDER BY term out of range - should be between 1 and 25}}

CREATE TABLE t7(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,
a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25);
}
catchsql {
SELECT * FROM t7 ORDER BY 0;
}
} {1 {1st ORDER BY term out of range - should be between 1 and 25}}
do_test tkt2822-7.2.1 {
catchsql {
SELECT * FROM t7 ORDER BY 1, 0;
}} {1 {2nd ORDER BY term out of range - should be between 1 and 25}}do_test tkt2822-7.2.2 { catchsql { SELECT * FROM t7 ORDER BY 1, 26; }} {1 {2nd ORDER BY term out of range - should be between 1 and 25}}do_test tkt2822-7.2.3 { catchsql { SELECT * FROM t7 ORDER BY 1, 65536;
}
} {1 {2nd ORDER BY term out of range - should be between 1 and 25}}
do_test tkt2822-7.3 {
catchsql {
SELECT * FROM t7 ORDER BY 1, 2, 0;
}
} {1 {3rd ORDER BY term out of range - should be between 1 and 25}}

This page was generated in about
0.011s by
Fossil 2.10 [b94e15cff7] 2019-09-13 13:54:36