firebird
firebird copied to clipboard
Triggers not replicated
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
I saw that I forgot to mention that it's Firebird 4.0.2
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?
I used RECREATE TRIGGER
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.
There were no errors in the replication log. It stated that there were no pending changes in fact.
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;
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