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

Unable to insert-as-select row to the table when primary key exist on destination table #8949

Open
shm-dmitry opened this issue Jul 26, 2019 · 1 comment
Assignees
Labels
enhancement Enhancement that doesn't fit into a more specific feature label. Try avoid using this feature: ux
Milestone

Comments

@shm-dmitry
Copy link

CrateDB version: 3.3.5

Problem description:
Insert-as-select silently rejected when PK exists on the dest table.

Ref to #8312 - Please, add parameter to raise error - maybe at session level, maybe at server level, maybe in syntax, maybe something else.
At now insert-as-select not usable, I have to re-check all results.
I can help with PR if need.

Steps to reproduce:
create table test1 (x string, primary key (x));
>> Table TEST1 created.
create table test2 (x string, primary key (x));
>> Table TEST2 created.
create table test3 (x string);
>> Table TEST3 created.
insert into test1 (x) values ('a');
>> 1 row inserted.
insert into test2 (x) select x from test1 where x = 'a';
>> 0 rows inserted. No data copied to dest table. No errors received ;(
insert into test2 (x) select 'a' from test1 where x = 'a'; Same then previous, but successful when value is constant
>> 1 row inserted.
insert into test3 (x) select x from test1 where x = 'a';
>> 1 row inserted. No PK on dest table - request successful

@shm-dmitry
Copy link
Author

shm-dmitry commented Jul 26, 2019

Workarounds:
insert into test2 (x) select x || '' from test1 where x = 'a';
>> 1 row inserted.

insert into test2 (x) select * from (select x from test1 where x = 'a') t;
>> 1 row inserted.

@mfussenegger mfussenegger self-assigned this Aug 22, 2019
@mfussenegger mfussenegger added enhancement Enhancement that doesn't fit into a more specific feature label. Try avoid using this feature: ux labels Jan 9, 2020
@mfussenegger mfussenegger added this to the Deck milestone Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement that doesn't fit into a more specific feature label. Try avoid using this feature: ux
Projects
None yet
Development

No branches or pull requests

2 participants