SQLite

Check-in [d28d1d68e5]
Login

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

Overview
Comment:Add the schema_cookie and user_cookie pragmas. (CVS 2089)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d28d1d68e5104726e6088361dfa7bf2cdd9985c7
User & Date: danielk1977 2004-11-11 05:10:44.000
Context
2004-11-11
19:32
Website updates. (CVS 2090) (check-in: 60fb0cef09 user: drh tags: trunk)
05:10
Add the schema_cookie and user_cookie pragmas. (CVS 2089) (check-in: d28d1d68e5 user: danielk1977 tags: trunk)
01:50
Add documentation for DEFAULT CURRENT_TIME & co. (CVS 2088) (check-in: c85f13f8f2 user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.263 2004/10/06 15:41:17 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** The following constant value is used by the SQLITE_BIGENDIAN and







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.264 2004/11/11 05:10:44 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** The following constant value is used by the SQLITE_BIGENDIAN and
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
  **
  ** Meta values are as follows:
  **    meta[0]   Schema cookie.  Changes with each schema change.
  **    meta[1]   File format of schema layer.
  **    meta[2]   Size of the page cache.
  **    meta[3]   Use freelist if 0.  Autovacuum if greater than zero.
  **    meta[4]   Db text encoding. 1:UTF-8 3:UTF-16 LE 4:UTF-16 BE
  **    meta[5]
  **    meta[6]   
  **    meta[7]
  **    meta[8]
  **    meta[9]
  **
  ** Note: The hash defined SQLITE_UTF* symbols in sqliteInt.h correspond to
  ** the possible values of meta[4].







|







198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
  **
  ** Meta values are as follows:
  **    meta[0]   Schema cookie.  Changes with each schema change.
  **    meta[1]   File format of schema layer.
  **    meta[2]   Size of the page cache.
  **    meta[3]   Use freelist if 0.  Autovacuum if greater than zero.
  **    meta[4]   Db text encoding. 1:UTF-8 3:UTF-16 LE 4:UTF-16 BE
  **    meta[5]   The user cookie. Used by the application.
  **    meta[6]   
  **    meta[7]
  **    meta[8]
  **    meta[9]
  **
  ** Note: The hash defined SQLITE_UTF* symbols in sqliteInt.h correspond to
  ** the possible values of meta[4].
Changes to src/pragma.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
** 2003 April 6
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    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.75 2004/11/09 12:44:38 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
# include "pager.h"
# include "btree.h"













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
** 2003 April 6
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    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.76 2004/11/11 05:10:44 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
# include "pager.h"
# include "btree.h"
720
721
722
723
724
725
726



























































727
728
729
730
731
732
733
        }
        if( !pEnc->zName ){
          sqlite3ErrorMsg(pParse, "unsupported encoding: %s", zRight);
        }
      }
    }
  }else




























































#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
  /*
  ** Report the current state of file logs for all databases
  */
  if( sqlite3StrICmp(zLeft, "lock_status")==0 ){
    static const char *const azLockName[] = {







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







720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
        }
        if( !pEnc->zName ){
          sqlite3ErrorMsg(pParse, "unsupported encoding: %s", zRight);
        }
      }
    }
  }else
  /*
  **   PRAGMA [database.]schema_cookie
  **   PRAGMA [database.]schema_cookie = <integer>
  **
  **   PRAGMA [database.]user_cookie
  **   PRAGMA [database.]user_cookie = <integer>
  **
  ** The pragma's schema_cookie and user_cookie are used to set or get
  ** the value of the schema-cookie and user-cookie, respectively. Both
  ** the schema-cookie and the user-cookie are 32-bit signed integers
  ** stored in the database header.
  **
  ** The schema-cookie is usually only manipulated internally by SQLite. It
  ** is incremented by SQLite whenever the database schema is modified (by
  ** creating or dropping a table or index). The schema cookie is used by
  ** SQLite each time a query is executed to ensure that the internal cache
  ** of the schema used when compiling the SQL query matches the schema of
  ** the database against which the compiled query is actually executed.
  ** Subverting this mechanism by using "PRAGMA schema_cookie" to modify
  ** the schema-cookie is potentially dangerous and may lead to program
  ** crashes or database corruption. Use with caution!
  **
  ** The user-cookie is not used internally by SQLite. It may be used by
  ** applications for any purpose.
  */
  if( sqlite3StrICmp(zLeft, "schema_cookie")==0 ||
      sqlite3StrICmp(zLeft, "user_cookie")==0 ){

    int iCookie;   /* Cookie index. 0 for schema-cookie, 6 for user-cookie. */
    if( zLeft[0]=='s' || zLeft[0]=='S' ){
      iCookie = 0;
    }else{
      iCookie = 5;
    }

    if( zRight ){
      /* Write the specified cookie value */
      static const VdbeOpList setCookie[] = {
        { OP_Transaction,    0,  1,  0},    /* 0 */
        { OP_Integer,        0,  0,  0},    /* 1 */
        { OP_SetCookie,      0,  0,  0},    /* 2 */
      };
      int addr = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie);
      sqlite3VdbeChangeP1(v, addr, iDb);
      sqlite3VdbeChangeP1(v, addr+1, atoi(zRight));
      sqlite3VdbeChangeP1(v, addr+2, iDb);
      sqlite3VdbeChangeP2(v, addr+2, iCookie);
    }else{
      /* Read the specified cookie value */
      static const VdbeOpList readCookie[] = {
        { OP_ReadCookie,      0,  0,  0},    /* 0 */
        { OP_Callback,        1,  0,  0}
      };
      int addr = sqlite3VdbeAddOpList(v, ArraySize(readCookie), readCookie);
      sqlite3VdbeChangeP1(v, addr, iDb);
      sqlite3VdbeChangeP2(v, addr, iCookie);
      sqlite3VdbeSetNumCols(v, 1);
    }
  }

#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
  /*
  ** Report the current state of file logs for all databases
  */
  if( sqlite3StrICmp(zLeft, "lock_status")==0 ){
    static const char *const azLockName[] = {
Changes to test/pragma.test.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    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.21 2004/11/04 14:47:13 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.







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    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.22 2004/11/11 05:10:44 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.
363
364
365
366
367
368
369



370








































































































































































































371


  sqlite3 db test.db
  execsql {
    pragma lock_status;
  }
} {main unlocked temp closed}














































































































































































































finish_test









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

>
>
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
  sqlite3 db test.db
  execsql {
    pragma lock_status;
  }
} {main unlocked temp closed}


#----------------------------------------------------------------------
# Test cases pragma-8.* test the "PRAGMA schema_cookie" and "PRAGMA
# user_cookie" statements.
#
# pragma-8.1: PRAGMA schema_cookie
# pragma-8.2: PRAGMA user_cookie
#

# First check that we can set the schema cookie and then retrieve the
# same value.
do_test pragma-8.1.1 {
  execsql {
    PRAGMA schema_cookie = 105;
  }
} {}
do_test pragma-8.1.2 {
  execsql {
    PRAGMA schema_cookie;
  }
} 105
do_test pragma-8.1.3 {
  execsql {
    PRAGMA schema_cookie = 106;
  }
} {}
do_test pragma-8.1.4 {
  execsql {
    PRAGMA schema_cookie;
  }
} 106

# Check that creating a table modifies the schema-cookie (this is really
# to verify that the value being read is in fact the schema cookie).
do_test pragma-8.1.5 {
  execsql {
    CREATE TABLE t4(a, b, c);
    INSERT INTO t4 VALUES(1, 2, 3);
    SELECT * FROM t4;
  }
} {1 2 3}
do_test pragma-8.1.6 {
  execsql {
    PRAGMA schema_cookie;
  }
} 107

