+void PrivilegeDb::GetDefaultMapping(const std::string &version_from,
+ const std::string &version_to,
+ std::vector<std::string> &mappings)
+{
+ try_catch<void>([&] {
+ auto &command = getStatement(StmtType::EGetDefaultMappings);
+ command->BindString(1, version_from);
+ command->BindString(2, version_to);
+
+ mappings.clear();
+ while (command->Step()) {
+ std::string mapping = command->GetColumnString(0);
+ LogDebug("Default Privilege from version " << version_from
+ <<" to version " << version_to << " is " << mapping);
+ mappings.push_back(mapping);
+ }
+ });
+}
+
+void PrivilegeDb::GetPrivilegeMappings(const std::string &version_from,
+ const std::string &version_to,
+ const std::string &privilege,
+ std::vector<std::string> &mappings)
+{
+ try_catch<void>([&] {
+ auto &command = getStatement(StmtType::EGetPrivilegeMappings);
+ command->BindString(1, version_from);
+ command->BindString(2, version_to);
+ command->BindString(3, privilege);
+
+ mappings.clear();
+ while (command->Step()) {
+ std::string mapping = command->GetColumnString(0);
+ LogDebug("Privilege " << privilege << " in version " << version_from
+ <<" has mapping " << mapping << " in version " << version_to);
+ mappings.push_back(mapping);
+ }
+ });
+}
+
+void PrivilegeDb::GetPrivilegesMappings(const std::string &version_from,
+ const std::string &version_to,
+ const std::vector<std::string> &privileges,
+ std::vector<std::string> &mappings)
+{
+ try_catch<void>([&] {
+ auto &deleteCmd = getStatement(StmtType::EDeletePrivilegesToMap);
+ deleteCmd->Step();
+
+ auto & insertCmd = getStatement(StmtType::EInsertPrivilegeToMap);
+ for (auto &privilege : privileges) {
+ if (privilege.empty())
+ continue;
+ insertCmd->BindString(1, privilege);
+ insertCmd->Step();
+ insertCmd->Reset();
+ }
+
+ insertCmd->BindNull(1);
+ insertCmd->Step();
+
+ auto &queryCmd = getStatement(StmtType::EGetPrivilegesMappings);
+ queryCmd->BindString(1, version_from);
+ queryCmd->BindString(2, version_to);
+
+ mappings.clear();
+ while (queryCmd->Step()) {
+ std::string mapping = queryCmd->GetColumnString(0);
+ LogDebug("Privilege set in version " << version_from
+ <<" has mapping " << mapping << " in version " << version_to);
+ mappings.push_back(mapping);
+ }
+ });
+}
+