Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix stack overflow issue when using initializer_list #9367

Merged
merged 1 commit into from Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbms/src/Common/COW.h
Expand Up @@ -292,7 +292,7 @@ class COWHelper : public Base
static MutablePtr create(Args &&... args) { return MutablePtr(new Derived(std::forward<Args>(args)...)); }

template <typename T>
static MutablePtr create(std::initializer_list<T> && arg) { return create(std::forward<std::initializer_list<T>>(arg)); }
static MutablePtr create(std::initializer_list<T> && arg) { return MutablePtr(new Derived(std::forward<std::initializer_list<T>>(arg))); }

typename Base::MutablePtr clone() const override { return typename Base::MutablePtr(new Derived(*derived())); }

Expand Down
9 changes: 5 additions & 4 deletions dbms/src/DataStreams/tests/collapsing_sorted_stream.cpp
Expand Up @@ -30,13 +30,13 @@ try
ColumnWithTypeAndName column1;
column1.name = "Sign";
column1.type = std::make_shared<DataTypeInt8>();
column1.column = ColumnInt8::create({1, -1});
column1.column = ColumnInt8::create({static_cast<int8_t>(1), static_cast<int8_t>(-1)});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't make the type of initializer list generic in ColumnVector and PODArray constructors? Let me try to do it in subsequent PR...

block1.insert(column1);

ColumnWithTypeAndName column2;
column2.name = "CounterID";
column2.type = std::make_shared<DataTypeUInt32>();
column2.column = ColumnUInt32::create({123, 123});
column2.column = ColumnUInt32::create({static_cast<uint32_t>(123), static_cast<uint32_t>(123)});
block1.insert(column2);
}

Expand All @@ -46,13 +46,13 @@ try
ColumnWithTypeAndName column1;
column1.name = "Sign";
column1.type = std::make_shared<DataTypeInt8>();
column1.column = ColumnInt8::create({1, 1});
column1.column = ColumnInt8::create({static_cast<int8_t>(1), static_cast<int8_t>(1)});
block2.insert(column1);

ColumnWithTypeAndName column2;
column2.name = "CounterID";
column2.type = std::make_shared<DataTypeUInt32>();
column2.column = ColumnUInt32::create({123, 456});
column2.column = ColumnUInt32::create({static_cast<uint32_t>(123), static_cast<uint32_t>(456)});
block2.insert(column2);
}

Expand All @@ -76,6 +76,7 @@ try

return 0;
}

catch (const DB::Exception & e)
{
std::cerr << e.what() << ", " << e.displayText() << std::endl;
Expand Down