# Now open a second connection to the database. Ensure that changing the
# schema-cookie using the first connection forces the second connection
# to reload the schema. This has to be done using the C-API test functions,
# because the TCL API accounts for SCHEMA_ERROR and retries the query.
do_test pragma-8.1.7 {
  set ::DB2 [sqlite3 db2 test.db]
  execsql {
    SELECT * FROM t4;
  } db2
} {1 2 3}
do_test pragma-8.1.8 {
  execsql {
    PRAGMA schema_cookie = 108;
  }
} {}
do_test pragma-8.1.9 {
  set ::STMT [sqlite3_prepare $::DB2 "SELECT * FROM t4" -1 DUMMY]
  sqlite3_step $::STMT
} SQLITE_ERROR
do_test pragma-8.1.10 {
  sqlite3_finalize $::STMT
} SQLITE_SCHEMA

# Make sure the schema-cookie can be manipulated in an attached database.
file delete -force test2.db
file delete -force test2.db-journal
do_test pragma-8.1.11 {
  execsql {
    ATTACH 'test2.db' AS aux;
    CREATE TABLE aux.t1(a, b, c);
    PRAGMA aux.schema_cookie = 205;
  }
} {}
do_test pragma-8.1.12 {
  execsql {
    PRAGMA aux.schema_cookie;
  }
} 205
do_test pragma-8.1.13 {
  execsql {
    PRAGMA schema_cookie;
  }
} 108

# And check that modifying the schema-cookie in an attached database
# forces the second connection to reload the schema.
do_test pragma-8.1.14 {
  set ::DB2 [sqlite3 db2 test.db]
  execsql {
    ATTACH 'test2.db' AS aux;
    SELECT * FROM aux.t1;
  } db2
} {}
do_test pragma-8.1.15 {
  execsql {
    PRAGMA aux.schema_cookie = 206;
  }
} {}
do_test pragma-8.1.16 {
  set ::STMT [sqlite3_prepare $::DB2 "SELECT * FROM aux.t1" -1 DUMMY]
  sqlite3_step $::STMT
} SQLITE_ERROR
do_test pragma-8.1.17 {
  sqlite3_finalize $::STMT
} SQLITE_SCHEMA
do_test pragma-8.1.18 {
  db2 close
} {}

# Now test that the user-cookie can be read and written (and that we aren't
# accidentally manipulating the schema-cookie instead).
do_test pragma-8.2.1 {
  execsql {
    PRAGMA user_cookie;
  }
} {0}
do_test pragma-8.2.2 {
  execsql {
    PRAGMA user_cookie = 2;
  }
} {}
do_test pragma-8.2.3 {
  execsql {
    PRAGMA user_cookie;
  }
} {2}
do_test pragma-8.2.4 {
  execsql {
    PRAGMA schema_cookie;
  }
} {108}

# Check that the user-cookie in the auxilary database can be manipulated (
# and that we aren't accidentally manipulating the same in the main db).
do_test pragma-8.2.5 {
  execsql {
    PRAGMA aux.user_cookie;
  }
} {0}
do_test pragma-8.2.6 {
  execsql {
    PRAGMA aux.user_cookie = 3;
  }
} {}
do_test pragma-8.2.7 {
  execsql {
    PRAGMA aux.user_cookie;
  }
} {3}
do_test pragma-8.2.8 {
  execsql {
    PRAGMA main.user_cookie;
  }
} {2}

# Now check that a ROLLBACK resets the user-cookie if it has been modified
# within a transaction.
do_test pragma-8.2.9 {
  execsql {
    BEGIN;
    PRAGMA aux.user_cookie = 10;
    PRAGMA user_cookie = 11;
  }
} {}
do_test pragma-8.2.10 {
  execsql {
    PRAGMA aux.user_cookie;
  }
} {10}
do_test pragma-8.2.11 {
  execsql {
    PRAGMA main.user_cookie;
  }
} {11}
do_test pragma-8.2.12 {
  execsql {
    ROLLBACK;
    PRAGMA aux.user_cookie;
  }
} {3}
do_test pragma-8.2.13 {
  execsql {
    PRAGMA main.user_cookie;
  }
} {2}

