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

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

Merged
merged 1 commit into from Nov 8, 2019
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/DataStreams/NativeBlockInputStream.cpp
Expand Up @@ -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});
}
Expand Down
3 changes: 3 additions & 0 deletions dbms/src/Interpreters/InterpreterInsertQuery.cpp
Expand Up @@ -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;
}


Expand Down Expand Up @@ -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));
}
Expand Down
@@ -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;