Fix load record bug 48/207748/3
authorhyunho <hhstark.kang@samsung.com>
Wed, 12 Jun 2019 04:11:55 +0000 (13:11 +0900)
committerhyunho <hhstark.kang@samsung.com>
Wed, 12 Jun 2019 04:52:46 +0000 (13:52 +0900)
Change-Id: I9c001eb5c8b26f43db83f5ecf3a142c56335e059
Signed-off-by: hyunho <hhstark.kang@samsung.com>
src/db-schema.h
src/rua.c
src/rua_internal.c

index 97724b70f5ff853d7902420aaf3954cfa871fb1f..090a441cca32b69ae1ffb29de8886ba7e4bfc4ad 100644 (file)
@@ -25,12 +25,12 @@ CREATE TABLE IF NOT EXISTS rua_history ( \
        app_path TEXT, \
        arg TEXT, \
        launch_time INTEGER, \
-       comp_id TEXT, \
        instance_id TEXT, \
        instance_name TEXT, \
        icon TEXT, \
        uri TEXT, \
        image TEXT, \
+       comp_id TEXT, \
        PRIMARY KEY(pkg_name, comp_id, instance_id) \
 );"
 
index a3f24c5e9e13f80e4473d6f0961a5e8c35c20717..9e3ddef4807770d0b4e43b6752ed00689cc74aee 100644 (file)
--- a/src/rua.c
+++ b/src/rua.c
@@ -134,8 +134,8 @@ API int rua_clear_history(void)
 API int rua_history_load_db_for_uid(char ***table, int *nrows, int *ncols, uid_t uid)
 {
        static const char query[] =
-               "SELECT pkg_name, app_path, arg, launch_time, comp_id,"
-               "  instance_id, instance_name, icon, uri, image "
+               "SELECT pkg_name, app_path, arg, launch_time,"
+               "  instance_id, instance_name, icon, uri, image, comp_id "
                "FROM rua_history ORDER BY launch_time DESC";
        int r;
        char *db_err = NULL;
@@ -283,6 +283,12 @@ API int rua_history_get_rec(struct rua_rec *rec, char **table, int nrows, int nc
        else
                rec->image = NULL;
 
+       tmp = db_result[RUA_COL_COMP_ID];
+       if (tmp && tmp[0] != '\0')
+               rec->comp_id = tmp;
+       else
+               rec->comp_id = NULL;
+
        return 0;
 }
 
index 8f4cf98304521d090d2e5fce6f46c4a159fa3046..0bb4305f8a274fc52bf3d1ffe6935617c93ebaf2 100644 (file)
@@ -217,8 +217,8 @@ static int __insert_history(sqlite3 *db, struct rua_rec *rec)
        static const char query[] =
                "INSERT OR REPLACE INTO rua_history ("
                "  pkg_name, app_path, arg, launch_time,"
-               "  comp_id, instance_id, instance_name, icon, uri,"
-               "  image) "
+               "  instance_id, instance_name, icon, uri,"
+               "  image, comp_id) "
                "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
        int r;
        sqlite3_stmt *stmt;
@@ -234,13 +234,13 @@ static int __insert_history(sqlite3 *db, struct rua_rec *rec)
        __BIND_TEXT(db, stmt, idx++, rec->app_path);
        __BIND_TEXT(db, stmt, idx++, rec->arg ? rec->arg : "");
        __BIND_INT(db, stmt, idx++, (int)rec->launch_time);
-       __BIND_TEXT(db, stmt, idx++, rec->comp_id ? rec->comp_id : "");
        __BIND_TEXT(db, stmt, idx++, rec->instance_id ? rec->instance_id : "");
        __BIND_TEXT(db, stmt, idx++,
                        rec->instance_name ? rec->instance_name : "");
        __BIND_TEXT(db, stmt, idx++, rec->icon ? rec->icon : "");
        __BIND_TEXT(db, stmt, idx++, rec->uri ? rec->uri : "");
        __BIND_TEXT(db, stmt, idx++, rec->image ? rec->image : "");
+       __BIND_TEXT(db, stmt, idx++, rec->comp_id ? rec->comp_id : "");
 
        r = sqlite3_step(stmt);
        if (r != SQLITE_DONE) {