1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Change pragmas schema_cookie and user_cookie to schema_version and user_version. (CVS 2094)

FossilOrigin-Name: 5e058318441bb5043c609cc8fba1653995e90efb
This commit is contained in:
danielk1977
2004-11-12 16:11:59 +00:00
parent 1c8c23cc36
commit b92b70bb0a
5 changed files with 81 additions and 81 deletions

View File

@@ -1,5 +1,5 @@
C Add\sauthorization\scallbacks\sto\sALTER\sTABLE.\s(CVS\s2093) C Change\spragmas\sschema_cookie\sand\suser_cookie\sto\sschema_version\sand\suser_version.\s(CVS\s2094)
D 2004-11-12T15:53:37 D 2004-11-12T16:12:00
F Makefile.in c4d2416860f472a1e3393714d0372074197565df F Makefile.in c4d2416860f472a1e3393714d0372074197565df
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
@@ -55,7 +55,7 @@ F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c ee88fcecb081e3635c281bc09d604e934429e2f5 F src/pager.c ee88fcecb081e3635c281bc09d604e934429e2f5
F src/pager.h 9eba8c53dd91eae7f3f90743b2ee242da02a9862 F src/pager.h 9eba8c53dd91eae7f3f90743b2ee242da02a9862
F src/parse.y b64ebeb91d9fc1c813f4517b80e3a3659e94b032 F src/parse.y b64ebeb91d9fc1c813f4517b80e3a3659e94b032
F src/pragma.c bb1c76dae9911b9312997b353c1e316fa603a0c6 F src/pragma.c 32ce8fad1a1e05eff97a3dfe02acc61b6936eeee
F src/printf.c 3d20b21cfecadacecac3fb7274e746cb81d3d357 F src/printf.c 3d20b21cfecadacecac3fb7274e746cb81d3d357
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
F src/select.c 156990c636102bb6b8de85e7ff3396a62568476b F src/select.c 156990c636102bb6b8de85e7ff3396a62568476b
@@ -157,7 +157,7 @@ F test/pager.test 394455707a079804e8a4e431d12edce831a065f0
F test/pager2.test c7e731ac56a2984a605b032ffd19b9deee820377 F test/pager2.test c7e731ac56a2984a605b032ffd19b9deee820377
F test/pager3.test 647f696a9cf7409df00a1e0047c2eb55585a1b85 F test/pager3.test 647f696a9cf7409df00a1e0047c2eb55585a1b85
F test/pagesize.test 6f94b70ed9645dbe6314b627ae765c5dec8036d9 F test/pagesize.test 6f94b70ed9645dbe6314b627ae765c5dec8036d9
F test/pragma.test 1d2ca2b52e08ed5af81f7f02e4490182bfd2f832 F test/pragma.test d14ed14407a00c10562ca35128120dc09019ed34
F test/printf.test 92ba4c510b4fc61120ffa4a01820446ed917ae57 F test/printf.test 92ba4c510b4fc61120ffa4a01820446ed917ae57
F test/progress.test 5ddba78cb6011fba36093973cfb3ac473b8fb96a x F test/progress.test 5ddba78cb6011fba36093973cfb3ac473b8fb96a x
F test/quick.test 9e968949a20b5ed5990c03dc45df3781a03c4b1a F test/quick.test 9e968949a20b5ed5990c03dc45df3781a03c4b1a
@@ -247,7 +247,7 @@ F www/nulls.tcl ec35193f92485b87b90a994a01d0171b58823fcf
F www/oldnews.tcl 7aa4478e64631859770a5fe4b413919ba6ee8a08 F www/oldnews.tcl 7aa4478e64631859770a5fe4b413919ba6ee8a08
F www/omitted.tcl 7bd62b6f0f53b60c5360895b16b3af8407bbca03 F www/omitted.tcl 7bd62b6f0f53b60c5360895b16b3af8407bbca03
F www/opcode.tcl dafa030a5a3cc24a2f9fd4cfbfb7d7323d2151b0 F www/opcode.tcl dafa030a5a3cc24a2f9fd4cfbfb7d7323d2151b0
F www/pragma.tcl 5bac2d73a92136fb711d558003648383ec2b139b F www/pragma.tcl c62b02e3c5d80d0166c0ace75a70ee0cfa4cca54
F www/quickstart.tcl 6f6f694b6139be2d967b1492eb9a6bdf7058aa60 F www/quickstart.tcl 6f6f694b6139be2d967b1492eb9a6bdf7058aa60
F www/speed.tcl de99c82c4729a10b6733463636f15473c4ec95bc F www/speed.tcl de99c82c4729a10b6733463636f15473c4ec95bc
F www/sqlite.tcl b51fd15f0531a54874de785a9efba323eecd5975 F www/sqlite.tcl b51fd15f0531a54874de785a9efba323eecd5975
@@ -256,7 +256,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618 F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c
P a1b2cc63e604785bd51e358ff72c485d858752e3 P c4115aa3a1b010704af76c5ae9f6dcbfa4038df8
R ef4bbd1e2466e0b000964937492388e1 R aad8608531c726385c6e9788af9bc8b9
U danielk1977 U danielk1977
Z f041132b38a543a682f3a1cb1fe1f777 Z 1177c79f2e60c6c7d6713520bedefc82

View File

@@ -1 +1 @@
c4115aa3a1b010704af76c5ae9f6dcbfa4038df8 5e058318441bb5043c609cc8fba1653995e90efb

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** This file contains code used to implement the PRAGMA command. ** This file contains code used to implement the PRAGMA command.
** **
** $Id: pragma.c,v 1.76 2004/11/11 05:10:44 danielk1977 Exp $ ** $Id: pragma.c,v 1.77 2004/11/12 16:12:00 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -725,32 +725,32 @@ void sqlite3Pragma(
} }
}else }else
/* /*
** PRAGMA [database.]schema_cookie ** PRAGMA [database.]schema_version
** PRAGMA [database.]schema_cookie = <integer> ** PRAGMA [database.]schema_version = <integer>
** **
** PRAGMA [database.]user_cookie ** PRAGMA [database.]user_version
** PRAGMA [database.]user_cookie = <integer> ** PRAGMA [database.]user_version = <integer>
** **
** The pragma's schema_cookie and user_cookie are used to set or get ** The pragma's schema_version and user_version are used to set or get
** the value of the schema-cookie and user-cookie, respectively. Both ** the value of the schema-version and user-version, respectively. Both
** the schema-cookie and the user-cookie are 32-bit signed integers ** the schema-version and the user-version are 32-bit signed integers
** stored in the database header. ** stored in the database header.
** **
** The schema-cookie is usually only manipulated internally by SQLite. It ** The schema-cookie is usually only manipulated internally by SQLite. It
** is incremented by SQLite whenever the database schema is modified (by ** is incremented by SQLite whenever the database schema is modified (by
** creating or dropping a table or index). The schema cookie is used by ** creating or dropping a table or index). The schema version is used by
** SQLite each time a query is executed to ensure that the internal cache ** 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 ** of the schema used when compiling the SQL query matches the schema of
** the database against which the compiled query is actually executed. ** the database against which the compiled query is actually executed.
** Subverting this mechanism by using "PRAGMA schema_cookie" to modify ** Subverting this mechanism by using "PRAGMA schema_version" to modify
** the schema-cookie is potentially dangerous and may lead to program ** the schema-version is potentially dangerous and may lead to program
** crashes or database corruption. Use with caution! ** crashes or database corruption. Use with caution!
** **
** The user-cookie is not used internally by SQLite. It may be used by ** The user-version is not used internally by SQLite. It may be used by
** applications for any purpose. ** applications for any purpose.
*/ */
if( sqlite3StrICmp(zLeft, "schema_cookie")==0 || if( sqlite3StrICmp(zLeft, "schema_version")==0 ||
sqlite3StrICmp(zLeft, "user_cookie")==0 ){ sqlite3StrICmp(zLeft, "user_version")==0 ){
int iCookie; /* Cookie index. 0 for schema-cookie, 6 for user-cookie. */ int iCookie; /* Cookie index. 0 for schema-cookie, 6 for user-cookie. */
if( zLeft[0]=='s' || zLeft[0]=='S' ){ if( zLeft[0]=='s' || zLeft[0]=='S' ){

View File

@@ -12,7 +12,7 @@
# #
# This file implements tests for the PRAGMA command. # This file implements tests for the PRAGMA command.
# #
# $Id: pragma.test,v 1.22 2004/11/11 05:10:44 danielk1977 Exp $ # $Id: pragma.test,v 1.23 2004/11/12 16:12:00 danielk1977 Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -368,38 +368,38 @@ do_test pragma-7.3 {
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# Test cases pragma-8.* test the "PRAGMA schema_cookie" and "PRAGMA # Test cases pragma-8.* test the "PRAGMA schema_version" and "PRAGMA
# user_cookie" statements. # user_version" statements.
# #
# pragma-8.1: PRAGMA schema_cookie # pragma-8.1: PRAGMA schema_version
# pragma-8.2: PRAGMA user_cookie # pragma-8.2: PRAGMA user_version
# #
# First check that we can set the schema cookie and then retrieve the # First check that we can set the schema version and then retrieve the
# same value. # same value.
do_test pragma-8.1.1 { do_test pragma-8.1.1 {
execsql { execsql {
PRAGMA schema_cookie = 105; PRAGMA schema_version = 105;
} }
} {} } {}
do_test pragma-8.1.2 { do_test pragma-8.1.2 {
execsql { execsql {
PRAGMA schema_cookie; PRAGMA schema_version;
} }
} 105 } 105
do_test pragma-8.1.3 { do_test pragma-8.1.3 {
execsql { execsql {
PRAGMA schema_cookie = 106; PRAGMA schema_version = 106;
} }
} {} } {}
do_test pragma-8.1.4 { do_test pragma-8.1.4 {
execsql { execsql {
PRAGMA schema_cookie; PRAGMA schema_version;
} }
} 106 } 106
# Check that creating a table modifies the schema-cookie (this is really # Check that creating a table modifies the schema-version (this is really
# to verify that the value being read is in fact the schema cookie). # to verify that the value being read is in fact the schema version).
do_test pragma-8.1.5 { do_test pragma-8.1.5 {
execsql { execsql {
CREATE TABLE t4(a, b, c); CREATE TABLE t4(a, b, c);
@@ -409,12 +409,12 @@ do_test pragma-8.1.5 {
} {1 2 3} } {1 2 3}
do_test pragma-8.1.6 { do_test pragma-8.1.6 {
execsql { execsql {
PRAGMA schema_cookie; PRAGMA schema_version;
} }
} 107 } 107
# Now open a second connection to the database. Ensure that changing the # Now open a second connection to the database. Ensure that changing the
# schema-cookie using the first connection forces the second connection # schema-version using the first connection forces the second connection
# to reload the schema. This has to be done using the C-API test functions, # 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. # because the TCL API accounts for SCHEMA_ERROR and retries the query.
do_test pragma-8.1.7 { do_test pragma-8.1.7 {
@@ -425,7 +425,7 @@ do_test pragma-8.1.7 {
} {1 2 3} } {1 2 3}
do_test pragma-8.1.8 { do_test pragma-8.1.8 {
execsql { execsql {
PRAGMA schema_cookie = 108; PRAGMA schema_version = 108;
} }
} {} } {}
do_test pragma-8.1.9 { do_test pragma-8.1.9 {
@@ -436,28 +436,28 @@ do_test pragma-8.1.10 {
sqlite3_finalize $::STMT sqlite3_finalize $::STMT
} SQLITE_SCHEMA } SQLITE_SCHEMA
# Make sure the schema-cookie can be manipulated in an attached database. # Make sure the schema-version can be manipulated in an attached database.
file delete -force test2.db file delete -force test2.db
file delete -force test2.db-journal file delete -force test2.db-journal
do_test pragma-8.1.11 { do_test pragma-8.1.11 {
execsql { execsql {
ATTACH 'test2.db' AS aux; ATTACH 'test2.db' AS aux;
CREATE TABLE aux.t1(a, b, c); CREATE TABLE aux.t1(a, b, c);
PRAGMA aux.schema_cookie = 205; PRAGMA aux.schema_version = 205;
} }
} {} } {}
do_test pragma-8.1.12 { do_test pragma-8.1.12 {
execsql { execsql {
PRAGMA aux.schema_cookie; PRAGMA aux.schema_version;
} }
} 205 } 205
do_test pragma-8.1.13 { do_test pragma-8.1.13 {
execsql { execsql {
PRAGMA schema_cookie; PRAGMA schema_version;
} }
} 108 } 108
# And check that modifying the schema-cookie in an attached database # And check that modifying the schema-version in an attached database
# forces the second connection to reload the schema. # forces the second connection to reload the schema.
do_test pragma-8.1.14 { do_test pragma-8.1.14 {
set ::DB2 [sqlite3 db2 test.db] set ::DB2 [sqlite3 db2 test.db]
@@ -468,7 +468,7 @@ do_test pragma-8.1.14 {
} {} } {}
do_test pragma-8.1.15 { do_test pragma-8.1.15 {
execsql { execsql {
PRAGMA aux.schema_cookie = 206; PRAGMA aux.schema_version = 206;
} }
} {} } {}
do_test pragma-8.1.16 { do_test pragma-8.1.16 {
@@ -482,92 +482,92 @@ do_test pragma-8.1.18 {
db2 close db2 close
} {} } {}
# Now test that the user-cookie can be read and written (and that we aren't # Now test that the user-version can be read and written (and that we aren't
# accidentally manipulating the schema-cookie instead). # accidentally manipulating the schema-version instead).
do_test pragma-8.2.1 { do_test pragma-8.2.1 {
execsql { execsql {
PRAGMA user_cookie; PRAGMA user_version;
} }
} {0} } {0}
do_test pragma-8.2.2 { do_test pragma-8.2.2 {
execsql { execsql {
PRAGMA user_cookie = 2; PRAGMA user_version = 2;
} }
} {} } {}
do_test pragma-8.2.3 { do_test pragma-8.2.3 {
execsql { execsql {
PRAGMA user_cookie; PRAGMA user_version;
} }
} {2} } {2}
do_test pragma-8.2.4 { do_test pragma-8.2.4 {
execsql { execsql {
PRAGMA schema_cookie; PRAGMA schema_version;
} }
} {108} } {108}
# Check that the user-cookie in the auxilary database can be manipulated ( # Check that the user-version in the auxilary database can be manipulated (
# and that we aren't accidentally manipulating the same in the main db). # and that we aren't accidentally manipulating the same in the main db).
do_test pragma-8.2.5 { do_test pragma-8.2.5 {
execsql { execsql {
PRAGMA aux.user_cookie; PRAGMA aux.user_version;
} }
} {0} } {0}
do_test pragma-8.2.6 { do_test pragma-8.2.6 {
execsql { execsql {
PRAGMA aux.user_cookie = 3; PRAGMA aux.user_version = 3;
} }
} {} } {}
do_test pragma-8.2.7 { do_test pragma-8.2.7 {
execsql { execsql {
PRAGMA aux.user_cookie; PRAGMA aux.user_version;
} }
} {3} } {3}
do_test pragma-8.2.8 { do_test pragma-8.2.8 {
execsql { execsql {
PRAGMA main.user_cookie; PRAGMA main.user_version;
} }
} {2} } {2}
# Now check that a ROLLBACK resets the user-cookie if it has been modified # Now check that a ROLLBACK resets the user-version if it has been modified
# within a transaction. # within a transaction.
do_test pragma-8.2.9 { do_test pragma-8.2.9 {
execsql { execsql {
BEGIN; BEGIN;
PRAGMA aux.user_cookie = 10; PRAGMA aux.user_version = 10;
PRAGMA user_cookie = 11; PRAGMA user_version = 11;
} }
} {} } {}
do_test pragma-8.2.10 { do_test pragma-8.2.10 {
execsql { execsql {
PRAGMA aux.user_cookie; PRAGMA aux.user_version;
} }
} {10} } {10}
do_test pragma-8.2.11 { do_test pragma-8.2.11 {
execsql { execsql {
PRAGMA main.user_cookie; PRAGMA main.user_version;
} }
} {11} } {11}
do_test pragma-8.2.12 { do_test pragma-8.2.12 {
execsql { execsql {
ROLLBACK; ROLLBACK;
PRAGMA aux.user_cookie; PRAGMA aux.user_version;
} }
} {3} } {3}
do_test pragma-8.2.13 { do_test pragma-8.2.13 {
execsql { execsql {
PRAGMA main.user_cookie; PRAGMA main.user_version;
} }
} {2} } {2}
# Try a negative value for the user-cookie # Try a negative value for the user-version
do_test pragma-8.2.14 { do_test pragma-8.2.14 {
execsql { execsql {
PRAGMA user_cookie = -450; PRAGMA user_version = -450;
} }
} {} } {}
do_test pragma-8.2.15 { do_test pragma-8.2.15 {
execsql { execsql {
PRAGMA user_cookie; PRAGMA user_version;
} }
} {-450} } {-450}

View File

@@ -1,7 +1,7 @@
# #
# Run this Tcl script to generate the pragma.html file. # 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 $} set rcsid {$Id: pragma.tcl,v 1.3 2004/11/12 16:12:00 danielk1977 Exp $}
source common.tcl source common.tcl
header {Pragma statements supported by SQLite} header {Pragma statements supported by SQLite}
@@ -34,8 +34,8 @@ different in the following important respects:
<li>Pragmas used to <a href="#modify">modify the operation</a> of the <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 SQLite library in some manner, or to query for the current mode of
operation. operation.
<li>Pragmas used to <a href="#cookie">query or modify the databases two <li>Pragmas used to <a href="#version">query or modify the databases two
cookie values</a>, the schema-cookie and the user-cookie. version values</a>, the schema-version and the user-version.
<li>Pragmas used to <a href="#debug">debug the library</a> and verify that <li>Pragmas used to <a href="#debug">debug the library</a> and verify that
database files are not corrupted. database files are not corrupted.
</ul> </ul>
@@ -249,33 +249,33 @@ puts {
</ul> </ul>
} }
Section {Pragmas to query/modify cookie values} cookie Section {Pragmas to query/modify version values} version
puts { puts {
<ul> <ul>
<li><p><b>PRAGMA [database.]schema_cookie; <li><p><b>PRAGMA [database.]schema_version;
<br>PRAGMA [database.]schema_cookie = </b><i>integer </i><b>; <br>PRAGMA [database.]schema_version = </b><i>integer </i><b>;
<br>PRAGMA [database.]user_cookie; <br>PRAGMA [database.]user_version;
<br>PRAGMA [database.]user_cookie = </b><i>integer </i><b>;</b> <br>PRAGMA [database.]user_version = </b><i>integer </i><b>;</b>
<p> The pragmas schema_cookie and user_cookie are used to set or get <p> The pragmas schema_version and user_version are used to set or get
the value of the schema-cookie and user-cookie, respectively. Both the value of the schema-version and user-version, respectively. Both
the schema-cookie and the user-cookie are 32-bit signed integers the schema-version and the user-version are 32-bit signed integers
stored in the database header.</p> stored in the database header.</p>
<p> The schema-cookie is usually only manipulated internally by SQLite. <p> The schema-version is usually only manipulated internally by SQLite.
It is incremented by SQLite whenever the database schema is modified It is incremented by SQLite whenever the database schema is modified
(by creating or dropping a table or index). The schema cookie is (by creating or dropping a table or index). The schema version is
used by SQLite each time a query is executed to ensure that the 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 internal cache of the schema used when compiling the SQL query matches
the schema of the database against which the compiled query is actually the schema of the database against which the compiled query is actually
executed. Subverting this mechanism by using "PRAGMA schema_cookie" executed. Subverting this mechanism by using "PRAGMA schema_version"
to modify the schema-cookie is potentially dangerous and may lead to modify the schema-version is potentially dangerous and may lead
to program crashes or database corruption. Use with caution!</p> 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 <p> The user-version is not used internally by SQLite. It may be used by
applications for any purpose.</p> applications for any purpose.</p>
</li> </li>
</ul> </ul>