media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_path", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL UNIQUE", USER_V2, NULL, false, false, true);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
- ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_display_name", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, "media_file_name_idx", false, false, true);
+ ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_display_name", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, false, false, true);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_type", MEDIA_SVC_DB_TYPE_INT, NULL, USER_V2, NULL, false, false, true);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_added_time", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
- ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_modified_time", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, "media_modified_time_idx", false, false, true);
+ ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_modified_time", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
- ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "folder_id", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, "folder_uuid_idx", false, false, false);
+ ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "folder_id", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, false, false, false);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_thumbnail_path", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_storage_type", MEDIA_SVC_DB_TYPE_INT, NULL, USER_V2, NULL, false, false, true);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
- ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_timeline", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, "media_timeline_idx", false, false, true);
+ ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_timeline", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "sync_status", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
int idx = 0;
int length = g_list_length(*query_list);
char *sql = NULL;
+ char *zErrMsg = NULL;
sqlite3 *handle = NULL;
+ bool with_transaction = true;
media_svc_debug("query list length[%d]", length);
if (length == 0)
ret = media_db_connect(&handle, uid, true);
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "DB connection failed");
+ ret = sqlite3_exec(handle, "BEGIN;", NULL, NULL, &zErrMsg);
+ if (SQLITE_OK != ret) {
+ media_svc_sec_error("Transaction failed[%s]. Try an individual insert.", zErrMsg);
+ SQLITE3_SAFE_FREE(zErrMsg);
+ with_transaction = false;
+ }
+
for (idx = 0; idx < length; idx++) {
sql = (char *)g_list_nth_data(*query_list, idx);
if (STRING_VALID(sql)) {
}
}
+ if (with_transaction) {
+ ret = sqlite3_exec(handle, "COMMIT;", NULL, NULL, &zErrMsg);
+ if (SQLITE_OK != ret) {
+ media_svc_sec_error("Commit failed[%s]", zErrMsg);
+ SQLITE3_SAFE_FREE(zErrMsg);
+ media_db_disconnect(handle);
+ _media_svc_sql_query_release(query_list);
+ return MS_MEDIA_ERR_DB_INTERNAL;
+ }
+ }
+
media_db_disconnect(handle);
ZERO_LEN: