[M85 Migration] Initialize sqlite3 before openning the database 74/245374/2
authoryh106.jung <yh106.jung@samsung.com>
Tue, 22 Jan 2019 00:36:43 +0000 (16:36 -0800)
committerBot Blink <blinkbot@samsung.com>
Mon, 12 Oct 2020 06:27:26 +0000 (06:27 +0000)
Since m69, sqlite3 is compiled with SQLITE_OMIT_AUTOINIT option.
So the application must call sqlite3_initialize() directly.
This patch ensures that sqlite3 is initialized before openning the
database.

Ref:
https://review.tizen.org/gerrit/c/platform/framework/web/chromium-efl/+/220027

Change-Id: Ib74c0290f6fb8de354672e74adc9a63ff2922c4c
Signed-off-by: yh106.jung <yh106.jung@samsung.com>
tizen_src/ewk/efl_integration/browser/favicon/favicon_database.cc

index 4bbb25e..d78dfd0 100644 (file)
@@ -19,6 +19,8 @@
                               return ret;\
                             }
 
+static bool g_sqlite3_initialized = false;
+
 const int FaviconDatabase::SYNC_DELAY = 3;
 
 FaviconDatabase *FaviconDatabase::Instance() {
@@ -185,10 +187,22 @@ bool FaviconDatabase::Open() {
   if (d->sqlite) {
     return true;
   }
-  int result = sqlite3_open(d->path.value().c_str(), &d->sqlite);
-  if (result != SQLITE_OK) {
+  // Since m69, sqlite is compiled with SQLITE_OMIT_AUTOINIT option.
+  // So application must call sqlite3_initialize() directly.
+  int result_code;
+  if (!g_sqlite3_initialized) {
+    result_code = sqlite3_initialize();
+    if (result_code != SQLITE_OK) {
+      LOG(ERROR) << "[FaviconDatabase] :: Error initialize sqlite3 ("
+                 << result_code << ")!";
+      return false;
+    }
+    g_sqlite3_initialized = true;
+  }
+  result_code = sqlite3_open(d->path.value().c_str(), &d->sqlite);
+  if (result_code != SQLITE_OK) {
     LOG(ERROR) << "[FaviconDatabase] :: Error opening SQLite database ("
-               << result << ")!";
+               << result_code << ")!";
     return false;
   }
   if (!IsDatabaseInitialized() && !InitDatabase()) {