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

Add the SQLITE_NOTADB return code for cases when you try to open a file

that does not even remotely resemble an SQLite database file. (CVS 1233)

FossilOrigin-Name: 0c77cee70f078152969933c1d340cea1c86286b0
This commit is contained in:
drh
2004-02-12 19:01:04 +00:00
parent 4d189ca48f
commit c602f9ae01
6 changed files with 18 additions and 16 deletions

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.100 2004/02/10 02:57:59 drh Exp $
** $Id: btree.c,v 1.101 2004/02/12 19:01:05 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -793,7 +793,7 @@ static int lockBtree(Btree *pBt){
PageOne *pP1 = pBt->page1;
if( strcmp(pP1->zMagic,zMagicHeader)!=0 ||
(pP1->iMagic!=MAGIC && swab32(pP1->iMagic)!=MAGIC) ){
rc = SQLITE_CORRUPT;
rc = SQLITE_NOTADB;
goto page1_init_failed;
}
pBt->needSwab = pP1->iMagic!=MAGIC;

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.149 2004/02/12 18:46:39 drh Exp $
** $Id: main.c,v 1.150 2004/02/12 19:01:05 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -770,6 +770,7 @@ const char *sqlite_error_string(int rc){
case SQLITE_AUTH: z = "authorization denied"; break;
case SQLITE_FORMAT: z = "auxiliary database format error"; break;
case SQLITE_RANGE: z = "bind index out of range"; break;
case SQLITE_NOTADB: z = "file is encrypted or is not a database";break;
default: z = "unknown error"; break;
}
return z;

View File

@@ -12,7 +12,7 @@
** This header file defines the interface that the SQLite library
** presents to client programs.
**
** @(#) $Id: sqlite.h.in,v 1.55 2004/02/01 01:22:52 drh Exp $
** @(#) $Id: sqlite.h.in,v 1.56 2004/02/12 19:01:05 drh Exp $
*/
#ifndef _SQLITE_H_
#define _SQLITE_H_
@@ -167,6 +167,7 @@ int sqlite_exec(
#define SQLITE_AUTH 23 /* Authorization denied */
#define SQLITE_FORMAT 24 /* Auxiliary database format error */
#define SQLITE_RANGE 25 /* 2nd parameter to sqlite_bind out of range */
#define SQLITE_NOTADB 26 /* File opened that is not a database file */
#define SQLITE_ROW 100 /* sqlite_step() has another row ready */
#define SQLITE_DONE 101 /* sqlite_step() has finished executing */