I haven't used it yet, but it seems to me that RDB$SET_CONTEXT() and RDB$GET_CONTEXT() , introduced in Firebird 2, is what you need. Using this, you can set (and get) additional information related to a user session ( USER_SESSION namespace) or the current transaction ( USER_TRANSACTION namespace). You can also get additional system information for the current session ( SYSTEM namespace), but this is probably not the case.
What you need to do is call the RDB$SET_CONTEXT() method in this OnUserAuthorize event, for example using (as a request):
SELECT RDB$SET_CONTEXT('USER_SESSION', 'actualuser', '<name of user') FROM RDB$DATABASE
Here 'actualuser' uses a context variable. In your triggers you can get a name (suppose PSQL with a declared variable actualuser )
actualuser = RDB$GET_CONTEXT('USER_SESSION', 'actualuser');
Then you can use actualuser in the rest of your trigger. Just make sure that you also consider the case where the context variable is not set (for example, the administrator makes direct changes to the database or something like that).
source share