diff options
author | drh <drh@noemail.net> | 2010-02-23 17:36:32 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2010-02-23 17:36:32 +0000 |
commit | 9978c97ec5d480741365687534690f04bc8cc6e4 (patch) | |
tree | 85ee2b948fb789b9245796ca35a2e947e8e662e2 /src/main.c | |
parent | 127f9d75e289e3a4cd45a16889bced0d94a1a608 (diff) | |
download | sqlite-9978c97ec5d480741365687534690f04bc8cc6e4.tar.gz sqlite-9978c97ec5d480741365687534690f04bc8cc6e4.zip |
Remove the obsolete sqlite3SafetyOn() mechanism. Add additional logging
output for CORRUPT, and CANTOPEN errors.
FossilOrigin-Name: 7c4cca6d1a23a6d1591b62f58c3716a944969947
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c index e4419d269..348ddb565 100644 --- a/src/main.c +++ b/src/main.c @@ -1939,16 +1939,31 @@ int sqlite3_get_autocommit(sqlite3 *db){ return db->autoCommit; } -#ifdef SQLITE_DEBUG /* -** The following routine is subtituted for constant SQLITE_CORRUPT in -** debugging builds. This provides a way to set a breakpoint for when -** corruption is first detected. +** The following routines are subtitutes for constants SQLITE_CORRUPT, +** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_IOERR and possibly other error +** constants. They server two purposes: +** +** 1. Serve as a convenient place to set a breakpoint in a debugger +** to detect when version error conditions occurs. +** +** 2. Invoke sqlite3_log() to provide the source code location where +** a low-level error is first detected. */ -int sqlite3Corrupt(void){ +int sqlite3CorruptError(int lineno){ + sqlite3_log(SQLITE_CORRUPT, + "database corruption found by source line %d", lineno); return SQLITE_CORRUPT; } -#endif +int sqlite3MisuseError(int lineno){ + sqlite3_log(SQLITE_MISUSE, "misuse detected by source line %d", lineno); + return SQLITE_MISUSE; +} +int sqlite3CantopenError(int lineno){ + sqlite3_log(SQLITE_CANTOPEN, "cannot open file at source line %d", lineno); + return SQLITE_CANTOPEN; +} + #ifndef SQLITE_OMIT_DEPRECATED /* @@ -1992,7 +2007,6 @@ int sqlite3_table_column_metadata( /* Ensure the database schema has been loaded */ sqlite3_mutex_enter(db->mutex); - (void)sqlite3SafetyOn(db); sqlite3BtreeEnterAll(db); rc = sqlite3Init(db, &zErrMsg); if( SQLITE_OK!=rc ){ @@ -2051,7 +2065,6 @@ int sqlite3_table_column_metadata( error_out: sqlite3BtreeLeaveAll(db); - (void)sqlite3SafetyOff(db); /* Whether the function call succeeded or failed, set the output parameters ** to whatever their local counterparts contain. If an error did occur, |