1*1da57d55SToomas Soome#
27c478bd9Sstevel@tonic-gate# 2001 September 15
37c478bd9Sstevel@tonic-gate#
47c478bd9Sstevel@tonic-gate# The author disclaims copyright to this source code.  In place of
57c478bd9Sstevel@tonic-gate# a legal notice, here is a blessing:
67c478bd9Sstevel@tonic-gate#
77c478bd9Sstevel@tonic-gate#    May you do good and not evil.
87c478bd9Sstevel@tonic-gate#    May you find forgiveness for yourself and forgive others.
97c478bd9Sstevel@tonic-gate#    May you share freely, never taking more than you give.
107c478bd9Sstevel@tonic-gate#
117c478bd9Sstevel@tonic-gate#***********************************************************************
127c478bd9Sstevel@tonic-gate# This file implements regression tests for SQLite library.  The
137c478bd9Sstevel@tonic-gate# focus of this file is testing SELECT statements that contain
147c478bd9Sstevel@tonic-gate# aggregate min() and max() functions and which are handled as
157c478bd9Sstevel@tonic-gate# as a special case.
167c478bd9Sstevel@tonic-gate#
177c478bd9Sstevel@tonic-gate# $Id: minmax.test,v 1.9.2.2 2004/07/18 21:14:05 drh Exp $
187c478bd9Sstevel@tonic-gate
197c478bd9Sstevel@tonic-gateset testdir [file dirname $argv0]
207c478bd9Sstevel@tonic-gatesource $testdir/tester.tcl
217c478bd9Sstevel@tonic-gate
227c478bd9Sstevel@tonic-gatedo_test minmax-1.0 {
237c478bd9Sstevel@tonic-gate  execsql {
247c478bd9Sstevel@tonic-gate    BEGIN;
257c478bd9Sstevel@tonic-gate    CREATE TABLE t1(x, y);
267c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(1,1);
277c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(2,2);
287c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(3,2);
297c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(4,3);
307c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(5,3);
317c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(6,3);
327c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(7,3);
337c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(8,4);
347c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(9,4);
357c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(10,4);
367c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(11,4);
377c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(12,4);
387c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(13,4);
397c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(14,4);
407c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(15,4);
417c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(16,5);
427c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(17,5);
437c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(18,5);
447c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(19,5);
457c478bd9Sstevel@tonic-gate    INSERT INTO t1 VALUES(20,5);
467c478bd9Sstevel@tonic-gate    COMMIT;
477c478bd9Sstevel@tonic-gate    SELECT DISTINCT y FROM t1 ORDER BY y;
487c478bd9Sstevel@tonic-gate  }
497c478bd9Sstevel@tonic-gate} {1 2 3 4 5}
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gatedo_test minmax-1.1 {
527c478bd9Sstevel@tonic-gate  set sqlite_search_count 0
537c478bd9Sstevel@tonic-gate  execsql {SELECT min(x) FROM t1}
547c478bd9Sstevel@tonic-gate} {1}
557c478bd9Sstevel@tonic-gatedo_test minmax-1.2 {
567c478bd9Sstevel@tonic-gate  set sqlite_search_count
577c478bd9Sstevel@tonic-gate} {19}
587c478bd9Sstevel@tonic-gatedo_test minmax-1.3 {
597c478bd9Sstevel@tonic-gate  set sqlite_search_count 0
607c478bd9Sstevel@tonic-gate  execsql {SELECT max(x) FROM t1}
617c478bd9Sstevel@tonic-gate} {20}
627c478bd9Sstevel@tonic-gatedo_test minmax-1.4 {
637c478bd9Sstevel@tonic-gate  set sqlite_search_count
647c478bd9Sstevel@tonic-gate} {19}
657c478bd9Sstevel@tonic-gatedo_test minmax-1.5 {
667c478bd9Sstevel@tonic-gate  execsql {CREATE INDEX t1i1 ON t1(x)}
677c478bd9Sstevel@tonic-gate  set sqlite_search_count 0
687c478bd9Sstevel@tonic-gate  execsql {SELECT min(x) FROM t1}
697c478bd9Sstevel@tonic-gate} {1}
707c478bd9Sstevel@tonic-gatedo_test minmax-1.6 {
717c478bd9Sstevel@tonic-gate  set sqlite_search_count
727c478bd9Sstevel@tonic-gate} {2}
737c478bd9Sstevel@tonic-gatedo_test minmax-1.7 {
747c478bd9Sstevel@tonic-gate  set sqlite_search_count 0
757c478bd9Sstevel@tonic-gate  execsql {SELECT max(x) FROM t1}
767c478bd9Sstevel@tonic-gate} {20}
777c478bd9Sstevel@tonic-gatedo_test minmax-1.8 {
787c478bd9Sstevel@tonic-gate  set sqlite_search_count
797c478bd9Sstevel@tonic-gate} {1}
807c478bd9Sstevel@tonic-gatedo_test minmax-1.9 {
817c478bd9Sstevel@tonic-gate  set sqlite_search_count 0
827c478bd9Sstevel@tonic-gate  execsql {SELECT max(y) FROM t1}
837c478bd9Sstevel@tonic-gate} {5}
847c478bd9Sstevel@tonic-gatedo_test minmax-1.10 {
857c478bd9Sstevel@tonic-gate  set sqlite_search_count
867c478bd9Sstevel@tonic-gate} {19}
877c478bd9Sstevel@tonic-gate
887c478bd9Sstevel@tonic-gatedo_test minmax-2.0 {
897c478bd9Sstevel@tonic-gate  execsql {
907c478bd9Sstevel@tonic-gate    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
917c478bd9Sstevel@tonic-gate    INSERT INTO t2 SELECT * FROM t1;
927c478bd9Sstevel@tonic-gate  }
937c478bd9Sstevel@tonic-gate  set sqlite_search_count 0
947c478bd9Sstevel@tonic-gate  execsql {SELECT min(a) FROM t2}
957c478bd9Sstevel@tonic-gate} {1}
967c478bd9Sstevel@tonic-gatedo_test minmax-2.1 {
977c478bd9Sstevel@tonic-gate  set sqlite_search_count
987c478bd9Sstevel@tonic-gate} {0}
997c478bd9Sstevel@tonic-gatedo_test minmax-2.2 {
1007c478bd9Sstevel@tonic-gate  set sqlite_search_count 0
1017c478bd9Sstevel@tonic-gate  execsql {SELECT max(a) FROM t2}
1027c478bd9Sstevel@tonic-gate} {20}
1037c478bd9Sstevel@tonic-gatedo_test minmax-2.3 {
1047c478bd9Sstevel@tonic-gate  set sqlite_search_count
1057c478bd9Sstevel@tonic-gate} {0}
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gatedo_test minmax-3.0 {
1087c478bd9Sstevel@tonic-gate  execsql {INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)}
1097c478bd9Sstevel@tonic-gate  set sqlite_search_count 0
1107c478bd9Sstevel@tonic-gate  execsql {SELECT max(a) FROM t2}
1117c478bd9Sstevel@tonic-gate} {21}
1127c478bd9Sstevel@tonic-gatedo_test minmax-3.1 {
1137c478bd9Sstevel@tonic-gate  set sqlite_search_count
1147c478bd9Sstevel@tonic-gate} {0}
1157c478bd9Sstevel@tonic-gatedo_test minmax-3.2 {
1167c478bd9Sstevel@tonic-gate  execsql {INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)}
1177c478bd9Sstevel@tonic-gate  set sqlite_search_count 0
1187c478bd9Sstevel@tonic-gate  execsql {
1197c478bd9Sstevel@tonic-gate    SELECT b FROM t2 WHERE a=(SELECT max(a) FROM t2)
1207c478bd9Sstevel@tonic-gate  }
1217c478bd9Sstevel@tonic-gate} {999}
1227c478bd9Sstevel@tonic-gatedo_test minmax-3.3 {
1237c478bd9Sstevel@tonic-gate  set sqlite_search_count
1247c478bd9Sstevel@tonic-gate} {0}
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gatedo_test minmax-4.1 {
1277c478bd9Sstevel@tonic-gate  execsql {
1287c478bd9Sstevel@tonic-gate    SELECT coalesce(min(x+0),-1), coalesce(max(x+0),-1) FROM
1297c478bd9Sstevel@tonic-gate      (SELECT * FROM t1 UNION SELECT NULL as 'x', NULL as 'y')
1307c478bd9Sstevel@tonic-gate  }
1317c478bd9Sstevel@tonic-gate} {1 20}
1327c478bd9Sstevel@tonic-gatedo_test minmax-4.2 {
1337c478bd9Sstevel@tonic-gate  execsql {
1347c478bd9Sstevel@tonic-gate    SELECT y, sum(x) FROM
1357c478bd9Sstevel@tonic-gate      (SELECT null, y+1 FROM t1 UNION SELECT * FROM t1)
1367c478bd9Sstevel@tonic-gate    GROUP BY y ORDER BY y;
1377c478bd9Sstevel@tonic-gate  }
1387c478bd9Sstevel@tonic-gate} {1 1 2 5 3 22 4 92 5 90 6 0}
1397c478bd9Sstevel@tonic-gatedo_test minmax-4.3 {
1407c478bd9Sstevel@tonic-gate  execsql {
1417c478bd9Sstevel@tonic-gate    SELECT y, count(x), count(*) FROM
1427c478bd9Sstevel@tonic-gate      (SELECT null, y+1 FROM t1 UNION SELECT * FROM t1)
1437c478bd9Sstevel@tonic-gate    GROUP BY y ORDER BY y;
1447c478bd9Sstevel@tonic-gate  }
1457c478bd9Sstevel@tonic-gate} {1 1 1 2 2 3 3 4 5 4 8 9 5 5 6 6 0 1}
1467c478bd9Sstevel@tonic-gate
1477c478bd9Sstevel@tonic-gate# Make sure the min(x) and max(x) optimizations work on empty tables
1487c478bd9Sstevel@tonic-gate# including empty tables with indices. Ticket #296.
1497c478bd9Sstevel@tonic-gate#
1507c478bd9Sstevel@tonic-gatedo_test minmax-5.1 {
1517c478bd9Sstevel@tonic-gate  execsql {
1527c478bd9Sstevel@tonic-gate    CREATE TABLE t3(x INTEGER UNIQUE NOT NULL);
1537c478bd9Sstevel@tonic-gate    SELECT coalesce(min(x),999) FROM t3;
1547c478bd9Sstevel@tonic-gate  }
1557c478bd9Sstevel@tonic-gate} {999}
1567c478bd9Sstevel@tonic-gatedo_test minmax-5.2 {
1577c478bd9Sstevel@tonic-gate  execsql {
1587c478bd9Sstevel@tonic-gate    SELECT coalesce(min(rowid),999) FROM t3;
1597c478bd9Sstevel@tonic-gate  }
1607c478bd9Sstevel@tonic-gate} {999}
1617c478bd9Sstevel@tonic-gatedo_test minmax-5.3 {
1627c478bd9Sstevel@tonic-gate  execsql {
1637c478bd9Sstevel@tonic-gate    SELECT coalesce(max(x),999) FROM t3;
1647c478bd9Sstevel@tonic-gate  }
1657c478bd9Sstevel@tonic-gate} {999}
1667c478bd9Sstevel@tonic-gatedo_test minmax-5.4 {
1677c478bd9Sstevel@tonic-gate  execsql {
1687c478bd9Sstevel@tonic-gate    SELECT coalesce(max(rowid),999) FROM t3;
1697c478bd9Sstevel@tonic-gate  }
1707c478bd9Sstevel@tonic-gate} {999}
1717c478bd9Sstevel@tonic-gatedo_test minmax-5.5 {
1727c478bd9Sstevel@tonic-gate  execsql {
1737c478bd9Sstevel@tonic-gate    SELECT coalesce(max(rowid),999) FROM t3 WHERE rowid<25;
1747c478bd9Sstevel@tonic-gate  }
1757c478bd9Sstevel@tonic-gate} {999}
1767c478bd9Sstevel@tonic-gate
1777c478bd9Sstevel@tonic-gate# Make sure the min(x) and max(x) optimizations work when there
1787c478bd9Sstevel@tonic-gate# is a LIMIT clause.  Ticket #396.
1797c478bd9Sstevel@tonic-gate#
1807c478bd9Sstevel@tonic-gatedo_test minmax-6.1 {
1817c478bd9Sstevel@tonic-gate  execsql {
1827c478bd9Sstevel@tonic-gate    SELECT min(a) FROM t2 LIMIT 1
1837c478bd9Sstevel@tonic-gate  }
1847c478bd9Sstevel@tonic-gate} {1}
1857c478bd9Sstevel@tonic-gatedo_test minmax-6.2 {
1867c478bd9Sstevel@tonic-gate  execsql {
1877c478bd9Sstevel@tonic-gate    SELECT max(a) FROM t2 LIMIT 3
1887c478bd9Sstevel@tonic-gate  }
1897c478bd9Sstevel@tonic-gate} {22}
1907c478bd9Sstevel@tonic-gatedo_test minmax-6.3 {
1917c478bd9Sstevel@tonic-gate  execsql {
1927c478bd9Sstevel@tonic-gate    SELECT min(a) FROM t2 LIMIT 0,100
1937c478bd9Sstevel@tonic-gate  }
1947c478bd9Sstevel@tonic-gate} {1}
1957c478bd9Sstevel@tonic-gatedo_test minmax-6.4 {
1967c478bd9Sstevel@tonic-gate  execsql {
1977c478bd9Sstevel@tonic-gate    SELECT max(a) FROM t2 LIMIT 1,100
1987c478bd9Sstevel@tonic-gate  }
1997c478bd9Sstevel@tonic-gate} {}
2007c478bd9Sstevel@tonic-gatedo_test minmax-6.5 {
2017c478bd9Sstevel@tonic-gate  execsql {
2027c478bd9Sstevel@tonic-gate    SELECT min(x) FROM t3 LIMIT 1
2037c478bd9Sstevel@tonic-gate  }
2047c478bd9Sstevel@tonic-gate} {{}}
2057c478bd9Sstevel@tonic-gatedo_test minmax-6.6 {
2067c478bd9Sstevel@tonic-gate  execsql {
2077c478bd9Sstevel@tonic-gate    SELECT max(x) FROM t3 LIMIT 0
2087c478bd9Sstevel@tonic-gate  }
2097c478bd9Sstevel@tonic-gate} {}
2107c478bd9Sstevel@tonic-gatedo_test minmax-6.7 {
2117c478bd9Sstevel@tonic-gate  execsql {
2127c478bd9Sstevel@tonic-gate    SELECT max(a) FROM t2 LIMIT 0
2137c478bd9Sstevel@tonic-gate  }
2147c478bd9Sstevel@tonic-gate} {}
2157c478bd9Sstevel@tonic-gate
2167c478bd9Sstevel@tonic-gate# Make sure the max(x) and min(x) optimizations work for nested
2177c478bd9Sstevel@tonic-gate# queries.  Ticket #587.
2187c478bd9Sstevel@tonic-gate#
2197c478bd9Sstevel@tonic-gatedo_test minmax-7.1 {
2207c478bd9Sstevel@tonic-gate  execsql {
2217c478bd9Sstevel@tonic-gate    SELECT max(x) FROM t1;
2227c478bd9Sstevel@tonic-gate  }
2237c478bd9Sstevel@tonic-gate} 20
2247c478bd9Sstevel@tonic-gatedo_test minmax-7.2 {
2257c478bd9Sstevel@tonic-gate  execsql {
2267c478bd9Sstevel@tonic-gate    SELECT * FROM (SELECT max(x) FROM t1);
2277c478bd9Sstevel@tonic-gate  }
2287c478bd9Sstevel@tonic-gate} 20
2297c478bd9Sstevel@tonic-gatedo_test minmax-7.3 {
2307c478bd9Sstevel@tonic-gate  execsql {
2317c478bd9Sstevel@tonic-gate    SELECT min(x) FROM t1;
2327c478bd9Sstevel@tonic-gate  }
2337c478bd9Sstevel@tonic-gate} 1
2347c478bd9Sstevel@tonic-gatedo_test minmax-7.4 {
2357c478bd9Sstevel@tonic-gate  execsql {
2367c478bd9Sstevel@tonic-gate    SELECT * FROM (SELECT min(x) FROM t1);
2377c478bd9Sstevel@tonic-gate  }
2387c478bd9Sstevel@tonic-gate} 1
2397c478bd9Sstevel@tonic-gate
2407c478bd9Sstevel@tonic-gate# Make sure min(x) and max(x) work correctly when the datatype is
2417c478bd9Sstevel@tonic-gate# TEXT instead of NUMERIC.  Ticket #623.
2427c478bd9Sstevel@tonic-gate#
2437c478bd9Sstevel@tonic-gatedo_test minmax-8.1 {
2447c478bd9Sstevel@tonic-gate  execsql {
2457c478bd9Sstevel@tonic-gate    CREATE TABLE t4(a TEXT);
2467c478bd9Sstevel@tonic-gate    INSERT INTO t4 VALUES('1234');
2477c478bd9Sstevel@tonic-gate    INSERT INTO t4 VALUES('234');
2487c478bd9Sstevel@tonic-gate    INSERT INTO t4 VALUES('34');
2497c478bd9Sstevel@tonic-gate    SELECT min(a), max(a) FROM t4;
2507c478bd9Sstevel@tonic-gate  }
2517c478bd9Sstevel@tonic-gate} {1234 34}
2527c478bd9Sstevel@tonic-gatedo_test minmax-8.2 {
2537c478bd9Sstevel@tonic-gate  execsql {
2547c478bd9Sstevel@tonic-gate    CREATE TABLE t5(a INTEGER);
2557c478bd9Sstevel@tonic-gate    INSERT INTO t5 VALUES('1234');
2567c478bd9Sstevel@tonic-gate    INSERT INTO t5 VALUES('234');
2577c478bd9Sstevel@tonic-gate    INSERT INTO t5 VALUES('34');
2587c478bd9Sstevel@tonic-gate    SELECT min(a), max(a) FROM t5;
2597c478bd9Sstevel@tonic-gate  }
2607c478bd9Sstevel@tonic-gate} {34 1234}
2617c478bd9Sstevel@tonic-gate
2627c478bd9Sstevel@tonic-gate# Ticket #658:  Test the min()/max() optimization when the FROM clause
2637c478bd9Sstevel@tonic-gate# is a subquery.
2647c478bd9Sstevel@tonic-gate#
2657c478bd9Sstevel@tonic-gatedo_test minmax-9.1 {
2667c478bd9Sstevel@tonic-gate  execsql {
2677c478bd9Sstevel@tonic-gate    SELECT max(rowid) FROM (
2687c478bd9Sstevel@tonic-gate      SELECT max(rowid) FROM t4 UNION SELECT max(rowid) FROM t5
2697c478bd9Sstevel@tonic-gate    )
2707c478bd9Sstevel@tonic-gate  }
2717c478bd9Sstevel@tonic-gate} {1}
2727c478bd9Sstevel@tonic-gatedo_test minmax-9.2 {
2737c478bd9Sstevel@tonic-gate  execsql {
2747c478bd9Sstevel@tonic-gate    SELECT max(rowid) FROM (
2757c478bd9Sstevel@tonic-gate      SELECT max(rowid) FROM t4 EXCEPT SELECT max(rowid) FROM t5
2767c478bd9Sstevel@tonic-gate    )
2777c478bd9Sstevel@tonic-gate  }
2787c478bd9Sstevel@tonic-gate} {{}}
2797c478bd9Sstevel@tonic-gate
2807c478bd9Sstevel@tonic-gate# If there is a NULL in an aggregate max() or min(), ignore it.  An
2817c478bd9Sstevel@tonic-gate# aggregate min() or max() will only return NULL if all values are NULL.
2827c478bd9Sstevel@tonic-gate#
2837c478bd9Sstevel@tonic-gatedo_test minmax-10.1 {
2847c478bd9Sstevel@tonic-gate  execsql {
2857c478bd9Sstevel@tonic-gate    CREATE TABLE t6(x);
2867c478bd9Sstevel@tonic-gate    INSERT INTO t6 VALUES(1);
2877c478bd9Sstevel@tonic-gate    INSERT INTO t6 VALUES(2);
2887c478bd9Sstevel@tonic-gate    INSERT INTO t6 VALUES(NULL);
2897c478bd9Sstevel@tonic-gate    SELECT coalesce(min(x),-1) FROM t6;
2907c478bd9Sstevel@tonic-gate  }
2917c478bd9Sstevel@tonic-gate} {1}
2927c478bd9Sstevel@tonic-gatedo_test minmax-10.2 {
2937c478bd9Sstevel@tonic-gate  execsql {
2947c478bd9Sstevel@tonic-gate    SELECT max(x) FROM t6;
2957c478bd9Sstevel@tonic-gate  }
2967c478bd9Sstevel@tonic-gate} {2}
2977c478bd9Sstevel@tonic-gatedo_test minmax-10.3 {
2987c478bd9Sstevel@tonic-gate  execsql {
2997c478bd9Sstevel@tonic-gate    CREATE INDEX i6 ON t6(x);
3007c478bd9Sstevel@tonic-gate    SELECT coalesce(min(x),-1) FROM t6;
3017c478bd9Sstevel@tonic-gate  }
3027c478bd9Sstevel@tonic-gate} {1}
3037c478bd9Sstevel@tonic-gatedo_test minmax-10.4 {
3047c478bd9Sstevel@tonic-gate  execsql {
3057c478bd9Sstevel@tonic-gate    SELECT max(x) FROM t6;
3067c478bd9Sstevel@tonic-gate  }
3077c478bd9Sstevel@tonic-gate} {2}
3087c478bd9Sstevel@tonic-gatedo_test minmax-10.5 {
3097c478bd9Sstevel@tonic-gate  execsql {
3107c478bd9Sstevel@tonic-gate    DELETE FROM t6 WHERE x NOT NULL;
3117c478bd9Sstevel@tonic-gate    SELECT count(*) FROM t6;
3127c478bd9Sstevel@tonic-gate  }
3137c478bd9Sstevel@tonic-gate} 1
3147c478bd9Sstevel@tonic-gatedo_test minmax-10.6 {
3157c478bd9Sstevel@tonic-gate  execsql {
3167c478bd9Sstevel@tonic-gate    SELECT count(x) FROM t6;
3177c478bd9Sstevel@tonic-gate  }
3187c478bd9Sstevel@tonic-gate} 0
3197c478bd9Sstevel@tonic-gatedo_test minmax-10.7 {
3207c478bd9Sstevel@tonic-gate  execsql {
3217c478bd9Sstevel@tonic-gate    SELECT (SELECT min(x) FROM t6), (SELECT max(x) FROM t6);
3227c478bd9Sstevel@tonic-gate  }
3237c478bd9Sstevel@tonic-gate} {{} {}}
3247c478bd9Sstevel@tonic-gatedo_test minmax-10.8 {
3257c478bd9Sstevel@tonic-gate  execsql {
3267c478bd9Sstevel@tonic-gate    SELECT min(x), max(x) FROM t6;
3277c478bd9Sstevel@tonic-gate  }
3287c478bd9Sstevel@tonic-gate} {{} {}}
3297c478bd9Sstevel@tonic-gatedo_test minmax-10.9 {
3307c478bd9Sstevel@tonic-gate  execsql {
3317c478bd9Sstevel@tonic-gate    INSERT INTO t6 SELECT * FROM t6;
3327c478bd9Sstevel@tonic-gate    INSERT INTO t6 SELECT * FROM t6;
3337c478bd9Sstevel@tonic-gate    INSERT INTO t6 SELECT * FROM t6;
3347c478bd9Sstevel@tonic-gate    INSERT INTO t6 SELECT * FROM t6;
3357c478bd9Sstevel@tonic-gate    INSERT INTO t6 SELECT * FROM t6;
3367c478bd9Sstevel@tonic-gate    INSERT INTO t6 SELECT * FROM t6;
3377c478bd9Sstevel@tonic-gate    INSERT INTO t6 SELECT * FROM t6;
3387c478bd9Sstevel@tonic-gate    INSERT INTO t6 SELECT * FROM t6;
3397c478bd9Sstevel@tonic-gate    INSERT INTO t6 SELECT * FROM t6;
3407c478bd9Sstevel@tonic-gate    INSERT INTO t6 SELECT * FROM t6;
3417c478bd9Sstevel@tonic-gate    SELECT count(*) FROM t6;
3427c478bd9Sstevel@tonic-gate  }
3437c478bd9Sstevel@tonic-gate} 1024
3447c478bd9Sstevel@tonic-gatedo_test minmax-10.10 {
3457c478bd9Sstevel@tonic-gate  execsql {
3467c478bd9Sstevel@tonic-gate    SELECT count(x) FROM t6;
3477c478bd9Sstevel@tonic-gate  }
3487c478bd9Sstevel@tonic-gate} 0
3497c478bd9Sstevel@tonic-gatedo_test minmax-10.11 {
3507c478bd9Sstevel@tonic-gate  execsql {
3517c478bd9Sstevel@tonic-gate    SELECT (SELECT min(x) FROM t6), (SELECT max(x) FROM t6);
3527c478bd9Sstevel@tonic-gate  }
3537c478bd9Sstevel@tonic-gate} {{} {}}
3547c478bd9Sstevel@tonic-gatedo_test minmax-10.12 {
3557c478bd9Sstevel@tonic-gate  execsql {
3567c478bd9Sstevel@tonic-gate    SELECT min(x), max(x) FROM t6;
3577c478bd9Sstevel@tonic-gate  }
3587c478bd9Sstevel@tonic-gate} {{} {}}
3597c478bd9Sstevel@tonic-gate
3607c478bd9Sstevel@tonic-gatefinish_test
361