SQLite

Check-in [c82e05c4b8]
Login

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

Overview
Comment:Tweak the new PRAGMA name parser to achieve full branch test coverage.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c82e05c4b8e000684d95ac8417afaef5e4d633e6
User & Date: drh 2013-09-13 19:00:06.116
Context
2013-09-13
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)
18:15
Remove one unreachable branch and add asserts() to dupedExprStructSize(). New asserts verify that removed branch is unused and that constants that are ORed together in the output do not overlap. (check-in: 86ad358b5a user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pragma.c.
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#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 */
  int ePragTyp;             /* PragTyp_XXX value */
  u32 iArg;                 /* Extra argument */
} aPragmaNames[] = {
#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
  { "activate_extensions",     PragTyp_ACTIVATE_EXTENSIONS,    0 },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
  { "application_id",          PragTyp_HEADER_VALUE,           0 },







|







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#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 },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
  { "application_id",          PragTyp_HEADER_VALUE,           0 },
232
233
234
235
236
237
238

239
240
241
242
243
244
245
#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 },
};

/* 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







>







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
1952
1953
1954
1955
1956
1957
1958
1959

1960
1961
1962
1963
1964
1965
1966
  **   PRAGMA busy_timeout = N
  **
  ** Call sqlite3_busy_timeout(db, N).  Return the current timeout value
  ** if one is set.  If no busy handler or a different busy handler is set
  ** then 0 is returned.  Setting the busy_timeout to 0 or negative
  ** disables the timeout.
  */
  case PragTyp_BUSY_TIMEOUT: {

    if( zRight ){
      sqlite3_busy_timeout(db, sqlite3Atoi(zRight));
    }
    returnSingleInt(pParse, "timeout",  db->busyTimeout);
    break;
  }








|
>







1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
  **   PRAGMA busy_timeout = N
  **
  ** Call sqlite3_busy_timeout(db, N).  Return the current timeout value
  ** if one is set.  If no busy handler or a different busy handler is set
  ** then 0 is returned.  Setting the busy_timeout to 0 or negative
  ** disables the timeout.
  */
  /*case PragTyp_BUSY_TIMEOUT*/ default: {
    assert( aPragmaNames[mid].ePragTyp==PragTyp_BUSY_TIMEOUT );
    if( zRight ){
      sqlite3_busy_timeout(db, sqlite3Atoi(zRight));
    }
    returnSingleInt(pParse, "timeout",  db->busyTimeout);
    break;
  }

Changes to tool/mkpragmatab.tcl.
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
  incr pnum
}

# Generate the lookup table
#
puts "static const struct sPragmaNames \173"
puts "  const char const *zName;  /* Name of pragma */"
puts "  int ePragTyp;             /* PragTyp_XXX value */"
puts "  u32 iArg;                 /* Extra argument */"
puts "\175 aPragmaNames\[\] = \173"

set current_if {}
set spacer [format {    %26s } {}]
foreach name $allnames {
  foreach {type arg if} $allbyname($name) break







|







306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
  incr pnum
}

# Generate the lookup table
#
puts "static const struct sPragmaNames \173"
puts "  const char const *zName;  /* Name of pragma */"
puts "  u8 ePragTyp;              /* PragTyp_XXX value */"
puts "  u32 iArg;                 /* Extra argument */"
puts "\175 aPragmaNames\[\] = \173"

set current_if {}
set spacer [format {    %26s } {}]
foreach name $allnames {
  foreach {type arg if} $allbyname($name) break