Issue Details (XML | Word | Printable)

Key: CORE-5322
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Vlad Khorsun
Reporter: Koltcov Viktor
Votes: 1
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Cascade deletion in self-referencing table could raise "no current record for fetch operation" error

Created: 01/Aug/16 05:20 AM   Updated: 09/Sep/16 06:08 AM
Component/s: Engine
Affects Version/s: 3.0.0
Fix Version/s: 3.0.1, 4.0 Alpha 1

Environment: Windows 10 firebird WI-V3.0.0.32483

QA Status: Done successfully


 Description  « Hide
Can't delete record with cascade foreign key, but it worked in firebird 2.5.2

when try to delete
DELETE FROM TABLE_A WHERE (ID = 1)

get error
The cursor identified in the UPDATE or DELETE statement is not positioned on a row.
no current record for fetch operation.
At trigger 'CHECK_1'.


test DDL:

/******************************************************************************/
/*** Generated by IBExpert 2016.6.22.1 01.08.2016 9:58:18 ***/
/******************************************************************************/

SET SQL DIALECT 3;

SET NAMES WIN1251;

CREATE DATABASE 'TEST.FDB '
USER 'SYSDBA' PASSWORD 'masterkey'
PAGE_SIZE 16384
DEFAULT CHARACTER SET WIN1251 COLLATION WIN1251;



/******************************************************************************/
/*** Tables ***/
/******************************************************************************/



CREATE TABLE "TABLE_A" (
    "ID" INTEGER NOT NULL,
    "SOME_DATA" INTEGER
);


CREATE TABLE "TABLE_B" (
    "ID" INTEGER NOT NULL,
    "TABLE_A_ID" INTEGER,
    "SOME_DATA" INTEGER,
    "PARENT_ID" INTEGER
);


INSERT INTO "TABLE_A" ("ID", "SOME_DATA") VALUES (1, 10);

COMMIT WORK;

INSERT INTO "TABLE_B" ("ID", "TABLE_A_ID", "SOME_DATA", "PARENT_ID") VALUES (1, 1, 555, NULL);
INSERT INTO "TABLE_B" ("ID", "TABLE_A_ID", "SOME_DATA", "PARENT_ID") VALUES (2, 1, 222, 1);

COMMIT WORK;



/******************************************************************************/
/*** Primary keys ***/
/******************************************************************************/

ALTER TABLE "TABLE_A" ADD CONSTRAINT "PK_TABLE_A" PRIMARY KEY ("ID");
ALTER TABLE "TABLE_B" ADD CONSTRAINT "PK_TABLE_B" PRIMARY KEY ("ID");


/******************************************************************************/
/*** Foreign keys ***/
/******************************************************************************/

ALTER TABLE "TABLE_B" ADD CONSTRAINT "FK_TABLE_B_1" FOREIGN KEY ("TABLE_A_ID") REFERENCES "TABLE_A" ("ID") ON DELETE CASCADE;
ALTER TABLE "TABLE_B" ADD CONSTRAINT "FK_TABLE_B_2" FOREIGN KEY ("PARENT_ID") REFERENCES "TABLE_B" ("ID") ON DELETE CASCADE;




 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dmitry Yemanov added a comment - 01/Aug/16 06:51 AM
Could be related to CORE-5305.

Vlad Khorsun added a comment - 02/Aug/16 08:57 AM
It is about self-referenced FK, i believe