mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Make MCV return false when a boolean tie.
This is to maintain compatibility with the older Perl code that returned the lowest sorted order item in a tie. For other datatypes the C code returns the same value, often enough at least to not cause churn in the expect tests.
This commit is contained in:
parent
ab0974cc8e
commit
d15ed33821
@ -108,7 +108,9 @@ mcvResult(const MostCommonValue *this)
|
||||
{
|
||||
MostCommonValueEntry *entry = (MostCommonValueEntry *)lstGet(this->list, listIdx);
|
||||
|
||||
if (entry->total > resultTotal)
|
||||
if (entry->total > resultTotal ||
|
||||
// If boolean always return false when there is a tie. This is to maintain compatibility with older mcv code/tests.
|
||||
(entry->total == resultTotal && varType(entry->value) == varTypeBool && !varBool(entry->value)))
|
||||
{
|
||||
result = entry->value;
|
||||
resultTotal = entry->total;
|
||||
|
@ -44,6 +44,24 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_VOID(mcvUpdate(mcv, varNewUInt(555)), "update 555");
|
||||
TEST_RESULT_UINT(varUInt(mcvResult(mcv)), 555, "result is 555");
|
||||
|
||||
// Bool MCV
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_ASSIGN(mcv, mcvNew(), "new mcv");
|
||||
|
||||
TEST_RESULT_VOID(mcvUpdate(mcv, varNewBool(true)), "update true");
|
||||
TEST_RESULT_BOOL(varBool(mcvResult(mcv)), true, "result is true");
|
||||
|
||||
TEST_RESULT_VOID(mcvUpdate(mcv, varNewBool(false)), "update false");
|
||||
TEST_RESULT_BOOL(varBool(mcvResult(mcv)), false, "result is false");
|
||||
|
||||
TEST_ASSIGN(mcv, mcvNew(), "new mcv");
|
||||
|
||||
TEST_RESULT_VOID(mcvUpdate(mcv, varNewBool(false)), "update false");
|
||||
TEST_RESULT_BOOL(varBool(mcvResult(mcv)), false, "result is false");
|
||||
|
||||
TEST_RESULT_VOID(mcvUpdate(mcv, varNewBool(true)), "update true");
|
||||
TEST_RESULT_BOOL(varBool(mcvResult(mcv)), false, "result is false");
|
||||
}
|
||||
|
||||
FUNCTION_HARNESS_RESULT_VOID();
|
||||
|
Loading…
Reference in New Issue
Block a user