~ubuntu-branches/ubuntu/maverick/sqlite3/maverick-updates

« back to all changes in this revision

Viewing changes to test/shared.test

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2008-10-01 20:16:18 UTC
  • mfrom: (3.1.20 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081001201618-yfvqqj1qs29wdtcc
Tags: 3.5.9-5
Backport fix for distinct on indexes (closes: #500792).

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
#
10
10
#***********************************************************************
11
11
#
12
 
# $Id: shared.test,v 1.21 2006/01/23 21:38:03 drh Exp $
 
12
# $Id: shared.test,v 1.31 2008/04/28 16:19:35 danielk1977 Exp $
13
13
 
14
14
set testdir [file dirname $argv0]
15
15
source $testdir/tester.tcl
16
16
db close
17
17
 
18
 
ifcapable !shared_cache {
 
18
# These tests cannot be run without the ATTACH command.
 
19
#
 
20
ifcapable !shared_cache||!attach {
19
21
  finish_test
20
22
  return
21
23
}
572
574
} {}
573
575
do_test shared-$av.7.2 {
574
576
  # This test case deletes the contents of table t1 (the one at the start of
575
 
  # the file) while many cursors are open on table t2 and it's index. All of
 
577
  # the file) while many cursors are open on table t2 and its index. All of
576
578
  # the non-root pages will be moved from the end to the start of the file
577
579
  # when the DELETE is committed - this test verifies that moving the pages
578
580
  # does not disturb the open cursors.
634
636
  do_test shared-$av.8.1.2 {
635
637
    string range [execsql {PRAGMA encoding;}] 0 end-2
636
638
  } {UTF-16}
 
639
 
637
640
  do_test shared-$av.8.1.3 {
638
641
    sqlite3 db2 test.db
639
642
    execsql {
652
655
      PRAGMA encoding;
653
656
    }
654
657
  } {UTF-8}
 
658
 
655
659
  file delete -force test2.db test2.db-journal
656
660
  do_test shared-$av.8.2.1 {
657
661
    execsql {
667
671
    } db2
668
672
    string range [execsql {PRAGMA encoding;} db2] 0 end-2
669
673
  } {UTF-16}
 
674
 
 
675
  catch {db close}
 
676
  catch {db2 close}
 
677
  file delete -force test.db test2.db
 
678
 
 
679
  do_test shared-$av.8.3.2 {
 
680
    sqlite3 db test.db
 
681
    execsql { CREATE TABLE def(d, e, f) }
 
682
    execsql { PRAGMA encoding }
 
683
  } {UTF-8}
 
684
  do_test shared-$av.8.3.3 {
 
685
    set zDb16 "[encoding convertto unicode test.db]\x00\x00"
 
686
    set db16 [sqlite3_open16 $zDb16 {}]
 
687
 
 
688
    set stmt [sqlite3_prepare $db16 "SELECT sql FROM sqlite_master" -1 DUMMY]
 
689
    sqlite3_step $stmt
 
690
    set sql [sqlite3_column_text $stmt 0]
 
691
    sqlite3_finalize $stmt
 
692
    set sql
 
693
  } {CREATE TABLE def(d, e, f)}
 
694
  do_test shared-$av.8.3.4 {
 
695
    set stmt [sqlite3_prepare $db16 "PRAGMA encoding" -1 DUMMY]
 
696
    sqlite3_step $stmt
 
697
    set enc [sqlite3_column_text $stmt 0]
 
698
    sqlite3_finalize $stmt
 
699
    set enc
 
700
  } {UTF-8}
 
701
 
 
702
  sqlite3_close $db16
 
703
 
 
704
# Bug #2547 is causing this to fail.
 
705
if 0 {
670
706
  do_test shared-$av.8.2.3 {
671
707
    catchsql {
672
708
      SELECT * FROM aux.sqlite_master;
673
709
    }
674
710
  } {1 {attached databases must use the same text encoding as main database}}
675
711
}
 
712
}
676
713
 
677
714
catch {db close}
678
715
catch {db2 close}
848
885
  }
849
886
  set res
850
887
} {1 4 {} 7}
 
888
if {[llength [info command sqlite3_shared_cache_report]]==1} {
 
889
  do_test shared-$av.11.9 {
 
890
    string tolower [sqlite3_shared_cache_report]
 
891
  } [string tolower [list [file normalize test.db] 2]]
 
892
}
851
893
 
852
894
do_test shared-$av.11.11 {
853
895
  db close
854
896
  db2 close
855
897
} {}
856
898
 
 
899
# This tests that if it is impossible to free any pages, SQLite will
 
900
# exceed the limit set by PRAGMA cache_size.
 
901
file delete -force test.db test.db-journal
 
902
sqlite3 db test.db 
 
903
ifcapable pager_pragmas {
 
904
  do_test shared-$av.12.1 {
 
905
    execsql {
 
906
      PRAGMA cache_size = 10;
 
907
      PRAGMA cache_size;
 
908
    }
 
909
  } {10}
 
910
}
 
911
do_test shared-$av.12.2 {
 
912
  set ::db_handles [list]
 
913
  for {set i 1} {$i < 15} {incr i} {
 
914
    lappend ::db_handles db$i
 
915
    sqlite3 db$i test.db 
 
916
    execsql "CREATE TABLE db${i}(a, b, c)" db$i 
 
917
    execsql "INSERT INTO db${i} VALUES(1, 2, 3)"
 
918
  }
 
919
} {}
 
920
proc nested_select {handles} {
 
921
  [lindex $handles 0] eval "SELECT * FROM [lindex $handles 0]" {
 
922
    lappend ::res $a $b $c
 
923
    if {[llength $handles]>1} {
 
924
      nested_select [lrange $handles 1 end]
 
925
    }
 
926
  }
 
927
}
 
928
do_test shared-$av.12.3 {
 
929
  set ::res [list]
 
930
  nested_select $::db_handles
 
931
  set ::res
 
932
} [string range [string repeat "1 2 3 " [llength $::db_handles]] 0 end-1]
 
933
 
 
934
do_test shared-$av.12.X {
 
935
  db close
 
936
  foreach h $::db_handles { 
 
937
    $h close
 
938
  }
 
939
} {}
 
940
 
857
941
}
858
942
 
859
943
sqlite3_enable_shared_cache $::enable_shared_cache