Skip to content

Commit

Permalink
Remove deleteKeyValueEntry fucntion which is not useful in the expect…
Browse files Browse the repository at this point in the history
…ed use of this table.
  • Loading branch information
herve-er committed Apr 26, 2024
1 parent 0a3ea50 commit 2947e9f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
30 changes: 0 additions & 30 deletions src/libparms/db/parmsdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,6 @@
#define UPDATE_VALUE_WITH_KEY_CLIENT_REQUEST_ID "update_value_with_key"
#define UPDATE_VALUE_WITH_KEY_CLIENT_REQUEST "UPDATE key_value SET value=?2 WHERE key=?1;"

#define DELETE_VALUE_WITH_KEY_CLIENT_REQUEST_ID "delete_value_with_key"
#define DELETE_VALUE_WITH_KEY_CLIENT_REQUEST "DELETE FROM key_value WHERE key=?1;"

namespace KDC {

std::shared_ptr<ParmsDb> ParmsDb::_instance = nullptr;
Expand Down Expand Up @@ -1378,12 +1375,6 @@ bool ParmsDb::prepare() {
return sqlFail(UPDATE_VALUE_WITH_KEY_CLIENT_REQUEST_ID, error);
}

ASSERT(queryCreate(DELETE_VALUE_WITH_KEY_CLIENT_REQUEST_ID));
if (!queryPrepare(DELETE_VALUE_WITH_KEY_CLIENT_REQUEST_ID, DELETE_VALUE_WITH_KEY_CLIENT_REQUEST, false, errId, error)) {
queryFree(DELETE_VALUE_WITH_KEY_CLIENT_REQUEST_ID);
return sqlFail(DELETE_VALUE_WITH_KEY_CLIENT_REQUEST_ID, error);
}

if (!initData()) {
LOG_WARN(_logger, "Error in initParameters");
return false;
Expand Down Expand Up @@ -3469,10 +3460,6 @@ bool ParmsDb::selectValueForKey(const std::string &key, std::string &value, cons
}

bool ParmsDb::setValueForKey(const std::string &key, const std::string &value) {
if (value.empty()) {
return deleteKeyValueEntry(key);
}

std::string existingValue;
int errId;
std::string error;
Expand Down Expand Up @@ -3501,21 +3488,4 @@ bool ParmsDb::setValueForKey(const std::string &key, const std::string &value) {
}
return true;
}

bool ParmsDb::deleteKeyValueEntry(const std::string &key) {
const std::scoped_lock lock(_mutex);

int errId;
std::string error;

ASSERT(queryResetAndClearBindings(DELETE_VALUE_WITH_KEY_CLIENT_REQUEST_ID));
ASSERT(queryBindValue(DELETE_VALUE_WITH_KEY_CLIENT_REQUEST_ID, 1, key));
if (!queryExec(DELETE_VALUE_WITH_KEY_CLIENT_REQUEST_ID, errId, error)) {
LOG_WARN(_logger, "Error running query: " << DELETE_VALUE_WITH_KEY_CLIENT_REQUEST_ID);
return false;
}
ASSERT(queryResetAndClearBindings(DELETE_VALUE_WITH_KEY_CLIENT_REQUEST_ID));

return true;
}
} // namespace KDC
3 changes: 1 addition & 2 deletions src/libparms/db/parmsdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ class PARMS_EXPORT ParmsDb : public Db {
bool selectLastClientSelfRestartTime(int64_t &lastClientRestartTime);

bool selectValueForKey(const std::string &key, std::string &value, const std::string &defaultValue = "");
bool setValueForKey(const std::string &key, const std::string &value); // update or insert
bool deleteKeyValueEntry(const std::string &key);
bool setValueForKey(const std::string &key, const std::string &value); // update or insert

bool updateLastServerSelfRestartTime(int64_t lastServerRestartTime = -1 /* -1 means now*/);
bool updateLastClientSelfRestartTime(int64_t lastClientRestartTime = -1 /* -1 means now*/);
Expand Down

0 comments on commit 2947e9f

Please sign in to comment.