[Maria-developers] Logoff trigger for MariaDB
Hi all, As suggested by Sergei we should discuss this here. Copying the login trigger stuff to a place in the code where I thought it makes sense I have created a logout trigger. This gives the capability to track a session from its beginning to its end and collects all the data from each session. With this capability we can start thinking about auditing of MySQL users like it is needed/wanted from big companies. I am NOT a developer and I was just lucky that it worked out how I did it. So I am not of much help for an other approach as Sergei hinted in his comment. Now: free to discuss... http://www.fromdual.com/mysql-logon-and-logoff-trigger-for-auditing Regards, Oli -- FromDual - Vendor independent and neutral MySQL consulting. Website http://www.fromdual.com/ Skype fromdual Jabber fromdual@swissjabber.ch Yahoo IM fromdual Xing https://www.xing.com/profile/Oliver_Sennhauser LinkedIn http://ch.linkedin.com/in/shinguz Twitter http://twitter.com/shinguz
Hi, Oli! On Dec 11, Oli Sennhauser wrote:
Hi all,
As suggested by Sergei we should discuss this here.
Copying the login trigger stuff to a place in the code where I thought it makes sense I have created a logout trigger. This gives the capability to track a session from its beginning to its end and collects all the data from each session. With this capability we can start thinking about auditing of MySQL users like it is needed/wanted from big companies. http://www.fromdual.com/mysql-logon-and-logoff-trigger-for-auditing
I am NOT a developer and I was just lucky that it worked out how I did it. So I am not of much help for an other approach as Sergei hinted in his comment.
I didn't thought so much about the implementation, but about the interface, how it look from the user point of view. You, yourself, used the word "logon and logoff triggers" - perhaps, these *should* indeed be defined as triggers? There are different "events" that a user can attach SQL code on - isn't it time to consolidate the interface to them, and to use a unified syntax for that? Like CREATE TRIGGER foo BEFORE INSERT ON test1 FOR EACH ROW CALL sp1(); CREATE TRIGGER bar ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO UPDATE myschema.mytable SET mycol = mycol + 1; CREATE TRIGGER xyz ON LOGON INSERT INTO logons VALUES (USER(), NOW()); etc. In this form, this is purely a syntax extension - different set of keywords, providing exactly the same functionality as before. Old syntax should continue to work, of course. Regards, Sergei P.S. I'd also like to see changes in functionality, coming after changes in the syntax. E.g. an I_S table that shows all triggers. Or MySQL remembering and preserving LOGON/LOGOFF triggers over restart. But I don't mind moving forward one step at time.
Hello Sergei,
I didn't thought so much about the implementation, but about the interface, how it look from the user point of view.
You, yourself, used the word "logon and logoff triggers" - perhaps, these *should* indeed be defined as triggers?
Sure, absolutely. I was not aware, that this is a request programme! ;-)
In this form, this is purely a syntax extension - different set of keywords, providing exactly the same functionality as before. Old syntax should continue to work, of course.
The origins come from Oracles Database triggers: http://www.adp-gmbh.ch/ora/sql/create_trigger.html http://psoug.org/reference/system_trigger.html http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_70... There we have triggers for logon, logoff, startup and shutdown (which is represented in MySQL as init-connect and init-file hook) In Oracle they know: BEFORE, AFTER and INSTEAD OF triggers. And and as database events are known: SERVERERROR, LOGON, LOGOFF, STARTUP, SHUTDOWN and SUSPEND So I prefer triggers if it is not too much work. I was just not capable to implement this change.
P.S. I'd also like to see changes in functionality, coming after changes in the syntax. E.g. an I_S table that shows all triggers. Or MySQL remembering and preserving LOGON/LOGOFF triggers over restart. But I don't mind moving forward one step at time.
Sure! Best regards, Oli -- FromDual - Vendor independent and neutral MySQL consulting. Oli Sennhauser Rebenweg 6 CH - 8610 Uster / Switzerland Phone +41 44 940 24 82 Mobile +41 79 830 09 33 e-Mail oli.sennhauser@fromdual.com Website http://www.fromdual.com/ Skype fromdual Jabber fromdual@swissjabber.ch Yahoo IM fromdual Xing https://www.xing.com/profile/Oliver_Sennhauser LinkedIn http://ch.linkedin.com/in/shinguz Twitter http://twitter.com/shinguz
participants (2)
-
Oli Sennhauser
-
Sergei Golubchik