/*** met this bug during refactoring the legacy database ***/
/*** database is default in IBExpert Dialect 3, UTF-8, SYSDBA/masterkey ****/
/*** Crashing Firebird 2.5.1 Win64 on creating self-referential FK ***/
CREATE DOMAIN T_TEXT_V064 AS
VARCHAR(64) CHARACTER SET WIN1251
CREATE DOMAIN T_TEXT_V256 AS
VARCHAR(255) CHARACTER SET WIN1251
CREATE DOMAIN T_IDLONG AS INTEGER;
CREATE TABLE EVENTS (
ID_EVENT T_IDLONG NOT NULL ,
EVENT_NAME T_TEXT_V256 NOT NULL COLLATE PXW_CYRL,
ID_RE_EVENT T_IDLONG );
ALTER TABLE EVENTS ADD CONSTRAINT PK_EVENTS PRIMARY KEY (ID_EVENT);
INSERT into events values (10, 'abcdefgh', 0);
/**** this data was old-style. Should have pre-NULLed ID_RE_EVENT, but did not noticed it.
Then suddenly... ***/
update RDB$RELATION_FIELDS set RDB$FIELD_SOURCE = 'T_TEXT_V064'
where (RDB$FIELD_NAME = 'EVENT_NAME') and (RDB$RELATION_NAME = 'EVENTS');
COMMENT ON COLUMN EVENTS.EVENT_NAME IS 'unit IBEvents; const
IB_MAX_EVENT_LENGTH = 64;' ;
ALTER TABLE EVENTS
ADD CONSTRAINT FK_EVENTS_ANSWERS
FOREIGN KEY (ID_RE_EVENT)
ON DELETE CASCADE
ON UPDATE CASCADE;
/* violation of FOREIGN KEY constraint "".
violation of FOREIGN KEY constraint "FK_EVENTS_ANSWERS" on table "EVENTS".
Foreign key reference target does not exist. */
delete from events;
/* Unsuccessful execution caused by a system error that precludes
successful execution of subsequent statements.
internal gds software consistency check (partner index description not found
(175), file: idx.cpp line: 1346). */