File detect_sqlite3.patch of Package sqlite2

--- sqlite-2.8.17/src/btree.c.orig	2005-04-24 00:43:22.000000000 +0200
+++ sqlite-2.8.17/src/btree.c	2012-12-31 16:58:06.288576336 +0100
@@ -112,6 +112,8 @@ typedef struct FreelistInfo FreelistInfo
 static const char zMagicHeader[] = 
    "** This file contains an SQLite 2.1 database **";
 #define MAGIC_SIZE (sizeof(zMagicHeader))
+static const char zMagicHeader_V3[] = "SQLite format 3";
+#define MAGIC_SIZE_V3 (sizeof(zMagicHeader_V3))
 
 /*
 ** This is a magic integer also used to test the integrity of the database
@@ -794,6 +800,8 @@ static int lockBtree(Btree *pBt){
     if( strcmp(pP1->zMagic,zMagicHeader)!=0 ||
           (pP1->iMagic!=MAGIC && swab32(pP1->iMagic)!=MAGIC) ){
       rc = SQLITE_NOTADB;
+      if (!strcmp(pP1->zMagic,zMagicHeader_V3))
+        rc = SQLITE_V3;
       goto page1_init_failed;
     }
     pBt->needSwab = pP1->iMagic!=MAGIC;
--- sqlite-2.8.17/src/main.c.orig	2005-04-24 00:43:22.000000000 +0200
+++ sqlite-2.8.17/src/main.c	2012-12-31 16:52:50.296168240 +0100
@@ -851,6 +851,7 @@ const char *sqlite_error_string(int rc){
     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;
+    case SQLITE_V3:         z = "database version mismatch. Try sqlite3";break;
     default:                z = "unknown error";                         break;
   }
   return z;
--- sqlite-2.8.17/src/sqlite.h.in.orig	2005-04-24 00:43:22.000000000 +0200
+++ sqlite-2.8.17/src/sqlite.h.in	2012-12-31 16:52:51.619178446 +0100
@@ -172,6 +172,7 @@ int sqlite_exec(
 #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_V3          27   /* 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 */
 
openSUSE Build Service is sponsored by