PS-9328: Fix valgrind errors in test_services.test_execute_prepared_s… #5431
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…tatement test.
Implementation of "mysql_statement_service" service which allows to execute normal and prepared SQL statements from components, didn't initialize arrays of value_t objects which it used to represent rows produced by SQL statement.
As result valgrind errors were generated when test_execute_prepared_statement test used this service and the service code tried to store some values in such a uninitialized array. This was done using value_t's "operator =". And since value_t is a specialization of std::variant template, its "operator =" needs to read old data in object being assigned into to correctly handle disposal of old value stored in it (and this old data was uninitialized in this case).
This patch fixes the problem by ensuring that we call default value_t constructor for elements of array in question after its allocation. It also fixes code which resets such arrays before reuse, instead of filling it with zeros using memset() (which is not guaranteed to work in general case), we simply reset each element of array by assigning std::monostate to it.