| 1 | | -- formerly stratcon.mv_loading_dock_check_s |
|---|
| | 1 | -- formerly check_currently |
|---|
| | 2 | |
|---|
| | 3 | set search_path = noit; |
|---|
| | 4 | |
|---|
| | 5 | CREATE OR REPLACE FUNCTION check_archive_log_changes() |
|---|
| | 6 | RETURNS trigger |
|---|
| | 7 | AS $$ |
|---|
| | 8 | DECLARE |
|---|
| | 9 | v_remote_address INET; |
|---|
| | 10 | v_target TEXT; |
|---|
| | 11 | v_name TEXT; |
|---|
| | 12 | BEGIN |
|---|
| | 13 | |
|---|
| | 14 | IF TG_OP = 'INSERT' THEN |
|---|
| | 15 | SELECT remote_address,target,name FROM check_currently WHERE sid = NEW.sid AND id=NEW.id |
|---|
| | 16 | INTO v_remote_address,v_target,v_name; |
|---|
| | 17 | |
|---|
| | 18 | IF v_remote_address IS DISTINCT FROM NEW.remote_address OR v_target IS DISTINCT FROM NEW.target OR v_name IS DISTINCT FROM NEW.name THEN |
|---|
| | 19 | |
|---|
| | 20 | DELETE from check_currently WHERE sid = NEW.sid AND id=NEW.id; |
|---|
| | 21 | |
|---|
| | 22 | INSERT INTO check_currently (sid,remote_address,whence,id,target,module,name) |
|---|
| | 23 | VALUES (NEW.sid,NEW.remote_address,NEW.whence,NEW.id,NEW.target,NEW.module,NEW.name); |
|---|
| | 24 | |
|---|
| | 25 | END IF; |
|---|
| | 26 | |
|---|
| | 27 | ELSE |
|---|
| | 28 | RAISE EXCEPTION 'Something wrong with check_archive_log_changes'; |
|---|
| | 29 | END IF; |
|---|
| | 30 | |
|---|
| | 31 | RETURN NULL; |
|---|
| | 32 | |
|---|
| | 33 | END |
|---|
| | 34 | $$ LANGUAGE plpgsql |
|---|
| | 35 | SECURITY DEFINER |
|---|
| | 36 | ; |
|---|
| | 37 | |
|---|