FirebirdSQL / firebird

Firebird server, client and tools
https://www.firebirdsql.org/
1.23k stars 212 forks source link

Can`t restore from .fbk which contains two tables linked by PK/FK and trivial function which returns int: message about corrupted RDB$FLAGS for trigger CHECK_1 appears [CORE4479] #4799

Closed firebird-automations closed 10 years ago

firebird-automations commented 10 years ago

Submitted by: @pavel-zotov

0. Consider the following script (named 'test_ddl.sql' below): -------------------------------- create table doc_list( id int ,constraint pk_doc_list primary key(id) using index pk_doc_list ); commit;

create table doc_data( id int ,doc_id int ,constraint pk_doc_data primary key(id) using index pk_doc_data ); commit;

alter table doc_data add constraint fk_doc_data_doc_lists foreign key (doc_id) references doc_list(id) on delete cascade using index fk_doc_data_doc_lists ; commit;

set term ^; create or alter function fn_a returns int as begin return 1; end ^ set term ;^ commit; --------------------------------

1. On LINUX host with LI-T3.0.0.31204: apply this script to newly created database:

/opt/fb30trnk/bin/isql -q SQL> create database 'oltp30.fdb'; commit; SQL> connect 'localhost/3333:/var/db/fb30/oltp30.fdb'; Database: 'localhost/3333:/var/db/fb30/oltp30.fdb' SQL> in test_ddl.sql;

-- Ensure that all objects were created OK:

SQL> show table doc_list; ID INTEGER Not Null CONSTRAINT PK_DOC_LIST: Primary key (ID)

SQL> show table doc_data; ID INTEGER Not Null DOC_ID INTEGER Nullable CONSTRAINT FK_DOC_DATA_DOC_LISTS: Foreign key (DOC_ID) References DOC_LIST (ID) On Delete Cascade CONSTRAINT PK_DOC_DATA: Primary key (ID)

SQL> show function fn_a; Function text:

begin return 1; end

Parameters: OUTPUT INTEGER SQL> exit;

2. Then create backup in order to copy .fbk on windows machine: /opt/fb30trnk/bin/gbak -b /var/db/fb30/oltp30.fdb /var/db/fb30/oltp30.test.fbk

3. Copy .fbk on windows host with with WI-T3.0.0.31202 and try to restore it:

C:\1INSTALL\FB30SNAP>gbak -rep oltp30.test.fbk oltp30.test.fdb gbak: ERROR:action cancelled by trigger (2) to preserve data integrity gbak: ERROR: user does not have GRANT privileges for operation gbak:Exiting before completion due to errors

In firebird.log after this attempt there will be: IT_TEST Wed Jul 02 16:23:59 2014 Database: C:\1INSTALL\FB30SNAP\OLTP30.TEST.FDB RDB$FLAGS for trigger CHECK_1 in RDB$TRIGGERS is corrupted (304)

The CHECK_1 trigger has been created for providing FK_DOC_DATA_DOC_LISTS constraint.

There will be *NO* problem in restoring of such .fbk if definition of function FN_A will be commented.

firebird-automations commented 10 years ago

Commented by: @pavel-zotov

PS. No problems if create such database on WINDOWS and restore on LINUX build.

firebird-automations commented 10 years ago

Commented by: @asfernandes

Cannot reproduce with Windows 3.0.0.31252 and current linux trunk

firebird-automations commented 10 years ago

Commented by: Sean Leyne (seanleyne)

How should this case be resolved? Fixed or "not reproducible"?

firebird-automations commented 10 years ago

Commented by: @dyemanov

We need Pavel's confirmation before closing the ticket.

firebird-automations commented 10 years ago

Commented by: @pavel-zotov

I do confirm: no such error on LI-T3.0.0.31250.

firebird-automations commented 10 years ago
Modified by: @asfernandes status: Open \[ 1 \] =\> Resolved \[ 5 \] resolution: Cannot Reproduce \[ 5 \]
firebird-automations commented 10 years ago
Modified by: @pcisar status: Resolved \[ 5 \] =\> Closed \[ 6 \]