Describe the bug
MERGE statement is deleting rows if the column is set as NOT NULL even though it should not.
To Reproduce
drop table sys.v;
CREATE TABLE "sys"."v" (
"id" INTEGER NOT NULL,
"version" INTEGER NOT NULL,
"value" DOUBLE
);
insert into sys."v" values (1,1622470128,1);
insert into sys."v" values (2,1622470128,2);
insert into sys."v" values (3,1622470128,3);
insert into sys."v" values (4,1622470128,4);
insert into sys."v" values (5,1622470128,5);
MERGE INTO sys."v" dst
USING (SELECT id, version FROM (SELECT id, version, DENSE_RANK() OVER (PARTITION BY id ORDER BY id, version DESC) AS rn FROM sys."v")t WHERE rn > 1 ) src
ON src.id = dst.id AND src.version = dst.version
WHEN MATCHED THEN DELETE;
Above merge statement deletes all rows in the table, even if it should not.
Expected behavior
drop table sys.v;
CREATE TABLE "sys"."v" (
"id" INTEGER,
"version" INTEGER,
"value" DOUBLE
);
insert into sys."v" values (1,1622470128,1);
insert into sys."v" values (2,1622470128,2);
insert into sys."v" values (3,1622470128,3);
insert into sys."v" values (4,1622470128,4);
insert into sys."v" values (5,1622470128,5);
MERGE INTO sys."v" dst
USING (SELECT id, version FROM (SELECT id, version, DENSE_RANK() OVER (PARTITION BY id ORDER BY id, version DESC) AS rn FROM sys."v")t WHERE rn > 1 ) src
ON src.id = dst.id AND src.version = dst.version
WHEN MATCHED THEN DELETE;
If the column is NOT set as NOT NULL, the statement works as expected.
Software versions
Linux, Docker, latest version od MDB (MonetDB v11.39.17 (Oct2020-SP5))
The text was updated successfully, but these errors were encountered:
As a side note, I had to disable subqueries on the joining clause too. This is because the current way they are handled in the query parser makes it difficult to integrate with merge statements.
Describe the bug
MERGE statement is deleting rows if the column is set as NOT NULL even though it should not.
To Reproduce
Above merge statement deletes all rows in the table, even if it should not.
Expected behavior
If the column is NOT set as NOT NULL, the statement works as expected.
Software versions
Linux, Docker, latest version od MDB (MonetDB v11.39.17 (Oct2020-SP5))
The text was updated successfully, but these errors were encountered: