Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Change pragmas schema_cookie and user_cookie to schema_version and user_version. (CVS 2094) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5e058318441bb5043c609cc8fba16539 |
User & Date: | danielk1977 2004-11-12 16:12:00.000 |
Context
2004-11-13
| ||
03:48 | Autoincrement is now working and has regression tests. (CVS 2095) (check-in: 10c712a219 user: drh tags: trunk) | |
2004-11-12
| ||
16:12 | Change pragmas schema_cookie and user_cookie to schema_version and user_version. (CVS 2094) (check-in: 5e05831844 user: danielk1977 tags: trunk) | |
15:53 | Add authorization callbacks to ALTER TABLE. (CVS 2093) (check-in: c4115aa3a1 user: danielk1977 tags: trunk) | |
Changes
Changes to src/pragma.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 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. ** | | | 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.77 2004/11/12 16:12:00 danielk1977 Exp $ */ #include "sqliteInt.h" #include <ctype.h> #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) # include "pager.h" # include "btree.h" |
︙ | ︙ | |||
721 722 723 724 725 726 727 | if( !pEnc->zName ){ sqlite3ErrorMsg(pParse, "unsupported encoding: %s", zRight); } } } }else /* | | | | | | | | | | | | | | | 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 | if( !pEnc->zName ){ sqlite3ErrorMsg(pParse, "unsupported encoding: %s", zRight); } } } }else /* ** PRAGMA [database.]schema_version ** PRAGMA [database.]schema_version = <integer> ** ** PRAGMA [database.]user_version ** PRAGMA [database.]user_version = <integer> ** ** The pragma's schema_version and user_version are used to set or get ** the value of the schema-version and user-version, respectively. Both ** the schema-version and the user-version 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 version 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_version" to modify ** the schema-version is potentially dangerous and may lead to program ** crashes or database corruption. Use with caution! ** ** The user-version is not used internally by SQLite. It may be used by ** applications for any purpose. */ if( sqlite3StrICmp(zLeft, "schema_version")==0 || sqlite3StrICmp(zLeft, "user_version")==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; } |
︙ | ︙ |
Changes to test/pragma.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # 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. # | | | 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.23 2004/11/12 16:12:00 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. |
︙ | ︙ | |||
364 365 366 367 368 369 370 | execsql { pragma lock_status; } } {main unlocked temp closed} #---------------------------------------------------------------------- | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | execsql { pragma lock_status; } } {main unlocked temp closed} #---------------------------------------------------------------------- # Test cases pragma-8.* test the "PRAGMA schema_version" and "PRAGMA # user_version" statements. # # pragma-8.1: PRAGMA schema_version # pragma-8.2: PRAGMA user_version # # First check that we can set the schema version and then retrieve the # same value. do_test pragma-8.1.1 { execsql { PRAGMA schema_version = 105; } } {} do_test pragma-8.1.2 { execsql { PRAGMA schema_version; } } 105 do_test pragma-8.1.3 { execsql { PRAGMA schema_version = 106; } } {} do_test pragma-8.1.4 { execsql { PRAGMA schema_version; } } 106 # Check that creating a table modifies the schema-version (this is really # to verify that the value being read is in fact the schema version). 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_version; } } 107 # Now open a second connection to the database. Ensure that changing the # 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, # 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_version = 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-version 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_version = 205; } } {} do_test pragma-8.1.12 { execsql { PRAGMA aux.schema_version; } } 205 do_test pragma-8.1.13 { execsql { PRAGMA schema_version; } } 108 # And check that modifying the schema-version 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_version = 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-version can be read and written (and that we aren't # accidentally manipulating the schema-version instead). do_test pragma-8.2.1 { execsql { PRAGMA user_version; } } {0} do_test pragma-8.2.2 { execsql { PRAGMA user_version = 2; } } {} do_test pragma-8.2.3 { execsql { PRAGMA user_version; } } {2} do_test pragma-8.2.4 { execsql { PRAGMA schema_version; } } {108} # 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). do_test pragma-8.2.5 { execsql { PRAGMA aux.user_version; } } {0} do_test pragma-8.2.6 { execsql { PRAGMA aux.user_version = 3; } } {} do_test pragma-8.2.7 { execsql { PRAGMA aux.user_version; } } {3} do_test pragma-8.2.8 { execsql { PRAGMA main.user_version; } } {2} # Now check that a ROLLBACK resets the user-version if it has been modified # within a transaction. do_test pragma-8.2.9 { execsql { BEGIN; PRAGMA aux.user_version = 10; PRAGMA user_version = 11; } } {} do_test pragma-8.2.10 { execsql { PRAGMA aux.user_version; } } {10} do_test pragma-8.2.11 { execsql { PRAGMA main.user_version; } } {11} do_test pragma-8.2.12 { execsql { ROLLBACK; PRAGMA aux.user_version; } } {3} do_test pragma-8.2.13 { execsql { PRAGMA main.user_version; } } {2} # Try a negative value for the user-version do_test pragma-8.2.14 { execsql { PRAGMA user_version = -450; } } {} do_test pragma-8.2.15 { execsql { PRAGMA user_version; } } {-450} finish_test |
Changes to www/pragma.tcl.
1 2 3 | # # Run this Tcl script to generate the pragma.html file. # | | | 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.3 2004/11/12 16:12:00 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 |
︙ | ︙ | |||
30 31 32 33 34 35 36 | <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. | | | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <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="#version">query or modify the databases two version values</a>, the schema-version and the user-version. <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 |
︙ | ︙ | |||
245 246 247 248 249 250 251 | <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> } | | | | | | | | | | | | | | | 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 | <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 version values} version puts { <ul> <li><p><b>PRAGMA [database.]schema_version; <br>PRAGMA [database.]schema_version = </b><i>integer </i><b>; <br>PRAGMA [database.]user_version; <br>PRAGMA [database.]user_version = </b><i>integer </i><b>;</b> <p> The pragmas schema_version and user_version are used to set or get the value of the schema-version and user-version, respectively. Both the schema-version and the user-version are 32-bit signed integers stored in the database header.</p> <p> The schema-version 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 version 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_version" to modify the schema-version is potentially dangerous and may lead to program crashes or database corruption. Use with caution!</p> <p> The user-version 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 |
︙ | ︙ |