mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Forbidden to use column name more than once in insert query.
This commit is contained in:
parent
4e68211879
commit
40a5cf4bb9
@ -188,7 +188,7 @@ Block NativeBlockInputStream::readImpl()
|
|||||||
for (auto & col : header)
|
for (auto & col : header)
|
||||||
{
|
{
|
||||||
if (res.has(col.name))
|
if (res.has(col.name))
|
||||||
tmp_res.insert(std::move(res.getByName(col.name)));
|
tmp_res.insert(res.getByName(col.name));
|
||||||
else
|
else
|
||||||
tmp_res.insert({col.type->createColumn()->cloneResized(rows), col.type, col.name});
|
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 NO_SUCH_COLUMN_IN_TABLE;
|
||||||
extern const int READONLY;
|
extern const int READONLY;
|
||||||
extern const int ILLEGAL_COLUMN;
|
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))
|
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);
|
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));
|
res.insert(ColumnWithTypeAndName(table_sample.getByName(current_name).type, current_name));
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
1
|
@ -0,0 +1,17 @@
|
|||||||
|
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;
|
Loading…
Reference in New Issue
Block a user