OLD | NEW |
1 # 2011 October 03 | 1 # 2011 October 03 |
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 30 matching lines...) Expand all Loading... |
41 # | 41 # |
42 # 7.* - Test that if content=xxx is specified and table xxx does not | 42 # 7.* - Test that if content=xxx is specified and table xxx does not |
43 # exist, the FTS table can still be used for INSERT and some | 43 # exist, the FTS table can still be used for INSERT and some |
44 # SELECT statements. | 44 # SELECT statements. |
45 # | 45 # |
46 # 8.* - Test that if the content=xxx and prefix options are used together, | 46 # 8.* - Test that if the content=xxx and prefix options are used together, |
47 # the 'rebuild' command still works. | 47 # the 'rebuild' command still works. |
48 # | 48 # |
49 # 9.* - Test using content=xxx where xxx is a virtual table. | 49 # 9.* - Test using content=xxx where xxx is a virtual table. |
50 # | 50 # |
| 51 # 11.* - Test that circular references (e.g. "t1(content=t1)") are |
| 52 # detected. |
| 53 # |
51 | 54 |
52 do_execsql_test 1.1.1 { | 55 do_execsql_test 1.1.1 { |
53 CREATE TABLE t1(a, b, c); | 56 CREATE TABLE t1(a, b, c); |
54 INSERT INTO t1 VALUES('w x', 'x y', 'y z'); | 57 INSERT INTO t1 VALUES('w x', 'x y', 'y z'); |
55 CREATE VIRTUAL TABLE ft1 USING fts4(content=t1); | 58 CREATE VIRTUAL TABLE ft1 USING fts4(content=t1); |
56 } | 59 } |
57 | 60 |
58 do_execsql_test 1.1.2 { | 61 do_execsql_test 1.1.2 { |
59 PRAGMA table_info(ft1); | 62 PRAGMA table_info(ft1); |
60 } { | 63 } { |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 SELECT name FROM sqlite_master WHERE name LIKE '%t5%'; | 402 SELECT name FROM sqlite_master WHERE name LIKE '%t5%'; |
400 } { | 403 } { |
401 t5 t5_content | 404 t5 t5_content |
402 } | 405 } |
403 | 406 |
404 #------------------------------------------------------------------------- | 407 #------------------------------------------------------------------------- |
405 # Test cases 6.* test | 408 # Test cases 6.* test |
406 # | 409 # |
407 do_catchsql_test 6.1.1 { | 410 do_catchsql_test 6.1.1 { |
408 CREATE VIRTUAL TABLE ft7 USING fts4(content=t7); | 411 CREATE VIRTUAL TABLE ft7 USING fts4(content=t7); |
409 } {1 {vtable constructor failed: ft7}} | 412 } {1 {no such table: main.t7}} |
410 | 413 |
411 do_execsql_test 6.2.1 { | 414 do_execsql_test 6.2.1 { |
412 CREATE TABLE t7(one, two); | 415 CREATE TABLE t7(one, two); |
413 CREATE VIRTUAL TABLE ft7 USING fts4(content=t7); | 416 CREATE VIRTUAL TABLE ft7 USING fts4(content=t7); |
414 INSERT INTO t7 VALUES('A B', 'B A'); | 417 INSERT INTO t7 VALUES('A B', 'B A'); |
415 INSERT INTO t7 VALUES('C D', 'A A'); | 418 INSERT INTO t7 VALUES('C D', 'A A'); |
416 SELECT * FROM ft7; | 419 SELECT * FROM ft7; |
417 } { | 420 } { |
418 {A B} {B A} {C D} {A A} | 421 {A B} {B A} {C D} {A A} |
419 } | 422 } |
420 | 423 |
421 do_catchsql_test 6.2.2 { | 424 do_catchsql_test 6.2.2 { |
422 DROP TABLE t7; | 425 DROP TABLE t7; |
423 SELECT * FROM ft7; | 426 SELECT * FROM ft7; |
424 } {1 {SQL logic error or missing database}} | 427 } {1 {SQL logic error or missing database}} |
425 | 428 |
426 db close | 429 db close |
427 sqlite3 db test.db | 430 sqlite3 db test.db |
428 do_execsql_test 6.2.3 { | 431 do_execsql_test 6.2.3 { |
429 SELECT name FROM sqlite_master WHERE name LIKE '%t7%' | 432 SELECT name FROM sqlite_master WHERE name LIKE '%t7%' |
430 } { | 433 } { |
431 ft7 ft7_segments ft7_segdir sqlite_autoindex_ft7_segdir_1 | 434 ft7 ft7_segments ft7_segdir sqlite_autoindex_ft7_segdir_1 |
432 ft7_docsize ft7_stat | 435 ft7_docsize ft7_stat |
433 } | 436 } |
434 do_catchsql_test 6.2.4 { | 437 do_catchsql_test 6.2.4 { |
435 SELECT * FROM ft7; | 438 SELECT * FROM ft7; |
436 } {1 {vtable constructor failed: ft7}} | 439 } {1 {no such table: main.t7}} |
437 do_execsql_test 6.2.5 { | 440 do_execsql_test 6.2.5 { |
438 CREATE TABLE t7(x, y); | 441 CREATE TABLE t7(x, y); |
439 INSERT INTO t7 VALUES('A B', 'B A'); | 442 INSERT INTO t7 VALUES('A B', 'B A'); |
440 INSERT INTO t7 VALUES('C D', 'A A'); | 443 INSERT INTO t7 VALUES('C D', 'A A'); |
441 SELECT * FROM ft7; | 444 SELECT * FROM ft7; |
442 } { | 445 } { |
443 {A B} {B A} {C D} {A A} | 446 {A B} {B A} {C D} {A A} |
444 } | 447 } |
445 | 448 |
446 do_execsql_test 6.2.6 { | 449 do_execsql_test 6.2.6 { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 write_file t2.txt {a b c d e f g h i j k l m a b c d e f g h i j k l m} | 580 write_file t2.txt {a b c d e f g h i j k l m a b c d e f g h i j k l m} |
578 write_file t3.txt {n o p q r s t u v w x y z n o p q r s t u v w x y z} | 581 write_file t3.txt {n o p q r s t u v w x y z n o p q r s t u v w x y z} |
579 | 582 |
580 do_execsql_test 10.1 { | 583 do_execsql_test 10.1 { |
581 CREATE TABLE idx(id INTEGER PRIMARY KEY, path TEXT); | 584 CREATE TABLE idx(id INTEGER PRIMARY KEY, path TEXT); |
582 INSERT INTO idx VALUES (1, 't1.txt'); | 585 INSERT INTO idx VALUES (1, 't1.txt'); |
583 INSERT INTO idx VALUES (2, 't2.txt'); | 586 INSERT INTO idx VALUES (2, 't2.txt'); |
584 INSERT INTO idx VALUES (3, 't3.txt'); | 587 INSERT INTO idx VALUES (3, 't3.txt'); |
585 | 588 |
586 CREATE VIRTUAL TABLE vt USING fs(idx); | 589 CREATE VIRTUAL TABLE vt USING fs(idx); |
587 SELECT * FROM vt; | 590 SELECT path, data FROM vt; |
588 } { | 591 } { |
589 1 {a b c d e f g h i j k l m n o p q r s t u v w x y z} | 592 1 {a b c d e f g h i j k l m n o p q r s t u v w x y z} |
590 2 {a b c d e f g h i j k l m a b c d e f g h i j k l m} | 593 2 {a b c d e f g h i j k l m a b c d e f g h i j k l m} |
591 3 {n o p q r s t u v w x y z n o p q r s t u v w x y z} | 594 3 {n o p q r s t u v w x y z n o p q r s t u v w x y z} |
592 } | 595 } |
593 | 596 |
594 do_execsql_test 10.2 { | 597 do_execsql_test 10.2 { |
595 SELECT * FROM vt WHERE rowid = 2; | 598 SELECT path, data FROM vt WHERE rowid = 2; |
596 } { | 599 } { |
597 2 {a b c d e f g h i j k l m a b c d e f g h i j k l m} | 600 2 {a b c d e f g h i j k l m a b c d e f g h i j k l m} |
598 } | 601 } |
599 | 602 |
600 do_execsql_test 10.3 { | 603 do_execsql_test 10.3 { |
601 CREATE VIRTUAL TABLE ft USING fts4(content=vt); | 604 CREATE VIRTUAL TABLE ft USING fts4(content=vt); |
602 INSERT INTO ft(ft) VALUES('rebuild'); | 605 INSERT INTO ft(ft) VALUES('rebuild'); |
603 } | 606 } |
604 | 607 |
605 do_execsql_test 10.4 { | 608 do_execsql_test 10.4 { |
606 SELECT snippet(ft, '[', ']', '...', -1, 5) FROM ft WHERE ft MATCH 'e' | 609 SELECT snippet(ft, '[', ']', '...', -1, 5) FROM ft WHERE ft MATCH 'e' |
607 } { | 610 } { |
608 {...c d [e] f g...} {...c d [e] f g...} | 611 {...c d [e] f g...} {...c d [e] f g...} |
609 } | 612 } |
610 | 613 |
611 do_execsql_test 10.5 { | 614 do_execsql_test 10.5 { |
612 SELECT snippet(ft, '[', ']', '...', -1, 5) FROM ft WHERE ft MATCH 't' | 615 SELECT snippet(ft, '[', ']', '...', -1, 5) FROM ft WHERE ft MATCH 't' |
613 } { | 616 } { |
614 {...r s [t] u v...} {...r s [t] u v...} | 617 {...r s [t] u v...} {...r s [t] u v...} |
615 } | 618 } |
616 | 619 |
617 do_execsql_test 10.6 { DELETE FROM ft WHERE docid=2 } | 620 do_execsql_test 10.6 { DELETE FROM ft WHERE docid=2 } |
618 | 621 |
619 do_execsql_test 10.7 { | 622 do_execsql_test 10.7 { |
620 SELECT snippet(ft, '[', ']', '...', -1, 5) FROM ft WHERE ft MATCH 'e' | 623 SELECT snippet(ft, '[', ']', '...', -1, 5) FROM ft WHERE ft MATCH 'e' |
621 } { | 624 } { |
622 {...c d [e] f g...} | 625 {...c d [e] f g...} |
623 } | 626 } |
624 | 627 |
| 628 #------------------------------------------------------------------------- |
| 629 # Test cases 11.* |
| 630 # |
| 631 reset_db |
| 632 |
| 633 do_catchsql_test 11.1 { |
| 634 CREATE VIRTUAL TABLE x1 USING fts4(content=x1); |
| 635 } {1 {vtable constructor called recursively: x1}} |
| 636 |
| 637 |
625 finish_test | 638 finish_test |
| 639 |
OLD | NEW |