mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-03 13:40:21 +01:00
pg listen/notify part
This commit is contained in:
parent
d98df1c1cd
commit
3c4b217364
23
pg/send_block_changes.sql
Normal file
23
pg/send_block_changes.sql
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
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;
|
Loading…
Reference in New Issue
Block a user