/ Check-in [a8d6d935]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Modify the behaviour of writable_schema to ignore schema parsing errors. (CVS 3686)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a8d6d935fbe32a759a55c1ef90adda7fe534acc1
User & Date: danielk1977 2007-03-14 15:37:04
Context
2007-03-15
01:16
Enhanced temp-file security under unix. There are no known attacks against prior versions - this check-in is just an added precaution. (CVS 3687) check-in: 5af61402 user: drh tags: trunk
2007-03-14
15:37
Modify the behaviour of writable_schema to ignore schema parsing errors. (CVS 3686) check-in: a8d6d935 user: danielk1977 tags: trunk
2007-03-13
16:33
Add hyperlink anchors to the lockingv3.html document. (CVS 3685) check-in: 3e66ea6f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pragma.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the PRAGMA command.
    13     13   **
    14         -** $Id: pragma.c,v 1.127 2007/01/27 02:24:56 drh Exp $
           14  +** $Id: pragma.c,v 1.128 2007/03/14 15:37:04 danielk1977 Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include "os.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /* Ignore this whole file if pragmas are disabled
    21     21   */
................................................................................
   153    153       { "empty_result_callbacks",   SQLITE_NullCallback  },
   154    154       { "legacy_file_format",       SQLITE_LegacyFileFmt },
   155    155       { "fullfsync",                SQLITE_FullFSync     },
   156    156   #ifndef SQLITE_OMIT_CHECK
   157    157       { "ignore_check_constraints", SQLITE_IgnoreChecks  },
   158    158   #endif
   159    159       /* The following is VERY experimental */
   160         -    { "writable_schema",          SQLITE_WriteSchema   },
          160  +    { "writable_schema",          SQLITE_WriteSchema|SQLITE_RecoveryMode },
   161    161       { "omit_readlock",            SQLITE_NoReadlock    },
   162    162   
   163    163       /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted
   164    164       ** flag if there are any active statements. */
   165    165       { "read_uncommitted",         SQLITE_ReadUncommitted },
   166    166     };
   167    167     int i;

Changes to src/prepare.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains the implementation of the sqlite3_prepare()
    13     13   ** interface, and routines that contribute to loading the database schema
    14     14   ** from disk.
    15     15   **
    16         -** $Id: prepare.c,v 1.43 2007/01/09 14:01:13 drh Exp $
           16  +** $Id: prepare.c,v 1.44 2007/03/14 15:37:04 danielk1977 Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "os.h"
    20     20   #include <ctype.h>
    21     21   
    22     22   /*
    23     23   ** Fill the InitData structure with an error message that indicates
................................................................................
   306    306       sqlite3BtreeCloseCursor(curMain);
   307    307     }
   308    308     if( sqlite3MallocFailed() ){
   309    309       /* sqlite3SetString(pzErrMsg, "out of memory", (char*)0); */
   310    310       rc = SQLITE_NOMEM;
   311    311       sqlite3ResetInternalSchema(db, 0);
   312    312     }
   313         -  if( rc==SQLITE_OK ){
          313  +  if( rc==SQLITE_OK || (db->flags&SQLITE_RecoveryMode)){
          314  +    /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider
          315  +    ** the schema loaded, even if errors occured. In this situation the 
          316  +    ** current sqlite3_prepare() operation will fail, but the following one
          317  +    ** will attempt to compile the supplied statement against whatever subset
          318  +    ** of the schema was loaded before the error occured. The primary
          319  +    ** purpose of this is to allow access to the sqlite_master table
          320  +    ** even when it's contents have been corrupted.
          321  +    */
   314    322       DbSetProperty(db, iDb, DB_SchemaLoaded);
   315         -  }else{
   316         -    sqlite3ResetInternalSchema(db, iDb);
          323  +    rc = SQLITE_OK;
   317    324     }
   318    325     return rc;
   319    326   }
   320    327   
   321    328   /*
   322    329   ** Initialize all database files - the main database file, the file
   323    330   ** used to store temporary tables, and any additional database files

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.541 2007/03/02 06:24:19 danielk1977 Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.542 2007/03/14 15:37:04 danielk1977 Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** Extra interface definitions for those who need them
    21     21   */
................................................................................
   540    540   #define SQLITE_NoReadlock     0x00001000  /* Readlocks are omitted when 
   541    541                                             ** accessing read-only databases */
   542    542   #define SQLITE_IgnoreChecks   0x00002000  /* Do not enforce check constraints */
   543    543   #define SQLITE_ReadUncommitted 0x00004000 /* For shared-cache mode */
   544    544   #define SQLITE_LegacyFileFmt  0x00008000  /* Create new databases in format 1 */
   545    545   #define SQLITE_FullFSync      0x00010000  /* Use full fsync on the backend */
   546    546   #define SQLITE_LoadExtension  0x00020000  /* Enable load_extension */
          547  +
          548  +#define SQLITE_RecoveryMode   0x00040000  /* Ignore schema errors */
   547    549   
   548    550   /*
   549    551   ** Possible values for the sqlite.magic field.
   550    552   ** The numbers are obtained at random and have no special meaning, other
   551    553   ** than being distinct from one another.
   552    554   */
   553    555   #define SQLITE_MAGIC_OPEN     0xa029a697  /* Database is open */