return TRUE;
}
-int _account_query_by_account_id(sqlite3 *account_db_handle, account_add_capability_cb capability_cb, account_add_custom_cb custom_cb, int account_id, void *user_data)
+int _account_query_by_account_id(sqlite3 *account_db_handle, account_add_capability_cb capability_cb,
+ account_add_custom_cb custom_cb, int account_id, void *user_data)
{
_INFO("_account_query_by_account_id start");
ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+ /*check in proper tables of Capability & Account_Custom*/
if (capability_cb != NULL) {
- _INFO("account query capability by account-id");
- ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE account_id = %d", CAPABILITY_TABLE, account_id);
+ _INFO("account query capability by account-id - original table");
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id = %d", CAPABILITY_TABLE, account_id);
query_for_capability = true;
} else if (custom_cb != NULL) {
- _INFO("account query custom by account-id");
+ _INFO("account query custom by account-id - original table");
ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AccountId = %d", ACCOUNT_CUSTOM_TABLE, account_id);
query_for_custom = true;
}
+
+ hstmt = _account_prepare_query(account_db_handle, query);
+
+ if (_account_db_err_code(account_db_handle) == SQLITE_PERM) {
+ ACCOUNT_ERROR("Access failed(%s)", _account_db_err_msg(account_db_handle));
+ return _ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ rc = _account_query_step(hstmt);
+ if (rc != SQLITE_ROW) {
+ rc = _account_query_finalize(hstmt);
+ ACCOUNT_RETURN_VAL((rc == _ACCOUNT_ERROR_NONE), {}, rc, ("finalize error"));
+ hstmt = NULL;
+ }
+
+ if ((rc != SQLITE_ROW) && query_for_capability) {
+ _INFO("account query capability by account-id - deleted capability table");
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE _id = %d", DELETED_CAPABILITY_TABLE, account_id);
+ } else if ((rc != SQLITE_ROW) && query_for_custom) {
+ _INFO("account query capability by account-id - deleted account_custom table");
+ ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX);
+ ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE AccountId = %d", DELETED_ACCOUNT_CUSTOM_TABLE, account_id);
+ }
+
hstmt = _account_prepare_query(account_db_handle, query);
if (_account_db_err_code(account_db_handle) == SQLITE_PERM) {
}
rc = _account_query_step(hstmt);
- ACCOUNT_CATCH_ERROR(rc == SQLITE_ROW, {}, _ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n"));
if (query_for_capability) {
account_capability_s *capability_record = NULL;
return _ACCOUNT_ERROR_NONE;
}
-int _account_delete_table(sqlite3 *account_db_handle, account_stmt *phstmt,
- GSList *account_id_list, const char *package_name, const char *app_id, const char* table)
+int _account_delete_table(sqlite3 *account_db_handle, account_stmt *phstmt, GSList *account_id_list,
+ const char *package_name, const char *app_id, const char* table)
{
_INFO("_account_delete_table start - table[%s]", table);
int error_code = _ACCOUNT_ERROR_NONE;
int rc = 0;
char query[ACCOUNT_SQL_LEN_MAX] = {0, };
- /*function params like "phstmt", "account_id_list", "package_name" & "app_id" can be NULL in
- * case of table deletion performed either by package_name or app_id; hence no need to check them for NULL*/
-
ACCOUNT_RETURN_VAL((account_db_handle != NULL), {}, _ACCOUNT_ERROR_DB_NOT_OPENED, ("The database isn't connected."));
ACCOUNT_RETURN_VAL((table != NULL), {}, _ACCOUNT_ERROR_INVALID_PARAMETER, ("table is null!"));
_INFO("start delete custom table");
/* delete custom table */
- error_code = _account_delete_table(account_db_handle, &hstmt, account_id_list, package_name, NULL, ACCOUNT_CUSTOM_TABLE);
+ error_code = _account_delete_table(account_db_handle, &hstmt, account_id_list, NULL, package_name, ACCOUNT_CUSTOM_TABLE);
if ((error_code == _ACCOUNT_ERROR_DB_FAILED) || (error_code == _ACCOUNT_ERROR_RECORD_NOT_FOUND)) {
_ERR("account-custom-table deletion failed - db error[%d]", error_code);
goto CATCH;