提交 40a5cf4b 编写于 作者: A alesapin

Forbidden to use column name more than once in insert query.

上级 4e682118
......@@ -188,7 +188,7 @@ Block NativeBlockInputStream::readImpl()
for (auto & col : header)
{
if (res.has(col.name))
tmp_res.insert(std::move(res.getByName(col.name)));
tmp_res.insert(res.getByName(col.name));
else
tmp_res.insert({col.type->createColumn()->cloneResized(rows), col.type, col.name});
}
......
......@@ -30,6 +30,7 @@ namespace ErrorCodes
extern const int NO_SUCH_COLUMN_IN_TABLE;
extern const int READONLY;
extern const int ILLEGAL_COLUMN;
extern const int DUPLICATE_COLUMN;
}
......@@ -84,6 +85,8 @@ Block InterpreterInsertQuery::getSampleBlock(const ASTInsertQuery & query, const
if (!allow_materialized && !table_sample_non_materialized.has(current_name))
throw Exception("Cannot insert column " + current_name + ", because it is MATERIALIZED column.", ErrorCodes::ILLEGAL_COLUMN);
if (res.has(current_name))
throw Exception("Column " + current_name + " specified more than once", ErrorCodes::DUPLICATE_COLUMN);
res.insert(ColumnWithTypeAndName(table_sample.getByName(current_name).type, current_name));
}
......
DROP TABLE IF EXISTS sometable;
CREATE TABLE sometable (
date Date,
time Int64,
value UInt64
) ENGINE=MergeTree()
ORDER BY time;
INSERT INTO sometable (date, time, value) VALUES ('2019-11-08', 1573185600, 100);
SELECT COUNT() from sometable;
INSERT INTO sometable (date, time, value, time) VALUES ('2019-11-08', 1573185600, 100, 1573185600); -- {serverError 15}
DROP TABLE IF EXISTS sometable;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册