OLD | NEW |
1 # 2010 November 6 | 1 # 2010 November 6 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 # 0|0|0|COMPOUND SUBQUERIES 1 AND 2 (EXCEPT) | 509 # 0|0|0|COMPOUND SUBQUERIES 1 AND 2 (EXCEPT) |
510 # | 510 # |
511 det 5.13 "SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1" { | 511 det 5.13 "SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1" { |
512 1 0 0 {SCAN TABLE t1 USING COVERING INDEX i1} | 512 1 0 0 {SCAN TABLE t1 USING COVERING INDEX i1} |
513 2 0 0 {SCAN TABLE t2} | 513 2 0 0 {SCAN TABLE t2} |
514 2 0 0 {USE TEMP B-TREE FOR ORDER BY} | 514 2 0 0 {USE TEMP B-TREE FOR ORDER BY} |
515 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)} | 515 0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)} |
516 } | 516 } |
517 | 517 |
518 | 518 |
519 #------------------------------------------------------------------------- | 519 if {![nonzero_reserved_bytes]} { |
520 # The following tests - eqp-6.* - test that the example C code on | 520 #------------------------------------------------------------------------- |
521 # documentation page eqp.html works. The C code is duplicated in test1.c | 521 # The following tests - eqp-6.* - test that the example C code on |
522 # and wrapped in Tcl command [print_explain_query_plan] | 522 # documentation page eqp.html works. The C code is duplicated in test1.c |
523 # | 523 # and wrapped in Tcl command [print_explain_query_plan] |
524 set boilerplate { | 524 # |
525 proc explain_query_plan {db sql} { | 525 set boilerplate { |
526 set stmt [sqlite3_prepare_v2 db $sql -1 DUMMY] | 526 proc explain_query_plan {db sql} { |
527 print_explain_query_plan $stmt | 527 set stmt [sqlite3_prepare_v2 db $sql -1 DUMMY] |
528 sqlite3_finalize $stmt | 528 print_explain_query_plan $stmt |
| 529 sqlite3_finalize $stmt |
| 530 } |
| 531 sqlite3 db test.db |
| 532 explain_query_plan db {%SQL%} |
| 533 db close |
| 534 exit |
529 } | 535 } |
530 sqlite3 db test.db | 536 |
531 explain_query_plan db {%SQL%} | 537 # Do a "Print Explain Query Plan" test. |
532 db close | 538 proc do_peqp_test {tn sql res} { |
533 exit | 539 set fd [open script.tcl w] |
534 } | 540 puts $fd [string map [list %SQL% $sql] $::boilerplate] |
535 | |
536 # Do a "Print Explain Query Plan" test. | |
537 proc do_peqp_test {tn sql res} { | |
538 set fd [open script.tcl w] | |
539 puts $fd [string map [list %SQL% $sql] $::boilerplate] | |
540 close $fd | |
541 | |
542 uplevel do_test $tn [list { | |
543 set fd [open "|[info nameofexec] script.tcl"] | |
544 set data [read $fd] | |
545 close $fd | 541 close $fd |
546 set data | 542 |
547 }] [list $res] | 543 uplevel do_test $tn [list { |
548 } | 544 set fd [open "|[info nameofexec] script.tcl"] |
549 | 545 set data [read $fd] |
550 do_peqp_test 6.1 { | 546 close $fd |
551 SELECT a, b FROM t1 EXCEPT SELECT d, 99 FROM t2 ORDER BY 1 | 547 set data |
552 } [string trimleft { | 548 }] [list $res] |
| 549 } |
| 550 |
| 551 do_peqp_test 6.1 { |
| 552 SELECT a, b FROM t1 EXCEPT SELECT d, 99 FROM t2 ORDER BY 1 |
| 553 } [string trimleft { |
553 1 0 0 SCAN TABLE t1 USING COVERING INDEX i2 | 554 1 0 0 SCAN TABLE t1 USING COVERING INDEX i2 |
554 2 0 0 SCAN TABLE t2 | 555 2 0 0 SCAN TABLE t2 |
555 2 0 0 USE TEMP B-TREE FOR ORDER BY | 556 2 0 0 USE TEMP B-TREE FOR ORDER BY |
556 0 0 0 COMPOUND SUBQUERIES 1 AND 2 (EXCEPT) | 557 0 0 0 COMPOUND SUBQUERIES 1 AND 2 (EXCEPT) |
557 }] | 558 }] |
| 559 } |
558 | 560 |
559 #------------------------------------------------------------------------- | 561 #------------------------------------------------------------------------- |
560 # The following tests - eqp-7.* - test that queries that use the OP_Count | 562 # The following tests - eqp-7.* - test that queries that use the OP_Count |
561 # optimization return something sensible with EQP. | 563 # optimization return something sensible with EQP. |
562 # | 564 # |
563 drop_all_tables | 565 drop_all_tables |
564 | 566 |
565 do_execsql_test 7.0 { | 567 do_execsql_test 7.0 { |
566 CREATE TABLE t1(a INT, b INT, ex CHAR(100)); | 568 CREATE TABLE t1(a INT, b INT, ex CHAR(100)); |
567 CREATE TABLE t2(a INT, b INT, ex CHAR(100)); | 569 CREATE TABLE t2(a INT, b INT, ex CHAR(100)); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 0 0 0 {SCAN TABLE t1} | 639 0 0 0 {SCAN TABLE t1} |
638 } | 640 } |
639 | 641 |
640 | 642 |
641 | 643 |
642 | 644 |
643 | 645 |
644 | 646 |
645 | 647 |
646 finish_test | 648 finish_test |
OLD | NEW |