Merge branch 'master' into add_parser_dbpath
author연정현/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <jungh.yeon@samsung.com>
Mon, 8 Mar 2021 05:34:22 +0000 (14:34 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 8 Mar 2021 05:34:22 +0000 (14:34 +0900)
1  2 
src/common/database/cert_get_db_handler.cc
src/common/database/depinfo_db_handler.cc
src/common/database/pkg_get_db_handler.cc
src/common/database/pkg_set_db_handler.cc
src/common/database/query_handler.cc

@@@ -16,8 -16,7 +16,9 @@@
  
  #include "cert_get_db_handler.hh"
  
 +#include <vector>
 +
+ #include "pkgmgrinfo_debug.h"
  #include "pkgmgrinfo_internal.h"
  
  namespace pkgmgr_common {
@@@ -16,8 -16,7 +16,9 @@@
  
  #include "depinfo_db_handler.hh"
  
 +#include <vector>
 +
+ #include "pkgmgrinfo_debug.h"
  #include "pkgmgrinfo_internal.h"
  
  namespace pkgmgr_common {
@@@ -40,16 -39,14 +41,19 @@@ int DepInfoGetDBHandler::Execute() 
    SetOpType(OPERATION_TYPE_READ);
    SetDBType(DB_TYPE_FILE_PKGDB);
  
-   if (!Connect()) return PMINFO_R_ERROR;
+   if (!Connect()) {
+     _LOGE("Failed to connect database");
+     return PMINFO_R_ERROR;
+   }
    GList *list = nullptr;
 -  int ret = pkginfo_internal_filter_get_depends_on(
 -      GetConnection(), pkgid_.c_str(), &list);
 -
 +  std::vector<sqlite3*> conn_list = GetConnection();
 +  int ret;
 +  for (auto& conn : conn_list) {
 +    ret = pkginfo_internal_filter_get_depends_on(
 +        conn, pkgid_.c_str(), &list);
 +    if (ret == PMINFO_R_ERROR)
 +      break;
 +  }
    return ret;
  }
  
@@@ -16,8 -16,7 +16,9 @@@
  
  #include "pkg_get_db_handler.hh"
  
 +#include <vector>
 +
+ #include "pkgmgrinfo_debug.h"
  #include "pkgmgrinfo_internal.h"
  
  namespace {
@@@ -17,8 -17,7 +17,9 @@@
  #include "db_handle_provider.hh"
  #include "pkg_set_db_handler.hh"
  
 +#include <vector>
 +
+ #include "pkgmgrinfo_debug.h"
  #include "pkgmgr_parser_db.h"
  
  namespace pkgmgr_common {
@@@ -51,16 -50,14 +52,16 @@@ int PkgSetDBHandler::Execute() 
    int ret = 0;
  
    DBHandleProvider::GetInst(uid_).SetMemoryMode(true);
 +  std::vector<sqlite3*> conn_list = GetConnection();
 +  sqlite3* conn = conn_list.front();
    if (write_type_ == Insert) {
 -    ret = pkgmgr_parser_insert_pkg_info(GetConnection(), package_, uid_);
 +    ret = pkgmgr_parser_insert_pkg_info(conn, package_, uid_);
    } else if (write_type_ == Update) {
 -    ret = pkgmgr_parser_update_pkg_info(GetConnection(), package_, uid_);
 +    ret = pkgmgr_parser_update_pkg_info(conn, package_, uid_);
    } else if (write_type_ == Delete) {
 -    ret = pkgmgr_parser_delete_pkg_info(GetConnection(), package_->package, uid_);
 +    ret = pkgmgr_parser_delete_pkg_info(conn, package_->package, uid_);
    } else {
+     _LOGE("Unknown db write type");
    }
  
    if (ret != PM_PARSER_R_OK) {
@@@ -16,8 -16,7 +16,9 @@@
  
  #include "query_handler.hh"
  
 +#include <vector>
 +
+ #include "pkgmgrinfo_debug.h"
  #include "pkgmgrinfo_internal.h"
  
  namespace pkgmgr_common {
@@@ -45,32 -47,29 +49,33 @@@ int QueryHandler::Execute() 
    GList* list =nullptr;
    int row = 0;
    int col = 0;
-   if (query_.size() == 0)
+   if (query_.size() == 0) {
+     _LOGE("Empty query");
      return PMINFO_R_ERROR;
+   }
  
 +  int ret;
 +  std::vector<sqlite3*> conn_list = GetConnection();
    if (GetOpType() == OPERATION_TYPE_READ) {
 -    int ret = get_query_result(GetConnection(), query_[0].c_str(), &list, &row, &col);
 -    if (ret != PMINFO_R_OK) {
 -      _LOGE("Failed to execute query");
 -      return ret;
 -    }
 -
 -    result_.clear();
 -    result_.resize(row);
 -    GList* tmp = list;
 -    for (int i = 0; i < row; ++i) {
 -      for (int j = 0; j < col; ++j) {
 -        result_[i].emplace_back(reinterpret_cast<char *>(tmp->data));
 -        tmp = tmp->next;
 +    for (auto& conn : conn_list) {
 +      ret = get_query_result(conn, query_[0].c_str(), &list, &row, &col);
 +      if (ret == PMINFO_R_ERROR) {
-         // TODO: error log
++        _LOGE("Failed to execute query");
 +        return ret;
 +      }
++      
 +      result_.clear();
 +      result_.resize(row);
 +      GList* tmp = list;
 +      for (int i = 0; i < row; ++i) {
 +        for (int j = 0; j < col; ++j) {
 +          result_[i].emplace_back(reinterpret_cast<char *>(tmp->data));
 +          tmp = tmp->next;
 +        }
        }
 -    }
  
 -    g_list_free(list);
 +      g_list_free(list);
 +    }
      return ret;
    } else {
      const char **queries = (const char **)calloc(query_.size(), sizeof(char *));