Subject Re: [firebird-support]Engine Error - Partner Index
Author Helen Borrie
Hello Nico,

Friday, December 22, 2017, 10:29:05 PM, you wrote:

> Hello,

> I have a problem with inserting a row in table
> OrderTypeDescriptions. Here you can find the sql script for the
> tables OrderTypes and OrderTypeDescriptions.


> CREATE TABLE ORDERTYPES (

> ID INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL,

> STOCKORDER BOOLEAN DEFAULT FALSE NOT NULL,

> ROWVERSION TIMESTAMP,

> /* Keys */

> CONSTRAINT PK_ORDERTYPES

> PRIMARY KEY (ID)

> );



> CREATE TABLE ORDERTYPEDESCRIPTIONS (

> ID INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL,

> ORDERTYPEID INTEGER NOT NULL,

> ORDERTYPEDESCRIPTION VARCHAR(100) COLLATE UNICODE_CI_AI,

> LANGUAGEID INTEGER NOT NULL,

> ROWVERSION TIMESTAMP,

> /* Keys */

> CONSTRAINT PK_ORDERTYPEDESCRIPTIONS

> PRIMARY KEY (ID),

> /* Foreign keys */

> CONSTRAINT FK_ORDERTYPEDESC_LANGUAGEID

> FOREIGN KEY (LANGUAGEID)

> REFERENCES LANGUAGES(ID) <--------------------------

> ON DELETE CASCADE,

> CONSTRAINT FK_ORDERTYPEDESC_ORDERTYPEID

> FOREIGN KEY (ORDERTYPEID)

> REFERENCES ORDERTYPES(ID)

> ON DELETE CASCADE

> );



> CREATE INDEX IX_ORDERTYPEDESC_DESCRIPTION

> ON ORDERTYPEDESCRIPTIONS

> (ORDERTYPEID, LANGUAGEID);

> If I insert a row in table OrderType there is no problem.
> Id = 1
> Stockorder = true

> If I post a new row in table OrderTypeDescriptions I got a problem

Insert into OrderTypeDescriptions (OrderTypeId, OrderTypeDescription, LanguageId)

values (1, 'Test', 1)

> Problem
> Engine Error (code = 335544333): internal Firebird consistency
> check (partner index description not found (175), file: idx.cpp line: 1271).
> SQL error (code = -902): Unsuccessful execution caused by a system
> error that precludes successful execution of subsequent statements.

Where is the insert for the master record in LANGUAGES with
LANGUAGEID=1?

Also, don't forget that you must commit the DDL for the master tables
before you can define foreign keys that refer to them. If you are
using isql then the default behaviour is to autocommit DDL statements.
The same is likely to be untrue if you are using a third-party tool.

After that, if you have uncommitted inserts to a referenced table in
one transaction, then those uncommitted records are not visible to a
transaction that is trying to insert into the detail table.

Note that isql does not autocommit DML statements.

Helen