/ 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 Unified Diffs Show Whitespace Changes Patch

Changes to src/pragma.c.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
** $Id: pragma.c,v 1.131 2007/03/30 11:12:08 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/* Ignore this whole file if pragmas are disabled
*/
................................................................................
/*
** Invalidate temp storage, either when the temp storage is changed
** from default, or when 'file' and the temp_store_directory has changed
*/
static int invalidateTempStorage(Parse *pParse){
  sqlite3 *db = pParse->db;
  if( db->aDb[1].pBt!=0 ){
    if( db->flags & SQLITE_InTrans ){
      sqlite3ErrorMsg(pParse, "temporary storage cannot be changed "
        "from within a transaction");
      return SQLITE_ERROR;
    }
    sqlite3BtreeClose(db->aDb[1].pBt);
    db->aDb[1].pBt = 0;
    sqlite3ResetInternalSchema(db, 0);







|







 







|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
** $Id: pragma.c,v 1.132 2007/03/30 17:11:13 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/* Ignore this whole file if pragmas are disabled
*/
................................................................................
/*
** Invalidate temp storage, either when the temp storage is changed
** from default, or when 'file' and the temp_store_directory has changed
*/
static int invalidateTempStorage(Parse *pParse){
  sqlite3 *db = pParse->db;
  if( db->aDb[1].pBt!=0 ){
    if( !db->autoCommit ){
      sqlite3ErrorMsg(pParse, "temporary storage cannot be changed "
        "from within a transaction");
      return SQLITE_ERROR;
    }
    sqlite3BtreeClose(db->aDb[1].pBt);
    db->aDb[1].pBt = 0;
    sqlite3ResetInternalSchema(db, 0);

Changes to test/misc7.test.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
61
62
63
64
65
66
67
68
69
70
71
72

73
74
75

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

















99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
...
212
213
214
215
216
217
218




219
















220
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# $Id: misc7.test,v 1.6 2007/03/30 14:56:35 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_test misc7-1 {
  c_misuse_test
} {}
................................................................................
  set ret [list]
  catch {
    while 1 { lappend ret [open test.db] }
  }
  return $ret
}

execsql { CREATE TABLE abc(a PRIMARY KEY, b, c); }
db close
set fd_list [use_up_files]
set ::go 1
set ::n 1

while {$::go} {
  catch {db close}
  do_test misc7-6.$::n {

    set rc [catch {
      sqlite db test.db
      db eval {
        BEGIN;
        INSERT INTO abc VALUES(1, 2, 3);
        INSERT INTO abc VALUES(2, 3, 4);
        INSERT INTO abc SELECT a+2, b, c FROM abc;
        COMMIT;
      }
    } msg]
    if {$rc == 0} {set ::go 0}

    expr {$rc == 0 || ($rc == 1 && $msg eq "unable to open database file")}
  } 1

  close [lindex $fd_list 0]
  set fd_list [lrange $fd_list 1 end]
  incr ::n
}
foreach fd $fd_list {
  close $fd
}
db close

















#
# End of tests for out-of-file-descriptors condition.
#--------------------------------------------------------------------

sqlite3 db test.db
#--------------------------------------------------------------------
# Test that the sqlite3_busy_timeout call seems to delay approximately
# the right amount of time.
#
do_test misc7-6 {
  sqlite3 db2 test.db
  sqlite3_busy_timeout [sqlite3_connection_pointer db] 2000
  execsql {
    BEGIN EXCLUSIVE;
  } db2

  # Now db2 has an exclusive lock on the database file, and db has
................................................................................
    register_echo_module [sqlite3_connection_pointer db]
    set ::echo_module_cost 2.0e+99
    execsql {SELECT * FROM t1 WHERE a = 1;}
  } {1 2 3}
  unset ::echo_module_cost
}






















finish_test







|







 







|
<



>
|
|
<
>
|
|
|
<
<
<
<
<
<



|










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









|







 







>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
61
62
63
64
65
66
67
68

69
70
71
72
73
74

75
76
77
78






79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
...
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# $Id: misc7.test,v 1.7 2007/03/30 17:11:13 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_test misc7-1 {
  c_misuse_test
} {}
................................................................................
  set ret [list]
  catch {
    while 1 { lappend ret [open test.db] }
  }
  return $ret
}

proc do_fileopen_test {prefix sql} {

  set fd_list [use_up_files]
  set ::go 1
  set ::n 1
  set ::sql $sql
  while {$::go} {
    catch {db close}

    do_test ${prefix}.${::n} {
      set rc [catch {
        sqlite db test.db
        db eval $::sql






      } msg]
      if {$rc == 0} {set ::go 0}
  
      expr {$rc == 0 || ($rc == 1 && [string first unable $msg]==0)}
    } 1
  
    close [lindex $fd_list 0]
    set fd_list [lrange $fd_list 1 end]
    incr ::n
  }
  foreach fd $fd_list {
    close $fd
  }
  db close
}

execsql { CREATE TABLE abc(a PRIMARY KEY, b, c); }
db close

do_fileopen_test misc7-6.1 {
  BEGIN;
  INSERT INTO abc VALUES(1, 2, 3);
  INSERT INTO abc VALUES(2, 3, 4);
  INSERT INTO abc SELECT a+2, b, c FROM abc;
  COMMIT;
}

do_fileopen_test misc7-6.2 {
  PRAGMA temp.cache_size = 1000;
}

#
# End of tests for out-of-file-descriptors condition.
#--------------------------------------------------------------------

sqlite3 db test.db
#--------------------------------------------------------------------
# Test that the sqlite3_busy_timeout call seems to delay approximately
# the right amount of time.
#
do_test misc7-7.0 {
  sqlite3 db2 test.db
  sqlite3_busy_timeout [sqlite3_connection_pointer db] 2000
  execsql {
    BEGIN EXCLUSIVE;
  } db2

  # Now db2 has an exclusive lock on the database file, and db has
................................................................................
    register_echo_module [sqlite3_connection_pointer db]
    set ::echo_module_cost 2.0e+99
    execsql {SELECT * FROM t1 WHERE a = 1;}
  } {1 2 3}
  unset ::echo_module_cost
}

db close
file delete -force test.db
file delete -force test.db-journal
sqlite3 db test.db

ifcapable explain {
  do_test misc7-14 {
    execsql {
      CREATE TABLE abc(a PRIMARY KEY, b, c);
    }
    execsql {
      EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid = 1;
    }
  } {0 0 {TABLE abc AS t2 USING PRIMARY KEY}}
  do_test misc7-15 {
    execsql {
      EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE a = 1;
    }
  } {0 0 {TABLE abc AS t2 WITH INDEX sqlite_autoindex_abc_1}}
}

finish_test

Changes to test/pragma.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
850
851
852
853
854
855
856








































857
858
859
860
861
862
863
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the PRAGMA command.
#
# $Id: pragma.test,v 1.51 2007/01/27 14:26:07 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test organization:
#
# pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
................................................................................
}
do_test pragma-9.10 {
  catchsql "
    PRAGMA temp_store_directory='$pwd';
    SELECT * FROM temp_store_directory_test;
  "
} {1 {no such table: temp_store_directory_test}}








































} ;# ifcapable pager_pragmas

ifcapable trigger {

do_test pragma-10.0 {
  catchsql {
    DROP TABLE main.t1;







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the PRAGMA command.
#
# $Id: pragma.test,v 1.52 2007/03/30 17:11:13 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test organization:
#
# pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
................................................................................
}
do_test pragma-9.10 {
  catchsql "
    PRAGMA temp_store_directory='$pwd';
    SELECT * FROM temp_store_directory_test;
  "
} {1 {no such table: temp_store_directory_test}}

do_test pragma-9.11 {
  execsql {
    PRAGMA temp_store = 0;
    PRAGMA temp_store;
  }
} {0}
do_test pragma-9.12 {
  execsql {
    PRAGMA temp_store = 1;
    PRAGMA temp_store;
  }
} {1}
do_test pragma-9.13 {
  execsql {
    PRAGMA temp_store = 2;
    PRAGMA temp_store;
  }
} {2}
do_test pragma-9.14 {
  execsql {
    PRAGMA temp_store = 3;
    PRAGMA temp_store;
  }
} {0}
breakpoint
do_test pragma-9.15 {
  catchsql {
    BEGIN EXCLUSIVE;
    CREATE TEMP TABLE temp_table(t);
    INSERT INTO temp_table VALUES('valuable data');
    PRAGMA temp_store = 1;
  }
} {1 {temporary storage cannot be changed from within a transaction}}
do_test pragma-9.16 {
  execsql {
    SELECT * FROM temp_table;
    COMMIT;
  }
} {{valuable data}}
} ;# ifcapable pager_pragmas

ifcapable trigger {

do_test pragma-10.0 {
  catchsql {
    DROP TABLE main.t1;