3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
12 # This file is to test that ticket #2927 is fixed.
14 # $Id: tkt2927.test,v 1.4 2008/08/04 03:51:24 danielk1977 Exp $
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
29 CREATE TABLE t1(a, b);
30 INSERT INTO t1 VALUES(1,11);
31 INSERT INTO t1 VALUES(2,22);
32 INSERT INTO t1 VALUES(3,33);
33 INSERT INTO t1 VALUES(4,44);
34 INSERT INTO t1 VALUES(5,55);
37 } {1 11 2 22 3 33 4 44 5 55}
46 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
48 #set sqlite_addop_trace 1
52 SELECT a, abs(b) FROM t1
54 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
59 SELECT abs(a), b FROM t1
61 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
66 SELECT abs(a), abs(b) FROM t1
68 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
71 SELECT a, abs(b) FROM t1
75 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
78 SELECT a, abs(b) FROM t1
80 SELECT a, abs(b) FROM t1
82 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
85 SELECT a, abs(b) FROM t1
87 SELECT abs(a), b FROM t1
89 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
92 SELECT a, abs(b) FROM t1
94 SELECT abs(a), abs(b) FROM t1
96 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
99 SELECT abs(a), b FROM t1
103 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
104 do_test tkt2927-2.10 {
106 SELECT abs(a), b FROM t1
108 SELECT a, abs(b) FROM t1
110 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
111 do_test tkt2927-2.11 {
113 SELECT abs(a), b FROM t1
115 SELECT abs(a), b FROM t1
117 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
118 do_test tkt2927-2.12 {
120 SELECT abs(a), b FROM t1
122 SELECT abs(a), abs(b) FROM t1
124 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
125 do_test tkt2927-2.13 {
127 SELECT abs(a), abs(b) FROM t1
131 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
132 do_test tkt2927-2.14 {
134 SELECT abs(a), abs(b) FROM t1
136 SELECT a, abs(b) FROM t1
138 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
139 do_test tkt2927-2.15 {
141 SELECT abs(a), abs(b) FROM t1
143 SELECT abs(a), b FROM t1
145 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
146 do_test tkt2927-2.16 {
148 SELECT abs(a), abs(b) FROM t1
150 SELECT abs(a), abs(b) FROM t1
152 } {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}
155 do_test tkt2927-3.1 {
162 } {1 11 2 22 3 33 4 44 5 55}
163 do_test tkt2927-3.2 {
167 SELECT a, abs(b) FROM t1
170 } {1 11 2 22 3 33 4 44 5 55}
171 do_test tkt2927-3.3 {
175 SELECT abs(a), b FROM t1
178 } {1 11 2 22 3 33 4 44 5 55}
179 do_test tkt2927-3.4 {
183 SELECT abs(a), abs(b) FROM t1
186 } {1 11 2 22 3 33 4 44 5 55}
187 do_test tkt2927-3.5 {
189 SELECT a, abs(b) FROM t1
194 } {1 11 2 22 3 33 4 44 5 55}
195 do_test tkt2927-3.6 {
197 SELECT a, abs(b) FROM t1
199 SELECT a, abs(b) FROM t1
202 } {1 11 2 22 3 33 4 44 5 55}
203 do_test tkt2927-3.7 {
205 SELECT a, abs(b) FROM t1
207 SELECT abs(a), b FROM t1
210 } {1 11 2 22 3 33 4 44 5 55}
211 do_test tkt2927-3.8 {
213 SELECT a, abs(b) FROM t1
215 SELECT abs(a), abs(b) FROM t1
218 } {1 11 2 22 3 33 4 44 5 55}
219 do_test tkt2927-3.9 {
221 SELECT abs(a), b FROM t1
226 } {1 11 2 22 3 33 4 44 5 55}
227 do_test tkt2927-3.10 {
229 SELECT abs(a), b FROM t1
231 SELECT a, abs(b) FROM t1
234 } {1 11 2 22 3 33 4 44 5 55}
235 do_test tkt2927-3.11 {
237 SELECT abs(a), b FROM t1
239 SELECT abs(a), b FROM t1
242 } {1 11 2 22 3 33 4 44 5 55}
243 do_test tkt2927-3.12 {
245 SELECT abs(a), b FROM t1
247 SELECT abs(a), abs(b) FROM t1
250 } {1 11 2 22 3 33 4 44 5 55}
251 do_test tkt2927-3.13 {
253 SELECT abs(a), abs(b) FROM t1
258 } {1 11 2 22 3 33 4 44 5 55}
259 do_test tkt2927-3.14 {
261 SELECT abs(a), abs(b) FROM t1
263 SELECT a, abs(b) FROM t1
266 } {1 11 2 22 3 33 4 44 5 55}
267 do_test tkt2927-3.15 {
269 SELECT abs(a), abs(b) FROM t1
271 SELECT abs(a), b FROM t1
274 } {1 11 2 22 3 33 4 44 5 55}
275 do_test tkt2927-3.16 {
277 SELECT abs(a), abs(b) FROM t1
279 SELECT abs(a), abs(b) FROM t1
282 } {1 11 2 22 3 33 4 44 5 55}
285 do_test tkt2927-4.1 {
287 SELECT a+b, a-b, a, b FROM t1
289 SELECT a+b, a-b, a, b FROM t1
291 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
292 do_test tkt2927-4.2 {
294 SELECT a+b, a-b, a, b FROM t1
296 SELECT a+b, a-b, a, abs(b) FROM t1
298 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
299 do_test tkt2927-4.3 {
301 SELECT a+b, a-b, a, b FROM t1
303 SELECT a+b, a-b, abs(a), b FROM t1
305 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
306 do_test tkt2927-4.4 {
308 SELECT a+b, a-b, a, b FROM t1
310 SELECT a+b, a-b, abs(a), abs(b) FROM t1
312 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
313 do_test tkt2927-4.5 {
315 SELECT a+b, a-b, a, abs(b) FROM t1
317 SELECT a+b, a-b, a, b FROM t1
319 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
320 do_test tkt2927-4.6 {
322 SELECT a+b, a-b, a, abs(b) FROM t1
324 SELECT a+b, a-b, a, abs(b) FROM t1
326 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
327 do_test tkt2927-4.7 {
329 SELECT a+b, a-b, a, abs(b) FROM t1
331 SELECT a+b, a-b, abs(a), b FROM t1
333 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
334 do_test tkt2927-4.8 {
336 SELECT a+b, a-b, a, abs(b) FROM t1
338 SELECT a+b, a-b, abs(a), abs(b) FROM t1
340 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
341 do_test tkt2927-4.9 {
343 SELECT a+b, a-b, abs(a), b FROM t1
345 SELECT a+b, a-b, a, b FROM t1
347 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
348 do_test tkt2927-4.10 {
350 SELECT a+b, a-b, abs(a), b FROM t1
352 SELECT a+b, a-b, a, abs(b) FROM t1
354 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
355 do_test tkt2927-4.11 {
357 SELECT a+b, a-b, abs(a), b FROM t1
359 SELECT a+b, a-b, abs(a), b FROM t1
361 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
362 do_test tkt2927-4.12 {
364 SELECT a+b, a-b, abs(a), b FROM t1
366 SELECT a+b, a-b, abs(a), abs(b) FROM t1
368 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
369 do_test tkt2927-4.13 {
371 SELECT a+b, a-b, abs(a), abs(b) FROM t1
373 SELECT a+b, a-b, a, b FROM t1
375 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
376 do_test tkt2927-4.14 {
378 SELECT a+b, a-b, abs(a), abs(b) FROM t1
380 SELECT a+b, a-b, a, abs(b) FROM t1
382 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
383 do_test tkt2927-4.15 {
385 SELECT a+b, a-b, abs(a), abs(b) FROM t1
387 SELECT a+b, a-b, abs(a), b FROM t1
389 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
390 do_test tkt2927-4.16 {
392 SELECT a+b, a-b, abs(a), abs(b) FROM t1
394 SELECT a+b, a-b, abs(a), abs(b) FROM t1
396 } {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}
399 do_test tkt2927-5.1 {
406 do_test tkt2927-5.2 {
410 SELECT a, abs(b) FROM t1
413 do_test tkt2927-5.3 {
417 SELECT abs(a), b FROM t1
420 do_test tkt2927-5.4 {
424 SELECT abs(a), abs(b) FROM t1
427 do_test tkt2927-5.5 {
429 SELECT a, abs(b) FROM t1
434 do_test tkt2927-5.6 {
436 SELECT a, abs(b) FROM t1
438 SELECT a, abs(b) FROM t1
441 do_test tkt2927-5.7 {
443 SELECT a, abs(b) FROM t1
445 SELECT abs(a), b FROM t1
448 do_test tkt2927-5.8 {
450 SELECT a, abs(b) FROM t1
452 SELECT abs(a), abs(b) FROM t1
455 do_test tkt2927-5.9 {
457 SELECT abs(a), b FROM t1
462 do_test tkt2927-5.10 {
464 SELECT abs(a), b FROM t1
466 SELECT a, abs(b) FROM t1
469 do_test tkt2927-5.11 {
471 SELECT abs(a), b FROM t1
473 SELECT abs(a), b FROM t1
476 do_test tkt2927-5.12 {
478 SELECT abs(a), b FROM t1
480 SELECT abs(a), abs(b) FROM t1
483 do_test tkt2927-5.13 {
485 SELECT abs(a), abs(b) FROM t1
490 do_test tkt2927-5.14 {
492 SELECT abs(a), abs(b) FROM t1
494 SELECT a, abs(b) FROM t1
497 do_test tkt2927-5.15 {
499 SELECT abs(a), abs(b) FROM t1
501 SELECT abs(a), b FROM t1
504 do_test tkt2927-5.16 {
506 SELECT abs(a), abs(b) FROM t1
508 SELECT abs(a), abs(b) FROM t1
513 do_test tkt2927-6.1 {
520 } {1 11 2 22 3 33 4 44 5 55}
521 do_test tkt2927-6.2 {
525 SELECT a, abs(b) FROM t1
528 } {1 11 2 22 3 33 4 44 5 55}
529 do_test tkt2927-6.3 {
533 SELECT abs(a), b FROM t1
536 } {1 11 2 22 3 33 4 44 5 55}
537 do_test tkt2927-6.4 {
541 SELECT abs(a), abs(b) FROM t1
544 } {1 11 2 22 3 33 4 44 5 55}
545 do_test tkt2927-6.5 {
547 SELECT a, abs(b) FROM t1
552 } {1 11 2 22 3 33 4 44 5 55}
553 do_test tkt2927-6.6 {
555 SELECT a, abs(b) FROM t1
557 SELECT a, abs(b) FROM t1
560 } {1 11 2 22 3 33 4 44 5 55}
561 do_test tkt2927-6.7 {
563 SELECT a, abs(b) FROM t1
565 SELECT abs(a), b FROM t1
568 } {1 11 2 22 3 33 4 44 5 55}
569 do_test tkt2927-6.8 {
571 SELECT a, abs(b) FROM t1
573 SELECT abs(a), abs(b) FROM t1
576 } {1 11 2 22 3 33 4 44 5 55}
577 do_test tkt2927-6.9 {
579 SELECT abs(a), b FROM t1
584 } {1 11 2 22 3 33 4 44 5 55}
585 do_test tkt2927-6.10 {
587 SELECT abs(a), b FROM t1
589 SELECT a, abs(b) FROM t1
592 } {1 11 2 22 3 33 4 44 5 55}
593 do_test tkt2927-6.11 {
595 SELECT abs(a), b FROM t1
597 SELECT abs(a), b FROM t1
600 } {1 11 2 22 3 33 4 44 5 55}
601 do_test tkt2927-6.12 {
603 SELECT abs(a), b FROM t1
605 SELECT abs(a), abs(b) FROM t1
608 } {1 11 2 22 3 33 4 44 5 55}
609 do_test tkt2927-6.13 {
611 SELECT abs(a), abs(b) FROM t1
616 } {1 11 2 22 3 33 4 44 5 55}
617 do_test tkt2927-6.14 {
619 SELECT abs(a), abs(b) FROM t1
621 SELECT a, abs(b) FROM t1
624 } {1 11 2 22 3 33 4 44 5 55}
625 do_test tkt2927-6.15 {
627 SELECT abs(a), abs(b) FROM t1
629 SELECT abs(a), b FROM t1
632 } {1 11 2 22 3 33 4 44 5 55}
633 do_test tkt2927-6.16 {
635 SELECT abs(a), abs(b) FROM t1
637 SELECT abs(a), abs(b) FROM t1
640 } {1 11 2 22 3 33 4 44 5 55}
642 # Ticket #3092 is the same bug. But another test case never hurts.
644 do_test tkt2927-7.1 {
647 hostname text not null primary key,
651 INSERT INTO "host" VALUES('aald04','aalp03','4');
652 INSERT INTO "host" VALUES('aald17','aalp01','1');
653 CREATE VIEW consolemap1a as
654 select hostname, consolehost, '/dev/cuaD0.' || (consoleport-1) consoleport
655 from host where consolehost='aalp01';
656 CREATE VIEW consolemap1b as
657 select hostname hostname, consolehost consolehost, '/dev/cuaD' ||
658 substr('01',1+((consoleport-1)/16),1) ||
659 substr('0123456789abcdef',1+((consoleport-1)%16),1) consoleport
660 from host where consolehost='aalp03';
661 CREATE VIEW consolemap1 as
662 select * from consolemap1a
664 select * from consolemap1b;
665 SELECT * from consolemap1b;
667 } {aald04 aalp03 /dev/cuaD03}
668 do_test tkt2927-7.2 {
670 SELECT * FROM consolemap1
672 } {aald04 aalp03 /dev/cuaD03 aald17 aalp01 /dev/cuaD0.0}