/ Check-in [eec7ab63]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Coverage tests for some pragmas. (CVS 3767)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: eec7ab63beed875a3b16c3bf8d28ac4f296dfb4c
User & Date: danielk1977 2007-03-30 17:11:13
Context
2007-03-30
17:17
Get the memleak.test script working again after recent changes. (CVS 3768) check-in: cd6ca078 user: drh tags: trunk
17:11
Coverage tests for some pragmas. (CVS 3767) check-in: eec7ab63 user: danielk1977 tags: trunk
16:01
Always enable exclusive access mode for TEMP databases. This cannot be changed. The locking_mode pragma has not effect on the TEMP database. (CVS 3766) check-in: 04d3b909 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pragma.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the PRAGMA command.
    13     13   **
    14         -** $Id: pragma.c,v 1.131 2007/03/30 11:12:08 drh Exp $
           14  +** $Id: pragma.c,v 1.132 2007/03/30 17:11:13 danielk1977 Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include "os.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /* Ignore this whole file if pragmas are disabled
    21     21   */
................................................................................
    96     96   /*
    97     97   ** Invalidate temp storage, either when the temp storage is changed
    98     98   ** from default, or when 'file' and the temp_store_directory has changed
    99     99   */
   100    100   static int invalidateTempStorage(Parse *pParse){
   101    101     sqlite3 *db = pParse->db;
   102    102     if( db->aDb[1].pBt!=0 ){
   103         -    if( db->flags & SQLITE_InTrans ){
          103  +    if( !db->autoCommit ){
   104    104         sqlite3ErrorMsg(pParse, "temporary storage cannot be changed "
   105    105           "from within a transaction");
   106    106         return SQLITE_ERROR;
   107    107       }
   108    108       sqlite3BtreeClose(db->aDb[1].pBt);
   109    109       db->aDb[1].pBt = 0;
   110    110       sqlite3ResetInternalSchema(db, 0);

Changes to test/misc7.test.

     6      6   #    May you do good and not evil.
     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13         -# $Id: misc7.test,v 1.6 2007/03/30 14:56:35 danielk1977 Exp $
           13  +# $Id: misc7.test,v 1.7 2007/03/30 17:11:13 danielk1977 Exp $
    14     14   
    15     15   set testdir [file dirname $argv0]
    16     16   source $testdir/tester.tcl
    17     17   
    18     18   do_test misc7-1 {
    19     19     c_misuse_test
    20     20   } {}
................................................................................
    60     60   proc use_up_files {} {
    61     61     set ret [list]
    62     62     catch {
    63     63       while 1 { lappend ret [open test.db] }
    64     64     }
    65     65     return $ret
    66     66   }
           67  +
           68  +proc do_fileopen_test {prefix sql} {
           69  +  set fd_list [use_up_files]
           70  +  set ::go 1
           71  +  set ::n 1
           72  +  set ::sql $sql
           73  +  while {$::go} {
           74  +    catch {db close}
           75  +    do_test ${prefix}.${::n} {
           76  +      set rc [catch {
           77  +        sqlite db test.db
           78  +        db eval $::sql
           79  +      } msg]
           80  +      if {$rc == 0} {set ::go 0}
           81  +  
           82  +      expr {$rc == 0 || ($rc == 1 && [string first unable $msg]==0)}
           83  +    } 1
           84  +  
           85  +    close [lindex $fd_list 0]
           86  +    set fd_list [lrange $fd_list 1 end]
           87  +    incr ::n
           88  +  }
           89  +  foreach fd $fd_list {
           90  +    close $fd
           91  +  }
           92  +  db close
           93  +}
    67     94   
    68     95   execsql { CREATE TABLE abc(a PRIMARY KEY, b, c); }
    69     96   db close
    70         -set fd_list [use_up_files]
    71         -set ::go 1
    72         -set ::n 1
    73         -while {$::go} {
    74         -  catch {db close}
    75         -  do_test misc7-6.$::n {
    76         -    set rc [catch {
    77         -      sqlite db test.db
    78         -      db eval {
    79         -        BEGIN;
    80         -        INSERT INTO abc VALUES(1, 2, 3);
    81         -        INSERT INTO abc VALUES(2, 3, 4);
    82         -        INSERT INTO abc SELECT a+2, b, c FROM abc;
    83         -        COMMIT;
    84         -      }
    85         -    } msg]
    86         -    if {$rc == 0} {set ::go 0}
    87     97   
    88         -    expr {$rc == 0 || ($rc == 1 && $msg eq "unable to open database file")}
    89         -  } 1
           98  +do_fileopen_test misc7-6.1 {
           99  +  BEGIN;
          100  +  INSERT INTO abc VALUES(1, 2, 3);
          101  +  INSERT INTO abc VALUES(2, 3, 4);
          102  +  INSERT INTO abc SELECT a+2, b, c FROM abc;
          103  +  COMMIT;
          104  +}
    90    105   
    91         -  close [lindex $fd_list 0]
    92         -  set fd_list [lrange $fd_list 1 end]
    93         -  incr ::n
          106  +do_fileopen_test misc7-6.2 {
          107  +  PRAGMA temp.cache_size = 1000;
    94    108   }
    95         -foreach fd $fd_list {
    96         -  close $fd
    97         -}
    98         -db close
          109  +
    99    110   #
   100    111   # End of tests for out-of-file-descriptors condition.
   101    112   #--------------------------------------------------------------------
   102    113   
   103    114   sqlite3 db test.db
   104    115   #--------------------------------------------------------------------
   105    116   # Test that the sqlite3_busy_timeout call seems to delay approximately
   106    117   # the right amount of time.
   107    118   #
   108         -do_test misc7-6 {
          119  +do_test misc7-7.0 {
   109    120     sqlite3 db2 test.db
   110    121     sqlite3_busy_timeout [sqlite3_connection_pointer db] 2000
   111    122     execsql {
   112    123       BEGIN EXCLUSIVE;
   113    124     } db2
   114    125   
   115    126     # Now db2 has an exclusive lock on the database file, and db has
................................................................................
   212    223       register_echo_module [sqlite3_connection_pointer db]
   213    224       set ::echo_module_cost 2.0e+99
   214    225       execsql {SELECT * FROM t1 WHERE a = 1;}
   215    226     } {1 2 3}
   216    227     unset ::echo_module_cost
   217    228   }
   218    229   
          230  +db close
          231  +file delete -force test.db
          232  +file delete -force test.db-journal
          233  +sqlite3 db test.db
          234  +
          235  +ifcapable explain {
          236  +  do_test misc7-14 {
          237  +    execsql {
          238  +      CREATE TABLE abc(a PRIMARY KEY, b, c);
          239  +    }
          240  +    execsql {
          241  +      EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid = 1;
          242  +    }
          243  +  } {0 0 {TABLE abc AS t2 USING PRIMARY KEY}}
          244  +  do_test misc7-15 {
          245  +    execsql {
          246  +      EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE a = 1;
          247  +    }
          248  +  } {0 0 {TABLE abc AS t2 WITH INDEX sqlite_autoindex_abc_1}}
          249  +}
   219    250   
   220    251   finish_test

Changes to test/pragma.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for the PRAGMA command.
    14     14   #
    15         -# $Id: pragma.test,v 1.51 2007/01/27 14:26:07 drh Exp $
           15  +# $Id: pragma.test,v 1.52 2007/03/30 17:11:13 danielk1977 Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Test organization:
    21     21   #
    22     22   # pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
................................................................................
   850    850   }
   851    851   do_test pragma-9.10 {
   852    852     catchsql "
   853    853       PRAGMA temp_store_directory='$pwd';
   854    854       SELECT * FROM temp_store_directory_test;
   855    855     "
   856    856   } {1 {no such table: temp_store_directory_test}}
          857  +
          858  +do_test pragma-9.11 {
          859  +  execsql {
          860  +    PRAGMA temp_store = 0;
          861  +    PRAGMA temp_store;
          862  +  }
          863  +} {0}
          864  +do_test pragma-9.12 {
          865  +  execsql {
          866  +    PRAGMA temp_store = 1;
          867  +    PRAGMA temp_store;
          868  +  }
          869  +} {1}
          870  +do_test pragma-9.13 {
          871  +  execsql {
          872  +    PRAGMA temp_store = 2;
          873  +    PRAGMA temp_store;
          874  +  }
          875  +} {2}
          876  +do_test pragma-9.14 {
          877  +  execsql {
          878  +    PRAGMA temp_store = 3;
          879  +    PRAGMA temp_store;
          880  +  }
          881  +} {0}
          882  +breakpoint
          883  +do_test pragma-9.15 {
          884  +  catchsql {
          885  +    BEGIN EXCLUSIVE;
          886  +    CREATE TEMP TABLE temp_table(t);
          887  +    INSERT INTO temp_table VALUES('valuable data');
          888  +    PRAGMA temp_store = 1;
          889  +  }
          890  +} {1 {temporary storage cannot be changed from within a transaction}}
          891  +do_test pragma-9.16 {
          892  +  execsql {
          893  +    SELECT * FROM temp_table;
          894  +    COMMIT;
          895  +  }
          896  +} {{valuable data}}
   857    897   } ;# ifcapable pager_pragmas
   858    898   
   859    899   ifcapable trigger {
   860    900   
   861    901   do_test pragma-10.0 {
   862    902     catchsql {
   863    903       DROP TABLE main.t1;