Fix a shared-cache mode problem triggered when sqlite3_open16() was used to open the second or subsequent connections to a utf-8 database. (CVS 5059)

FossilOrigin-Name: 20946bf6dd704416c41edd863103e85fc7ab4ef2
diff --git a/src/main.c b/src/main.c
index 940a3c1..06fc5c1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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.434 2008/04/16 00:49:12 drh Exp $
+** $Id: main.c,v 1.435 2008/04/28 16:19:35 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1248,12 +1248,8 @@
     rc = openDatabase(zFilename8, ppDb,
                       SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
     assert( *ppDb || rc==SQLITE_NOMEM );
-    if( rc==SQLITE_OK ){
+    if( rc==SQLITE_OK && !DbHasProperty(*ppDb, 0, DB_SchemaLoaded) ){
       ENC(*ppDb) = SQLITE_UTF16NATIVE;
-      if( rc!=SQLITE_OK ){
-        sqlite3_close(*ppDb);
-        *ppDb = 0;
-      }
     }
   }
   sqlite3ValueFree(pVal);