Change the timing of adding sqlite busy handler
[platform/core/appfw/pkgmgr-info.git] / parser / src / pkgmgr_parser_db.c
index 95f2472..74a8f47 100644 (file)
@@ -474,6 +474,14 @@ static int __open_db(uid_t uid, const char *path, sqlite3 **db, int flags)
        if (ret != SQLITE_OK)
                return ret;
 
+       ret = sqlite3_busy_handler(*db, __db_busy_handler, NULL);
+       if (ret != SQLITE_OK) {
+               _LOGE("failed to register busy handler: %s",
+                               sqlite3_errmsg(*db));
+               sqlite3_close_v2(*db);
+               return ret;
+       }
+
        if (flags & SQLITE_OPEN_CREATE) {
                ret = __initialize_db(*db, path, uid);
                if (ret) {
@@ -491,14 +499,6 @@ static int __open_db(uid_t uid, const char *path, sqlite3 **db, int flags)
                return ret;
        }
 
-       ret = sqlite3_busy_handler(*db, __db_busy_handler, NULL);
-       if (ret != SQLITE_OK) {
-               _LOGE("failed to register busy handler: %s",
-                               sqlite3_errmsg(*db));
-               sqlite3_close_v2(*db);
-               return ret;
-       }
-
        return ret;
 }