Better check

This commit is contained in:
Alexey Milovidov 2019-12-28 08:08:22 +03:00
parent 608d8e854d
commit 56ec171fc0

View File

@ -23,11 +23,22 @@ namespace
struct AggregateFunctionThrowData
{
std::unique_ptr<char> memory{ new char };
bool allocated;
AggregateFunctionThrowData() : allocated(true) {}
~AggregateFunctionThrowData()
{
volatile bool * allocated_ptr = &allocated;
if (*allocated_ptr)
*allocated_ptr = false;
else
abort();
}
};
/** Throw on creation with probability specified in parameter.
* Allocates some memory in constructor and deallocates in desctructor.
* It will check correct destruction of the state.
* This is intended to check for exception safety.
*/
class AggregateFunctionThrow final : public IAggregateFunctionDataHelper<AggregateFunctionThrowData, AggregateFunctionThrow>