mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
fix use-after-free [#CLICKHOUSE-3101]
This commit is contained in:
parent
a030ce90b5
commit
a2debdb724
@ -25,7 +25,7 @@ namespace Poco { class Logger; }
|
||||
namespace DB
|
||||
{
|
||||
|
||||
struct ColumnsDescription;
|
||||
class ColumnsDescription;
|
||||
|
||||
/// State of query processing.
|
||||
struct QueryState
|
||||
|
@ -111,6 +111,20 @@ ColumnsDescription::ColumnsDescription(NamesAndTypesList ordinary)
|
||||
add(ColumnDescription(std::move(elem.name), std::move(elem.type)));
|
||||
}
|
||||
|
||||
ColumnsDescription::ColumnsDescription(const ColumnsDescription & other)
|
||||
: columns(other.columns)
|
||||
{
|
||||
for (auto it = columns.begin(); it != columns.end(); ++it)
|
||||
name_to_column.emplace(it->name, it);
|
||||
}
|
||||
|
||||
ColumnsDescription & ColumnsDescription::operator=(const ColumnsDescription & other)
|
||||
{
|
||||
if (&other != this)
|
||||
*this = ColumnsDescription(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/// We are trying to find first column from end with name `column_name` or with a name beginning with `column_name` and ".".
|
||||
/// For example "fruits.bananas"
|
||||
|
@ -29,15 +29,15 @@ struct ColumnDescription
|
||||
void readText(ReadBuffer & buf);
|
||||
};
|
||||
|
||||
struct ColumnsDescription
|
||||
class ColumnsDescription
|
||||
{
|
||||
private:
|
||||
std::list<ColumnDescription> columns;
|
||||
std::unordered_map<String, std::list<ColumnDescription>::iterator> name_to_column;
|
||||
|
||||
public:
|
||||
ColumnsDescription() = default;
|
||||
explicit ColumnsDescription(NamesAndTypesList ordinary_);
|
||||
ColumnsDescription(const ColumnsDescription & other);
|
||||
ColumnsDescription & operator=(const ColumnsDescription & other);
|
||||
ColumnsDescription(ColumnsDescription &&) noexcept = default;
|
||||
ColumnsDescription & operator=(ColumnsDescription &&) noexcept = default;
|
||||
|
||||
/// `after_column` can be a Nested column name;
|
||||
void add(ColumnDescription column, const String & after_column = String());
|
||||
@ -80,6 +80,10 @@ public:
|
||||
static ColumnsDescription parse(const String & str);
|
||||
|
||||
static const ColumnsDescription * loadFromContext(const Context & context, const String & db, const String & table);
|
||||
|
||||
private:
|
||||
std::list<ColumnDescription> columns;
|
||||
std::unordered_map<String, std::list<ColumnDescription>::iterator> name_to_column;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user