firebird icon indicating copy to clipboard operation
firebird copied to clipboard

Triggers not replicated

Open lwennekers opened this issue 2 years ago • 7 comments

I was changing the triggers for a table in a replication environment and found out that those triggers were not replicated. Am I missing something? Thanks in advance for your support

lwennekers avatar Aug 29 '22 13:08 lwennekers

I saw that I forgot to mention that it's Firebird 4.0.2

lwennekers avatar Aug 31 '22 07:08 lwennekers

How did you change triggers? ALTER TRIGGER commands are surely replicated as well as any other DDL. Are there any errors in replication.log on the replica side?

dyemanov avatar Aug 31 '22 07:08 dyemanov

I used RECREATE TRIGGER

lwennekers avatar Aug 31 '22 07:08 lwennekers

Perhaps you were still connected to the replica and thus RECREATE failed due to "object in use" error? If so, it should be recorded in replication.log.

dyemanov avatar Aug 31 '22 07:08 dyemanov

There were no errors in the replication log. It stated that there were no pending changes in fact.

lwennekers avatar Aug 31 '22 12:08 lwennekers

I cannot reproduce it.

isql
Use CONNECT or CREATE DATABASE to specify a database
SQL> create database 'localhost:/data/a.fdb';
SQL> create table t (id int);
SQL> set term ^;
SQL> create trigger tt for t active before insert as begin :new.id = 1; end^
SQL> set term ;^
SQL> exit;

cp /data/a.fdb /data/a2.fdb
gfix -replica read_only /data/a2.fdb
# modify replication.conf for both databases

isql
Use CONNECT or CREATE DATABASE to specify a database
SQL> connect /data/a.fdb;
Database: /data/a.fdb, User: DIMITR
SQL> alter database enable publication;
SQL> alter database include all to publication;
SQL> commit;
SQL> insert into t values (123);
SQL> commit;
SQL> select * from t;

          ID 
============ 
           1 

SQL> commit;
SQL> set term ^;
SQL> recreate trigger tt for t active before insert as begin :new.id = 2; end^
SQL> set term ;^
SQL> commit;
SQL> insert into t values (456);
SQL> commit;
SQL> select * from t;

          ID 
============ 
           1 
           2 

SQL> connect localhost:/data/a2.fdb;
Commit current transaction (y/n)?y
Committing.
Database: /data/a2.fdb, User: DIMITR
SQL> select * from t;

          ID 
============ 
           1 
           2 

SQL> show trigger tt;

Triggers on Table T:
TT, Sequence: 0, Type: BEFORE INSERT, Active
Trigger text:
=============================================================================
as begin :new.id = 2; end
=============================================================================
SQL> exit;

dyemanov avatar Sep 07 '22 07:09 dyemanov

Last week I did some testing too and I noticed the same as you did yourself, it works. I'm however still looking for the problem that occurred. As stated there was no logging but no replication as well. I keep on testing and will let you know if something happens. For now this functions as it seems

lwennekers avatar Sep 07 '22 08:09 lwennekers