SQLite

Check-in [c326356f9a]
Login

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

Overview
Comment:Add the soft_heap_limit pragma.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c326356f9a18bff5cf36bd59331e2cc207e349fa
User & Date: drh 2013-09-13 21:01:56.467
Context
2013-09-13
21:03
Fix the "const" qualifiers on the pragma name table. (check-in: b74e6be818 user: drh tags: trunk)
21:01
Add the soft_heap_limit pragma. (check-in: c326356f9a user: drh tags: trunk)
19:00
Tweak the new PRAGMA name parser to achieve full branch test coverage. (check-in: c82e05c4b8 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pragma.c.
51
52
53
54
55
56
57

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#define PragTyp_LOCK_PROXY_FILE               20
#define PragTyp_LOCKING_MODE                  21
#define PragTyp_PAGE_COUNT                    22
#define PragTyp_MMAP_SIZE                     23
#define PragTyp_PAGE_SIZE                     24
#define PragTyp_SECURE_DELETE                 25
#define PragTyp_SHRINK_MEMORY                 26

#define PragTyp_SYNCHRONOUS                   27
#define PragTyp_TABLE_INFO                    28
#define PragTyp_TEMP_STORE                    29
#define PragTyp_TEMP_STORE_DIRECTORY          30
#define PragTyp_WAL_AUTOCHECKPOINT            31
#define PragTyp_WAL_CHECKPOINT                32
#define PragTyp_ACTIVATE_EXTENSIONS           33
#define PragTyp_HEXKEY                        34
#define PragTyp_KEY                           35
#define PragTyp_REKEY                         36
#define PragTyp_LOCK_STATUS                   37
#define PragTyp_PARSER_TRACE                  38
static const struct sPragmaNames {
  const char const *zName;  /* Name of pragma */
  u8 ePragTyp;              /* PragTyp_XXX value */
  u32 iArg;                 /* Extra argument */
} aPragmaNames[] = {
#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
  { "activate_extensions",     PragTyp_ACTIVATE_EXTENSIONS,    0 },







>
|
|
|
|
|
|
|
|
|
|
|
|







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#define PragTyp_LOCK_PROXY_FILE               20
#define PragTyp_LOCKING_MODE                  21
#define PragTyp_PAGE_COUNT                    22
#define PragTyp_MMAP_SIZE                     23
#define PragTyp_PAGE_SIZE                     24
#define PragTyp_SECURE_DELETE                 25
#define PragTyp_SHRINK_MEMORY                 26
#define PragTyp_SOFT_HEAP_LIMIT               27
#define PragTyp_SYNCHRONOUS                   28
#define PragTyp_TABLE_INFO                    29
#define PragTyp_TEMP_STORE                    30
#define PragTyp_TEMP_STORE_DIRECTORY          31
#define PragTyp_WAL_AUTOCHECKPOINT            32
#define PragTyp_WAL_CHECKPOINT                33
#define PragTyp_ACTIVATE_EXTENSIONS           34
#define PragTyp_HEXKEY                        35
#define PragTyp_KEY                           36
#define PragTyp_REKEY                         37
#define PragTyp_LOCK_STATUS                   38
#define PragTyp_PARSER_TRACE                  39
static const struct sPragmaNames {
  const char const *zName;  /* Name of pragma */
  u8 ePragTyp;              /* PragTyp_XXX value */
  u32 iArg;                 /* Extra argument */
} aPragmaNames[] = {
#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
  { "activate_extensions",     PragTyp_ACTIVATE_EXTENSIONS,    0 },
198
199
200
201
202
203
204

205
206
207
208
209
210
211
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
  { "secure_delete",           PragTyp_SECURE_DELETE,          0 },
#endif
  { "short_column_names",      PragTyp_FLAG,                  
                               SQLITE_ShortColNames },
  { "shrink_memory",           PragTyp_SHRINK_MEMORY,          0 },

#if defined(SQLITE_DEBUG)
  { "sql_trace",               PragTyp_FLAG,                  
                               SQLITE_SqlTrace },
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
  { "synchronous",             PragTyp_SYNCHRONOUS,            0 },
#endif







>







199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
  { "secure_delete",           PragTyp_SECURE_DELETE,          0 },
#endif
  { "short_column_names",      PragTyp_FLAG,                  
                               SQLITE_ShortColNames },
  { "shrink_memory",           PragTyp_SHRINK_MEMORY,          0 },
  { "soft_heap_limit",         PragTyp_SOFT_HEAP_LIMIT,        0 },
#if defined(SQLITE_DEBUG)
  { "sql_trace",               PragTyp_FLAG,                  
                               SQLITE_SqlTrace },
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
  { "synchronous",             PragTyp_SYNCHRONOUS,            0 },
#endif
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#if !defined(SQLITE_OMIT_WAL)
  { "wal_autocheckpoint",      PragTyp_WAL_AUTOCHECKPOINT,     0 },
  { "wal_checkpoint",          PragTyp_WAL_CHECKPOINT,         0 },
#endif
  { "writable_schema",         PragTyp_FLAG,                  
                               SQLITE_WriteSchema|SQLITE_RecoveryMode },
};
/* Number of pragmas: 54 on by default, 65 total. */
/* End of the automatically generated pragma table.
***************************************************************************/

/*
** Interpret the given string as a safety level.  Return 0 for OFF,
** 1 for ON or NORMAL and 2 for FULL.  Return 1 for an empty or 
** unrecognized string argument.  The FULL option is disallowed







|







234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#if !defined(SQLITE_OMIT_WAL)
  { "wal_autocheckpoint",      PragTyp_WAL_AUTOCHECKPOINT,     0 },
  { "wal_checkpoint",          PragTyp_WAL_CHECKPOINT,         0 },
#endif
  { "writable_schema",         PragTyp_FLAG,                  
                               SQLITE_WriteSchema|SQLITE_RecoveryMode },
};
/* Number of pragmas: 55 on by default, 66 total. */
/* End of the automatically generated pragma table.
***************************************************************************/

/*
** Interpret the given string as a safety level.  Return 0 for OFF,
** 1 for ON or NORMAL and 2 for FULL.  Return 1 for an empty or 
** unrecognized string argument.  The FULL option is disallowed
1961
1962
1963
1964
1965
1966
1967
















1968
1969
1970
1971
1972
1973
1974
    assert( aPragmaNames[mid].ePragTyp==PragTyp_BUSY_TIMEOUT );
    if( zRight ){
      sqlite3_busy_timeout(db, sqlite3Atoi(zRight));
    }
    returnSingleInt(pParse, "timeout",  db->busyTimeout);
    break;
  }

















#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
  /*
  ** Report the current state of file logs for all databases
  */
  case PragTyp_LOCK_STATUS: {
    static const char *const azLockName[] = {







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







1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
    assert( aPragmaNames[mid].ePragTyp==PragTyp_BUSY_TIMEOUT );
    if( zRight ){
      sqlite3_busy_timeout(db, sqlite3Atoi(zRight));
    }
    returnSingleInt(pParse, "timeout",  db->busyTimeout);
    break;
  }

  /*
  **   PRAGMA soft_heap_limit
  **   PRAGMA soft_heap_limit = N
  **
  ** Call sqlite3_soft_heap_limit64(N).  Return the result.  If N is omitted,
  ** use -1.
  */
  case PragTyp_SOFT_HEAP_LIMIT: {
    sqlite3_int64 N;
    if( zRight && sqlite3Atoi64(zRight, &N, 1000000, SQLITE_UTF8)==SQLITE_OK ){
      sqlite3_soft_heap_limit64(N);
    }
    returnSingleInt(pParse, "soft_heap_limit",  sqlite3_soft_heap_limit64(-1));
    break;
  }

#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
  /*
  ** Report the current state of file logs for all databases
  */
  case PragTyp_LOCK_STATUS: {
    static const char *const azLockName[] = {
Changes to test/softheap1.test.
20
21
22
23
24
25
26


27




28








29
30



31
32
33
34
35
36
37
source $testdir/tester.tcl

ifcapable !integrityck {
  finish_test
  return
}



sqlite3_soft_heap_limit -1




sqlite3_soft_heap_limit 0








sqlite3_soft_heap_limit 5000
do_test softheap1-1.1 {



  execsql {
    PRAGMA auto_vacuum=1;
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES(hex(randomblob(1000)));
    BEGIN;
  }
  execsql {







>
>
|
>
>
>
>
|
>
>
>
>
>
>
>
>

|
>
>
>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
source $testdir/tester.tcl

ifcapable !integrityck {
  finish_test
  return
}

do_test softheap1-1.0 {
  execsql {PRAGMA soft_heap_limit}
} [sqlite3_soft_heap_limit -1]
do_test softheap1-1.1 {
  execsql {PRAGMA soft_heap_limit=123456; PRAGMA soft_heap_limit;}
} {123456 123456}
do_test softheap1-1.2 {
  sqlite3_soft_heap_limit -1
} {123456}
do_test softheap1-1.3 {
  execsql {PRAGMA soft_heap_limit(-1); PRAGMA soft_heap_limit;}
} {123456 123456}
do_test softheap1-1.4 {
  execsql {PRAGMA soft_heap_limit(0); PRAGMA soft_heap_limit;}
} {0 0}

sqlite3_soft_heap_limit 5000
do_test softheap1-2.0 {
  execsql {PRAGMA soft_heap_limit}
} {5000}
do_test softheap1-2.1 {
  execsql {
    PRAGMA auto_vacuum=1;
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES(hex(randomblob(1000)));
    BEGIN;
  }
  execsql {
Changes to tool/mkpragmatab.tcl.
235
236
237
238
239
240
241


242
243
244
245
246
247
248
  IF:   defined(SQLITE_HAS_CODEC)

  NAME: hexkey
  IF:   defined(SQLITE_HAS_CODEC)

  NAME: activate_extensions
  IF:   defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)


}
set name {}
set type {}
set if {}
set arg 0
proc record_one {} {
  global name type if arg allbyname typebyif







>
>







235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
  IF:   defined(SQLITE_HAS_CODEC)

  NAME: hexkey
  IF:   defined(SQLITE_HAS_CODEC)

  NAME: activate_extensions
  IF:   defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)

  NAME: soft_heap_limit
}
set name {}
set type {}
set if {}
set arg 0
proc record_one {} {
  global name type if arg allbyname typebyif