I can see how to fix that algorithmically, but my C++ isn't up to it.
---
In memory, add a 1 byte field to the rule struct, called hasNote, default value false
When loading rules from DB, set hasNote to true if note field is non empty
In _SaveRule use an UPDATE instead of REPLACE if hasNote is true.
---
If rule isn't in DB then hasNote is false and the current REPLACE query is run.
Cost is slightly longer load time at server startup, and less than a kb of memory (assuming that there are less than a k of rules!).
I'll learn C++ by breaking my server trying to implement this.... it'll take me a while.
|