xref: /sqlite-3.40.0/test/selectF.test (revision 6295524e)
1*6295524eSdrh# 2014-03-03
2*6295524eSdrh#
3*6295524eSdrh# The author disclaims copyright to this source code.  In place of
4*6295524eSdrh# a legal notice, here is a blessing:
5*6295524eSdrh#
6*6295524eSdrh#    May you do good and not evil.
7*6295524eSdrh#    May you find forgiveness for yourself and forgive others.
8*6295524eSdrh#    May you share freely, never taking more than you give.
9*6295524eSdrh#
10*6295524eSdrh#***********************************************************************
11*6295524eSdrh#
12*6295524eSdrh# This file verifies that an OP_Copy operation is used instead of OP_SCopy
13*6295524eSdrh# in a compound select in a case where the source register might be changed
14*6295524eSdrh# before the copy is used.
15*6295524eSdrh#
16*6295524eSdrh
17*6295524eSdrhset testdir [file dirname $argv0]
18*6295524eSdrhsource $testdir/tester.tcl
19*6295524eSdrhset testprefix selectF
20*6295524eSdrh
21*6295524eSdrhdo_execsql_test 1 {
22*6295524eSdrh  BEGIN TRANSACTION;
23*6295524eSdrh  CREATE TABLE t1(a, b, c);
24*6295524eSdrh  INSERT INTO "t1" VALUES(1,'one','I');
25*6295524eSdrh  CREATE TABLE t2(d, e, f);
26*6295524eSdrh  INSERT INTO "t2" VALUES(5,'ten','XX');
27*6295524eSdrh  INSERT INTO "t2" VALUES(6,NULL,NULL);
28*6295524eSdrh
29*6295524eSdrh  CREATE INDEX i1 ON t1(b, a);
30*6295524eSdrh  COMMIT;
31*6295524eSdrh}
32*6295524eSdrh
33*6295524eSdrh#explain_i {
34*6295524eSdrh#  SELECT * FROM t2
35*6295524eSdrh#  UNION ALL
36*6295524eSdrh#  SELECT * FROM t1 WHERE a<5
37*6295524eSdrh#  ORDER BY 2, 1
38*6295524eSdrh#}
39*6295524eSdrh
40*6295524eSdrhdo_execsql_test 2 {
41*6295524eSdrh  SELECT * FROM t2
42*6295524eSdrh  UNION ALL
43*6295524eSdrh  SELECT * FROM t1 WHERE a<5
44*6295524eSdrh  ORDER BY 2, 1
45*6295524eSdrh} {6 {} {} 1 one I 5 ten XX}
46*6295524eSdrh
47*6295524eSdrh
48*6295524eSdrh
49*6295524eSdrhfinish_test
50