fdhwlib
2.0.25
|
The database can be used to control the readout daemon. Before a control item is inserted in the the Eventloop log table the described action will be send to the daemon process. If the action causes an error, an error message to the calling process is send.
Eventloop Log Table timestamp unsigned int Timestamp UTC format cmd enumeration / better string (!) sender ip address IP address of the sender process pid pid PID of the sender process error error number
CREATE TABLE control( ControlId INT NOT NULL AUTO_INCREMENT PRIMARY KEY, Sec INT DEFAULT 0 Cmd Sender Pid Error );
Warning: All user defined funnctions have to be thread safe. Are the socket function thread safe?
Trigger? The trigger have to be handled like the table definition itself. For the first approach it is suffient to store both definition in a text file.
CREATE TRIGGER testref BEFORE INSERT ON test1 FOR EACH ROW BEGIN INSERT INTO test2 SET a2 = NEW.a1; DELETE FROM test3 WHERE a3 = NEW.a1; UPDATE test4 SET b4 = b4 + 1 WHERE a4 = NEW.a1; END; CREATE TRIGGER sendCmd AFTER INSERT ON control FOR EACH ROW BEGIN SELECT udfSendCmds(NEW.Cmd); # Store the result in the error line?! UPDATE control SET ... END;
Example: Call a user defined function
mysql> create function metaphon returns string soname 'libFEdataMysqlUDF.so'; Query OK, 0 rows affected (0.00 sec) mysql> select metaphon(); ERROR: Wrong arguments to metaphon; Use the source mysql> select metaphon('Andreas'); +---------------------+ | metaphon('Andreas') | +---------------------+ | ANTRS | +---------------------+ 1 row in set (0.00 sec) mysql> select metaphon('kopmann'); +---------------------+ | metaphon('kopmann') | +---------------------+ | KPMN | +---------------------+ 1 row in set (0.00 sec)