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
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: CORE-4479
                 URL: http://tracker.firebirdsql.org/browse/CORE-4479
             Project: Firebird Core
          Issue Type: Bug
    Affects Versions: 3.0 Alpha 2
            Reporter: 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.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to