1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-24 14:17:58 +03:00

Basic error checking. Resolve symbols in the aggregate ORDER BY expressions.

FossilOrigin-Name: c83a53a574d312130d1238c05ffa449d8bed2535d5ef5b5d9cf02f894494cca4
This commit is contained in:
drh
2023-10-18 13:58:31 +00:00
parent f8202f1ff3
commit db19f48b69
5 changed files with 54 additions and 11 deletions

31
test/aggorderby.test Normal file
View File

@@ -0,0 +1,31 @@
# 2023-10-18
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements tests for ORDER BY on aggregate functions.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_execsql_test aggorderby-1.1 {
CREATE TABLE t1(a,b,c,d);
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<20)
INSERT INTO t1(a,b,c,d) SELECT printf('x%d',x),1,x,200-x FROM c;
INSERT INTO t1(a,b,c,d) SELECT a, 2, c-3, -d FROM t1;
CREATE INDEX t1b ON t1(b);
}
do_catchsql_test aggorderby-1.2 {
SELECT b, group_concat(a ORDER BY max(d)) FROM t1 GROUP BY b;
} {1 {misuse of aggregate function max()}}
do_catchsql_test aggorderby-1.3 {
SELECT abs(a ORDER BY max(d)) FROM t1;
} {1 {ORDER BY may not be used with non-aggregate abs()}}
finish_test