SQLite
Check-in [bd960d937f]
Not logged in
Overview
SHA1 Hash:bd960d937f8d6521c8ec4b7bd8a77a498dd432d4
Date: 2012-12-07 23:23:53
User: drh
Comment:Improved error messages when column integers in an ORDER BY clause are out of range.
Tags And Properties
Changes
hide diffs unified diffs patch

Changes to src/resolve.c

952 pItem->iOrderByCol = (u16)iCol; 952 pItem->iOrderByCol = (u16)iCol; 953 continue; 953 continue; 954 } 954 } 955 if( sqlite3ExprIsInteger(sqlite3ExprSkipCollate(pE), &iCol) ){ 955 if( sqlite3ExprIsInteger(sqlite3ExprSkipCollate(pE), &iCol) ){ 956 /* The ORDER BY term is an integer constant. Again, set the column 956 /* The ORDER BY term is an integer constant. Again, set the column 957 ** number so that sqlite3ResolveOrderGroupBy() will convert the 957 ** number so that sqlite3ResolveOrderGroupBy() will convert the 958 ** order-by term to a copy of the result-set expression */ 958 ** order-by term to a copy of the result-set expression */ 959 if( (iCol & ~0xffff)!=0 ){ | 959 if( iCol<1 || iCol>0xffff ){ 960 resolveOutOfRangeError(pParse, zType, i+1, nResult); 960 resolveOutOfRangeError(pParse, zType, i+1, nResult); 961 return 1; 961 return 1; 962 } 962 } 963 pItem->iOrderByCol = (u16)iCol; 963 pItem->iOrderByCol = (u16)iCol; 964 continue; 964 continue; 965 } 965 } 966 966

Changes to test/tkt2822.test

269 CREATE TABLE t7(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14, 269 CREATE TABLE t7(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14, 270 a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25); 270 a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25); 271 } 271 } 272 catchsql { 272 catchsql { 273 SELECT * FROM t7 ORDER BY 0; 273 SELECT * FROM t7 ORDER BY 0; 274 } 274 } 275 } {1 {1st ORDER BY term out of range - should be between 1 and 25}} 275 } {1 {1st ORDER BY term out of range - should be between 1 and 25}} 276 do_test tkt2822-7.2 { | 276 do_test tkt2822-7.2.1 { 277 catchsql { 277 catchsql { 278 SELECT * FROM t7 ORDER BY 1, 0; 278 SELECT * FROM t7 ORDER BY 1, 0; > 279 } > 280 } {1 {2nd ORDER BY term out of range - should be between 1 and 25}} > 281 do_test tkt2822-7.2.2 { > 282 catchsql { > 283 SELECT * FROM t7 ORDER BY 1, 26; > 284 } > 285 } {1 {2nd ORDER BY term out of range - should be between 1 and 25}} > 286 do_test tkt2822-7.2.3 { > 287 catchsql { > 288 SELECT * FROM t7 ORDER BY 1, 65536; 279 } 289 } 280 } {1 {2nd ORDER BY term out of range - should be between 1 and 25}} 290 } {1 {2nd ORDER BY term out of range - should be between 1 and 25}} 281 do_test tkt2822-7.3 { 291 do_test tkt2822-7.3 { 282 catchsql { 292 catchsql { 283 SELECT * FROM t7 ORDER BY 1, 2, 0; 293 SELECT * FROM t7 ORDER BY 1, 2, 0; 284 } 294 } 285 } {1 {3rd ORDER BY term out of range - should be between 1 and 25}} 295 } {1 {3rd ORDER BY term out of range - should be between 1 and 25}}