# Try a negative value for the user-cookie
do_test pragma-8.2.14 {
  execsql {
    PRAGMA user_cookie = -450;
  }
} {}
do_test pragma-8.2.15 {
  execsql {
    PRAGMA user_cookie;
  }
} {-450}

finish_test


Changes to www/pragma.tcl.
1
2
3
4
5
6
7
8
9
10
11
#
# Run this Tcl script to generate the pragma.html file.
#
set rcsid {$Id: pragma.tcl,v 1.1 2004/11/10 05:48:57 danielk1977 Exp $}
source common.tcl
header {Pragma statements supported by SQLite}

puts {
<p>The <a href="#syntax">PRAGMA command</a> is a special command used to 
modify the operation of the SQLite library or to query the library for 
internal (non-table) data. The PRAGMA command is issued using the same



|







1
2
3
4
5
6
7
8
9
10
11
#
# Run this Tcl script to generate the pragma.html file.
#
set rcsid {$Id: pragma.tcl,v 1.2 2004/11/11 05:10:44 danielk1977 Exp $}
source common.tcl
header {Pragma statements supported by SQLite}

puts {
<p>The <a href="#syntax">PRAGMA command</a> is a special command used to 
modify the operation of the SQLite library or to query the library for 
internal (non-table) data. The PRAGMA command is issued using the same
23
24
25
26
27
28
29
30
31
32
33
34
35
36


37
38
39
40
41
42
43
    sqlite3_step(), sqlite3_finalize() API (or similar in a wrapper 
    interface), the pragma may be applied to the library during the 
    sqlite3_compile() call.
<li>The pragma command is unlikely to be compatible with any other SQL
    engine.
</ul>

<p>The available pragma's fall into three basic categories:</p>
<ul>
<li>Pragmas used to <a href="#schema">query the schema</a> of the current 
    database.
<li>Pragmas used to <a href="#modify">modify the operation</a> of the 
    SQLite library in some manner, or to query for the current mode of 
    operation.


<li>Pragmas used to <a href="#debug">debug the library</a> and verify that
    database files are not corrupted.
</ul>
}

Section {PRAGMA command syntax} syntax








|






>
>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    sqlite3_step(), sqlite3_finalize() API (or similar in a wrapper 
    interface), the pragma may be applied to the library during the 
    sqlite3_compile() call.
<li>The pragma command is unlikely to be compatible with any other SQL
    engine.
</ul>

<p>The available pragmas fall into four basic categories:</p>
<ul>
<li>Pragmas used to <a href="#schema">query the schema</a> of the current 
    database.
<li>Pragmas used to <a href="#modify">modify the operation</a> of the 
    SQLite library in some manner, or to query for the current mode of 
    operation.
<li>Pragmas used to <a href="#cookie">query or modify the databases two 
    cookie values</a>, the schema-cookie and the user-cookie.
<li>Pragmas used to <a href="#debug">debug the library</a> and verify that
    database files are not corrupted.
</ul>
}

Section {PRAGMA command syntax} syntax

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
are equivalent to <b>1</b>.  The strings "<b>off</b>", "<b>false</b>", 
and "<b>no</b>" are equivalent to <b>0</b>.  These strings are case-
insensitive, and do not require quotes.  An unrecognized string will be 
treated as <b>1</b>, and will not generate an error.  When the <i>value</i> 
is returned it is as an integer.</p>
}

Section {Pragmas used to modify library operation} modify

