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
UNIQUE CONSTRAINT violation [CORE6252] #6495
Comments
Modified by: Mattia Rosin (rmattia)environment: Server Version : Ubuntu 16.04.6 LTS Linux Diesel2 4.15.18-24-pve => Server Version : Ubuntu 16.04.6 LTS Linux |
Commented by: @WarmBooter I hear this for years: Mixing DML and DDL in the same transaction is ask for trouble :-( |
Commented by: @pavel-zotov This is author's slightly modified script; checked on 2.1.7, 2.5.9, 3.0.6, 4.0.0 - result the same. It will create PK and UNIQUE for table with fully duplicate rows. set bail on; set autoddl off; -- [ !! ] commit; commit; insert into test(a, b) values (1,1); commit; ------------------------------------------------------- ------------------------------------------------------- show table test; select * from test; |
Modified by: @hvladassignee: Vlad Khorsun [ hvlad ] |
Modified by: @hvladstatus: Open [ 1 ] => Resolved [ 5 ] resolution: Fixed [ 1 ] Fix Version: 4.0 Beta 2 [ 10888 ] Fix Version: 3.0.6 [ 10889 ] |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Resolved [ 5 ] QA Status: No test => Done successfully |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Closed [ 6 ] |
Submitted by: Mattia Rosin (rmattia)
Updating the data of a table with non-unique data and the creation of a unique costraint on the same table in the same transaction, does not result in the exception of non-unique records
Example :
SET TERM ^;
/* Creating simple stucture */
DROP TABLE test_table
^
CREATE TABLE test_table(
a integer,
b integer
)
^
COMMIT
^
/* Simple Data*/
INSERT INTO test_table(a, b) VALUES (1,1)
^
INSERT INTO test_table(a, b) VALUES (1,2)
^
COMMIT
^
/* Problem start here */
UPDATE test_table
SET b = -999
^
ALTER TABLE TEST_TABLE
ADD CONSTRAINT UNQ1_TEST_TABLE
UNIQUE (A)
^
COMMIT
^
/* Now test_table have a unique costraint on column a but column a not contains unique value */
Commits: 1922f1f 9a25464
The text was updated successfully, but these errors were encountered: