mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-17 23:58:17 +01:00
24 lines
376 B
MySQL
24 lines
376 B
MySQL
|
BEGIN;
|
||
|
|
||
|
CREATE OR REPLACE FUNCTION send_block_changes()
|
||
|
RETURNS TRIGGER AS
|
||
|
$$
|
||
|
BEGIN
|
||
|
PERFORM pg_notify('blockchanges',
|
||
|
json_build_object(
|
||
|
'X', NEW.posx,
|
||
|
'Z', NEW.posz
|
||
|
)::text
|
||
|
);
|
||
|
RETURN NEW;
|
||
|
END;
|
||
|
$$ LANGUAGE plpgsql;
|
||
|
|
||
|
CREATE TRIGGER blocks_changed
|
||
|
AFTER INSERT OR UPDATE
|
||
|
ON blocks
|
||
|
FOR EACH ROW
|
||
|
EXECUTE PROCEDURE send_block_changes();
|
||
|
|
||
|
END;
|