puts {
<ul>
<a name="pragma_auto_vacuum"></a>
<li><p><b>PRAGMA auto_vacuum;
       <br>PRAGMA auto_vacuum = </b><i>0 | 1</i><b>;</b></p>
    <p> Query or set the auto-vacuum flag in the database.</p>







|







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
are equivalent to <b>1</b>.  The strings "<b>off</b>", "<b>false</b>", 
and "<b>no</b>" are equivalent to <b>0</b>.  These strings are case-
insensitive, and do not require quotes.  An unrecognized string will be 
treated as <b>1</b>, and will not generate an error.  When the <i>value</i> 
is returned it is as an integer.</p>
}

Section {Pragmas to modify library operation} modify

puts {
<ul>
<a name="pragma_auto_vacuum"></a>
<li><p><b>PRAGMA auto_vacuum;
       <br>PRAGMA auto_vacuum = </b><i>0 | 1</i><b>;</b></p>
    <p> Query or set the auto-vacuum flag in the database.</p>
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
    <p>When the temp_store setting is changed, all existing temporary
    tables, indices, triggers, and viewers are immediately deleted.
    </p>
    </li>
</ul>
}

Section {Pragma's used to query the database schema} schema

puts {
<ul>
<li><p><b>PRAGMA database_list;</b></p>
    <p>For each open database, invoke the callback function once with
    information about that database.  Arguments include the index and 
    the name the database was attached with.  The first row will be for 







|







208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
    <p>When the temp_store setting is changed, all existing temporary
    tables, indices, triggers, and viewers are immediately deleted.
    </p>
    </li>
</ul>
}

Section {Pragmas to query the database schema} schema

puts {
<ul>
<li><p><b>PRAGMA database_list;</b></p>
    <p>For each open database, invoke the callback function once with
    information about that database.  Arguments include the index and 
    the name the database was attached with.  The first row will be for 
243
244
245
246
247
248
249
































250
251
252
253
254
255
256
257
    <p>For each column in the named table, invoke the callback function
    once with information about that column, including the column name,
    data type, whether or not the column can be NULL, and the default
    value for the column.</p></li>
</ul>
}

































Section {Pragma's used to debug the library} debug

puts {
<ul>
<li><p><b>PRAGMA integrity_check;</b></p>
    <p>The command does an integrity check of the entire database.  It
    looks for out-of-order records, missing pages, malformed records, and
    corrupt indices.







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







245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
    <p>For each column in the named table, invoke the callback function
    once with information about that column, including the column name,
    data type, whether or not the column can be NULL, and the default
    value for the column.</p></li>
</ul>
}

Section {Pragmas to query/modify cookie values} cookie

puts {

<ul>
<li><p><b>PRAGMA [database.]schema_cookie; 
       <br>PRAGMA [database.]schema_cookie = </b><i>integer </i><b>;
       <br>PRAGMA [database.]user_cookie;
       <br>PRAGMA [database.]user_cookie = </b><i>integer </i><b>;</b>

  
<p>    The pragmas schema_cookie and user_cookie are used to set or get
       the value of the schema-cookie and user-cookie, respectively. Both
       the schema-cookie and the user-cookie are 32-bit signed integers
       stored in the database header.</p>
  
<p>    The schema-cookie is usually only manipulated internally by SQLite.  
       It is incremented by SQLite whenever the database schema is modified 
       (by creating or dropping a table or index). The schema cookie is 
       used by SQLite each time a query is executed to ensure that the 
       internal cache of the schema used when compiling the SQL query matches 
       the schema of the database against which the compiled query is actually 
       executed.  Subverting this mechanism by using "PRAGMA schema_cookie" 
       to modify the schema-cookie is potentially dangerous and may lead 
       to program crashes or database corruption. Use with caution!</p>
  
<p>    The user-cookie is not used internally by SQLite. It may be used by
       applications for any purpose.</p>
</li>
</ul>
}

Section {Pragmas to debug the library} debug

puts {
<ul>
<li><p><b>PRAGMA integrity_check;</b></p>
    <p>The command does an integrity check of the entire database.  It
    looks for out-of-order records, missing pages, malformed records, and
    corrupt indices.