| 1 |
-- |
|---|
| 2 |
-- Name: update_config(inet, text, timestamp with time zone, xml); Type: FUNCTION; Schema: stratcon; Owner: reconnoiter |
|---|
| 3 |
-- |
|---|
| 4 |
|
|---|
| 5 |
CREATE FUNCTION stratcon.update_config(v_remote_address_in inet, v_node_type_in text, v_whence_in timestamp with time zone, v_config_in xml) RETURNS void |
|---|
| 6 |
AS $$ |
|---|
| 7 |
DECLARE |
|---|
| 8 |
v_config xml; |
|---|
| 9 |
BEGIN |
|---|
| 10 |
select config into v_config from stratcon.current_node_config |
|---|
| 11 |
where remote_address = v_remote_address_in |
|---|
| 12 |
and node_type = v_node_type_in; |
|---|
| 13 |
IF FOUND THEN |
|---|
| 14 |
IF v_config::text = v_config_in::text THEN |
|---|
| 15 |
RETURN; |
|---|
| 16 |
END IF; |
|---|
| 17 |
delete from stratcon.current_node_config |
|---|
| 18 |
where remote_address = v_remote_address_in |
|---|
| 19 |
and node_type = v_node_type_in; |
|---|
| 20 |
END IF; |
|---|
| 21 |
insert into stratcon.current_node_config |
|---|
| 22 |
(remote_address, node_type, whence, config) |
|---|
| 23 |
values (v_remote_address_in, v_node_type_in, v_whence_in, v_config_in); |
|---|
| 24 |
insert into stratcon.current_node_config_changelog |
|---|
| 25 |
(remote_address, node_type, whence, config) |
|---|
| 26 |
values (v_remote_address_in, v_node_type_in, v_whence_in, v_config_in); |
|---|
| 27 |
END |
|---|
| 28 |
$$ |
|---|
| 29 |
LANGUAGE plpgsql |
|---|
| 30 |
SECURITY DEFINER |
|---|
| 31 |
; |
|---|
| 32 |
|
|---|
| 33 |
ALTER FUNCTION stratcon.update_config(v_remote_address_in inet, v_node_type_in text, v_whence_in timestamp with time zone, v_config_in xml) OWNER TO reconnoiter; |
|---|
| 34 |
|
|---|
| 35 |
GRANT EXECUTE ON FUNCTION stratcon.update_config(inet, text, timestamp with time zone, xml) TO stratcon; |
|---|
| 36 |
|
|---|